@@ -120,6 +120,10 @@ struct OnTheFlyDecayer {
120120 std::vector<o2::upgrade::OTFParticle> allParticles;
121121 void decayParticles (const int start, const int stop)
122122 {
123+ if (start >= stop) {
124+ return ;
125+ }
126+
123127 int ndau = 0 ;
124128 for (int i = start; i < stop; ++i) {
125129 o2::upgrade::OTFParticle& particle = allParticles[i];
@@ -134,6 +138,10 @@ struct OnTheFlyDecayer {
134138
135139 particle.setBitOff (o2::upgrade::DecayerBits::IsAlive);
136140 std::vector<o2::upgrade::OTFParticle> decayStack = decayer.decayParticle (pdgDB, particle);
141+ if (decayStack.empty ()) {
142+ continue ;
143+ }
144+
137145 const float decayRadius = decayer.getDecayRadius ();
138146 const float trackVelocity = o2::upgrade::computeParticleVelocity (particle.p (), pdgDB->GetParticle (particle.pdgCode ())->Mass ());
139147 const int charge = pdgDB->GetParticle (particle.pdgCode ())->Charge () / 3 ;
@@ -151,19 +159,15 @@ struct OnTheFlyDecayer {
151159
152160 const float trackTimeNS = trackLength / trackVelocity * PicoToNano;
153161 particle.setIndicesDaughter (allParticles.size (), allParticles.size () + (decayStack.size () - 1 ));
154- for (const o2::upgrade::OTFParticle & daughter : decayStack) {
162+ for (auto & daughter : decayStack) {
155163 daughter.setIndicesMother (i, i);
156164 daughter.setCollisionId (particle.collisionId ());
157165 daughter.setBitOn (o2::upgrade::DecayerBits::IsAlive);
158166 daughter.setBitOff (o2::upgrade::DecayerBits::IsPrimary);
159167 daughter.setProductionTime (trackTimeNS);
160168 allParticles.push_back (daughter);
161- ndau++;
162169 }
163- }
164-
165- if (start >= stop) {
166- return ;
170+ ndau += decayStack.size ();
167171 }
168172
169173 decayParticles (stop, stop + ndau);
@@ -172,6 +176,7 @@ struct OnTheFlyDecayer {
172176 void process (aod::McCollisions_001From<aod::Hash<" TMP" _h>>::iterator const & collision, aod::McParticles_001From<aod::Hash<" TMP" _h>> const & mcParticles)
173177 {
174178 allParticles.clear ();
179+ allParticles.reserve (mcParticles.size () * 2 );
175180 if (collision.globalIndex () == 0 ) {
176181 indexOffset = 0 ;
177182 }
@@ -190,7 +195,8 @@ struct OnTheFlyDecayer {
190195 decayParticles (0 , allParticles.size ());
191196
192197 // Fill output table
193- for (const o2::upgrade::OTFParticle& otfParticle : allParticles) {
198+ int id = indexOffset;
199+ for (auto & otfParticle : allParticles) {
194200 otfParticle.setIndexOffset (indexOffset);
195201 if (otfParticle.hasNaN ()) {
196202 histos.fill (HIST (" hNaNBookkeeping" ), 1 );
@@ -199,7 +205,7 @@ struct OnTheFlyDecayer {
199205 }
200206
201207 tableOTFDecayerBits (otfParticle.getBitsValue ());
202- tableMcParticles (otfParticle. collisionId (), otfParticle.pdgCode (), otfParticle.statusCode (), otfParticle.flags (),
208+ tableMcParticles (tableMcCollisions. lastIndex (), otfParticle.pdgCode (), otfParticle.statusCode (), otfParticle.flags (),
203209 otfParticle.getMotherSpan (), otfParticle.getDaughters ().data (), otfParticle.weight (),
204210 otfParticle.px (), otfParticle.py (), otfParticle.pz (), otfParticle.e (),
205211 otfParticle.vx (), otfParticle.vy (), otfParticle.vz (), otfParticle.vt ());
@@ -208,7 +214,7 @@ struct OnTheFlyDecayer {
208214 // Particles for later collisions in df's needs to have thier mother
209215 // and daughter indices adjusted since their global index will be
210216 // shifted due to the appending of decay products
211- indexOffset += ( allParticles.size () - mcParticles. size () );
217+ indexOffset += allParticles.size ();
212218 }
213219};
214220
0 commit comments