Skip to content

Commit 73f585d

Browse files
authored
PYTHIA8 Box Generator: Minimum-Bias Events with Injected π⁰/η Decays (#2504)
* Create the Non-HFE–enhanced dataset. We will produce a Non-HFE–enhanced dataset by generating Monte Carlo samples with increased π⁰ and η production, to improve the statistical precision of the non-HFE efficiency measurement. * Create the Non-HFE–enhanced dataset We will produce a Non-HFE–enhanced dataset by generating Monte Carlo samples with increased π⁰ and η production, to improve the statistical precision of the non-HFE efficiency measurement. * Create the Non-HFE–enhanced dataset We will produce a Non-HFE–enhanced dataset by generating Monte Carlo samples with increased π⁰ and η production, to improve the statistical precision of the non-HFE efficiency measurement. * Update and rename GeneratorHF_Non_Hfe_enhance.ini to GeneratorHF_Non_Hfe.ini Rename File and add nonHfe.c file * Create generator_pythia8_gaptriggered_nonhfe.C Add generator_pythia8_gaptriggered_nonhfe.C file for enance pion and eta * Update generator_pythia8_gaptriggered_nonhfe.C * remove build error * Update generator_pythia8_gaptriggered_nonhfe.C * Correct name * correct name * remove build error * remove e and add pion , eta ID * Remove build error * Update generator_pythia8_gaptriggered_nonhfe.C * Update GeneratorHF_Non_Hfe.ini * Replace 1/2 to 1/3 * ncrease the tolerance to 10% * Update and rename MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_nonhfe.C to MC/config/PWGHF/trigger/selectNonHfe.C remove gaptrigger and add trigger selection * Update GeneratorHF_Non_Hfe.ini Change .c file * Update pythia8_NonHfe.cfg Remove Heavy flavour decay off * Update GeneratorHF_Non_Hfe.C Remove quark level information * Update GeneratorHF_Non_Hfe.ini * Add correctly pDg cut * Update GeneratorHF_Non_Hfe.ini * usetriggerexternal C * Rename MC/config/PWGHF/trigger/selectNonHfe.C to MC/config/PWGHF/external/generator/selectNonHfe.C change path * Update GeneratorHF_Non_Hfe.ini change filepath * Update GeneratorHF_Non_Hfe.ini * Rename MC/config/PWGHF/external/generator/selectNonHfe.C to MC/config/PWGHF/trigger/selectNonHfe.C * Update GeneratorHF_Non_Hfe.ini * Use triggerexternal * use configuration file * Create GeneratorHF_Non_Hfe.json * Update GeneratorHF_Non_Hfe.C * Rename MC/config/PWGHF/ini/hybrid/GeneratorHF_Non_Hfe.json to MC/config/PWGHF/hybrid/GeneratorHF_Non_Hfe.json * Rename MC/config/PWGHF/ini/hybrid/GeneratorHF_Non_Hfe.ini to MC/config/PWGHF/hybrid/GeneratorHF_Non_Hfe.ini * Rename MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C to MC/config/PWGHF/trigger/GeneratorHF_Non_Hfe.C * Rename GeneratorHF_Non_Hfe.C to GeneratorHF_Non_Hfe.C * Rename MC/config/PWGHF/hybrid/GeneratorHF_Non_Hfe.C to MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C * Rename GeneratorHF_Non_Hfe.ini to GeneratorHF_Non_Hfe.ini * Update pythia8_NonHfe.cfg * Update and rename MC/config/PWGHF/trigger/selectNonHfe.C to MC/config/PWGHF/external/generator/selectNonHfe.C Add Boxgen with Minimum bias * Update GeneratorHF_Non_Hfe.ini
1 parent fc9fea6 commit 73f585d

4 files changed

Lines changed: 83 additions & 96 deletions

File tree

Lines changed: 79 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
/// Select π⁰ and η within a given rapidity window for enhancement
2-
/// pdgPartForAccCut: PDG of the particle to select (111=π⁰, 221=η)
3-
/// minNb: minimum number of such particles per event for enhancement
4-
5-
//// authors: Rashi Gupta (rashi.gupta@cern.ch)
6-
/// authors: Ravindra Singh (ravindra.singh@cern.ch)
7-
81

92
#if !defined(__CLING__) || defined(__ROOTCLING__)
103
#include "FairGenerator.h"
@@ -14,83 +7,117 @@
147
#include "TParticlePDG.h"
158
#include "TDatabasePDG.h"
169
#include "TMath.h"
10+
#include <fairlogger/Logger.h>
1711
#include <cmath>
1812
#include <vector>
1913
#endif
2014

2115
#include "Pythia8/Pythia.h"
22-
using namespace Pythia8;
2316

2417
class GeneratorPythia8Box : public o2::eventgen::GeneratorPythia8
2518
{
2619
public:
27-
28-
GeneratorPythia8Box(std::vector<int> pdgList, int nInject = 3, float ptMin = 0.1, float ptMax = 50.0, float etaMin = -0.8, float etaMax = 0.8)
29-
: mPdgList(pdgList), nParticles(nInject), genMinPt(ptMin), genMaxPt(ptMax), genMinEta(etaMin), genMaxEta(etaMax)
20+
21+
GeneratorPythia8Box(std::vector<int> pdgList, int nInject = 3,
22+
float ptMin = 0.1, float ptMax = 50.0,
23+
float etaMin = -0.8, float etaMax = 0.8)
24+
: mPdgList(pdgList), nParticles(nInject),
25+
genMinPt(ptMin), genMaxPt(ptMax),
26+
genMinEta(etaMin), genMaxEta(etaMax)
3027
{
28+
// Initialize dedicated Pythia instance for injection/decay only
29+
// Reuses same config as main Pythia; beam settings are ignored by moreDecays()
30+
auto& param = o2::eventgen::GeneratorPythia8Param::Instance();
31+
std::string cfg = gSystem->ExpandPathName(param.config.c_str());
32+
if (!mPythiaGun.readFile(cfg, true)) {
33+
LOG(fatal) << "Failed to read config for mPythiaGun: " << cfg;
34+
}
35+
if (!mPythiaGun.init()) {
36+
LOG(fatal) << "Failed to init mPythiaGun";
37+
}
3138
}
3239

3340
~GeneratorPythia8Box() = default;
3441

35-
Bool_t generateEvent() override
36-
{
37-
bool hasElectron = false;
38-
39-
while (!hasElectron) {
40-
mPythia.event.reset();
42+
bool Init() override
43+
{
44+
return o2::eventgen::GeneratorPythia8::Init();
45+
}
4146

42-
for (int i{0}; i < nParticles; ++i)
43-
{
44-
int currentPdg = mPdgList[gRandom->Integer(mPdgList.size())];
45-
double mass = TDatabasePDG::Instance()->GetParticle(currentPdg)->Mass();
47+
protected:
4648

47-
const double pt = gRandom->Uniform(genMinPt, genMaxPt);
48-
const double eta = gRandom->Uniform(genMinEta, genMaxEta);
49-
const double phi = gRandom->Uniform(0, TMath::TwoPi());
49+
// ── generateEvent: MB + injection ──
50+
Bool_t generateEvent() override
51+
{
52+
bool hasElectron = false;
53+
54+
while (!hasElectron) {
55+
// ===== 1. Generate minimum-bias event =====
56+
if (!mPythia.next()) continue;
57+
58+
// ===== 2. Inject π⁰/η into separate gun, decay only them =====
59+
mPythiaGun.event.reset();
60+
for (int i = 0; i < nParticles; ++i) {
61+
int pdg = mPdgList[gRandom->Integer(mPdgList.size())];
62+
auto* pPDG = TDatabasePDG::Instance()->GetParticle(pdg);
63+
if (!pPDG) continue;
64+
double mass = pPDG->Mass();
65+
66+
double pt = gRandom->Uniform(genMinPt, genMaxPt);
67+
double eta = gRandom->Uniform(genMinEta, genMaxEta);
68+
double phi = gRandom->Uniform(0., TMath::TwoPi());
69+
double px = pt * cos(phi);
70+
double py = pt * sin(phi);
71+
double pz = pt * sinh(eta);
72+
double e = sqrt(px * px + py * py + pz * pz + mass * mass);
73+
74+
mPythiaGun.event.append(pdg, 11, 0, 0, px, py, pz, e, mass);
75+
}
5076

51-
const double px{pt * std::cos(phi)};
52-
const double py{pt * std::sin(phi)};
53-
const double pz{pt * std::sinh(eta)};
54-
const double et{std::hypot(std::hypot(pt, pz), mass)};
77+
mPythiaGun.moreDecays();
5578

56-
57-
mPythia.event.append(currentPdg, 11, 0, 0, px, py, pz, et, mass);
79+
// ===== 3. Check for electron from injection in acceptance =====
80+
for (int i = 0; i < mPythiaGun.event.size(); ++i) {
81+
auto& part = mPythiaGun.event[i];
82+
if (std::abs(part.id()) == 11 && part.isFinal()) {
83+
if (part.pT() > 0.1 && std::abs(part.eta()) < 1.2) {
84+
hasElectron = true;
85+
break;
86+
}
87+
}
88+
}
5889
}
5990

60-
61-
if (!mPythia.next()) continue;
91+
// ===== 4. Copy injection products to MB event with index offset =====
92+
int offset = mPythia.event.size();
6293

63-
64-
for (int i = 0; i < mPythia.event.size(); ++i) {
65-
if (std::abs(mPythia.event[i].id()) == 11) {
66-
67-
68-
double childPt = mPythia.event[i].pT();
69-
double childEta = mPythia.event[i].eta();
70-
71-
if (childPt > 0.1 && std::abs(childEta) < 1.2) {
72-
hasElectron = true; // Mil gaya!
73-
break;
74-
}
75-
}
94+
for (int i = 0; i < mPythiaGun.event.size(); ++i) {
95+
auto part = mPythiaGun.event[i];
96+
if (part.id() == 90) continue; // skip system placeholder
97+
if (!part.isFinal() && part.id() != 111 && part.id() != 221) continue;
98+
99+
if (part.mother1() > 0) part.mother1(part.mother1() + offset - 1);
100+
if (part.mother2() > 0) part.mother2(part.mother2() + offset - 1);
101+
if (part.daughter1() > 0) part.daughter1(part.daughter1() + offset - 1);
102+
if (part.daughter2() > 0) part.daughter2(part.daughter2() + offset - 1);
103+
104+
mPythia.event.append(part);
76105
}
77-
78-
}
79106

80-
return true;
81-
}
107+
return true;
108+
}
82109

83110
private:
84111
std::vector<int> mPdgList;
85112
double genMinPt, genMaxPt;
86113
double genMinEta, genMaxEta;
87114
int nParticles;
115+
116+
Pythia8::Pythia mPythiaGun;
88117
};
89118

90-
91119
FairGenerator *generatePythia8Box(float ptMin = 0.1, float ptMax = 50.0)
92120
{
93-
94121
std::vector<int> pdgList = {111, 221};
95122
return new GeneratorPythia8Box(pdgList, 3, ptMin, ptMax, -0.8, 0.8);
96-
}
123+
}
Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +0,0 @@
1-
{
2-
"generators": [
3-
{
4-
"name": "pythia8",
5-
"config": {
6-
"config": "${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/generator/pythia8_NonHfe.cfg"
7-
},
8-
"triggers": {
9-
"mode": "or",
10-
"specs": [
11-
{
12-
"macro": "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/trigger/selectNonHfe.C",
13-
"function": "selectPionEtaWithinAcc(\"111;221\",-1.5,1.5,1)"
14-
}
15-
]
16-
}
17-
},
18-
{
19-
"name": "boxgen",
20-
"config": {
21-
"pdg": 111,
22-
"prange[0]": 0.1,
23-
"prange[1]": 50.0,
24-
"eta[0]": -0.8,
25-
"eta[1]": 0.8
26-
}
27-
},
28-
{
29-
"name": "boxgen",
30-
"config": {
31-
"pdg": 221,
32-
"prange[0]": 0.1,
33-
"prange[1]": 50.0,
34-
"eta[0]": -0.8,
35-
"eta[1]": 0.8
36-
}
37-
}
38-
],
39-
"fractions": [1, 1, 1]
40-
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#### This configuration uses the Box generator to trigger π⁰/η production within the specified rapidity window
21
[GeneratorExternal]
32
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/selectNonHfe.C
4-
funcName = generatePythia8Box(0.1, 50.0)
3+
funcName=generatePythia8Box(0.1,50.0)
4+
55
[GeneratorPythia8]
66
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg
7-
includePartonEvent=true
7+
includePartonEvent=true

‎MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Beams:eCM 13600. # GeV
99

1010
### processes
1111

12-
ProcessLevel:all = off
1312

13+
SoftQCD:inelastic = on
1414
### decays
1515
ParticleDecays:limitTau0 on
1616
ParticleDecays:tau0Max 10.

0 commit comments

Comments
 (0)