Skip to content

Commit 3817800

Browse files
fmazzascgconesab
authored andcommitted
Add second particle type
1 parent 7e6be6a commit 3817800

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[GeneratorExternal]
2+
fileName=${O2DPG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_longlived.C
3+
funcName=generateLongLived(3112, 5, 1, 9, 3222)
4+
5+
[GeneratorPythia8]
6+
config=${O2_ROOT}/share/Generators/egconfig/pythia8_inel.cfg

MC/config/PWGLF/pythia8/generator_pythia8_longlived.C

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GeneratorPythia8LongLivedGun : public o2::eventgen::GeneratorPythia8
1414
{
1515
public:
1616
/// constructor
17-
GeneratorPythia8LongLivedGun(int input_pdg, int nInject = 1) : pdg{input_pdg}, nParticles{nInject}, m{getMass(input_pdg)}
17+
GeneratorPythia8LongLivedGun(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10, int input_pdg2 = -1) : pdg{input_pdg}, nParticles{nInject}, genMinPt{ptMin}, genMaxPt{ptMax}, m{getMass(input_pdg)}, pdg2{input_pdg2}
1818
{
1919
}
2020

@@ -60,6 +60,23 @@ public:
6060
sign *= randomizePDGsign ? -1 : 1;
6161
mParticles.push_back(TParticle(sign * pdg, 1, -1, -1, -1, -1, px, py, pz, et, 0., 0., 0., 0.));
6262
}
63+
64+
if (pdg2 != -1)
65+
{
66+
for (int i{0}; i < nParticles; ++i)
67+
{
68+
const double pt = gRandom->Uniform(genMinPt, genMaxPt);
69+
const double eta = gRandom->Uniform(genMinEta, genMaxEta);
70+
const double phi = gRandom->Uniform(0, TMath::TwoPi());
71+
const double px{pt * std::cos(phi)};
72+
const double py{pt * std::sin(phi)};
73+
const double pz{pt * std::sinh(eta)};
74+
const double et{std::hypot(std::hypot(pt, pz), m)};
75+
sign *= randomizePDGsign ? -1 : 1;
76+
mParticles.push_back(TParticle(sign * pdg2, 1, -1, -1, -1, -1, px, py, pz, et, 0., 0., 0., 0.));
77+
}
78+
}
79+
6380
return true;
6481
}
6582

@@ -73,11 +90,13 @@ private:
7390
int pdg = 0; /// particle pdg code
7491
int nParticles = 1; /// Number of injected particles
7592

93+
int pdg2 = -1; /// optional second particle pdg code
94+
7695
bool randomizePDGsign = true; /// bool to randomize the PDG code of the core particle
7796
};
7897

7998
///___________________________________________________________
80-
FairGenerator *generateLongLived(int pdg, int nInject)
99+
FairGenerator *generateLongLived(int pdg, int nInject, float ptMin = 1, float ptMax = 10, int pdg2 = -1)
81100
{
82-
return new GeneratorPythia8LongLivedGun(pdg, nInject);
101+
return new GeneratorPythia8LongLivedGun(pdg, nInject, ptMin, ptMax, pdg2);
83102
}

0 commit comments

Comments
 (0)