@@ -26,7 +26,7 @@ public:
2626 mInverseTriggerRatio = inputTriggerRatio ;
2727 // define minimum bias event generator
2828 auto seed = (gRandom -> TRandom ::GetSeed () % 900000000 );
29- TString pathconfigMB = gSystem -> ExpandPathName ("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ /pythia8/generator/pythia8_PbPb_5TeV .cfg" );
29+ TString pathconfigMB = gSystem -> ExpandPathName ("${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3 /pythia8/generator/pythia8_PbPb_536tev .cfg" );
3030 pythiaMBgen .readFile (pathconfigMB .Data ());
3131 pythiaMBgen .readString ("Random:setSeed on" );
3232 pythiaMBgen .readString ("Random:seed " + std ::to_string (seed ));
@@ -90,12 +90,22 @@ protected:
9090 return out ;
9191 }
9292
93+ bool keepAncestor (int idabs ){
94+ // charmonium
95+ int mid2 = (idabs / 10 ) % 100 ; // 443,100443,20443,445...
96+ if (mid2 == 44 ) return true;
97+
98+ // open charm/beauty hadron (D, B, charmed/bottom baryon...)
99+ int flav = (idabs / 100 ) % 10 ;
100+ if (flav == 4 || flav == 5 ) return true;
101+
102+ return false;
103+ }
104+
93105void collectAncestors (const Pythia8 ::Event & event , int idx , std ::vector < int > & decayChains , std ::vector < char > & visited ) {
94106 if (idx < 0 || idx >= event .size ()) return ;
95- if (!visited [idx ]) {
96- visited [idx ] = 1 ;
97- decayChains .push_back (idx );
98- }
107+ if (visited [idx ]) return ;
108+ visited [idx ] = 1 ;
99109
100110 const int idabs = std ::abs (event [idx ].id ());
101111 if (idabs == 4 || idabs == 5 || idabs == 21 ) return ;
@@ -108,6 +118,8 @@ void collectAncestors(const Pythia8::Event& event, int idx, std::vector<int>& de
108118 if (m == idx ) continue ;
109119 collectAncestors (event , m , decayChains , visited );
110120 }
121+
122+ if (keepAncestor (idabs )) decayChains .push_back (idx );
111123}
112124
113125void collectDaughters (const Pythia8 ::Event & event , int idx , std ::vector < int > & decayChains , std ::vector < char > & visited ) {
@@ -123,6 +135,7 @@ void collectDaughters(const Pythia8::Event& event, int idx, std::vector<int>& de
123135 int daughter2 = event [idx ].daughter2 ();
124136 if (daughter1 < 0 ) return ;
125137 if (daughter2 < daughter1 ) daughter2 = daughter1 ;
138+
126139 for (int d = daughter1 ; d <= daughter2 ; ++ d ) {
127140 if (d == idx ) continue ;
128141 collectDaughters (event , d , decayChains , visited );
@@ -131,19 +144,28 @@ void collectDaughters(const Pythia8::Event& event, int idx, std::vector<int>& de
131144
132145TParticle makeTParticleTemp (const Pythia8 ::Event & event , int idx ) {
133146 const auto& q = event [idx ];
134- int status = q .status ();
135- if (status < 0 ) {
136- return TParticle (0 , 0 , -1 , -1 , -1 , -1 ,
137- 0. ,0. ,0. ,0. , 0. ,0. ,0. ,0. );
138- }
139-
147+ int status = q .daughter1 () < 0 ? 1 : 2 ;
148+
140149 int m1 = q .mother1 ();
141150 int m2 = q .mother2 ();
142151 int d1 = q .daughter1 ();
143152 int d2 = q .daughter2 ();
144- return TParticle (q .id (), status , m1 , m2 , d1 , d2 ,
153+ TParticle tparticle (q .id (), status , m1 , m2 , d1 , d2 ,
145154 q .px (), q .py (), q .pz (), q .e (),
146155 q .xProd (), q .yProd (), q .zProd (), q .tProd ());
156+
157+ if (tparticle .GetStatusCode () == 1 ) {
158+ tparticle .SetStatusCode (
159+ o2 ::mcgenstatus ::MCGenStatusEncoding (1 , 91 ).fullEncoding );
160+ tparticle .SetBit (ParticleStatus ::kToBeDone , true);
161+ } else {
162+ tparticle .SetStatusCode (
163+ o2 ::mcgenstatus ::MCGenStatusEncoding (2 , -91 ).fullEncoding );
164+ tparticle .SetBit (ParticleStatus ::kToBeDone , false);
165+ }
166+
167+ return tparticle ;
168+
147169}
148170
149171Bool_t importParticles () override
@@ -169,7 +191,9 @@ Bool_t importParticles() override
169191
170192 std ::vector < int > decayChains ;
171193 std ::vector < char > visited (mPythia .event .size (), 0 );
172- decayChains .reserve (256 );
194+ decayChains .reserve (mPythia .event .size ());
195+
196+ //int originalSize = mParticles.size();
173197
174198 // find all ancestors of the charmonia
175199 for (size_t ic = 0 ; ic < charmonia .size (); ++ ic ) {
@@ -187,15 +211,14 @@ Bool_t importParticles() override
187211 mParticles .reserve (mParticles .size () + (int )decayChains .size ());
188212
189213 for (int i = 0 ; i < (int )decayChains .size (); ++ i ) {
190- const int srcIdx = decayChains [i ];
191- if (srcIdx < 0 || srcIdx >= mPythia .event .size ()) continue ;
214+ const int srcIdx = decayChains [i ];
215+ if (srcIdx < 0 || srcIdx >= mPythia .event .size ()) continue ;
192216
193- TParticle part = makeTParticleTemp (mPythia .event , srcIdx );
194- if (part .GetPdgCode () == 0 ) continue ;
217+ TParticle part = makeTParticleTemp (mPythia .event , srcIdx );
195218
196- int newIdx = (int )mParticles .size ();
197- mParticles .push_back (part );
198- idxMap [srcIdx ] = newIdx ;
219+ int newIdx = (int )mParticles .size ();
220+ mParticles .push_back (part );
221+ idxMap [srcIdx ] = newIdx ;
199222 }
200223
201224 for (int iLoc = 0 ; iLoc < (int ) decayChains .size (); ++ iLoc ) {
@@ -221,8 +244,17 @@ Bool_t importParticles() override
221244 LOG (info ) << "-----------------------------------------------" ;
222245 LOG (info ) << "============ After event " << isig << " (size " << decayChains .size () << ")" ;
223246 LOG (info ) << "Full stack (size " << mParticles .size () << "):" ;
247+ //LOG(info) << "New particles from signal event " << isig;
248+ //for (int id = originalSize; id < (int)mParticles.size(); ++id) {
249+ // const auto& p = mParticles[id];
250+ // LOG(info) << " id = " << id
251+ // << ", pdg = " << p.GetPdgCode()
252+ // << " --> firstMother=" << p.GetFirstMother()
253+ // << ", lastMother=" << p.GetSecondMother()
254+ // << ", firstDaughter=" << p.GetFirstDaughter()
255+ // << ", lastDaughter=" << p.GetLastDaughter();
256+ //}
224257 LOG (info ) << "-----------------------------------------------" ;
225- // printParticleVector(mParticles);
226258 }
227259
228260 if (mVerbose ) mOutputEvent .list ();
0 commit comments