@@ -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,9 @@ 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+ }
137144 const float decayRadius = decayer.getDecayRadius ();
138145 const float trackVelocity = o2::upgrade::computeParticleVelocity (particle.p (), pdgDB->GetParticle (particle.pdgCode ())->Mass ());
139146 const int charge = pdgDB->GetParticle (particle.pdgCode ())->Charge () / 3 ;
@@ -151,19 +158,15 @@ struct OnTheFlyDecayer {
151158
152159 const float trackTimeNS = trackLength / trackVelocity * PicoToNano;
153160 particle.setIndicesDaughter (allParticles.size (), allParticles.size () + (decayStack.size () - 1 ));
154- for (const o2::upgrade::OTFParticle & daughter : decayStack) {
161+ for (auto & daughter : decayStack) {
155162 daughter.setIndicesMother (i, i);
156163 daughter.setCollisionId (particle.collisionId ());
157164 daughter.setBitOn (o2::upgrade::DecayerBits::IsAlive);
158165 daughter.setBitOff (o2::upgrade::DecayerBits::IsPrimary);
159166 daughter.setProductionTime (trackTimeNS);
160167 allParticles.push_back (daughter);
161- ndau++;
162168 }
163- }
164-
165- if (start >= stop) {
166- return ;
169+ ndau += decayStack.size ();
167170 }
168171
169172 decayParticles (stop, stop + ndau);
@@ -172,6 +175,7 @@ struct OnTheFlyDecayer {
172175 void process (aod::McCollisions_001From<aod::Hash<" TMP" _h>>::iterator const & collision, aod::McParticles_001From<aod::Hash<" TMP" _h>> const & mcParticles)
173176 {
174177 allParticles.clear ();
178+ allParticles.reserve (mcParticles.size () * 2 );
175179 if (collision.globalIndex () == 0 ) {
176180 indexOffset = 0 ;
177181 }
@@ -190,7 +194,7 @@ struct OnTheFlyDecayer {
190194 decayParticles (0 , allParticles.size ());
191195
192196 // Fill output table
193- for (const o2::upgrade::OTFParticle & otfParticle : allParticles) {
197+ for (auto & otfParticle : allParticles) {
194198 otfParticle.setIndexOffset (indexOffset);
195199 if (otfParticle.hasNaN ()) {
196200 histos.fill (HIST (" hNaNBookkeeping" ), 1 );
@@ -199,7 +203,7 @@ struct OnTheFlyDecayer {
199203 }
200204
201205 tableOTFDecayerBits (otfParticle.getBitsValue ());
202- tableMcParticles (otfParticle. collisionId (), otfParticle.pdgCode (), otfParticle.statusCode (), otfParticle.flags (),
206+ tableMcParticles (tableMcCollisions. lastIndex (), otfParticle.pdgCode (), otfParticle.statusCode (), otfParticle.flags (),
203207 otfParticle.getMotherSpan (), otfParticle.getDaughters ().data (), otfParticle.weight (),
204208 otfParticle.px (), otfParticle.py (), otfParticle.pz (), otfParticle.e (),
205209 otfParticle.vx (), otfParticle.vy (), otfParticle.vz (), otfParticle.vt ());
0 commit comments