Skip to content

Commit f151a42

Browse files
committed
Added twoPhi trigger MC and renamed codes based on convention
1 parent cba47e1 commit f151a42

6 files changed

Lines changed: 277 additions & 72 deletions
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/generator_pythia8_twophi_trigger.C
3+
funcName=generateDoublePhi(0, 0.0, 100.0, 0.8)
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

‎MC/config/PWGLF/ini/GeneratorLF_phiphiInvMass.ini‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[GeneratorExternal]
2-
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/GeneratorLF_phiphi.C
3-
funcName=generatePhiResonanceGun(999999, 888888, 0.0, 50.0, 100.0, -1.0, 1.0, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", 3)
2+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_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", 0)
44

55
[GeneratorPythia8]
66
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 nMBPhi = 0;
24+
int nKPlusFromMBPhi = 0;
25+
int nKMinusFromMBPhi = 0;
26+
int numberOfEventsProcessed = 0;
27+
28+
for (Long64_t i = 0; i < tree->GetEntries(); ++i)
29+
{
30+
tree->GetEntry(i);
31+
++numberOfEventsProcessed;
32+
33+
for (size_t idx = 0; idx < tracks->size(); ++idx)
34+
{
35+
const auto &track = tracks->at(idx);
36+
const auto pdg = track.GetPdgCode();
37+
38+
if (pdg == 333)
39+
{
40+
++nMBPhi;
41+
42+
if (track.getFirstDaughterTrackId() >= 0)
43+
{
44+
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
45+
{
46+
auto dauPdg = tracks->at(j).GetPdgCode();
47+
if (dauPdg == 321)
48+
{
49+
++nKPlusFromMBPhi;
50+
}
51+
if (dauPdg == -321)
52+
{
53+
++nKMinusFromMBPhi;
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
61+
// --------------------------- Output ---------------------------
62+
std::cout << "=================================================\n";
63+
std::cout << "Total Events: " << tree->GetEntries() << "\n\n";
64+
std::cout << "Total events processed: " << numberOfEventsProcessed << "\n";
65+
std::cout << "Total Minimum Bias Phi (333): " << nMBPhi << "\n";
66+
std::cout << " -> Decayed to K+: " << nKPlusFromMBPhi << "\n";
67+
std::cout << " -> Decayed to K-: " << nKMinusFromMBPhi << "\n";
68+
std::cout << "=================================================\n";
69+
70+
return 0;
71+
}
72+
73+
void GeneratorLF_doublephi_trigger()
74+
{
75+
External();
76+
}

‎MC/config/PWGLF/ini/tests/GeneratorLF_phiphiInvMass.C‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ int External()
2828
int nKPlusFromResonancePhi = 0;
2929
int nKMinusFromResonancePhi = 0;
3030

31-
int nDirectInjectedPhi = 0;
3231
int nMBPhi = 0;
3332

34-
int nKPlusFromDirectPhi = 0;
35-
int nKMinusFromDirectPhi = 0;
3633
int nKPlusFromMBPhi = 0;
3734
int nKMinusFromMBPhi = 0;
3835

@@ -86,24 +83,6 @@ int External()
8683
}
8784
}
8885

89-
else if (pdg == 888888)
90-
{
91-
++nDirectInjectedPhi;
92-
hasInjection = true;
93-
94-
if (track.getFirstDaughterTrackId() >= 0)
95-
{
96-
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
97-
{
98-
auto dauPdg = tracks->at(j).GetPdgCode();
99-
if (dauPdg == 321)
100-
++nKPlusFromDirectPhi;
101-
if (dauPdg == -321)
102-
++nKMinusFromDirectPhi;
103-
}
104-
}
105-
}
106-
10786
// 2. Process Phi (333) Mesons
10887
else if (pdg == 333)
10988
{
@@ -149,12 +128,7 @@ int External()
149128
std::cout << " -> Decayed to K+: " << nKPlusFromResonancePhi << "\n";
150129
std::cout << " -> Decayed to K-: " << nKMinusFromResonancePhi << "\n\n";
151130

152-
std::cout << "--- 2. DIRECTLY INJECTED PHI (333) ---\n";
153-
std::cout << "Total Directly Injected Phi (333): " << nDirectInjectedPhi << "\n";
154-
std::cout << " -> Decayed to K+: " << nKPlusFromDirectPhi << "\n";
155-
std::cout << " -> Decayed to K-: " << nKMinusFromDirectPhi << "\n\n";
156-
157-
std::cout << "--- 3. MINIMUM BIAS PHI (333) ---\n";
131+
std::cout << "--- 2. MINIMUM BIAS PHI (333) ---\n";
158132
std::cout << "Total Minimum Bias Phi (333): " << nMBPhi << "\n";
159133
std::cout << " -> Decayed to K+: " << nKPlusFromMBPhi << "\n";
160134
std::cout << " -> Decayed to K-: " << nKMinusFromMBPhi << "\n";

MC/config/PWGLF/pythia8/GeneratorLF_phiphi.C renamed to MC/config/PWGLF/pythia8/generator_pythia8_phiphi.C

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,26 @@ class GeneratorPhiResonance : public o2::eventgen::GeneratorPythia8
2525
{
2626
public:
2727
GeneratorPhiResonance(int resoPDG = 999999,
28-
int customPhiPDG = 888888,
29-
float ptMin = 0.0, float ptMax = 50.0, float ptMaxPhi = 100.0,
28+
float ptMin = 0.0, float ptMax = 50.0,
3029
float yMin = -1.0, float yMax = 1.0,
3130
std::string pythiaCfgMb = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg",
32-
int signalInterval = 3)
33-
: GeneratorPythia8(), mResoPDG(resoPDG), mCustomPhiPDG(customPhiPDG), mPtMin(ptMin), mPtMaxPhiPhi(ptMax), mPtMaxPhi(ptMaxPhi), mYMin(yMin), mYMax(yMax), mSignalInterval(signalInterval)
31+
int signalInterval = 0)
32+
: GeneratorPythia8(), mResoPDG(resoPDG), mPtMin(ptMin), mPtMaxPhiPhi(ptMax), mYMin(yMin), mYMax(yMax), mSignalInterval(signalInterval)
3433
{
35-
// 1. Define Custom Directly Injected Phi (PDG: 888888) with mass, width, and decay to kaons
36-
std::string createCustomPhi = std::to_string(mCustomPhiPDG) + ":new = custom_phi custom_phi 3 0 0 1.019461 0.004249 0.980 1.100 0.0";
37-
std::string customPhiMayDecay = std::to_string(mCustomPhiPDG) + ":mayDecay = on";
38-
std::string addPhiDecayKPlusKMinus = std::to_string(mCustomPhiPDG) + ":addChannel = 1 0.492 0 321 -321";
3934

40-
// 2. Define Custom Signal Resonance (PDG: 999999) decay into standard Phis (333 333)
35+
// 1. Define Custom Signal Resonance (PDG: 999999) decay into standard Phis (333 333)
4136
std::string createReso = std::to_string(mResoPDG) + ":new = f2_Custom void 5 0 0 2.714 0.012 2.05 3.50 0.0";
4237
std::string resoMayDecay = std::to_string(mResoPDG) + ":mayDecay = on";
4338
std::string addResoDecay = std::to_string(mResoPDG) + ":addChannel = 1 1.0 0 333 333";
4439

4540
// Helper lambda to load custom particle definitions across ALL Pythia engines
4641
auto applyCustomParticles = [&](Pythia8::Pythia &pythiaInst)
4742
{
48-
pythiaInst.readString(createCustomPhi);
49-
pythiaInst.readString(customPhiMayDecay);
50-
pythiaInst.readString(addPhiDecayKPlusKMinus);
5143
pythiaInst.readString(createReso);
5244
pythiaInst.readString(resoMayDecay);
5345
pythiaInst.readString(addResoDecay);
46+
pythiaInst.readString("333:mayDecay = on");
47+
pythiaInst.readString("333:oneChannel = 1 1.0 0 321 -321");
5448
};
5549

5650
// 1: Apply particle definitions to mPythia, mPythiaGun, and pythiaObjectMinimumBias
@@ -99,15 +93,10 @@ public:
9993
mPythiaGun.event.reset();
10094

10195
// 3. Inject Signal Gun Particles into mPythiaGun
102-
if (mEventCounter % mSignalInterval == 0)
96+
if (mSignalInterval > 0 && mEventCounter % mSignalInterval == 0)
10397
{
104-
// Resonant signal -> Decays into 333 333 (Standard Phis)
105-
injectParticle(mResoPDG, 1, true);
106-
}
107-
else
108-
{
109-
// Directly injected uncorrelated Phi -> Uses Custom PDG 888888
110-
injectParticle(mCustomPhiPDG, 2, false);
98+
// Resonant signal -> Decays into 333 333
99+
injectParticle(mResoPDG, 1);
111100
}
112101

113102
// 4. Force Decay of injected particles using Pythia's Decayer
@@ -157,7 +146,7 @@ private:
157146
mPythia.event.restorePtrs();
158147
}
159148

160-
void injectParticle(int pdg, int nParticles, bool thermalPt)
149+
void injectParticle(int pdg, int nParticles)
161150
{
162151
const double phiMass = 1.019461;
163152

@@ -167,27 +156,15 @@ private:
167156
const double phi = gRandom->Uniform(0, TMath::TwoPi());
168157

169158
double mass = 0.0;
170-
if (pdg == mResoPDG)
171-
{
172-
do
173-
{
174-
mass = gRandom->BreitWigner(2.714, 0.012);
175-
} while (mass <= 2.0 * phiMass || mass < 2.05 || mass > 3.50);
176-
}
177-
else
159+
160+
do
178161
{
179-
mass = mPythiaGun.particleData.mSel(333); // Use standard phi mass for directly injected custom phi
180-
}
162+
mass = gRandom->BreitWigner(2.714, 0.012);
163+
} while (mass <= 2.0 * phiMass || mass < 2.05 || mass > 3.50);
181164

182165
double pt;
183-
if (thermalPt)
184-
{
185-
pt = gRandom->Uniform(mPtMin, mPtMaxPhiPhi);
186-
}
187-
else
188-
{
189-
pt = gRandom->Uniform(mPtMin, mPtMaxPhi);
190-
}
166+
167+
pt = gRandom->Uniform(mPtMin, mPtMaxPhiPhi);
191168

192169
const double px = pt * std::cos(phi);
193170
const double py = pt * std::sin(phi);
@@ -214,16 +191,15 @@ private:
214191

215192
int mEventCounter = 0;
216193
int mResoPDG;
217-
int mCustomPhiPDG;
218194
int mSignalInterval;
219-
float mPtMin, mPtMaxPhiPhi, mPtMaxPhi, mYMin, mYMax;
195+
float mPtMin, mPtMaxPhiPhi, mYMin, mYMax;
220196

221197
Pythia8::Pythia mPythiaGun;
222198
Pythia8::Pythia pythiaObjectMinimumBias;
223199
};
224200

225201
/// Entry point for o2-sim
226-
FairGenerator *generatePhiResonanceGun(int resoPDG = 999999, int customPhiPDG = 888888, float ptMin = 0.0, float ptMax = 50.0, float ptMaxPhi = 100.0, float yMin = -1.0, float yMax = 1.0, std::string pythiaCfgMb = "", int signalInterval = 3)
202+
FairGenerator *generatePhiResonanceGun(int resoPDG = 999999, float ptMin = 0.0, float ptMax = 50.0, float yMin = -1.0, float yMax = 1.0, std::string pythiaCfgMb = "", int signalInterval = 0)
227203
{
228-
return new GeneratorPhiResonance(resoPDG, customPhiPDG, ptMin, ptMax, ptMaxPhi, yMin, yMax, pythiaCfgMb, signalInterval);
204+
return new GeneratorPhiResonance(resoPDG, ptMin, ptMax, yMin, yMax, pythiaCfgMb, signalInterval);
229205
}

0 commit comments

Comments
 (0)