Skip to content

Commit 514cd66

Browse files
authored
[PWGLF] MC for Uncorrelated+Correlated phi-phi pairs for phi-phi resonance study (#2469)
* MC for Uncorrelated+Correlated phi-phi pairs for phi-phi resonance study * modified the test script to print relevant info regarding injected particles and their daughters * fixed path error * Rename function to GeneratorLF_phiphiInvMass.C * Renamed to GeneratorLF_phiphiInvMass.ini
1 parent 9b87eb1 commit 514cd66

3 files changed

Lines changed: 415 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[GeneratorExternal]
2+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/GeneratorLF_phiphi.C
3+
funcName=generatePhiResonanceGun(999999, 0.0, 50.0, -1.0, 1.0, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", 3)
4+
5+
[GeneratorPythia8]
6+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg
7+
8+
[DecayerPythia8]
9+
config[0]=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/decayer/base.cfg
10+
config[1]=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonances.cfg
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
int External()
2+
{
3+
const std::string path{"o2sim_Kine.root"};
4+
5+
TFile file(path.c_str(), "READ");
6+
if (file.IsZombie())
7+
{
8+
std::cerr << "Cannot open ROOT file " << path << "\n";
9+
return 1;
10+
}
11+
12+
auto tree = (TTree *)file.Get("o2sim");
13+
if (!tree)
14+
{
15+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
16+
return 1;
17+
}
18+
19+
std::vector<o2::MCTrack> *tracks{};
20+
tree->SetBranchAddress("MCTrack", &tracks);
21+
22+
// Counters
23+
int nResonance999999 = 0;
24+
int nNotDecayed999999 = 0;
25+
int nPhiFromResonance = 0;
26+
27+
// Decay counts into K+ K- (PDG 321, -321)
28+
int nKPlusFromResonancePhi = 0;
29+
int nKMinusFromResonancePhi = 0;
30+
31+
int nDirectInjectedPhi = 0;
32+
int nMBPhi = 0;
33+
34+
int nKPlusFromDirectPhi = 0;
35+
int nKMinusFromDirectPhi = 0;
36+
int nKPlusFromMBPhi = 0;
37+
int nKMinusFromMBPhi = 0;
38+
39+
int numberOfEventsProcessed = 0;
40+
int numberOfEventsProcessedWithoutInjection = 0;
41+
42+
for (Long64_t i = 0; i < tree->GetEntries(); ++i)
43+
{
44+
tree->GetEntry(i);
45+
++numberOfEventsProcessed;
46+
bool hasInjection = false;
47+
48+
for (size_t idx = 0; idx < tracks->size(); ++idx)
49+
{
50+
const auto &track = tracks->at(idx);
51+
const auto pdg = track.GetPdgCode();
52+
53+
// 1. Process Custom Resonance 999999
54+
if (pdg == 999999)
55+
{
56+
++nResonance999999;
57+
hasInjection = true;
58+
59+
if (track.getFirstDaughterTrackId() < 0)
60+
{
61+
++nNotDecayed999999;
62+
continue;
63+
}
64+
65+
// Loop through daughters of 999999 (Phi mesons)
66+
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
67+
{
68+
const auto &phiTrack = tracks->at(j);
69+
if (phiTrack.GetPdgCode() == 333)
70+
{
71+
++nPhiFromResonance;
72+
73+
// Check daughters of this Phi (granddaughters of 999999)
74+
if (phiTrack.getFirstDaughterTrackId() >= 0)
75+
{
76+
for (int k = phiTrack.getFirstDaughterTrackId(); k <= phiTrack.getLastDaughterTrackId(); ++k)
77+
{
78+
auto grandDauPdg = tracks->at(k).GetPdgCode();
79+
if (grandDauPdg == 321) ++nKPlusFromResonancePhi;
80+
if (grandDauPdg == -321) ++nKMinusFromResonancePhi;
81+
}
82+
}
83+
}
84+
}
85+
}
86+
87+
// 2. Process Phi (333) Mesons
88+
else if (pdg == 333)
89+
{
90+
int motherId = track.getMotherTrackId();
91+
int motherPdg = (motherId >= 0 && motherId < (int)tracks->size()) ? tracks->at(motherId).GetPdgCode() : 0;
92+
93+
// Skip Phi from 999999 here as it was handled above
94+
if (motherPdg == 999999)
95+
{
96+
continue;
97+
}
98+
99+
bool isDirectInjected = (motherId < 0);
100+
101+
if (isDirectInjected)
102+
{
103+
++nDirectInjectedPhi;
104+
hasInjection = true;
105+
106+
if (track.getFirstDaughterTrackId() >= 0)
107+
{
108+
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
109+
{
110+
auto dauPdg = tracks->at(j).GetPdgCode();
111+
if (dauPdg == 321) ++nKPlusFromDirectPhi;
112+
if (dauPdg == -321) ++nKMinusFromDirectPhi;
113+
}
114+
}
115+
}
116+
else
117+
{
118+
// Minimum Bias Phi
119+
++nMBPhi;
120+
121+
if (track.getFirstDaughterTrackId() >= 0)
122+
{
123+
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
124+
{
125+
auto dauPdg = tracks->at(j).GetPdgCode();
126+
if (dauPdg == 321) ++nKPlusFromMBPhi;
127+
if (dauPdg == -321) ++nKMinusFromMBPhi;
128+
}
129+
}
130+
}
131+
}
132+
}
133+
134+
if (!hasInjection)
135+
{
136+
++numberOfEventsProcessedWithoutInjection;
137+
}
138+
}
139+
140+
std::cout << "--------------------------------\n";
141+
std::cout << "Total Events Processed: " << tree->GetEntries() << "\n\n";
142+
143+
std::cout << "--- 1. INJECTED RESONANCE (999999) ---\n";
144+
std::cout << "Total Injected Resonance 999999: " << nResonance999999 << "\n";
145+
std::cout << "Resonances not decayed: " << nNotDecayed999999 << "\n";
146+
std::cout << "Daughter Phi (333) produced from 999999: " << nPhiFromResonance << "\n";
147+
std::cout << " -> Decayed to K+: " << nKPlusFromResonancePhi << "\n";
148+
std::cout << " -> Decayed to K-: " << nKMinusFromResonancePhi << "\n\n";
149+
150+
std::cout << "--- 2. DIRECTLY INJECTED PHI (333) ---\n";
151+
std::cout << "Total Directly Injected Phi (333): " << nDirectInjectedPhi << "\n";
152+
std::cout << " -> Decayed to K+: " << nKPlusFromDirectPhi << "\n";
153+
std::cout << " -> Decayed to K-: " << nKMinusFromDirectPhi << "\n\n";
154+
155+
std::cout << "--- 3. MINIMUM BIAS PHI (333) ---\n";
156+
std::cout << "Total Minimum Bias Phi (333): " << nMBPhi << "\n";
157+
std::cout << " -> Decayed to K+: " << nKPlusFromMBPhi << "\n";
158+
std::cout << " -> Decayed to K-: " << nKMinusFromMBPhi << "\n";
159+
std::cout << "--------------------------------\n";
160+
std::cout << "Events processed without signal injection: " << numberOfEventsProcessedWithoutInjection << "\n";
161+
162+
return 0;
163+
}
164+
165+
void GeneratorLF_phiphiInvMass()
166+
{
167+
External();
168+
}

0 commit comments

Comments
 (0)