Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions MC/config/PWGLF/ini/GeneratorLF_doublephi_trigger.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_twophi_trigger.C
funcName=generateDoublePhi(0, 0.0, 100.0, 0.8)

[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg

[DecayerPythia8]
config[0]=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/decayer/base.cfg
config[1]=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonances.cfg
4 changes: 2 additions & 2 deletions MC/config/PWGLF/ini/GeneratorLF_phiphiInvMass.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/GeneratorLF_phiphi.C
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)
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_phiphi.C
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)

[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg
Expand Down
76 changes: 76 additions & 0 deletions MC/config/PWGLF/ini/tests/GeneratorLF_doublephi_trigger.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
int External()
{
const std::string path{"o2sim_Kine.root"};

TFile file(path.c_str(), "READ");
if (file.IsZombie())
{
std::cerr << "Cannot open ROOT file " << path << "\n";
return 1;
}

auto tree = (TTree *)file.Get("o2sim");
if (!tree)
{
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
return 1;
}

std::vector<o2::MCTrack> *tracks{};
tree->SetBranchAddress("MCTrack", &tracks);

// Counters
int nMBPhi = 0;
int nKPlusFromMBPhi = 0;
int nKMinusFromMBPhi = 0;
int numberOfEventsProcessed = 0;

for (Long64_t i = 0; i < tree->GetEntries(); ++i)
{
tree->GetEntry(i);
++numberOfEventsProcessed;

for (size_t idx = 0; idx < tracks->size(); ++idx)
{
const auto &track = tracks->at(idx);
const auto pdg = track.GetPdgCode();

if (pdg == 333)
{
++nMBPhi;

if (track.getFirstDaughterTrackId() >= 0)
{
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
{
auto dauPdg = tracks->at(j).GetPdgCode();
if (dauPdg == 321)
{
++nKPlusFromMBPhi;
}
if (dauPdg == -321)
{
++nKMinusFromMBPhi;
}
}
}
}
}
}

// --------------------------- Output ---------------------------
std::cout << "=================================================\n";
std::cout << "Total Events: " << tree->GetEntries() << "\n\n";
std::cout << "Total events processed: " << numberOfEventsProcessed << "\n";
std::cout << "Total Minimum Bias Phi (333): " << nMBPhi << "\n";
std::cout << " -> Decayed to K+: " << nKPlusFromMBPhi << "\n";
std::cout << " -> Decayed to K-: " << nKMinusFromMBPhi << "\n";
std::cout << "=================================================\n";

return 0;
}

void GeneratorLF_doublephi_trigger()
{
External();
}
28 changes: 1 addition & 27 deletions MC/config/PWGLF/ini/tests/GeneratorLF_phiphiInvMass.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ int External()
int nKPlusFromResonancePhi = 0;
int nKMinusFromResonancePhi = 0;

int nDirectInjectedPhi = 0;
int nMBPhi = 0;

int nKPlusFromDirectPhi = 0;
int nKMinusFromDirectPhi = 0;
int nKPlusFromMBPhi = 0;
int nKMinusFromMBPhi = 0;

Expand Down Expand Up @@ -86,24 +83,6 @@ int External()
}
}

else if (pdg == 888888)
{
++nDirectInjectedPhi;
hasInjection = true;

if (track.getFirstDaughterTrackId() >= 0)
{
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j)
{
auto dauPdg = tracks->at(j).GetPdgCode();
if (dauPdg == 321)
++nKPlusFromDirectPhi;
if (dauPdg == -321)
++nKMinusFromDirectPhi;
}
}
}

// 2. Process Phi (333) Mesons
else if (pdg == 333)
{
Expand Down Expand Up @@ -149,12 +128,7 @@ int External()
std::cout << " -> Decayed to K+: " << nKPlusFromResonancePhi << "\n";
std::cout << " -> Decayed to K-: " << nKMinusFromResonancePhi << "\n\n";

std::cout << "--- 2. DIRECTLY INJECTED PHI (333) ---\n";
std::cout << "Total Directly Injected Phi (333): " << nDirectInjectedPhi << "\n";
std::cout << " -> Decayed to K+: " << nKPlusFromDirectPhi << "\n";
std::cout << " -> Decayed to K-: " << nKMinusFromDirectPhi << "\n\n";

std::cout << "--- 3. MINIMUM BIAS PHI (333) ---\n";
std::cout << "--- 2. MINIMUM BIAS PHI (333) ---\n";
std::cout << "Total Minimum Bias Phi (333): " << nMBPhi << "\n";
std::cout << " -> Decayed to K+: " << nKPlusFromMBPhi << "\n";
std::cout << " -> Decayed to K-: " << nKMinusFromMBPhi << "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,26 @@ class GeneratorPhiResonance : public o2::eventgen::GeneratorPythia8
{
public:
GeneratorPhiResonance(int resoPDG = 999999,
int customPhiPDG = 888888,
float ptMin = 0.0, float ptMax = 50.0, float ptMaxPhi = 100.0,
float ptMin = 0.0, float ptMax = 50.0,
float yMin = -1.0, float yMax = 1.0,
std::string pythiaCfgMb = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg",
int signalInterval = 3)
: GeneratorPythia8(), mResoPDG(resoPDG), mCustomPhiPDG(customPhiPDG), mPtMin(ptMin), mPtMaxPhiPhi(ptMax), mPtMaxPhi(ptMaxPhi), mYMin(yMin), mYMax(yMax), mSignalInterval(signalInterval)
int signalInterval = 0)
: GeneratorPythia8(), mResoPDG(resoPDG), mPtMin(ptMin), mPtMaxPhiPhi(ptMax), mYMin(yMin), mYMax(yMax), mSignalInterval(signalInterval)
{
// 1. Define Custom Directly Injected Phi (PDG: 888888) with mass, width, and decay to kaons
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";
std::string customPhiMayDecay = std::to_string(mCustomPhiPDG) + ":mayDecay = on";
std::string addPhiDecayKPlusKMinus = std::to_string(mCustomPhiPDG) + ":addChannel = 1 0.492 0 321 -321";

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

// Helper lambda to load custom particle definitions across ALL Pythia engines
auto applyCustomParticles = [&](Pythia8::Pythia &pythiaInst)
{
pythiaInst.readString(createCustomPhi);
pythiaInst.readString(customPhiMayDecay);
pythiaInst.readString(addPhiDecayKPlusKMinus);
pythiaInst.readString(createReso);
pythiaInst.readString(resoMayDecay);
pythiaInst.readString(addResoDecay);
pythiaInst.readString("333:mayDecay = on");
pythiaInst.readString("333:oneChannel = 1 1.0 0 321 -321");
};

// 1: Apply particle definitions to mPythia, mPythiaGun, and pythiaObjectMinimumBias
Expand Down Expand Up @@ -99,15 +93,15 @@ public:
mPythiaGun.event.reset();

// 3. Inject Signal Gun Particles into mPythiaGun
if (mEventCounter % mSignalInterval == 0)
if (mSignalInterval > 0 && mEventCounter % mSignalInterval == 0)
{
// Resonant signal -> Decays into 333 333 (Standard Phis)
injectParticle(mResoPDG, 1, true);
// Resonant signal -> Decays into 333 333
injectParticle(mResoPDG, 1);
}
else
else if (mSignalInterval <= 0)
{
// Directly injected uncorrelated Phi -> Uses Custom PDG 888888
injectParticle(mCustomPhiPDG, 2, false);
// Continuous signal -> Decays into 333 333
injectParticle(mResoPDG, 1);
}

// 4. Force Decay of injected particles using Pythia's Decayer
Expand Down Expand Up @@ -157,7 +151,7 @@ private:
mPythia.event.restorePtrs();
}

void injectParticle(int pdg, int nParticles, bool thermalPt)
void injectParticle(int pdg, int nParticles)
{
const double phiMass = 1.019461;

Expand All @@ -167,27 +161,15 @@ private:
const double phi = gRandom->Uniform(0, TMath::TwoPi());

double mass = 0.0;
if (pdg == mResoPDG)
{
do
{
mass = gRandom->BreitWigner(2.714, 0.012);
} while (mass <= 2.0 * phiMass || mass < 2.05 || mass > 3.50);
}
else

do
{
mass = mPythiaGun.particleData.mSel(333); // Use standard phi mass for directly injected custom phi
}
mass = gRandom->BreitWigner(2.714, 0.012);
} while (mass <= 2.0 * phiMass || mass < 2.05 || mass > 3.50);

double pt;
if (thermalPt)
{
pt = gRandom->Uniform(mPtMin, mPtMaxPhiPhi);
}
else
{
pt = gRandom->Uniform(mPtMin, mPtMaxPhi);
}

pt = gRandom->Uniform(mPtMin, mPtMaxPhiPhi);

const double px = pt * std::cos(phi);
const double py = pt * std::sin(phi);
Expand All @@ -214,16 +196,15 @@ private:

int mEventCounter = 0;
int mResoPDG;
int mCustomPhiPDG;
int mSignalInterval;
float mPtMin, mPtMaxPhiPhi, mPtMaxPhi, mYMin, mYMax;
float mPtMin, mPtMaxPhiPhi, mYMin, mYMax;

Pythia8::Pythia mPythiaGun;
Pythia8::Pythia pythiaObjectMinimumBias;
};

/// Entry point for o2-sim
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)
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)
{
return new GeneratorPhiResonance(resoPDG, customPhiPDG, ptMin, ptMax, ptMaxPhi, yMin, yMax, pythiaCfgMb, signalInterval);
return new GeneratorPhiResonance(resoPDG, ptMin, ptMax, yMin, yMax, pythiaCfgMb, signalInterval);
}
Loading
Loading