Skip to content

Commit 552d68f

Browse files
author
Ionut Cristian Arsene
committed
Adding a prompt Jpsi generator using pythia8 CharmoniumShower:all option
1 parent 2e41460 commit 552d68f

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
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 setConfigMBdecays(TString val){mConfigMBdecays = val;}
50+
51+
void setVerbose(bool val) { mVerbose = val; };
52+
53+
protected:
54+
55+
bool generateEvent() override {
56+
// reset event
57+
bool genOk = false;
58+
if (mGeneratedEvents % mInverseTriggerRatio == 0) {
59+
bool found = false;
60+
while (! (genOk && found)) {
61+
/// reset event
62+
mPythia.event.reset();
63+
genOk = GeneratorPythia8::generateEvent();
64+
// find the q-qbar or single hadron ancestor
65+
found = findHadrons(mPythia.event);
66+
}
67+
} else {
68+
/// reset event
69+
pythiaMBgen.event.reset();
70+
while (!genOk) {
71+
genOk = pythiaMBgen.next();
72+
}
73+
mPythia.event = pythiaMBgen.event;
74+
}
75+
mGeneratedEvents++;
76+
if (mVerbose) {
77+
mOutputEvent.list();
78+
}
79+
return true;
80+
}
81+
82+
bool Init() override {
83+
84+
if(mConfigMBdecays.Contains("cfg")) {
85+
pythiaMBgen.readFile(mConfigMBdecays.Data());
86+
}
87+
GeneratorPythia8::Init();
88+
pythiaMBgen.init();
89+
return true;
90+
}
91+
92+
// search for the presence of at least one of the required hadrons in a selected rapidity window
93+
bool findHadrons(Pythia8::Event& event) {
94+
95+
for (int ipa = 0; ipa < event.size(); ++ipa) {
96+
97+
auto daughterList = event[ipa].daughterList();
98+
99+
for (auto ida : daughterList) {
100+
for (int pdg : mHadronsPDGs) { // check that at least one of the pdg code is found in the event
101+
if (event[ida].id() == pdg) {
102+
if ((event[ida].y() > mRapidityMin) && (event[ida].y() < mRapidityMax)) {
103+
cout << "============= Found jpsi y,pt " << event[ida].y() << ", " << event[ida].pT() << endl;
104+
std::vector<int> daughters = event[ida].daughterList();
105+
for (int d : daughters) {
106+
cout << "###### daughter " << d << ": code " << event[d].id() << ", pt " << event[d].pT() << endl;
107+
}
108+
return true;
109+
}
110+
}
111+
}
112+
}
113+
}
114+
115+
return false;
116+
};
117+
118+
119+
private:
120+
// Interface to override import particles
121+
Pythia8::Event mOutputEvent;
122+
123+
// Control gap-triggering
124+
unsigned long long mGeneratedEvents;
125+
int mInverseTriggerRatio;
126+
Pythia8::Pythia pythiaMBgen; // minimum bias event
127+
TString mConfigMBdecays;
128+
std::vector<int> mHadronsPDGs;
129+
double mRapidityMin;
130+
double mRapidityMax;
131+
bool mVerbose;
132+
};
133+
134+
}
135+
136+
}
137+
138+
// Predefined generators:
139+
FairGenerator*
140+
GeneratorPromptJpsi_EvtGenMidY(double rapidityMin = -1.5, double rapidityMax = 1.5, bool verbose = false)
141+
{
142+
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorPythia8OniaPromptSignalsGapTriggered>();
143+
gen->setRapidityRange(rapidityMin, rapidityMax);
144+
gen->addHadronPDGs(443);
145+
gen->setVerbose(verbose);
146+
147+
TString pathO2table = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/decayer/switchOffBhadrons.cfg");
148+
gen->readFile(pathO2table.Data());
149+
gen->setConfigMBdecays(pathO2table);
150+
151+
gen->SetSizePdg(1);
152+
gen->AddPdg(443, 0);
153+
gen->SetForceDecay(kEvtDiElectron);
154+
155+
// set random seed
156+
gen->readString("Random:setSeed on");
157+
uint random_seed;
158+
unsigned long long int random_value = 0;
159+
ifstream urandom("/dev/urandom", ios::in|ios::binary);
160+
urandom.read(reinterpret_cast<char*>(&random_value), sizeof(random_seed));
161+
gen->readString(Form("Random:seed = %llu", random_value % 900000001));
162+
163+
// print debug
164+
// gen->PrintDebug();
165+
166+
return gen;
167+
}
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(-1.5,1.5)
5+
6+
[GeneratorPythia8]
7+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_onia_triggerGap.cfg
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)