diff --git a/ALICE3/Core/OTFParticle.h b/ALICE3/Core/OTFParticle.h index 9f93ea59597..4e600b99f62 100644 --- a/ALICE3/Core/OTFParticle.h +++ b/ALICE3/Core/OTFParticle.h @@ -88,6 +88,14 @@ class OTFParticle mPz = pz; mE = e; } + void setIndexOffset(const std::size_t offset) + { + static constexpr int NotFound = -1; + mIndicesMother[0] = (mIndicesMother[0] >= 0) ? mIndicesMother[0] + static_cast(offset) : NotFound; + mIndicesMother[1] = (mIndicesMother[1] >= 0) ? mIndicesMother[1] + static_cast(offset) : NotFound; + mIndicesDaughter[0] = (mIndicesDaughter[0] >= 0) ? mIndicesDaughter[0] + static_cast(offset) : NotFound; + mIndicesDaughter[1] = (mIndicesDaughter[1] >= 0) ? mIndicesDaughter[1] + static_cast(offset) : NotFound; + } // Getters int pdgCode() const { return mPdgCode; } @@ -171,7 +179,7 @@ class OTFParticle private: int mPdgCode{}, mGlobalIndex{-1}; - int mCollisionId{}; + int mCollisionId{-1}; float mVx{}, mVy{}, mVz{}, mVt{}; float mPx{}, mPy{}, mPz{}, mE{}; bool mIsAlive{}, mIsFromMcParticles{false}; diff --git a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx index b568364b80c..fb6cd64fdc4 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx @@ -86,9 +86,8 @@ struct OnTheFlyDecayer { {DefaultParameters[0], NumDecays, NumParameters, ParticleNames, ParameterNames}, "Enable option for particle to be decayed: 0 - no, 1 - yes"}; + std::size_t indexOffset = 0; static constexpr float PicoToNano = 1.e-3f; - int mCollisionId{-1}; - std::vector mEnabledDecays; void init(o2::framework::InitContext&) { @@ -154,7 +153,7 @@ struct OnTheFlyDecayer { particle.setIndicesDaughter(allParticles.size(), allParticles.size() + (decayStack.size() - 1)); for (o2::upgrade::OTFParticle daughter : decayStack) { daughter.setIndicesMother(i, i); - daughter.setCollisionId(mCollisionId); + daughter.setCollisionId(particle.collisionId()); daughter.setBitOn(o2::upgrade::DecayerBits::IsAlive); daughter.setBitOff(o2::upgrade::DecayerBits::IsPrimary); daughter.setProductionTime(trackTimeNS); @@ -173,18 +172,14 @@ struct OnTheFlyDecayer { void process(aod::McCollisions_001From>::iterator const& collision, aod::McParticles_001From> const& mcParticles) { allParticles.clear(); + if (collision.globalIndex() == 0) { + indexOffset = 0; + } // Reproduce collision table to have AOD origin - mCollisionId = collision.globalIndex(); - tableMcCollisions(collision.bcId(), - collision.generatorsID(), - collision.posX(), - collision.posY(), - collision.posZ(), - collision.t(), - collision.weight(), - collision.impactParameter(), - collision.eventPlaneAngle()); + tableMcCollisions(collision.bcId(), collision.generatorsID(), + collision.posX(), collision.posY(), collision.posZ(), collision.t(), + collision.weight(), collision.impactParameter(), collision.eventPlaneAngle()); // First we copy the particles from the table into a vector that is extendable for (const auto& particle : mcParticles) { @@ -195,7 +190,8 @@ struct OnTheFlyDecayer { decayParticles(0, allParticles.size()); // Fill output table - for (const auto& otfParticle : allParticles) { + for (auto& otfParticle : allParticles) { + otfParticle.setIndexOffset(indexOffset); if (otfParticle.hasNaN()) { histos.fill(HIST("hNaNBookkeeping"), 1); } else { @@ -208,6 +204,11 @@ struct OnTheFlyDecayer { otfParticle.px(), otfParticle.py(), otfParticle.pz(), otfParticle.e(), otfParticle.vx(), otfParticle.vy(), otfParticle.vz(), otfParticle.vt()); } + + // Particles for later collisions in df's needs to have thier mother + // and daughter indices adjusted since their global index will be + // shifted due to the appending of decay products + indexOffset += (allParticles.size() - mcParticles.size()); } };