Skip to content

Commit 72abf37

Browse files
iarseneIonut Cristian Arsene
andauthored
[PWGDQ] Add a generator of jpsi based on pythia8 with SoftQCD:inelastic and CharmoniumShower:all options (#1887)
* Adding a prompt Jpsi generator using pythia8 CharmoniumShower:all option * switch off the jpsi decays * adding the trigger gap as a parameter * Adding tags for min bias and events containing signal --------- Co-authored-by: Ionut Cristian Arsene <iarsene@cern.ch>
1 parent 0af4938 commit 72abf37

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
#include "FairGenerator.h"
2+
#include "Generators/GeneratorPythia8.h"
3+
#include "Pythia8/Pythia.h"
4+
#include "TRandom.h"
5+
6+
R__ADD_INCLUDE_PATH($O2DPG_MC_CONFIG_ROOT/MC/config/PWGDQ/EvtGen)
7+
#include "GeneratorEvtGen.C"
8+
9+
#include <string>
10+
11+
using namespace o2::eventgen;
12+
13+
namespace o2
14+
{
15+
namespace eventgen
16+
{
17+
18+
class GeneratorPythia8OniaPromptSignalsGapTriggered : public o2::eventgen::GeneratorPythia8 {
19+
public:
20+
21+
/// constructor
22+
GeneratorPythia8OniaPromptSignalsGapTriggered(int inputTriggerRatio = 5) {
23+
24+
mGeneratedEvents = 0;
25+
mInverseTriggerRatio = inputTriggerRatio;
26+
// define minimum bias event generator
27+
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
28+
TString pathconfigMB = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_inel_triggerGap.cfg");
29+
pythiaMBgen.readFile(pathconfigMB.Data());
30+
pythiaMBgen.readString("Random:setSeed on");
31+
pythiaMBgen.readString("Random:seed " + std::to_string(seed));
32+
mConfigMBdecays = "";
33+
mRapidityMin = -1.;
34+
mRapidityMax = 1.;
35+
mVerbose = false;
36+
}
37+
38+
/// Destructor
39+
~GeneratorPythia8OniaPromptSignalsGapTriggered() = default;
40+
41+
void addHadronPDGs(int pdg) { mHadronsPDGs.push_back(pdg); };
42+
43+
void setRapidityRange(double valMin, double valMax)
44+
{
45+
mRapidityMin = valMin;
46+
mRapidityMax = valMax;
47+
};
48+
49+
void setTriggerGap(int triggerGap) {mInverseTriggerRatio = triggerGap;}
50+
51+
void setConfigMBdecays(TString val){mConfigMBdecays = val;}
52+
53+
void setVerbose(bool val) { mVerbose = val; };
54+
55+
protected:
56+
57+
bool generateEvent() override {
58+
// reset event
59+
bool genOk = false;
60+
if (mGeneratedEvents % mInverseTriggerRatio == 0) {
61+
bool found = false;
62+
while (! (genOk && found)) {
63+
/// reset event
64+
mPythia.event.reset();
65+
genOk = GeneratorPythia8::generateEvent();
66+
// find the q-qbar or single hadron ancestor
67+
found = findHadrons(mPythia.event);
68+
}
69+
notifySubGenerator(1);
70+
} else {
71+
/// reset event
72+
pythiaMBgen.event.reset();
73+
while (!genOk) {
74+
genOk = pythiaMBgen.next();
75+
}
76+
mPythia.event = pythiaMBgen.event;
77+
notifySubGenerator(0);
78+
}
79+
mGeneratedEvents++;
80+
if (mVerbose) {
81+
mOutputEvent.list();
82+
}
83+
return true;
84+
}
85+
86+
bool Init() override {
87+
88+
if(mConfigMBdecays.Contains("cfg")) {
89+
pythiaMBgen.readFile(mConfigMBdecays.Data());
90+
}
91+
addSubGenerator(0, "Minimum bias");
92+
addSubGenerator(1, "Onia injected");
93+
GeneratorPythia8::Init();
94+
pythiaMBgen.init();
95+
return true;
96+
}
97+
98+
// search for the presence of at least one of the required hadrons in a selected rapidity window
99+
bool findHadrons(Pythia8::Event& event) {
100+
101+
for (int ipa = 0; ipa < event.size(); ++ipa) {
102+
103+
auto daughterList = event[ipa].daughterList();
104+
105+
for (auto ida : daughterList) {
106+
for (int pdg : mHadronsPDGs) { // check that at least one of the pdg code is found in the event
107+
if (event[ida].id() == pdg) {
108+
if ((event[ida].y() > mRapidityMin) && (event[ida].y() < mRapidityMax)) {
109+
cout << "============= Found jpsi y,pt " << event[ida].y() << ", " << event[ida].pT() << endl;
110+
std::vector<int> daughters = event[ida].daughterList();
111+
for (int d : daughters) {
112+
cout << "###### daughter " << d << ": code " << event[d].id() << ", pt " << event[d].pT() << endl;
113+
}
114+
return true;
115+
}
116+
}
117+
}
118+
}
119+
}
120+
121+
return false;
122+
};
123+
124+
125+
private:
126+
// Interface to override import particles
127+
Pythia8::Event mOutputEvent;
128+
129+
// Control gap-triggering
130+
unsigned long long mGeneratedEvents;
131+
int mInverseTriggerRatio;
132+
Pythia8::Pythia pythiaMBgen; // minimum bias event
133+
TString mConfigMBdecays;
134+
std::vector<int> mHadronsPDGs;
135+
double mRapidityMin;
136+
double mRapidityMax;
137+
bool mVerbose;
138+
};
139+
140+
}
141+
142+
}
143+
144+
// Predefined generators:
145+
FairGenerator*
146+
GeneratorPromptJpsi_EvtGenMidY(int triggerGap, double rapidityMin = -1.5, double rapidityMax = 1.5, bool verbose = false)
147+
{
148+
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorPythia8OniaPromptSignalsGapTriggered>();
149+
gen->setTriggerGap(triggerGap);
150+
gen->setRapidityRange(rapidityMin, rapidityMax);
151+
gen->addHadronPDGs(443);
152+
gen->setVerbose(verbose);
153+
154+
TString pathO2table = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/decayer/switchOffJpsi.cfg");
155+
gen->readFile(pathO2table.Data());
156+
gen->setConfigMBdecays(pathO2table);
157+
gen->PrintDebug(true);
158+
159+
gen->SetSizePdg(1);
160+
gen->AddPdg(443, 0);
161+
162+
gen->SetForceDecay(kEvtDiElectron);
163+
164+
// set random seed
165+
gen->readString("Random:setSeed on");
166+
uint random_seed;
167+
unsigned long long int random_value = 0;
168+
ifstream urandom("/dev/urandom", ios::in|ios::binary);
169+
urandom.read(reinterpret_cast<char*>(&random_value), sizeof(random_seed));
170+
gen->readString(Form("Random:seed = %llu", random_value % 900000001));
171+
172+
// print debug
173+
// gen->PrintDebug();
174+
175+
return gen;
176+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### The external generator derives from GeneratorPythia8.
2+
[GeneratorExternal]
3+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C
4+
funcName=GeneratorPromptJpsi_EvtGenMidY(5,-1.5,1.5)
5+
6+
[GeneratorPythia8]
7+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_onia_triggerGap.cfg
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#switch off jpsi decays
2+
3+
443:mayDecay off # J/psi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### beams
2+
Beams:idA 2212 # proton
3+
Beams:idB 2212 # proton
4+
Beams:eCM 13600. # GeV
5+
6+
### processes
7+
SoftQCD:inelastic on # all inelastic processes
8+
CharmoniumShower:all = on
9+
10+
### decays
11+
ParticleDecays:limitTau0 on
12+
ParticleDecays:tau0Max 10.

0 commit comments

Comments
 (0)