From 572bd82cd28023fa275dbbcfa68ce736a18d43d1 Mon Sep 17 00:00:00 2001 From: jesgum Date: Tue, 9 Jun 2026 13:04:52 +0200 Subject: [PATCH 1/4] Fix indices bug in otf decayer --- ALICE3/Core/OTFParticle.h | 11 ++++++- ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx | 30 +++++++++++--------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ALICE3/Core/OTFParticle.h b/ALICE3/Core/OTFParticle.h index 9f93ea59597..4088c39ac80 100644 --- a/ALICE3/Core/OTFParticle.h +++ b/ALICE3/Core/OTFParticle.h @@ -24,6 +24,7 @@ #include #include #include +#include #include namespace o2::upgrade @@ -88,6 +89,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 +180,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..11ff0cd010b 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx @@ -79,6 +79,7 @@ struct OnTheFlyDecayer { o2::upgrade::Decayer decayer; Service pdgDB; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + std::vector> mcParticlesGrouped; Configurable seed{"seed", 0, "Set seed for particle decayer"}; Configurable magneticField{"magneticField", 20., "Magnetic field (kG)"}; @@ -86,9 +87,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 +154,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 +173,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 +191,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 +205,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(); } }; From fac0b57aa9cd84ed2b320c944c1c5dfe75d3d78e Mon Sep 17 00:00:00 2001 From: jesgum Date: Tue, 9 Jun 2026 13:05:39 +0200 Subject: [PATCH 2/4] update --- ALICE3/Core/OTFParticle.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ALICE3/Core/OTFParticle.h b/ALICE3/Core/OTFParticle.h index 4088c39ac80..4e600b99f62 100644 --- a/ALICE3/Core/OTFParticle.h +++ b/ALICE3/Core/OTFParticle.h @@ -24,7 +24,6 @@ #include #include #include -#include #include namespace o2::upgrade From da02d0c27d2547dfabc302f3642659fccae4655c Mon Sep 17 00:00:00 2001 From: jesgum Date: Tue, 9 Jun 2026 13:26:22 +0200 Subject: [PATCH 3/4] remove unused --- ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx index 11ff0cd010b..da010a889db 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx @@ -79,7 +79,6 @@ struct OnTheFlyDecayer { o2::upgrade::Decayer decayer; Service pdgDB; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - std::vector> mcParticlesGrouped; Configurable seed{"seed", 0, "Set seed for particle decayer"}; Configurable magneticField{"magneticField", 20., "Magnetic field (kG)"}; From bc39fbcb0a23179d6dcc75787b5b3b4f9f01da76 Mon Sep 17 00:00:00 2001 From: jesgum Date: Tue, 9 Jun 2026 14:03:52 +0200 Subject: [PATCH 4/4] fix offset --- ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx index da010a889db..fb6cd64fdc4 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx @@ -208,7 +208,7 @@ struct OnTheFlyDecayer { // 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(); + indexOffset += (allParticles.size() - mcParticles.size()); } };