Skip to content

Commit 7cb3f9e

Browse files
committed
Add EVTGEN in HF generator + config for B2Jpsi
1 parent 7278c4a commit 7cb3f9e

4 files changed

Lines changed: 5167 additions & 1 deletion

File tree

MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
R__LOAD_LIBRARY(EvtGen)
2+
R__ADD_INCLUDE_PATH($EVTGEN_ROOT/include)
3+
14
#include "FairGenerator.h"
25
#include "Generators/GeneratorPythia8.h"
36
#include "Generators/GeneratorPythia8Param.h"
7+
#include "EvtGen/EvtGen.hh"
48
#include "Pythia8/Pythia.h"
9+
#include "Pythia8Plugins/EvtGen.h"
510
#include "TRandom.h"
611
#include "TDatabasePDG.h"
712
#include <fairlogger/Logger.h>
@@ -33,6 +38,8 @@ public:
3338
mHadronPdgList = hadronPdgList;
3439
mPartPdgToReplaceList = partPdgToReplaceList;
3540
mFreqReplaceList = freqReplaceList;
41+
mUseEvtGen = false;
42+
mEvtGenDecTable = "";
3643
// Ds1*(2700), Ds1*(2860), Ds3*(2860), Xic(3055)+, Xic(3080)+, Xic(3055)0, Xic(3080)0, LambdaC(2625), LambdaC(2595), LambdaC(2860), LambdaC(2880), LambdaC(2940), ThetaC(3100)
3744
mCustomPartPdgs = {30433, 40433, 437, 4315, 4316, 4325, 4326, 4124, 14122, 24124, 24126, 4125, 9422111};
3845
mCustomPartMasses[30433] = 2.714f;
@@ -114,6 +121,10 @@ public:
114121
pdgToReplace.push_back(mPartPdgToReplaceList[iRepl].at(0));
115122
}
116123

124+
if (mUseEvtGen) {
125+
mEvtGen = new Pythia8::EvtGenDecays(&mPythia, mEvtGenDecTable.data(), gSystem->ExpandPathName("$EVTGEN_ROOT/share/EvtGen/evt.pdl"));
126+
}
127+
117128
return o2::eventgen::GeneratorPythia8::Init();
118129
}
119130

@@ -135,6 +146,14 @@ public:
135146
{
136147
return mUsedSeed;
137148
};
149+
void setUseEvtGenDecayer(std::string evtGenDecTable = "") {
150+
mUseEvtGen = true;
151+
if (evtGenDecTable.empty()) {
152+
mEvtGenDecTable = gSystem->ExpandPathName("$EVTGEN_ROOT/share/EvtGen/DECAY.DEC");
153+
} else {
154+
mEvtGenDecTable = gSystem->ExpandPathName(evtGenDecTable.data());
155+
}
156+
}
138157

139158
protected:
140159
//__________________________________________________________________
@@ -167,6 +186,10 @@ protected:
167186
{
168187
if (GeneratorPythia8::generateEvent())
169188
{
189+
if (mEvtGen) {
190+
mEvtGen->decay();
191+
checkConsistency();
192+
}
170193
genOk = selectEvent();
171194
}
172195
}
@@ -179,6 +202,12 @@ protected:
179202
while (!genOk)
180203
{
181204
genOk = GeneratorPythia8::generateEvent();
205+
if (genOk) {
206+
if (mEvtGen) {
207+
mEvtGen->decay();
208+
checkConsistency();
209+
}
210+
}
182211
}
183212
notifySubGenerator(0);
184213
}
@@ -197,6 +226,8 @@ protected:
197226

198227
for (auto iPart{0}; iPart < mPythia.event.size(); ++iPart)
199228
{
229+
230+
200231
// search for Q-Qbar mother with at least one Q in rapidity window
201232
if (!isGoodAtPartonLevel)
202233
{
@@ -352,11 +383,28 @@ protected:
352383
return true;
353384
}
354385

386+
void checkConsistency() {
387+
for (int iPart{1}; iPart<mPythia.event.size(); ++iPart) {
388+
// verify if all particles of decay chain are in the TDatabasePDG
389+
if (!TDatabasePDG::Instance()->GetParticle(abs(mPythia.event[iPart].id()))) {
390+
std::cout << "Particle code non known in TDatabasePDG " << mPythia.event[iPart].id() << " - set pdg = 89" << std::endl;
391+
mPythia.event[iPart].id(89);
392+
}
393+
394+
// istat = mEvtstdhep->getIStat(i);
395+
396+
// if (istat != 1 && istat != 2)
397+
// std::cout << "ImportParticles: Attention unknown status code!" << std::endl;
398+
// if (istat == 2)
399+
// istat = 11; // status decayed
400+
}
401+
}
402+
355403
private:
356404
// Interface to override import particles
357405
Pythia8::Event mOutputEvent;
358406

359-
// Properties of selection
407+
// Properties of selection
360408
int mQuarkPdg;
361409
float mQuarkRapidityMin;
362410
float mQuarkRapidityMax;
@@ -379,6 +427,12 @@ protected:
379427

380428
// Control alternate trigger on different hadrons
381429
std::vector<int> mHadronPdgList = {};
430+
431+
// EVTGEN decayer from PYTHIA8 plugins
432+
Pythia8::EvtGenDecays *mEvtGen;
433+
bool mUseEvtGen;
434+
std::string mEvtGenDecTable;
435+
382436
};
383437

384438
// Predefined generators:
@@ -446,3 +500,20 @@ FairGenerator *GeneratorPythia8GapHF(int inputTriggerRatio, float yQuarkMin = -1
446500

447501
return myGen;
448502
}
503+
504+
// Beauty-enriched with EvtGen decayer
505+
FairGenerator *GeneratorPythia8GapTriggeredBeautyWithEvtGen(int inputTriggerRatio, float yQuarkMin = -1.5, float yQuarkMax = 1.5, float yHadronMin = -1.5, float yHadronMax = 1.5, std::vector<int> hadronPdgList = {}, std::vector<std::array<int, 2>> partPdgToReplaceList = {}, std::vector<float> freqReplaceList = {}, std::string decayTable = "")
506+
{
507+
auto myGen = new GeneratorPythia8GapTriggeredHF(inputTriggerRatio, std::vector<int>{5}, hadronPdgList, partPdgToReplaceList, freqReplaceList);
508+
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
509+
myGen->setUsedSeed(seed);
510+
myGen->readString("Random:setSeed on");
511+
myGen->readString("Random:seed " + std::to_string(seed));
512+
myGen->setQuarkRapidity(yQuarkMin, yQuarkMax);
513+
if (hadronPdgList.size() != 0)
514+
{
515+
myGen->setHadronRapidity(yHadronMin, yHadronMax);
516+
}
517+
myGen->setUseEvtGenDecayer(decayTable);
518+
return myGen;
519+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#NEV_TEST> 20
2+
### The external generator derives from GeneratorPythia8.
3+
[GeneratorExternal]
4+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C
5+
funcName=GeneratorPythia8GapTriggeredBeautyWithEvtGen(5, -1.5, 1.5, -1.5, 1.5, {}, {}, {}, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/decayer/EVTGEN_DECAY_B2JPSI.DEC")
6+
7+
[GeneratorPythia8]
8+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_Mode2_noforcedecays.cfg
9+
includePartonEvent=false

0 commit comments

Comments
 (0)