Skip to content

Commit 7fd86b6

Browse files
committed
PWGJE - trying jet sim with min bias gaps
1 parent 78ae2f6 commit 7fd86b6

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#include "FairGenerator.h"
2+
#include "Generators/GeneratorPythia8.h"
3+
#include "Pythia8/Pythia.h"
4+
#include "TRandom.h"
5+
#include <fairlogger/Logger.h>
6+
7+
#include <string>
8+
#include <vector>
9+
10+
// Example of an implementation of an event generator
11+
// that alternates between 2 gun generators. Serves as example
12+
// to construct any meta-generator (such as cocktails) consisting
13+
// or using a pool of underlying o2::eventgen::Generators.
14+
15+
// Test is using #o2-sim-dpl-eventgen --nEvents 10 --generator external --configKeyValues "GeneratorExternal.fileName=${O2DPG_ROOT}/MC/config/PWGGAJE/external/generator/generator_pythia8_gapgenerated_jets.C;GeneratorExternal.funcName=GeneratorPythia8GapGenJE()"
16+
17+
namespace o2
18+
{
19+
namespace eventgen
20+
{
21+
22+
23+
/// A very simple gap generator alternating between 2 different particle guns
24+
class GeneratorPythia8GapGenJE : public Generator
25+
{
26+
public:
27+
/// default constructor
28+
GeneratorPythia8GapGenJE(int inputTriggerRatio = 5) {
29+
// put 2 different generators in the cocktail of generators
30+
gens.push_back(new o2::eventgen::GeneratorPythia8);
31+
gens.push_back(new o2::eventgen::GeneratorPythia8);
32+
33+
mGeneratedEvents = 0;
34+
mInverseTriggerRatio = inputTriggerRatio;
35+
}
36+
37+
38+
/// Destructor
39+
~GeneratorPythia8GapGenJE() = default;
40+
41+
Bool_t Init() override
42+
{
43+
// init all sub-gens
44+
gens[0].config=${O2DPG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_jet.cfg;
45+
gens[1].config=${O2DPG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_minBias.cfg; //gotta keep this one identical with pythia8_jet, maybe have them be generated once we understand how it works and have more time
46+
for (auto gen : gens) {
47+
gen->Init();
48+
}
49+
addSubGenerator(0, "Minimum bias"); // name the generators
50+
addSubGenerator(1, "High jet pt biased gen");
51+
return Generator::Init();
52+
}
53+
54+
55+
void setUsedSeed(unsigned int seed)
56+
{
57+
mUsedSeed = seed;
58+
};
59+
unsigned int getUsedSeed() const
60+
{
61+
return mUsedSeed;
62+
};
63+
64+
// Bool_t generateEvent() override
65+
// {
66+
// // here we call the individual gun generators in turn
67+
// // (but we could easily call all of them to have cocktails)
68+
// currentindex++;
69+
// currentgen = gens[currentindex % 2];
70+
// currentgen->generateEvent();
71+
// // notify the sub event generator
72+
// notifySubGenerator(currentindex % 2);
73+
// return true;
74+
// }
75+
bool generateEvent() override
76+
{
77+
78+
79+
// Simple straightforward check to alternate generators
80+
if (mGeneratedEvents % mInverseTriggerRatio == 0)
81+
{
82+
currentgen = gens[1];
83+
currentgen->generateEvent();
84+
notifySubGenerator(1); // this gives the id 1 to the high pt jet biased pythia generator
85+
}
86+
else
87+
{
88+
currentgen = gens[0];
89+
currentgen->generateEvent(); //GeneratorPythia8::generateEvent()
90+
notifySubGenerator(0); // this gives the id 0 to the minimum-bias pythia generator
91+
}
92+
mGeneratedEvents++;
93+
return true;
94+
}
95+
96+
// We override this function to import the particles from the
97+
// underlying generators into **this** generator instance
98+
Bool_t importParticles() override // not sure about what this does
99+
{
100+
mParticles.clear(); // clear container of mother class
101+
currentgen->importParticles();
102+
std::copy(currentgen->getParticles().begin(), currentgen->getParticles().end(), std::back_insert_iterator(mParticles));
103+
104+
// we need to fix particles statuses --> need to enforce this on the importParticles level of individual generators
105+
for (auto& p : mParticles) {
106+
auto st = o2::mcgenstatus::MCGenStatusEncoding(p.GetStatusCode(), p.GetStatusCode()).fullEncoding;
107+
p.SetStatusCode(st);
108+
p.SetBit(ParticleStatus::kToBeDone, true);
109+
}
110+
111+
return true;
112+
}
113+
114+
private:
115+
// Interface to override import particles
116+
Pythia8::Event mOutputEvent;
117+
118+
// Properties of selection
119+
unsigned int mUsedSeed;
120+
121+
// Control gap-triggering
122+
unsigned long long mGeneratedEvents;
123+
int mInverseTriggerRatio;
124+
125+
// Handling generators
126+
std::vector<o2::eventgen::GeneratorPythia8*> gens;
127+
o2::eventgen::GeneratorPythia8* currentgen = nullptr;
128+
129+
};
130+
131+
} // namespace eventgen
132+
} // namespace o2
133+
134+
/** generator instance and settings **/
135+
136+
FairGenerator* getGeneratorPythia8GapGenJE() {
137+
auto myGen = new GeneratorPythia8GapTriggeredJE(inputTriggerRatio);
138+
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
139+
myGen->setUsedSeed(seed);
140+
myGen->readString("Random:setSeed on");
141+
myGen->readString("Random:seed " + std::to_string(seed));
142+
return new o2::eventgen::GeneratorPythia8GapGenJE();
143+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### The external generator derives from GeneratorPythia8.
2+
[GeneratorExternal]
3+
fileName=${O2DPG_ROOT}/MC/config/PWGGAJE/external/generator/generator_pythia8_gapgenerated_jets.C
4+
funcName=GeneratorPythia8GapGenJE(3)
5+
6+
# [GeneratorPythia8GapTriggeredJetsStandard]
7+
[GeneratorExternal]
8+
config=${O2DPG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_jet.cfg
9+
10+
# # [GeneratorPythia8MinBias]
11+
# [GeneratorPythia8]
12+
# config=${O2DPG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_standard.cfg ????????????????????????????
13+
14+
### The external generator derives from GeneratorPythia8.
15+
[GeneratorExternal]
16+
fileName=${O2DPG_ROOT}/MC/config/PWGGAJE/external/generator/generator_pythia8_gaptriggered_jets.C
17+
funcName=GeneratorPythia8GapTriggeredCharmAndBeauty(inputTriggerRatio_thatWeSet)
18+
19+
[GeneratorPythia8]
20+
config=${O2DPG_ROOT}/MC/config/PWGGAJE/pythia8/generator/theConfigWeWroteAbove.cfg
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# ### random
3+
# # if we want to input a spectific seed:
4+
5+
# Random:setSeed = on
6+
# Random:seed = seed
7+
8+
### beams
9+
Beams:idA = 2212 # proton
10+
Beams:idB = 2212 # proton
11+
Beams:eCM = 13600. # GeV
12+
13+
### processes
14+
SoftQCD:inelastic = off
15+
HardQCD:all = on
16+
17+
### decays
18+
ParticleDecays:limitTau0 = on
19+
ParticleDecays:tau0Max = 10.
20+
21+
### phase space cuts
22+
PhaseSpace:pTHatMin = 5
23+
PhaseSpace:pTHatMax = 300
24+
PhaseSpace:bias2Selection = on
25+
PhaseSpace:bias2SelectionPow = weightPower
26+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
# ### random
3+
# # if we want to input a spectific seed:
4+
5+
# Random:setSeed = on
6+
# Random:seed = seed
7+
8+
### beams
9+
Beams:idA = 2212 # proton
10+
Beams:idB = 2212 # proton
11+
Beams:eCM = 13600. # GeV
12+
13+
### processes
14+
SoftQCD:inelastic = off
15+
# HardQCD:all = on //
16+
17+
### decays
18+
ParticleDecays:limitTau0 = on
19+
ParticleDecays:tau0Max = 10.
20+
21+
# ### phase space cuts
22+
# PhaseSpace:pTHatMin = 5
23+
# PhaseSpace:pTHatMax = 300
24+
# PhaseSpace:bias2Selection = on
25+
# PhaseSpace:bias2SelectionPow = weightPower
26+
27+

0 commit comments

Comments
 (0)