Skip to content

Commit ab26c14

Browse files
committed
Fix coalescence and definition of event containing decayed charmed nuclei
1 parent e9c834b commit ab26c14

3 files changed

Lines changed: 94 additions & 56 deletions

File tree

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

Lines changed: 79 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ using namespace Pythia8;
1717
class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
1818
{
1919
public:
20-
/// default constructor
21-
GeneratorPythia8HFEmbedCharmNuclei() = default;
2220

2321
/// constructor
2422
GeneratorPythia8HFEmbedCharmNuclei(int pdgCode = 2010010020, float lifetime = 1.f, int nCharmNucleiPerEvent = 10, float yMin = -1.f, float yMax = 1.f, bool trivialCoal = false, float coalMomentum = 0.2)
@@ -35,42 +33,32 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
3533
LOG(fatal) << "********** [GeneratorPythia8HFEmbedCharmNuclei] Only c-deuteron (pdg=2010010020) currently supported! Exit **********";
3634
}
3735
mLifetimeCharmNucleus = lifetime;
38-
mDecayDistr = TF1("mDecayDistr", Form("exp(-x/%f)", mLifetimeCharmNucleus), 0., 1000.)
36+
mDecayDistr = new TF1("mDecayDistr", Form("exp(-x/%f)", mLifetimeCharmNucleus), 0., 1000.);
3937

4038
Print();
4139

4240
/** switch off process level **/
43-
mPythiaGun.readString("ProcessLevel:all off");
44-
auto& param = o2::eventgen::GeneratorPythia8::Instance();
41+
// mPythiaGun.readString("ProcessLevel:all off");
42+
auto& param = o2::eventgen::GeneratorPythia8Param::Instance();
4543
LOG(info) << "Init \'GeneratorPythia8HFEmbedCharmNuclei\' with following parameters";
4644
LOG(info) << param;
47-
for (int iCfg{0}; iCfg < 8; ++iCfg) {
48-
if (param.config[iCfg].empty()) {
49-
continue;
50-
}
51-
std::string config = gSystem->ExpandPathName(param.config[iCfg].c_str());
52-
LOG(info) << "GeneratorPythia8HFEmbedCharmNuclei Reading configuration from file: " << config;
53-
if (!mPythiaGun.readFile(config, true)) {
54-
LOG(fatal) << "Failed to init \'GeneratorPythia8\': problems with configuration file "
55-
<< config;
56-
return;
57-
}
45+
if (param.config.empty()) {
46+
LOG(fatal) << "Failed to init \'GeneratorPythia8\': problems with configuration file ";
47+
}
48+
std::string cfg = gSystem->ExpandPathName(param.config.c_str());
49+
LOG(info) << "GeneratorPythia8HFEmbedCharmNuclei Reading configuration from file: " << cfg;
50+
if (!mPythiaGun.readFile(cfg, true)) {
51+
LOG(fatal) << "Failed to init \'GeneratorPythia8\': problems with configuration file " << cfg;
5852
}
53+
5954
if (!mPythiaGun.init()) {
6055
LOG(fatal) << "Failed to init \'GeneratorPythia8\': init returned with error";
61-
return;
6256
}
6357
}
6458

6559
/// Destructor
6660
~GeneratorPythia8HFEmbedCharmNuclei() = default;
6761

68-
/// Init
69-
bool Init() override
70-
{
71-
return o2::eventgen::GeneratorPythia8::Init();
72-
}
73-
7462
/// Print the input
7563
void Print()
7664
{
@@ -79,7 +67,7 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
7967
LOG(info) << Form("* Mass of charm nuclei to be injected (GeV/c2): %f", mMassCharmNucleus);
8068
LOG(info) << Form("* Lifetime of charm nuclei to be injected (mm): %f", mLifetimeCharmNucleus);
8169
LOG(info) << Form("* Number of charm nuclei injected per event: %d", nNumberOfCharmNucleiPerEvent);
82-
LOG(info) << Form("* Hadron rapidity: %f - %f", mHadRapidityMin, mHadRapidityMax);
70+
LOG(info) << Form("* Hadron rapidity: %f - %f", mRapidityMinCharmNuclei, mRapidityMaxCharmNuclei);
8371
LOG(info) << Form("* Trivial coalescence: %d", mTrivialCoal);
8472
LOG(info) << Form("* Coalescence momentum: %f", mCoalMomentum);
8573
LOG(info) << "***********************************************************************";
@@ -101,7 +89,6 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
10189
return mUsedSeed;
10290
};
10391

104-
protected:
10592
//__________________________________________________________________
10693
bool generateEvent() override
10794
{
@@ -123,18 +110,18 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
123110
}
124111

125112
auto pt = gRandom->Uniform(0., 50.); // placeholder, to be modified
126-
auto y = gRandom->Uniform(mHadRapidityMin, mHadRapidityMax);
113+
auto y = gRandom->Uniform(mRapidityMinCharmNuclei, mRapidityMaxCharmNuclei);
127114
auto phi = gRandom->Uniform(0, TMath::TwoPi());
128115
auto px = pt * TMath::Cos(phi);
129116
auto py = pt * TMath::Sin(phi);
130117
auto mt = TMath::Sqrt(mMassCharmNucleus * mMassCharmNucleus + pt * pt);
131118
auto pz = mt * TMath::SinH(y);
132119
auto p = TMath::Sqrt(pt * pt + pz * pz);
133-
auto e = TMath::Sqrt(mass * mass + p * p);
120+
auto e = TMath::Sqrt(mMassCharmNucleus * mMassCharmNucleus + p * p);
134121

135122
Particle particle;
136123
particle.id(sign * mPdgCharmNucleus);
137-
particle.status(81);
124+
particle.status(83);
138125
particle.m(mMassCharmNucleus);
139126
particle.px(px);
140127
particle.py(py);
@@ -143,7 +130,7 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
143130
particle.xProd(0.f);
144131
particle.yProd(0.f);
145132
particle.zProd(0.f);
146-
particle.tau(mDecayDistr->GetRandom());
133+
particle.tau(0.f); //mDecayDistr->GetRandom());
147134
mPythiaGun.particleData.mayDecay(mPdgCharmNucleus, true); // force decay
148135

149136
bool isCoalSuccess{false};
@@ -152,48 +139,88 @@ class GeneratorPythia8HFEmbedCharmNuclei : public o2::eventgen::GeneratorPythia8
152139
mPythiaGun.event.append(particle);
153140
mPythiaGun.moreDecays();
154141
std::array<int, 2> dausToCoal = {-1, -1};
142+
std::vector<int> pdgShortLivedResos = {313, 2224, 102134};
143+
bool isResoFound{false};
144+
int idxCharmNucleus{-1};
145+
for (int iPart{0}; iPart<mPythiaGun.event.size(); ++iPart) {
146+
auto part = mPythiaGun.event[iPart];
147+
auto absPdg = std::abs(part.id());
148+
if (absPdg == mPdgCharmNucleus) {
149+
idxCharmNucleus = iPart;
150+
}
151+
// if we find a resonance, we remove it, otherwise we prevent the coalescence of daughters from resonances and daughters from charmed nucleus directly
152+
if (std::find(pdgShortLivedResos.begin(), pdgShortLivedResos.end(), absPdg) != pdgShortLivedResos.end()) {
153+
// we need to change the indices of the daughter particles to point to the charmed nucleus
154+
auto dauList = part.daughterList();
155+
for (auto const& dau : dauList) {
156+
mPythiaGun.event[dau].mother1(idxCharmNucleus);
157+
}
158+
mPythiaGun.event.remove(iPart, iPart, true);
159+
isResoFound=true;
160+
}
161+
}
162+
if (isResoFound) { // we have to reset all the particles as daughters of the charm nucleus
163+
mPythiaGun.event[idxCharmNucleus].daughter1(idxCharmNucleus + 1);
164+
mPythiaGun.event[idxCharmNucleus].daughter2(mPythiaGun.event.size() - 1);
165+
}
166+
155167
int iDau{-1};
156168
for (int iPart{0}; iPart<mPythiaGun.event.size(); ++iPart) {
157169
auto part = mPythiaGun.event[iPart];
158-
if (std::abs(iPart) == 2212 || std::abs(iPart) == 2112) { // coalescence of protons and deuterons
170+
auto absPdg = std::abs(part.id());
171+
172+
if (absPdg == 2212 || absPdg == 2112) { // coalescence of protons and deuterons
159173
dausToCoal[++iDau] = iPart;
160174
}
161-
if (iDau == 1) { // we found the proton and the neutron to coalesce
162-
break;
163-
}
164175
}
176+
165177
// we try the coalescence here, if successful we copy particles in the pythia event and we move to the next charm nucleus
166-
isCoalSuccess = CoalescencePythia8(mPythiaGun.event, std::vector<int>{1000010020}, mTrivialCoal, mCoalMomentum, dausToCoal[0], dausToCoal[1]);
178+
isCoalSuccess = CoalescencePythia8(mPythiaGun.event, std::vector<unsigned int>{1000010020}, mTrivialCoal, mCoalMomentum, dausToCoal[0], dausToCoal[1]);
167179
if (isCoalSuccess) {
180+
int offset = mPythia.event.size(); // we need to rescale the indices of mothers and daughters, accounting for the particles that are already appended to the event
168181
for (int iPart{0}; iPart<mPythiaGun.event.size(); ++iPart) {
169-
mPythia.append(mPythiaGun.event[iPart]);
182+
auto part = mPythiaGun.event[iPart];
183+
if (part.id() == 90) {
184+
continue;
185+
}
186+
auto mother1 = part.mother1();
187+
auto mother2 = part.mother2();
188+
auto daughter1 = part.daughter1();
189+
auto daughter2 = part.daughter2();
190+
if (mother1 > 0) {
191+
part.mother1(mother1 + offset);
192+
}
193+
if (mother2 > 0) {
194+
part.mother2(mother2 + offset);
195+
}
196+
if (daughter1 > 0) {
197+
part.daughter1(daughter1 + offset);
198+
}
199+
if (daughter2 > 0) {
200+
part.daughter2(daughter2 + offset);
201+
}
202+
mPythia.event.append(part);
170203
}
171204
}
172-
mPythiaGun.next();
173205
}
174206
}
175207

176-
mPythia.next();
177-
178208
return true;
179209
}
180210

181211
private:
182212
// Properties of selection
183-
float mMassCharmNucleus;
184-
int mPdgCharmNucleus;
185-
float mLifetimeCharmNucleus;
186-
int nNumberOfCharmNucleiPerEvent;
187-
float mRapidityMinCharmNuclei;
188-
float mRapidityMaxCharmNuclei;
189-
unsigned int mUsedSeed;
190-
191-
bool mTrivialCoal = false; /// if true, the coalescence is done without checking the distance in the phase space of the nucleons
192-
float mCoalMomentum; /// coalescence momentum
193-
194-
Pythia8::Pythia mPythiaGun; // Gun generator with decay support
195-
196-
TF1* mDecayDistr;
213+
float mMassCharmNucleus; /// mass of the charmed nucleus
214+
int mPdgCharmNucleus; /// pdg code of the charmed nucleus
215+
float mLifetimeCharmNucleus; /// lifetime of the charmed nucleus
216+
int nNumberOfCharmNucleiPerEvent; /// number of charmed nuclei injected per event
217+
float mRapidityMinCharmNuclei; /// rapidity min
218+
float mRapidityMaxCharmNuclei; /// rapidity max
219+
unsigned int mUsedSeed; /// seed
220+
bool mTrivialCoal; /// if true, the coalescence is done without checking the distance in the phase space of the nucleons
221+
float mCoalMomentum; /// coalescence momentum
222+
Pythia8::Pythia mPythiaGun; /// Gun generator with decay support
223+
TF1* mDecayDistr; /// Lifetime distribution
197224
};
198225

199226

MC/config/PWGHF/ini/GeneratorHF_CDeuteron_Injected.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
### The external generator derives from GeneratorPythia8.
33
[GeneratorExternal]
44
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/generator_pythia8_embed_charmnuclei.C
5-
funcName=GenerateHFEmbedCDeuteron(1.,10,-1.,1.,0,0.2)
5+
funcName=GenerateHFEmbedCDeuteron(1., 10, -1., 1., 0, 0.4)
66

7+
### includePartonEvent is needed to keep the c-deuteron in the event record, even if there are no partons in the event
78
[GeneratorPythia8]
89
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_cdeuteron_to_dkpi.cfg
9-
includePartonEvent=false
10+
includePartonEvent=true

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,29 @@ Beams:idB 2212 # proton
77
Beams:eCM 13600. # GeV
88

99
### processes
10-
ProcessLevel:all off # turning off all the processes, we do not have an underlying event
10+
SoftQCD:inelastic on # all inelastic processes
1111

1212
### decays
1313
ParticleDecays:limitTau0 on
1414
ParticleDecays:tau0Max 10.
1515

1616
### add the c-deuteron
1717
### id:all = name antiName spinType chargeType colType m0 mWidth mMin mMax tau0
18-
2010010020:all = CDeuteron+ AntiCDeuteron- 1 3 0 3.226 0 3.226 3.226 1.
18+
2010010020:all = CDeuteron AntiCDeuteron 1 3 0 3.226 0 3.226 3.226 1.
1919
2010010020:mayDecay = on
2020

2121
# same as Λc+ -> p K- π+ including resonances + a neutron
2222
2010010020:oneChannel = 1 0.14400 0 2112 2212 -321 211 ### Λc+ -> p K- π+ (non-resonant) 3.5%
2323
2010010020:addChannel = 1 0.08100 100 2112 2212 -313 ### Λc+ -> p K*0(892) 1.96%
2424
2010010020:addChannel = 1 0.04500 100 2112 2224 -321 ### Λc+ -> Delta++ K- 1.08%
2525
2010010020:addChannel = 1 0.09000 100 2112 102134 211 ### Λc+ -> Lambda(1520) K- 2.20e-3
26+
27+
### K*0(892) -> K- π+
28+
313:onMode = off
29+
313:onIfAll = 321 211
30+
### for Λc -> Delta++ K-
31+
2224:onMode = off
32+
2224:onIfAll = 2212 211
33+
### for Λc -> Lambda(1520) K-
34+
102134:onMode = off
35+
102134:onIfAll = 2212 321

0 commit comments

Comments
 (0)