Skip to content

Commit 9392eda

Browse files
authored
Merge pull request #95 from preghenella/rdev-dndneta
Prototype for hybrid fast/full simulation
2 parents 7557a79 + 8ad6a91 commit 9392eda

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

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+
}

0 commit comments

Comments
 (0)