Skip to content

Commit 3c424f8

Browse files
Merge branch 'master' of https://github.com/AliceO2Group/DelphesO2 into fwdpara
2 parents 1248dae + e0a2ea5 commit 3c424f8

File tree

15 files changed

+237
-69
lines changed

15 files changed

+237
-69
lines changed

examples/aod/createO2tables.C

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ int createO2tables(const char* inputFile = "delphes.root",
7171
TDatabasePDG::Instance()->AddParticle("deuteron", "deuteron", 1.8756134, kTRUE, 0.0, 3, "Nucleus", 1000010020);
7272
TDatabasePDG::Instance()->AddAntiParticle("anti-deuteron", -1000010020);
7373

74+
TDatabasePDG::Instance()->AddParticle("triton", "triton", 2.8089218, kTRUE, 0.0, 3, "Nucleus", 1000010030);
75+
TDatabasePDG::Instance()->AddAntiParticle("anti-triton", -1000010030);
76+
7477
TDatabasePDG::Instance()->AddParticle("helium3", "helium3", 2.80839160743, kTRUE, 0.0, 6, "Nucleus", 1000020030);
7578
TDatabasePDG::Instance()->AddAntiParticle("anti-helium3", -1000020030);
7679

@@ -102,7 +105,8 @@ int createO2tables(const char* inputFile = "delphes.root",
102105
mapPdgLut.insert(std::make_pair(2212, "lutCovm.pr.dat"));
103106
if (enable_nuclei) {
104107
mapPdgLut.insert(std::make_pair(1000010020, "lutCovm.de.dat"));
105-
mapPdgLut.insert(std::make_pair(1000020030, "lutCovm.he.dat"));
108+
mapPdgLut.insert(std::make_pair(1000010030, "lutCovm.tr.dat"));
109+
mapPdgLut.insert(std::make_pair(1000020030, "lutCovm.he3.dat"));
106110
}
107111
for (auto e : mapPdgLut) {
108112
if (!smearer.loadTable(e.first, e.second)) {

examples/o2kine/run.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /usr/bin/env bash
2+
3+
MODULES="TRK"
4+
MODULES="CAVE PIPE ITS TPC"
5+
NEVENTS=100
6+
NWORKERS=4
7+
8+
## create the transport.C macro
9+
cat <<EOF > transport.C
10+
o2::data::Stack::TransportFcn
11+
transport()
12+
{
13+
return [](const TParticle& p, const std::vector<TParticle>& particles) -> bool {
14+
auto eta = p.Eta();
15+
if (std::fabs(eta) > 1.0) return false;
16+
auto pdg = std::abs(p.GetPdgCode());
17+
if (pdg == 11) return false;
18+
if (pdg == 13) return false;
19+
if (pdg == 22) return false;
20+
if (pdg == 211) return false;
21+
if (pdg == 321) return false;
22+
if (pdg == 2212) return false;
23+
return true;
24+
};
25+
}
26+
EOF
27+
28+
## create the bkg_config.ini file with the required specs
29+
cat <<EOF > config.ini
30+
[Stack]
31+
transportPrimary = external
32+
transportPrimaryFileName = transport.C
33+
transportPrimaryFuncName = transport()
34+
transportPrimaryInvert = false
35+
EOF
36+
37+
o2-sim -j ${NWORKERS} -n ${NEVENTS} -g pythia8hi -m ${MODULES} --configFile config.ini
38+

examples/o2kine/smear_o2_kine.C

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
class SmearO2KineGenerator : public o2::eventgen::GeneratorFromO2Kine
2+
{
3+
4+
public:
5+
6+
SmearO2KineGenerator(const char *name) : GeneratorFromO2Kine(name) { };
7+
bool Init() override {
8+
auto retval = o2::eventgen::GeneratorFromO2Kine::Init();
9+
setContinueMode(true);
10+
return retval; };
11+
12+
// bool importParticles() override {
13+
14+
protected:
15+
16+
17+
};
18+
19+
20+
void
21+
smear_o2_kine(const char *o2kinefilename)
22+
{
23+
24+
o2::delphes::TrackSmearer smearer;
25+
smearer.loadTable(11, "lutCovm.el.dat");
26+
smearer.loadTable(13, "lutCovm.mu.dat");
27+
smearer.loadTable(211, "lutCovm.pi.dat");
28+
smearer.loadTable(321, "lutCovm.ka.dat");
29+
smearer.loadTable(2212, "lutCovm.pr.dat");
30+
31+
auto gen = new SmearO2KineGenerator(o2kinefilename);
32+
gen->Init();
33+
34+
// loop over events
35+
while (gen->importParticles()) {
36+
auto particles = gen->getParticles();
37+
38+
// loop over particles
39+
for (auto & particle : particles) {
40+
41+
// we did not transport them before, we do not smear them either
42+
if (std::fabs(particle.Eta()) > 1.0) continue;
43+
44+
// only particles to be transported, which are flagged as status code = 1
45+
// the particles that have been transported already have status code = 0
46+
if (particle.GetStatusCode() != 1) continue;
47+
48+
// only particles that we know how to smear
49+
// namely el, mu, pi, ka, pr
50+
auto pdg = std::abs(particle.GetPdgCode());
51+
if (pdg != 11 && pdg != 13 && pdg != 211 && pdg != 321 && pdg != 2212) continue;
52+
53+
// convert particle to o2 track and smear it
54+
O2Track o2track;
55+
o2::delphes::TrackUtils::convertTParticleToO2Track(particle, o2track);
56+
float nch = 1600.;
57+
o2track.print();
58+
if (!smearer.smearTrack(o2track, pdg, nch)) continue;
59+
o2track.print();
60+
61+
}
62+
}
63+
64+
}

examples/pythia8/pythia_nuclei.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Config file to define the nuclei species that are not in vanilla pythia
2+
1000020030:all 3He 3Hebar 1 6 0 2.8094

examples/scripts/clean.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ rm tmpscript*.sh
1717
rm lutWrite*.cc
1818
rm DetectorK.*
1919
rm -r fwdRes
20+
rm -r __pycache__

examples/scripts/createO2tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def do_copy(in_file, out_file=".", in_path=None):
107107
lut_tag = opt("lut_tag")
108108
lut_particles = ["el", "mu", "pi", "ka", "pr"]
109109
if use_nuclei:
110-
lut_particles += ["de", "he3"]
110+
lut_particles += ["de", "tr", "he3"]
111111
if create_luts:
112112
# Creating LUTs
113113
minimum_track_radius = opt("minimum_track_radius")

examples/scripts/create_luts.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,32 @@ for i in $PARTICLES; do
8484
TDatabasePDG::Instance()->AddParticle("deuteron", "deuteron", 1.8756134, kTRUE, 0.0, 3, "Nucleus", 1000010020);
8585
TDatabasePDG::Instance()->AddAntiParticle("anti-deuteron", -1000010020);
8686
87+
TDatabasePDG::Instance()->AddParticle("triton", "triton", 2.8089218, kTRUE, 0.0, 3, "Nucleus", 1000010030);
88+
TDatabasePDG::Instance()->AddAntiParticle("anti-triton", -1000010030);
89+
8790
TDatabasePDG::Instance()->AddParticle("helium3", "helium3", 2.80839160743, kTRUE, 0.0, 6, "Nucleus", 1000020030);
8891
TDatabasePDG::Instance()->AddAntiParticle("anti-helium3", -1000020030);
8992
90-
const TString pn[7] = {"el", "mu", "pi", "ka", "pr", "de", "he3"};
91-
const int pc[7] = {11, 13, 211, 321, 2212, 1000010020, 1000020030 };
93+
const int N = 8;
94+
const TString pn[N] = {"el", "mu", "pi", "ka", "pr", "de", "tr", "he3"};
95+
const int pc[N] = {11, 13, 211, 321, 2212, 1000010020, 1000010030, 1000020030 };
9296
const float field = ${FIELD}f;
9397
const float rmin = ${RMIN};
9498
const int i = ${i};
95-
lutWrite_${WHAT}("${OUT_PATH}/lutCovm." + pn[i] + "${OUT_TAG}.dat", pc[i], field, rmin);
99+
const TString out_file = "${OUT_PATH}/lutCovm." + pn[i] + "${OUT_TAG}.dat";
100+
Printf("Creating LUT for particle ID %i: %s with pdg code %i to %s", i, pn[i].Data(), pc[i], out_file.Data());
101+
if(i >= 0 && i < N){
102+
lutWrite_${WHAT}(out_file, pc[i], field, rmin);
103+
} else{
104+
Printf("Particle ID %i is too large or too small", i);
105+
}
96106
97107
EOF
98108
done
99109

100110
# Checking that the output LUTs are OK
101111
NullSize=""
102-
P=(el mu pi ka pr de he3)
112+
P=(el mu pi ka pr de tr he3)
103113
for i in $PARTICLES; do
104114
LUT_FILE=${OUT_PATH}/lutCovm.${P[$i]}${OUT_TAG}.dat
105115
if [[ ! -s ${LUT_FILE} ]]; then

examples/scripts/default_configfile.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,17 @@ custom_gen = INPUT_FILES /tmp/AnalysisResults_*.hepmc
7676
[GUN]
7777
custom_gen = rpythia8-gun --pdg 421 --px 1. --py 0. --pz 0. --xProd 0. --yProd 0. --zProd 0. --config $DELPHESO2_ROOT/examples/pythia8/decays/force_hadronic_D.cfg --decay
7878

79+
[BOX_pion]
80+
custom_gen = rpythia8-box --pdg 211 --etamin -2. --etamax 2. --phimin 0. --phimax 6.28 --pmin 0 --pmax 10 --xProd 0. --yProd 0. --zProd 0. --decay --npart 100
81+
82+
[BOX_proton]
83+
custom_gen = rpythia8-box --pdg 2212 --etamin -2. --etamax 2. --phimin 0. --phimax 6.28 --pmin 0 --pmax 10 --xProd 0. --yProd 0. --zProd 0. --decay --npart 100
84+
7985
[BOX_deuteron]
80-
custom_gen = rpythia8-box --pdg 1000010020 --etamin -2. --etamax 2. --phimin 0. --phimax 3.14 --pmin 100 --pmax 1000 --xProd 0. --yProd 0. --zProd 0. --config $DELPHESO2_ROOT/examples/pythia8/decays/force_hadronic_D.cfg --decay --npart 100
86+
custom_gen = rpythia8-box --pdg 1000010020 --etamin -2. --etamax 2. --phimin 0. --phimax 6.28 --pmin 0 --pmax 10 --xProd 0. --yProd 0. --zProd 0. --decay --npart 100
87+
88+
[BOX_helium3]
89+
custom_gen = rpythia8-box --pdg 1000020030 --etamin -2. --etamax 2. --phimin 0. --phimax 6.28 --pmin 0 --pmax 10 --xProd 0. --yProd 0. --zProd 0. --decay --npart 100 --config $DELPHESO2_ROOT/examples/pythia8/pythia_nuclei.cfg
8190

8291
[GUN_Lc_pKpi]
8392
custom_gen = rpythia8-gun --pdg 4122 --px 1. --py 0. --pz 0. --xProd 1. --yProd 0. --zProd 0. --config $O2DPG_ROOT/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_forceLcChannel1.cfg --decay

rpythia8/.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../examples/aod/.clang-format

rpythia8/rpythia8-box.cc

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main(int argc, char **argv)
1818
int npart;
1919
double xProd, yProd, zProd;
2020
bool verbose, decay;
21-
21+
2222
/** process arguments **/
2323
namespace po = boost::program_options;
2424
po::options_description desc("Options");
@@ -44,29 +44,40 @@ int main(int argc, char **argv)
4444
("verbose,V", po::bool_switch(&verbose)->default_value(false), "Verbose event listing")
4545
("seed", po::value<int>(&seed)->default_value(1), "initial seed")
4646
;
47-
47+
4848
po::variables_map vm;
4949
po::store(po::parse_command_line(argc, argv, desc), vm);
5050
po::notify(vm);
51-
51+
5252
if (vm.count("help")) {
5353
std::cout << desc << std::endl;
5454
return 1;
5555
}
56-
}
57-
catch(std::exception& e) {
56+
} catch (std::exception& e) {
5857
std::cerr << "Error: " << e.what() << std::endl;
5958
std::cout << desc << std::endl;
6059
return 1;
6160
}
62-
61+
6362
HepMC::Pythia8ToHepMC ToHepMC;
6463
HepMC::IO_GenEvent ascii_io(output, std::ios::out);
65-
64+
6665
// pythia
6766
Pythia pythia;
6867

68+
// configure pythia
69+
pythia.readString("ProcessLevel:all = off");
70+
// pythia.readString("SoftQCD:elastic on");
71+
if (!config.empty() && !pythia.readFile(config)) {
72+
std::cout << "Error: could not read config file \"" << config << "\"" << std::endl;
73+
return 1;
74+
}
75+
6976
// check valid pdg code
77+
if (!pythia.particleData.isParticle(pdg)) {
78+
std::cout << "Error: invalid PDG code \"" << pdg << "\" is not in the particle list" << std::endl;
79+
return 1;
80+
}
7081
if (!pythia.particleData.isLepton(pdg) &&
7182
!pythia.particleData.isHadron(pdg) &&
7283
!pythia.particleData.isResonance(pdg)) {
@@ -78,15 +89,7 @@ int main(int argc, char **argv)
7889
}
7990
}
8091

81-
// config
82-
pythia.readString("ProcessLevel:all = off");
83-
// pythia.readString("SoftQCD:elastic on");
84-
if (!config.empty() && !pythia.readFile(config)) {
85-
std::cout << "Error: could not read config file \"" << config << "\"" << std::endl;
86-
return 1;
87-
}
88-
89-
std::cout<<"Random:seed =" + std::to_string(seed)<<std::endl;
92+
std::cout << "Random:seed =" + std::to_string(seed) << std::endl;
9093
pythia.readString("Random:setSeed = on");
9194
pythia.readString("Random:seed =" + std::to_string(seed));
9295
// init
@@ -103,7 +106,7 @@ int main(int argc, char **argv)
103106
particle.zProd(zProd);
104107

105108
// background interface
106-
Pythia8::Pythia *pythia_bkg = nullptr;
109+
Pythia8::Pythia* pythia_bkg = nullptr;
107110
if (!background_config.empty()) {
108111
std::cout << "Background: configure from " << background_config << std::endl;
109112
pythia_bkg = new Pythia8::Pythia;
@@ -113,17 +116,15 @@ int main(int argc, char **argv)
113116
}
114117
pythia_bkg->init();
115118
}
116-
117119

118-
119120
// event loop
120121
double eta, phi, p, pt, pl, e;
121-
srand (time(NULL));
122+
srand(time(NULL));
122123
for (int iev = 0; iev < nevents; ++iev) {
123124

124125
// reset, add particle and decay
125126
pythia.event.reset();
126-
for(int ipart = 0; ipart < npart; ipart++){
127+
for (int ipart = 0; ipart < npart; ipart++) {
127128
eta = eta_min + static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / (eta_max - eta_min)));
128129
phi = phi_min + static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / (phi_max - phi_min)));
129130
p = p_min + static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / (p_max - p_min)));
@@ -135,21 +136,23 @@ int main(int argc, char **argv)
135136
particle.py(pt * sin(phi));
136137
particle.pz(pl);
137138
pythia.event.append(particle);
138-
if (decay) pythia.moreDecays();
139+
if (decay)
140+
pythia.moreDecays();
139141
pythia.next();
140142
}
141-
143+
142144
// print verbose
143-
if (verbose) pythia.event.list(1);
145+
if (verbose)
146+
pythia.event.list(1);
144147

145148
// background
146149
if (pythia_bkg) {
147150
pythia_bkg->next();
148151
pythia.event += pythia_bkg->event;
149-
}
150-
152+
}
153+
151154
// write HepMC
152-
HepMC::GenEvent *hepmcevt = new HepMC::GenEvent();
155+
HepMC::GenEvent* hepmcevt = new HepMC::GenEvent();
153156
ToHepMC.fill_next_event(pythia, hepmcevt);
154157
ascii_io << hepmcevt;
155158
delete hepmcevt;
@@ -161,7 +164,6 @@ int main(int argc, char **argv)
161164
pythia_bkg->stat();
162165
delete pythia_bkg;
163166
}
164-
167+
165168
return 0;
166-
167169
}

0 commit comments

Comments
 (0)