Skip to content

Commit 47b6c57

Browse files
authored
Add BoxGen function to implement flat pT generation for Non-HFE efficiency studies (#2334)
* Update GeneratorHF_Non_Hfe.json Flat pion and eta distributions are added to enhance statistics at high transverse momentum. * Update pythia8_NonHfe.cfg Remove CR mode2 * Update GeneratorHF_Non_Hfe.json * Remove number parameter * Update GeneratorHF_Non_Hfe.json * implement flat pT generation for pi0 and eta * implement flat pT generation for pi0 and eta * implement flat pT generation for pi0 and eta * Update GeneratorHF_Non_Hfe.ini * Update GeneratorHF_Non_Hfe.ini * Update GeneratorHF_Non_Hfe.C * Rename MC/config/PWGHF/trigger/selectNonHfe.C to MC/config/PWGHF/external/generator/selectNonHfe.C * Update GeneratorHF_Non_Hfe.ini * Update GeneratorHF_Non_Hfe.C
1 parent 9c78c06 commit 47b6c57

5 files changed

Lines changed: 108 additions & 47 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
8+
9+
#if !defined(__CLING__) || defined(__ROOTCLING__)
10+
#include "FairGenerator.h"
11+
#include "FairPrimaryGenerator.h"
12+
#include "Generators/GeneratorPythia8.h"
13+
#include "TRandom3.h"
14+
#include "TParticlePDG.h"
15+
#include "TDatabasePDG.h"
16+
#include "TMath.h"
17+
#include <cmath>
18+
#include <vector>
19+
#endif
20+
21+
#include "Pythia8/Pythia.h"
22+
using namespace Pythia8;
23+
24+
class GeneratorPythia8Box : public o2::eventgen::GeneratorPythia8
25+
{
26+
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)
30+
{
31+
}
32+
33+
~GeneratorPythia8Box() = default;
34+
35+
Bool_t generateEvent() override
36+
{
37+
bool hasElectron = false;
38+
39+
while (!hasElectron) {
40+
mPythia.event.reset();
41+
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();
46+
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());
50+
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)};
55+
56+
57+
mPythia.event.append(currentPdg, 11, 0, 0, px, py, pz, et, mass);
58+
}
59+
60+
61+
if (!mPythia.next()) continue;
62+
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+
}
76+
}
77+
78+
}
79+
80+
return true;
81+
}
82+
83+
private:
84+
std::vector<int> mPdgList;
85+
double genMinPt, genMaxPt;
86+
double genMinEta, genMaxEta;
87+
int nParticles;
88+
};
89+
90+
91+
FairGenerator *generatePythia8Box(float ptMin = 0.1, float ptMax = 50.0)
92+
{
93+
94+
std::vector<int> pdgList = {111, 221};
95+
return new GeneratorPythia8Box(pdgList, 3, ptMin, ptMax, -0.8, 0.8);
96+
}
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#### This configuration uses the Hybrid external generator to trigger π⁰/η production within the specified rapidity window
2-
3-
[GeneratorHybrid]
4-
configFile = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/hybrid/GeneratorHF_Non_Hfe.json
1+
#### This configuration uses the Box generator to trigger π⁰/η production within the specified rapidity window
2+
[GeneratorExternal]
3+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/selectNonHfe.C
4+
funcName = generatePythia8Box(0.1, 50.0)
5+
[GeneratorPythia8]
6+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_NonHfe.cfg
7+
includePartonEvent=true

MC/config/PWGHF/ini/tests/GeneratorHF_Non_Hfe.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
int Hybrid() {
1+
int External() {
22
std::string path{"o2sim_Kine.root"};
33

44
const int pdgPi0 = 111;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ Beams:idB 2212 # proton
88
Beams:eCM 13600. # GeV
99

1010
### processes
11-
SoftQCD:inelastic on # all inelastic processes
11+
12+
ProcessLevel:all = off
1213

1314
### decays
1415
ParticleDecays:limitTau0 on
1516
ParticleDecays:tau0Max 10.
17+
### processes
18+
1619

1720
### switch off all decay channels
1821
111:onMode = off

MC/config/PWGHF/trigger/selectNonHfe.C

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)