Skip to content

Commit 06dca18

Browse files
committed
comments from Alex
1 parent c81f9c3 commit 06dca18

2 files changed

Lines changed: 28 additions & 18 deletions

File tree

‎MC/config/PWGDQ/external/generator/generator_pythia8_HadronTriggered_withGap.C‎

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "Generators/GeneratorPythia8.h"
33
#include "Pythia8/Pythia.h"
44
#include "TRandom.h"
5+
#include "CommonConstants/PhysicsConstants.h"
56

67
R__ADD_INCLUDE_PATH($O2DPG_MC_CONFIG_ROOT/MC/config/PWGDQ/EvtGen)
78
#include "GeneratorEvtGen.C"
@@ -136,7 +137,7 @@ bool importParticles() override
136137
}
137138

138139
for (int idx = 0; idx < mParticles.size(); idx++) {
139-
if (mParticles[idx].GetPdgCode() != 20443) {
140+
if (mParticles[idx].GetPdgCode() != 20443 || mParticles[idx].Y() < mRapidityMin || mParticles[idx].Y() > mRapidityMax) {
140141
continue;
141142
}
142143

@@ -147,11 +148,21 @@ bool importParticles() override
147148
}
148149

149150
// modify e and pz to conserve rapidity and modify the mass
151+
float deltaMassSquared = o2::constants::physics::MassX3872 * o2::constants::physics::MassX3872 - o2::constants::physics::MassChiC1 * o2::constants::physics::MassChiC1;
152+
float pz_old = mParticles[idx].Pz();
153+
float e_old = mParticles[idx].Energy();
150154
float pz_new = 0.;
151-
float e_new = sqrt(3.87164*3.87164 - 3.51067*3.51067 + mParticles[idx].Energy()*mParticles[idx].Energy());
152-
if (std::fabs(mParticles[idx].Pz()) > 1e-8) {
153-
pz_new = sqrt(3.87164*3.87164 - 3.51067*3.51067 + mParticles[idx].Energy()*mParticles[idx].Energy() - mParticles[idx].Pz()*mParticles[idx].Pz()) / sqrt(mParticles[idx].Energy()*mParticles[idx].Energy()/mParticles[idx].Pz()/mParticles[idx].Pz() - 1.);
154-
e_new = mParticles[idx].Energy() / mParticles[idx].Pz() * pz_new;
155+
float e_new = sqrt(deltaMassSquared + e_old*e_old);
156+
if (std::fabs(pz_old) > 1e-8) {
157+
if (e_old*e_old <= pz_old*pz_old) {
158+
LOGF(error, "|E| <= |p_z|, this is not expected, so we don't replace the chi_c1");
159+
break;
160+
}
161+
pz_new = sqrt(deltaMassSquared + e_old*e_old - pz_old*pz_old) / sqrt(e_old*e_old/pz_old/pz_old - 1.);
162+
if (pz_old < 0.) {
163+
pz_new = -pz_new;
164+
}
165+
e_new = e_old / pz_old * pz_new;
155166
}
156167
mParticles[idx].SetMomentum(mParticles[idx].Px(), mParticles[idx].Py(), pz_new, e_new);
157168

@@ -221,7 +232,6 @@ bool findHadrons(Pythia8::Event& event) {
221232
bool isNonPrompt = false;
222233
if (isOpenBhadron(pdg)) {
223234
isNonPrompt = true;
224-
LOGF(info, "particle is non-prompt");
225235

226236
// if the B hadron decays to something else than a charmonia, we don't trigger it
227237
bool hasCharmoniaDecay = false;
@@ -253,7 +263,6 @@ bool findHadrons(Pythia8::Event& event) {
253263
cout << currentPdg << " ";
254264
if (isOpenBhadron(currentPdg)) {
255265
isNonPrompt = true;
256-
LOGF(info, "particle is non-prompt");
257266
break;
258267
}
259268
}
@@ -264,10 +273,8 @@ bool findHadrons(Pythia8::Event& event) {
264273

265274
// rejection factor given in the ini file
266275
float randomNumber = gRandom->Rndm();
267-
cout << randomNumber << " rej factor: " << (isNonPrompt ? mRejFactorNonPrompt[ihad] : mRejFactorPrompt[ihad]) << endl;
268276
if ((!isNonPrompt && (randomNumber <= mRejFactorPrompt[ihad])) ||
269277
(isNonPrompt && (randomNumber <= mRejFactorNonPrompt[ihad]))) {
270-
cout << "event triggered " << endl;
271278
return true;
272279
}
273280
}
@@ -448,7 +455,7 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
448455

449456
// For particle which are not produced by default in Pythia (chi_c1(3872)), the rejFactors string should be understood as a probabiliy to inject it (default being 0.)
450457

451-
int particleList[17] = {
458+
std::vector<int> particleList = {
452459
443, // Jpsi
453460
100443, // psi(2S)
454461
553, // upsilon(1S)
@@ -469,6 +476,9 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
469476
5232, // Xib0
470477
5332 // Omegab
471478
};
479+
480+
int nCharmonia = 9;
481+
int nCharmoniaWoChic = 5;
472482

473483
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorPythia8HadronTriggeredWithGap>();
474484
gen->setTriggerGap(triggerGap);
@@ -482,7 +492,7 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
482492
gen->setRapidityRange(rapidityMin - 1., rapidityMax + 1.);
483493
}
484494
// specify particles to be triggered
485-
for (int i = 0; i < 17; i++) {
495+
for (int i = 0; i < particleList.size(); i++) {
486496
gen->addHadronPDGs(particleList[i]);
487497
if (particleList[i] == 9920443) {
488498
// chi_c1(3872) is by default not produced
@@ -508,14 +518,14 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
508518
}
509519
if (str0.CompareTo("prompt") == 0) {
510520
// Common switch for all prompt particles
511-
for (int ihad = 0; ihad < 17; ihad++) {
521+
for (int ihad = 0; ihad < particleList.size(); ihad++) {
512522
gen->setRejFactorPrompt(particleList[ihad], str1.Atof());
513523
}
514524
continue;
515525
}
516526
if (str0.CompareTo("non-prompt") == 0) {
517527
// Common switch for all non-prompt particles
518-
for (int ihad = 0; ihad < 17; ihad++) {
528+
for (int ihad = 0; ihad < particleList.size(); ihad++) {
519529
gen->setRejFactorNonPrompt(particleList[ihad], str1.Atof());
520530
}
521531
continue;
@@ -557,10 +567,10 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
557567
gen->PrintDebug(true);
558568

559569
// specify particles to be decayed with EvtGen
560-
gen->SetSizePdg(17);
561-
for (int i = 0; i < 17; i++) {
570+
gen->SetSizePdg(particleList.size());
571+
for (int i = 0; i < particleList.size(); i++) {
562572
// Decay only what was left undecayed by Pythia
563-
if (decayMode == 0 || (i <= 8 && decayMode == 1) || (i <= 4 && decayMode == 2)) {
573+
if (decayMode == 0 || (i < nCharmonia && decayMode == 1) || (i < nCharmoniaWoChic && decayMode == 2)) {
564574
gen->AddPdg(particleList[i], i);
565575
}
566576
}
@@ -590,7 +600,7 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
590600
if (decayMode != 2) {
591601
// If decayMode == 2, EvtGen will not affect charmonia rapidities, so no need to start with a looser rapidity cut, first trigger already does the job
592602
gen->setTriggerMode(Generator::kTriggerOR);
593-
for (int i = 0; i < 17; i++) {
603+
for (int i = 0; i < particleList.size(); i++) {
594604
// we trigger either on B hadron rapidity or on charmonia rapidity
595605
gen->addTrigger(triggerPDGRap(rapidityMin, rapidityMax, particleList[i], gen));
596606
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### The external generator derives from GeneratorPythia8.
22
[GeneratorExternal]
33
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/generator_pythia8_HadronTriggered_withGap.C
4-
funcName=GeneratorInclusiveJpsiPsi2SChiC_EvtGenMidY(5,-1.,1.)
4+
funcName=GeneratorInclusiveJpsiPsi2SChiC_EvtGenMidY(5,-1.5,1.5)
55

66
[GeneratorPythia8]
77
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_inel_triggerGap.cfg

0 commit comments

Comments
 (0)