Skip to content

Commit 6575875

Browse files
authored
[PWGDQ] Add pythia8 prompt J/psi generator at forward rapidity (#1902)
* [PWGDQ] Add pythia8 prompt J/psi generator at forward rapidity * Adding test macro
1 parent 73fd429 commit 6575875

File tree

4 files changed

+124
-2
lines changed

4 files changed

+124
-2
lines changed

MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,37 @@ FairGenerator*
173173
// gen->PrintDebug();
174174

175175
return gen;
176-
}
176+
}
177+
178+
FairGenerator*
179+
GeneratorPromptJpsi_EvtGenFwdy(int triggerGap, double rapidityMin = -4.3, double rapidityMax = -2.3, bool verbose = false)
180+
{
181+
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorPythia8OniaPromptSignalsGapTriggered>();
182+
gen->setTriggerGap(triggerGap);
183+
gen->setRapidityRange(rapidityMin, rapidityMax);
184+
gen->addHadronPDGs(443);
185+
gen->setVerbose(verbose);
186+
187+
TString pathO2table = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/decayer/switchOffJpsi.cfg");
188+
gen->readFile(pathO2table.Data());
189+
gen->setConfigMBdecays(pathO2table);
190+
gen->PrintDebug(true);
191+
192+
gen->SetSizePdg(1);
193+
gen->AddPdg(443, 0);
194+
195+
gen->SetForceDecay(kEvtDiMuon);
196+
197+
// set random seed
198+
gen->readString("Random:setSeed on");
199+
uint random_seed;
200+
unsigned long long int random_value = 0;
201+
ifstream urandom("/dev/urandom", ios::in|ios::binary);
202+
urandom.read(reinterpret_cast<char*>(&random_value), sizeof(random_seed));
203+
gen->readString(Form("Random:seed = %llu", random_value % 900000001));
204+
205+
// print debug
206+
// gen->PrintDebug();
207+
208+
return gen;
209+
}
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_EvtGenFwdy(5,-4.3,-2.3)
5+
6+
[GeneratorPythia8]
7+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_onia_triggerGap.cfg
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
int External()
2+
{
3+
int checkPdgSignal[] = {443};
4+
int checkPdgDecay = 13;
5+
double rapiditymin = -4.3; double rapiditymax = -2.3;
6+
std::string path{"o2sim_Kine.root"};
7+
std::cout << "Check for\nsignal PDG " << checkPdgSignal[0] << "\n decay PDG " << checkPdgDecay << "\n";
8+
TFile file(path.c_str(), "READ");
9+
if (file.IsZombie()) {
10+
std::cerr << "Cannot open ROOT file " << path << "\n";
11+
return 1;
12+
}
13+
14+
auto tree = (TTree*)file.Get("o2sim");
15+
std::vector<o2::MCTrack>* tracks{};
16+
tree->SetBranchAddress("MCTrack", &tracks);
17+
18+
int nLeptons{};
19+
int nAntileptons{};
20+
int nLeptonPairs{};
21+
int nLeptonPairsToBeDone{};
22+
int nSignalJpsi{};
23+
int nSignalJpsiWithinAcc{};
24+
auto nEvents = tree->GetEntries();
25+
o2::steer::MCKinematicsReader mcreader("o2sim", o2::steer::MCKinematicsReader::Mode::kMCKine);
26+
Bool_t isInjected = kFALSE;
27+
28+
for (int i = 0; i < nEvents; i++) {
29+
tree->GetEntry(i);
30+
for (auto& track : *tracks) {
31+
auto pdg = track.GetPdgCode();
32+
auto rapidity = track.GetRapidity();
33+
auto idMoth = track.getMotherTrackId();
34+
if (pdg == checkPdgDecay) {
35+
// count leptons
36+
nLeptons++;
37+
} else if(pdg == -checkPdgDecay) {
38+
// count anti-leptons
39+
nAntileptons++;
40+
} else if (pdg == checkPdgSignal[0]) {
41+
if(idMoth < 0){
42+
// count signal PDG
43+
nSignalJpsi++;
44+
// count signal PDG within acceptance
45+
if(rapidity > rapiditymin && rapidity < rapiditymax) nSignalJpsiWithinAcc++;
46+
}
47+
auto child0 = o2::mcutils::MCTrackNavigator::getDaughter0(track, *tracks);
48+
auto child1 = o2::mcutils::MCTrackNavigator::getDaughter1(track, *tracks);
49+
if (child0 != nullptr && child1 != nullptr) {
50+
// check for parent-child relations
51+
auto pdg0 = child0->GetPdgCode();
52+
auto pdg1 = child1->GetPdgCode();
53+
std::cout << "First and last children of parent " << checkPdgSignal << " are PDG0: " << pdg0 << " PDG1: " << pdg1 << "\n";
54+
if (std::abs(pdg0) == checkPdgDecay && std::abs(pdg1) == checkPdgDecay && pdg0 == -pdg1) {
55+
nLeptonPairs++;
56+
if (child0->getToBeDone() && child1->getToBeDone()) {
57+
nLeptonPairsToBeDone++;
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}
64+
std::cout << "#events: " << nEvents << "\n"
65+
<< "#leptons: " << nLeptons << "\n"
66+
<< "#antileptons: " << nAntileptons << "\n"
67+
<< "#signal (prompt Jpsi): " << nSignalJpsi << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalJpsiWithinAcc << "\n"
68+
<< "#lepton pairs: " << nLeptonPairs << "\n"
69+
<< "#lepton pairs to be done: " << nLeptonPairs << "\n";
70+
71+
72+
if (nLeptonPairs == 0 || nLeptons == 0 || nAntileptons == 0) {
73+
std::cerr << "Number of leptons, number of anti-leptons as well as number of lepton pairs should all be greater than 1.\n";
74+
return 1;
75+
}
76+
if (nLeptonPairs != nLeptonPairsToBeDone) {
77+
std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n";
78+
return 1;
79+
}
80+
81+
return 0;
82+
}

MC/config/common/pythia8/generator/pythia8_hf.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### beams
22
Beams:idA 2212 # proton
33
Beams:idB 2212 # proton
4-
Beams:eCM 14000. # GeV
4+
Beams:eCM 13600. # GeV
55

66
### processes
77
HardQCD:hardccbar on # scatterings g-g / q-qbar -> c-cbar

0 commit comments

Comments
 (0)