@@ -79,16 +79,16 @@ struct OnTheFlyDecayer {
7979 o2::upgrade::Decayer decayer;
8080 Service<o2::framework::O2DatabasePDG> pdgDB;
8181 HistogramRegistry histos{" histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
82+ std::vector<std::vector<int >> mcParticlesGrouped;
8283
8384 Configurable<int > seed{" seed" , 0 , " Set seed for particle decayer" };
8485 Configurable<float > magneticField{" magneticField" , 20 ., " Magnetic field (kG)" };
8586 Configurable<LabeledArray<int >> enabledDecays{" enabledDecays" ,
8687 {DefaultParameters[0 ], NumDecays, NumParameters, ParticleNames, ParameterNames},
8788 " Enable option for particle to be decayed: 0 - no, 1 - yes" };
8889
90+ std::size_t indexOffset = 0 ;
8991 static constexpr float PicoToNano = 1 .e-3f ;
90- int mCollisionId {-1 };
91-
9292 std::vector<int > mEnabledDecays ;
9393 void init (o2::framework::InitContext&)
9494 {
@@ -154,7 +154,7 @@ struct OnTheFlyDecayer {
154154 particle.setIndicesDaughter (allParticles.size (), allParticles.size () + (decayStack.size () - 1 ));
155155 for (o2::upgrade::OTFParticle daughter : decayStack) {
156156 daughter.setIndicesMother (i, i);
157- daughter.setCollisionId (mCollisionId );
157+ daughter.setCollisionId (particle. collisionId () );
158158 daughter.setBitOn (o2::upgrade::DecayerBits::IsAlive);
159159 daughter.setBitOff (o2::upgrade::DecayerBits::IsPrimary);
160160 daughter.setProductionTime (trackTimeNS);
@@ -173,18 +173,14 @@ struct OnTheFlyDecayer {
173173 void process (aod::McCollisions_001From<aod::Hash<" TMP" _h>>::iterator const & collision, aod::McParticles_001From<aod::Hash<" TMP" _h>> const & mcParticles)
174174 {
175175 allParticles.clear ();
176+ if (collision.globalIndex () == 0 ) {
177+ indexOffset = 0 ;
178+ }
176179
177180 // Reproduce collision table to have AOD origin
178- mCollisionId = collision.globalIndex ();
179- tableMcCollisions (collision.bcId (),
180- collision.generatorsID (),
181- collision.posX (),
182- collision.posY (),
183- collision.posZ (),
184- collision.t (),
185- collision.weight (),
186- collision.impactParameter (),
187- collision.eventPlaneAngle ());
181+ tableMcCollisions (collision.bcId (), collision.generatorsID (),
182+ collision.posX (), collision.posY (), collision.posZ (), collision.t (),
183+ collision.weight (), collision.impactParameter (), collision.eventPlaneAngle ());
188184
189185 // First we copy the particles from the table into a vector that is extendable
190186 for (const auto & particle : mcParticles) {
@@ -195,7 +191,8 @@ struct OnTheFlyDecayer {
195191 decayParticles (0 , allParticles.size ());
196192
197193 // Fill output table
198- for (const auto & otfParticle : allParticles) {
194+ for (auto & otfParticle : allParticles) {
195+ otfParticle.setIndexOffset (indexOffset);
199196 if (otfParticle.hasNaN ()) {
200197 histos.fill (HIST (" hNaNBookkeeping" ), 1 );
201198 } else {
@@ -208,6 +205,11 @@ struct OnTheFlyDecayer {
208205 otfParticle.px (), otfParticle.py (), otfParticle.pz (), otfParticle.e (),
209206 otfParticle.vx (), otfParticle.vy (), otfParticle.vz (), otfParticle.vt ());
210207 }
208+
209+ // Particles for later collisions in df's needs to have thier mother
210+ // and daughter indices adjusted since their global index will be
211+ // shifted due to the appending of decay products
212+ indexOffset += allParticles.size ();
211213 }
212214};
213215
0 commit comments