Skip to content

Commit 9a9a541

Browse files
DQ InjectedInclusiveJpsiPsi2SMidy generators (#2350)
* Create Generator_InjectedInclusiveJpsiPsi2SMidy_2026_Pythia8_TriggerGap.C * Create Generator_InjectedInclusiveJpsiPsi2SMidy_Pythia8_TriggerGap.C
1 parent 7278c4a commit 9a9a541

3 files changed

Lines changed: 181 additions & 0 deletions
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_pythia8_HadronTriggered_withGap.C
4+
funcName=GeneratorInclusiveJpsiPsi2S_EvtGenMidY(5,-1.5,1.5)
5+
6+
[GeneratorPythia8]
7+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_inel_triggerGap.cfg
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
int External()
2+
{
3+
int checkPdgSignal[] = {443, 100443};
4+
int checkPdgDecay = 11;
5+
double rapiditymin = -4.3;
6+
double rapiditymax = -2.3;
7+
std::string path{"o2sim_Kine.root"};
8+
std::cout << "Check for\nsignal PDG " << checkPdgSignal << "\ndecay PDG " << checkPdgDecay << "\n";
9+
TFile file(path.c_str(), "READ");
10+
if (file.IsZombie())
11+
{
12+
std::cerr << "Cannot open ROOT file " << path << "\n";
13+
return 1;
14+
}
15+
16+
auto tree = (TTree *)file.Get("o2sim");
17+
std::vector<o2::MCTrack> *tracks{};
18+
tree->SetBranchAddress("MCTrack", &tracks);
19+
20+
int nLeptons{};
21+
int nAntileptons{};
22+
int nLeptonPairs{};
23+
int nLeptonPairsToBeDone{};
24+
int nSignalJpsi{};
25+
int nSignalPsi2S{};
26+
int nSignalJpsiWithinAcc{};
27+
int nSignalPsi2SWithinAcc{};
28+
auto nEvents = tree->GetEntries();
29+
o2::steer::MCKinematicsReader mcreader("o2sim", o2::steer::MCKinematicsReader::Mode::kMCKine);
30+
Bool_t isInjected = kFALSE;
31+
32+
for (int i = 0; i < nEvents; i++)
33+
{
34+
tree->GetEntry(i);
35+
for (auto &track : *tracks)
36+
{
37+
auto pdg = track.GetPdgCode();
38+
auto rapidity = track.GetRapidity();
39+
auto idMoth = track.getMotherTrackId();
40+
if (pdg == checkPdgDecay)
41+
{
42+
// count leptons
43+
nLeptons++;
44+
}
45+
else if (pdg == -checkPdgDecay)
46+
{
47+
// count anti-leptons
48+
nAntileptons++;
49+
}
50+
else if (pdg == checkPdgSignal[0] || pdg == checkPdgSignal[1])
51+
{
52+
if (idMoth < 0)
53+
{
54+
// count signal PDG
55+
pdg == checkPdgSignal[0] ? nSignalJpsi++ : nSignalPsi2S++;
56+
// count signal PDG within acceptance
57+
if (rapidity > rapiditymin && rapidity < rapiditymax)
58+
{
59+
pdg == checkPdgSignal[0] ? nSignalJpsiWithinAcc++ : nSignalPsi2SWithinAcc++;
60+
}
61+
}
62+
auto child0 = o2::mcutils::MCTrackNavigator::getDaughter0(track, *tracks);
63+
auto child1 = o2::mcutils::MCTrackNavigator::getDaughter1(track, *tracks);
64+
if (child0 != nullptr && child1 != nullptr)
65+
{
66+
// check for parent-child relations
67+
auto pdg0 = child0->GetPdgCode();
68+
auto pdg1 = child1->GetPdgCode();
69+
std::cout << "First and last children of parent " << checkPdgSignal << " are PDG0: " << pdg0 << " PDG1: " << pdg1 << "\n";
70+
if (std::abs(pdg0) == checkPdgDecay && std::abs(pdg1) == checkPdgDecay && pdg0 == -pdg1)
71+
{
72+
nLeptonPairs++;
73+
if (child0->getToBeDone() && child1->getToBeDone())
74+
{
75+
nLeptonPairsToBeDone++;
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}
82+
std::cout << "#events: " << nEvents << "\n"
83+
<< "#leptons: " << nLeptons << "\n"
84+
<< "#antileptons: " << nAntileptons << "\n"
85+
<< "#signal (prompt Jpsi): " << nSignalJpsi << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalJpsiWithinAcc << "\n"
86+
<< "#signal (prompt Psi(2S)): " << nSignalPsi2S << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalPsi2SWithinAcc << "\n"
87+
<< "#lepton pairs: " << nLeptonPairs << "\n"
88+
<< "#lepton pairs to be done: " << nLeptonPairs << "\n";
89+
90+
if (nLeptonPairs == 0 || nLeptons == 0 || nAntileptons == 0)
91+
{
92+
std::cerr << "Number of leptons, number of anti-leptons as well as number of lepton pairs should all be greater than 1.\n";
93+
return 1;
94+
}
95+
if (nLeptonPairs != nLeptonPairsToBeDone)
96+
{
97+
std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n";
98+
return 1;
99+
}
100+
101+
return 0;
102+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
int External()
2+
{
3+
int checkPdgSignal = 443;
4+
int checkPdgDecay = 11;
5+
std::string path{"o2sim_Kine.root"};
6+
std::cout << "Check for\nsignal PDG " << checkPdgSignal << "\ndecay PDG " << checkPdgDecay << "\n";
7+
TFile file(path.c_str(), "READ");
8+
if (file.IsZombie()) {
9+
std::cerr << "Cannot open ROOT file " << path << "\n";
10+
return 1;
11+
}
12+
13+
auto tree = (TTree*)file.Get("o2sim");
14+
std::vector<o2::MCTrack>* tracks{};
15+
tree->SetBranchAddress("MCTrack", &tracks);
16+
17+
int nLeptons{};
18+
int nAntileptons{};
19+
int nLeptonPairs{};
20+
int nLeptonPairsToBeDone{};
21+
int nSignal{};
22+
auto nEvents = tree->GetEntries();
23+
24+
for (int i = 0; i < nEvents; i++) {
25+
tree->GetEntry(i);
26+
for (auto& track : *tracks) {
27+
auto pdg = track.GetPdgCode();
28+
if (pdg == checkPdgDecay) {
29+
// count leptons
30+
nLeptons++;
31+
} else if(pdg == -checkPdgDecay) {
32+
// count anti-leptons
33+
nAntileptons++;
34+
} else if (pdg == checkPdgSignal) {
35+
// count signal PDG
36+
nSignal++;
37+
auto child0 = o2::mcutils::MCTrackNavigator::getDaughter0(track, *tracks);
38+
auto child1 = o2::mcutils::MCTrackNavigator::getDaughter1(track, *tracks);
39+
if (child0 != nullptr && child1 != nullptr) {
40+
// check for parent-child relations
41+
auto pdg0 = child0->GetPdgCode();
42+
auto pdg1 = child1->GetPdgCode();
43+
std::cout << "First and last children of parent " << checkPdgSignal << " are PDG0: " << pdg0 << " PDG1: " << pdg1 << "\n";
44+
if (std::abs(pdg0) == checkPdgDecay && std::abs(pdg1) == checkPdgDecay && pdg0 == -pdg1) {
45+
nLeptonPairs++;
46+
if (child0->getToBeDone() && child1->getToBeDone()) {
47+
nLeptonPairsToBeDone++;
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
std::cout << "#events: " << nEvents << "\n"
55+
<< "#leptons: " << nLeptons << "\n"
56+
<< "#antileptons: " << nAntileptons << "\n"
57+
<< "#signal: " << nSignal << "\n"
58+
<< "#lepton pairs: " << nLeptonPairs << "\n"
59+
<< "#lepton pairs to be done: " << nLeptonPairs << "\n";
60+
61+
62+
if (nLeptonPairs == 0 || nLeptons == 0 || nAntileptons == 0) {
63+
std::cerr << "Number of leptons, number of anti-leptons as well as number of lepton pairs should all be greater than 1.\n";
64+
return 1;
65+
}
66+
if (nLeptonPairs != nLeptonPairsToBeDone) {
67+
std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n";
68+
return 1;
69+
}
70+
71+
return 0;
72+
}

0 commit comments

Comments
 (0)