Skip to content

Commit 0b2c114

Browse files
authored
MC/PWGEM: add DY->ll config (#2117)
1 parent 865fc3a commit 0b2c114

10 files changed

+222
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#include "Pythia8/Pythia.h"
2+
#include "Pythia8/HeavyIons.h"
3+
#include "FairGenerator.h"
4+
#include "FairPrimaryGenerator.h"
5+
#include "Generators/GeneratorPythia8.h"
6+
#include "TString.h"
7+
#include "TRandom3.h"
8+
#include "TParticlePDG.h"
9+
#include "TDatabasePDG.h"
10+
11+
#include <map>
12+
#include <unordered_set>
13+
14+
using namespace Pythia8;
15+
16+
class GeneratorPythia8GapTriggeredDY : public o2::eventgen::GeneratorPythia8
17+
{
18+
public:
19+
/// default constructor
20+
GeneratorPythia8GapTriggeredDY() = default;
21+
22+
/// constructor
23+
GeneratorPythia8GapTriggeredDY(TString configsignal, int leptonPdg = 11, int lInputTriggerRatio = 5, int lInputExternalID = 1, int idA = 2212, int idB = 2212, float eCM = 13600.0)
24+
{
25+
lGeneratedEvents = 0;
26+
lInverseTriggerRatio = lInputTriggerRatio;
27+
lExternalID = lInputExternalID;
28+
mLeptonPdg = leptonPdg;
29+
30+
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
31+
32+
int offset = (int)(gRandom->Uniform(lInverseTriggerRatio)); // create offset to mitigate edge effects due to small number of events per job
33+
lGeneratedEvents += offset;
34+
35+
cout << "Initalizing extra PYTHIA object used to generate min-bias events..." << endl;
36+
TString pathconfigMB = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg");
37+
pythiaObjectMinimumBias.readFile(pathconfigMB.Data());
38+
pythiaObjectMinimumBias.readString("Random:setSeed on");
39+
pythiaObjectMinimumBias.readString("Random:seed " + std::to_string(seed));
40+
// overwrite basic configration
41+
pythiaObjectMinimumBias.readString(Form("Beams:idA %d", idA));
42+
pythiaObjectMinimumBias.readString(Form("Beams:idB %d", idB));
43+
pythiaObjectMinimumBias.readString(Form("Beams:eCM %f", eCM));
44+
pythiaObjectMinimumBias.init();
45+
cout << "Initalization complete" << endl;
46+
cout << "Initalizing extra PYTHIA object used to generate signal events..." << endl;
47+
TString pathconfigSignal = gSystem->ExpandPathName(configsignal.Data());
48+
pythiaObjectSignal.readFile(pathconfigSignal.Data());
49+
pythiaObjectSignal.readString("Random:setSeed on");
50+
pythiaObjectSignal.readString("Random:seed " + std::to_string(seed));
51+
pythiaObjectSignal.readString(Form("23:onIfMatch %d %d", -mLeptonPdg, mLeptonPdg));
52+
// overwrite basic configration
53+
pythiaObjectSignal.readString(Form("Beams:idA %d", idA));
54+
pythiaObjectSignal.readString(Form("Beams:idB %d", idB));
55+
pythiaObjectSignal.readString(Form("Beams:eCM %f", eCM));
56+
57+
pythiaObjectSignal.init();
58+
cout << "Initalization complete" << endl;
59+
addSubGenerator(0, "default generator");
60+
addSubGenerator(lExternalID, "Drell-Yan");
61+
}
62+
63+
/// Destructor
64+
~GeneratorPythia8GapTriggeredDY() = default;
65+
66+
void setZRapidity(float yMin, float yMax)
67+
{
68+
mZRapidityMin = yMin;
69+
mZRapidityMax = yMax;
70+
};
71+
72+
protected:
73+
//__________________________________________________________________
74+
Bool_t generateEvent() override
75+
{
76+
/// reset event
77+
mPythia.event.reset();
78+
79+
// Simple straightforward check to alternate generators
80+
if (lGeneratedEvents % lInverseTriggerRatio == 0) {
81+
// Generate event of interest
82+
Bool_t lGenerationOK = kFALSE;
83+
while (!lGenerationOK) {
84+
if (pythiaObjectSignal.next()) {
85+
lGenerationOK = selectEvent(pythiaObjectSignal.event);
86+
}
87+
}
88+
mPythia.event = pythiaObjectSignal.event;
89+
notifySubGenerator(lExternalID);
90+
} else {
91+
// Generate minimum-bias event
92+
Bool_t lGenerationOK = kFALSE;
93+
while (!lGenerationOK) {
94+
lGenerationOK = pythiaObjectMinimumBias.next();
95+
}
96+
mPythia.event = pythiaObjectMinimumBias.event;
97+
notifySubGenerator(0);
98+
}
99+
100+
lGeneratedEvents++;
101+
// mPythia.next();
102+
103+
return true;
104+
}
105+
106+
bool selectEvent(const Pythia8::Event& event)
107+
{
108+
for (size_t iPart = 0; iPart < event.size(); ++iPart) {
109+
if (event[iPart].id() == 23 && event[iPart].daughterList().size() == 2 && (mZRapidityMin < event[iPart].y() && event[iPart].y() < mZRapidityMax)
110+
&& std::abs(event[event[iPart].daughter1()].id()) == mLeptonPdg && std::abs(event[event[iPart].daughter2()].id()) == mLeptonPdg && event[event[iPart].daughter1()].id() * event[event[iPart].daughter2()].id() < 0) { // Z/gamma* -> l+l-
111+
printf("Z/gamma* is found. rapidity = %f, event[iPart].daughterList().size() = %zu\n", event[iPart].y(), event[iPart].daughterList().size());
112+
printf("event[event[iPart].daughter1()].id() = %d\n", event[event[iPart].daughter1()].id());
113+
printf("event[event[iPart].daughter2()].id() = %d\n", event[event[iPart].daughter2()].id());
114+
return true;
115+
}
116+
} // end of particle loop
117+
return false;
118+
};
119+
120+
private:
121+
// Interface to override import particles
122+
Pythia8::Event mOutputEvent;
123+
124+
// Properties of selection
125+
int mLeptonPdg;
126+
float mZRapidityMin;
127+
float mZRapidityMax;
128+
129+
// Control gap-triggering
130+
Long64_t lGeneratedEvents;
131+
int lInverseTriggerRatio;
132+
// ID for different generators
133+
int lExternalID;
134+
135+
// Base event generators
136+
Pythia8::Pythia pythiaObjectMinimumBias; ///Minimum bias collision generator
137+
Pythia8::Pythia pythiaObjectSignal; ///Signal collision generator
138+
};
139+
140+
// Predefined generators:
141+
142+
FairGenerator* GeneratorPythia8GapTriggeredDYll(int inputTriggerRatio, int inputExternalID, int pdgLepton = 11, float yMin = -1.5, float yMax = 1.5, int idA = 2212, int idB = 2212, float eCM = 13600.0)
143+
{
144+
auto myGen = new GeneratorPythia8GapTriggeredDY("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_DY.cfg", pdgLepton, inputTriggerRatio, inputExternalID, idA, idB, eCM);
145+
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
146+
myGen->readString("Random:setSeed on");
147+
myGen->readString("Random:seed " + std::to_string(seed));
148+
myGen->setZRapidity(yMin, yMax);
149+
return myGen;
150+
}
151+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 11, -1.5, +1.5, 1000080160, 1000080160, 5360.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 11, -1.5, +1.5, 1000822080, 1000822080, 5360.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 11, -1.5, +1.5, 2212, 2212, 13600.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 11, -1.5, +1.5, 2212, 2212, 5360.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 13, -6, -1, 1000080160, 1000080160, 5360.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 13, -6, -1, 1000822080, 1000822080, 5360.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 13, -6, -1, 2212, 2212, 13600.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[GeneratorExternal]
2+
fileName = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_DYll.C
3+
funcName = GeneratorPythia8GapTriggeredDYll(5, 1, 13, -6, -1, 2212, 2212, 5360.0)
4+
5+
[GeneratorPythia8]
6+
config = ${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGEM/pythia8/generator/configPythiaEmpty.cfg
7+
includePartonEvent = true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### beams
2+
Beams:idA 2212 # proton
3+
Beams:idB 2212 # proton
4+
Beams:eCM 13600. # GeV #user can change eCM from command line.
5+
6+
### processes
7+
WeakSingleBoson:ffbar2ffbar(s:gmZ) on # ffbar -> Z/gamma* -> ffbar
8+
PhaseSpace:mHatMin 0
9+
PhaseSpace:mHatMax -1
10+
PhaseSpace:pTHatMinDiverge 0.5 # this allows for mll > 1 GeV/c2
11+
23:onMode off # switch off all Z0 decay channels. # User must switch back on Z0 going to l+ l- in C or ini. gamma* is tread as 23, too.
12+
13+
### decays
14+
ParticleDecays:limitTau0 on
15+
ParticleDecays:tau0Max 10.

0 commit comments

Comments
 (0)