Skip to content

Commit a9dad91

Browse files
committed
[PWGDQ] Adding pythia Onia generator for prompt J/psi+psi(2S) at fwd-y
1 parent 628493e commit a9dad91

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,32 @@ FairGenerator*
207207

208208
return gen;
209209
}
210+
211+
FairGenerator*
212+
GeneratorPromptJpsiPsi2S_EvtGenFwdY(int triggerGap, double rapidityMin = -4.3, double rapidityMax = -2.3, bool verbose = false)
213+
{
214+
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorPythia8OniaPromptSignalsGapTriggered>();
215+
gen->setTriggerGap(triggerGap);
216+
gen->setRapidityRange(rapidityMin, rapidityMax);
217+
gen->addHadronPDGs(443);
218+
gen->addHadronPDGs(100443);
219+
gen->setVerbose(verbose);
220+
TString pathO2table = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/decayer/switchOffJpsi.cfg");
221+
gen->readFile(pathO2table.Data());
222+
gen->setConfigMBdecays(pathO2table);
223+
gen->PrintDebug(true);
224+
gen->SetSizePdg(2);
225+
gen->AddPdg(443, 0);
226+
gen->AddPdg(100443, 1);
227+
gen->SetForceDecay(kEvtDiMuon);
228+
// set random seed
229+
gen->readString("Random:setSeed on");
230+
uint random_seed;
231+
unsigned long long int random_value = 0;
232+
ifstream urandom("/dev/urandom", ios::in|ios::binary);
233+
urandom.read(reinterpret_cast<char*>(&random_value), sizeof(random_seed));
234+
gen->readString(Form("Random:seed = %llu", random_value % 900000001));
235+
// print debug
236+
// gen->PrintDebug();
237+
return gen;
238+
}
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=GeneratorPromptJpsiPsi2S_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: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
int External()
2+
{
3+
int checkPdgSignal[] = {443,100443};
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 << "\ndecay 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 nSignalPsi2S{};
24+
int nSignalJpsiWithinAcc{};
25+
int nSignalPsi2SWithinAcc{};
26+
auto nEvents = tree->GetEntries();
27+
o2::steer::MCKinematicsReader mcreader("o2sim", o2::steer::MCKinematicsReader::Mode::kMCKine);
28+
Bool_t isInjected = kFALSE;
29+
30+
for (int i = 0; i < nEvents; i++) {
31+
tree->GetEntry(i);
32+
for (auto& track : *tracks) {
33+
auto pdg = track.GetPdgCode();
34+
auto rapidity = track.GetRapidity();
35+
auto idMoth = track.getMotherTrackId();
36+
if (pdg == checkPdgDecay) {
37+
// count leptons
38+
nLeptons++;
39+
} else if(pdg == -checkPdgDecay) {
40+
// count anti-leptons
41+
nAntileptons++;
42+
} else if (pdg == checkPdgSignal[0] || pdg == checkPdgSignal[1]) {
43+
if(idMoth < 0){
44+
// count signal PDG
45+
pdg == checkPdgSignal[0] ? nSignalJpsi++ : nSignalPsi2S++;
46+
// count signal PDG within acceptance
47+
if(rapidity > rapiditymin && rapidity < rapiditymax) { pdg == checkPdgSignal[0] ? nSignalJpsiWithinAcc++ : nSignalPsi2SWithinAcc++;}
48+
}
49+
auto child0 = o2::mcutils::MCTrackNavigator::getDaughter0(track, *tracks);
50+
auto child1 = o2::mcutils::MCTrackNavigator::getDaughter1(track, *tracks);
51+
if (child0 != nullptr && child1 != nullptr) {
52+
// check for parent-child relations
53+
auto pdg0 = child0->GetPdgCode();
54+
auto pdg1 = child1->GetPdgCode();
55+
std::cout << "First and last children of parent " << checkPdgSignal << " are PDG0: " << pdg0 << " PDG1: " << pdg1 << "\n";
56+
if (std::abs(pdg0) == checkPdgDecay && std::abs(pdg1) == checkPdgDecay && pdg0 == -pdg1) {
57+
nLeptonPairs++;
58+
if (child0->getToBeDone() && child1->getToBeDone()) {
59+
nLeptonPairsToBeDone++;
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
std::cout << "#events: " << nEvents << "\n"
67+
<< "#leptons: " << nLeptons << "\n"
68+
<< "#antileptons: " << nAntileptons << "\n"
69+
<< "#signal (prompt Jpsi): " << nSignalJpsi << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalJpsiWithinAcc << "\n"
70+
<< "#signal (prompt Psi(2S)): " << nSignalPsi2S << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalPsi2SWithinAcc << "\n"
71+
<< "#lepton pairs: " << nLeptonPairs << "\n"
72+
<< "#lepton pairs to be done: " << nLeptonPairs << "\n";
73+
74+
75+
if (nLeptonPairs == 0 || nLeptons == 0 || nAntileptons == 0) {
76+
std::cerr << "Number of leptons, number of anti-leptons as well as number of lepton pairs should all be greater than 1.\n";
77+
return 1;
78+
}
79+
if (nLeptonPairs != nLeptonPairsToBeDone) {
80+
std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n";
81+
return 1;
82+
}
83+
84+
return 0;
85+
}

0 commit comments

Comments
 (0)