Advanced Computing Platform for Theoretical Physics

Commit 76f9dbbf authored by Yu-Chen Ding's avatar Yu-Chen Ding
Browse files

Merge remote-tracking branch 'upstream/master'

parents b1f90170 67a5715f
......@@ -147,14 +147,13 @@ SET (CRMC_HEADERS
${CMAKE_BINARY_DIR}/src/CRMCinterface.h)
include(GNUInstallDirs)
SET(CRMC_PARAM_DEFAULT ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}/crmc.param)
SET(CRMC_PARAM_DEFAULT ${CMAKE_INSTALL_PREFIX}/etc/crmc.param)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (CRMC_ENABLE_ROOT)
message("ROOT output is not encouraged. Consider HepMC or Rivet.")
FIND_PACKAGE (Root)
if (Root_FOUND)
INCLUDE_DIRECTORIES ("${ROOT_INCLUDE_DIR}")
......@@ -489,7 +488,7 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/crmc.param.in
SET(CRMC_TABDIR "${CMAKE_INSTALL_PREFIX}/share/crmc")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/crmc.param.in
${CMAKE_BINARY_DIR}/crmc.param.install @ONLY IMMEDIATE)
install(FILES ${CMAKE_BINARY_DIR}/crmc.param.install TYPE SYSCONF
install(FILES ${CMAKE_BINARY_DIR}/crmc.param.install DESTINATION etc
RENAME crmc.param)
# install tabs
......
......@@ -27,6 +27,8 @@ FOREACH (COMPONENT ${Fastjet_FIND_COMPONENTS})
${Fastjet_DIR}
${Fastjet_ROOT_DIR}
${HEP_ROOT}
$ENV{FASTJET_PREFIX}
$ENV{FASTJET_ROOT}
$ENV{Fastjet_PREFIX}
$ENV{Fastjet_ROOT}
$ENV{Fastjet_DIR}
......
......@@ -35,24 +35,32 @@ OBJS=$(FILES:%.f=$(LIBDIR)%.o)
CXXOBJS=$(CXXFILES:%.cc=$(LIBDIR)%.o)
all: check dirs bin_dir bin/analyse
all: check dirs bin_dir bin/analysis
.PHONY : check
check:
@if [ -z "$(HepMC3_ROOT)" ]; then echo "Please set HepMC3_ROOT to the root directory of HepMC3"; exit 1; fi
@if [ -z "$(ROOTSYS)" ]; then echo "Please set ROOTSYS to the root directory of root"; exit 1; fi
bin/analyse: $(OBJS) $(CXXOBJS)
bin/analysis: $(OBJS) $(CXXOBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(CXXOBJS) -o $@ $(LIBS)
@(echo "")
@(echo "==> compilation successful!")
@(echo "==> type bin/analyse")
@(echo "==> type bin/analysis")
@(echo "")
bin/analysisROOT: $(LIBDIR)/analysisROOT.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
@(echo "")
@(echo "==> compilation successful!")
@(echo "==> type bin/analysisROOT")
@(echo "")
$(OBJS) : $(LIBDIR)%.o : $(SOURCE_DIR)%.f
$(FC) -o $@ -c $<
$(CXXOBJS) : $(LIBDIR)%.o : $(SOURCE_DIR)%.cc src/analysis.h
$(LIBDIR)%.o : $(SOURCE_DIR)%.cc
$(CXX) $(CXXFLAGS) $(CFLAGS) -o $@ -c $<
dirs:
......
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <string>
#include <sstream>
#include <fstream>
#include <math.h>
#include <stdlib.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <TLorentzVector.h>
#include <TFile.h>
#include <TChain.h>
#include <TH1D.h>
using namespace std;
int main (int argc, char **argv)
{
if (argc==1) {
cout << "\n Please, provide input data file(s) in ROOT format\n" << endl;
return 0;
}
//-------------------SET UP DATA
TFile* theOutFile;
string outFileName ("new_histogram_file_ROOT.root");
cout << " ! Opening output file: " << outFileName << endl;
theOutFile = new TFile (outFileName.c_str(), "RECREATE");
TChain data("Particle");
for (int ia=1; ia<argc; ++ia) {
data.AddFile(argv[ia]);
}
int nPart;
data.SetBranchAddress("nPart", &nPart);
const int MAXP = 100000;
int pdgid[MAXP];
int status[MAXP];
double px[MAXP];
double py[MAXP];
double pz[MAXP];
double E[MAXP];
double m[MAXP];
data.SetBranchAddress("pdgid", pdgid);
data.SetBranchAddress("status", status);
data.SetBranchAddress("px", px);
data.SetBranchAddress("py", py);
data.SetBranchAddress("pz", pz);
data.SetBranchAddress("E", E);
data.SetBranchAddress("m", m);
theOutFile->mkdir ("model1");
//------------------SET UP HISTOGRAMS
TH1D* exampleHist = new TH1D ("dNdeta",";#eta;dN/d#eta",21,-10,10);
//-------------------EVENT LOOP
int nEvts = data.GetEntries();
for (int iEvt=0; iEvt<nEvts; ++iEvt)
{
data.GetEntry(iEvt);
//-------------------PARTICLE LOOP
for (int ipar=0; ipar < nPart; ++ipar)
{
if (status[ipar] != 1) continue; //get final state particles. status == 2 are decayed particles, status == 4 is beam particles
TLorentzVector lv(px[ipar],py[ipar],pz[ipar],E[ipar]);
//HepMC3::GenVertex* parent_vertex = p->production_vertex();
const int id = pdgid[ipar];
const double eta = lv.Eta();
//const double pt = p->momentum ().perp ();
//const double e = p->momentum ().e ();
//for more advance paramters see HepMC documentation or load #include <TParticle.h> and fill object (see analysis.h)
//-------------------EVENT SELECTION
//-------------------FILL HISTOGRAMS WITH PER PARTICLE VARIABLES
exampleHist->Fill (eta);
}//PARTICLE LOOP
//-------------------FILL HISTOGRAMS WITH PER EVENT VARIABLES
}//EVENT LOOP
//---------------FINALISE HISTOGRAMS
exampleHist->Scale (1. / nEvts, "width");
//----------------Closing Files
std::cout << " ! Writing output file: " << outFileName << std::endl;
theOutFile->Write();
delete exampleHist;
exampleHist = 0;
std::cout << " ! Closing output file: " << outFileName << std::endl;
theOutFile->Close();
delete theOutFile;
theOutFile = 0;
return 0;
}
......@@ -35,7 +35,11 @@ double mass(int id)
CRMCoptions::CRMCoptions(int argc, char **argv)
: fError(false)
#ifdef WITH_HEPMC3
, fOutputMode(eHepMC3GZ)
#else
, fOutputMode(eLHE)
#endif
, fNCollision(500)
, fSeed(0)
, fProjectileId(1)
......@@ -125,10 +129,14 @@ void CRMCoptions::ParseOptions(int argc, char **argv)
"output_mode",
"hepmc, hepmcgz, hepmc3, hepmc3gz (default), root, lhe, lhegz, rivet",
false,
"lhe",
#ifdef WITH_HEPMC3
"hepmc3gz",
#else
"lhegz",
#endif
"string");
cmd.add(output);
TCLAP::ValueArg<int> seed(
"s", "seed", "random seed between 0 and 1e9 (default: random)", false, 0, "int");
cmd.add(seed);
......@@ -203,31 +211,48 @@ void CRMCoptions::ParseOptions(int argc, char **argv)
}
const string om = output.getValue();
if (om == "hepmc3gz")
if (om == "hepmc3gz") {
#ifndef WITH_HEPMC3
cerr << " Compile with HepMC3 first " << endl;
exit(1);
#endif
fOutputMode = eHepMC3GZ;
else if (om == "hepmc3")
} else if (om == "hepmc3") {
#ifndef WITH_HEPMC3
cerr << " Compile with HepMC3 first " << endl;
exit(1);
#endif
fOutputMode = eHepMC3;
else if (om == "hepmcgz")
} else if (om == "hepmcgz") {
#ifndef WITH_HEPMC
cerr << " Compile with HepMC2 first " << endl;
exit(1);
#endif
fOutputMode = eHepMCGZ;
else if (om == "hepmc")
} else if (om == "hepmc") {
#ifndef WITH_HEPMC
cerr << " Compile with HepMC2 first " << endl;
exit(1);
#endif
fOutputMode = eHepMC;
else if (om == "lhe")
} else if (om == "lhe") {
fOutputMode = eLHE;
else if (om == "lhegz")
} else if (om == "lhegz") {
fOutputMode = eLHEGZ;
else if (om == "rivet")
} else if (om == "rivet") {
#ifndef WITH_RIVET
cerr << " Compile with Rivet first " << endl;
exit(1);
#endif
fOutputMode = eRivet;
else if (om == "root")
{
} else if (om == "root") {
#ifdef WITH_ROOT
fOutputMode = eROOT;
#else
cerr << " Compile with ROOT first " << endl;
exit(1);
#endif
}
else
{
} else {
fOutputMode = eNone;
OutputPolicyNone::dl_filename = om;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment