From 6ff68621c19465d3e66ecf8237345c579bfec06b Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Fri, 17 Jul 2026 20:28:32 +0000 Subject: [PATCH 1/4] Transparent fix proposal draft 1 --- .../include/Framework/AnalysisDataModel.h | 52 ++++++++++++++----- Framework/Core/include/Framework/DataTypes.h | 4 ++ 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index c8dd33fba62ee..d38f4355c786d 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -1918,6 +1918,8 @@ DECLARE_SOA_TABLE_VERSIONED(McCollisions_001, "AOD", "MCCOLLISION", 1, //! MC co using McCollisions = McCollisions_001; using McCollision = McCollisions::iterator; + + namespace mcparticle { DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! MC collision of this particle @@ -1984,34 +1986,56 @@ DECLARE_SOA_EXPRESSION_COLUMN(Y, y, float, //! Particle rapidity, conditionally (aod::mcparticle::e - aod::mcparticle::pz)))); } // namespace mcparticle +namespace mcparticle_v2 +{ +// for improved getters with protection against incorrect physical primary tagging +// note: this has to be declared in a separate namespace so it does not conflict with existing +// derived data table declarations in O2Physics +DECLARE_SOA_DYNAMIC_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, //! True if particle is considered a physical primary according to the ALICE definition + [](uint8_t flags, float vx, float vy) -> bool { + if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; + return (flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary; }); + +// avoid that the stored flags are provided unprotected via +// the getter '.flags': analysers will get the correct bit map transparently +DECLARE_SOA_COLUMN(Flags, storedFlags, uint8_t); //! ALICE specific flags, see MCParticleFlags. Do not use directly. Use the dynamic columns, e.g. producedByGenerator() +DECLARE_SOA_DYNAMIC_COLUMN(McParticleFlags, flags, //! protected against + [](uint8_t input_flags, float vx, float vy) -> uint8_t { + if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; + return input_flags; }); + +} + DECLARE_SOA_TABLE_FULL(StoredMcParticles_000, "McParticles", "AOD", "MCPARTICLE", //! MC particle table, version 000 o2::soa::Index<>, mcparticle::McCollisionId, - mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags, + mcparticle::PdgCode, mcparticle::StatusCode, mcparticle_v2::Flags, mcparticle::Mother0Id, mcparticle::Mother1Id, mcparticle::Daughter0Id, mcparticle::Daughter1Id, mcparticle::Weight, mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E, mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt, mcparticle::PVector, - mcparticle::ProducedByGenerator, - mcparticle::FromBackgroundEvent, - mcparticle::GetGenStatusCode, - mcparticle::GetHepMCStatusCode, - mcparticle::GetProcess, - mcparticle::IsPhysicalPrimary); + mcparticle::ProducedByGenerator, + mcparticle::FromBackgroundEvent, + mcparticle::GetGenStatusCode, + mcparticle::GetHepMCStatusCode, + mcparticle::GetProcess, + mcparticle_v2::McParticleFlags, + mcparticle_v2::IsPhysicalPrimary); DECLARE_SOA_TABLE_FULL_VERSIONED(StoredMcParticles_001, "McParticles", "AOD", "MCPARTICLE", 1, //! MC particle table, version 001 o2::soa::Index<>, mcparticle::McCollisionId, - mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags, + mcparticle::PdgCode, mcparticle::StatusCode, mcparticle_v2::Flags, mcparticle::MothersIds, mcparticle::DaughtersIdSlice, mcparticle::Weight, mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E, mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt, mcparticle::PVector, - mcparticle::ProducedByGenerator, - mcparticle::FromBackgroundEvent, - mcparticle::GetGenStatusCode, - mcparticle::GetHepMCStatusCode, - mcparticle::GetProcess, - mcparticle::IsPhysicalPrimary); + mcparticle::ProducedByGenerator, + mcparticle::FromBackgroundEvent, + mcparticle::GetGenStatusCode, + mcparticle::GetHepMCStatusCode, + mcparticle::GetProcess, + mcparticle_v2::McParticleFlags, + mcparticle_v2::IsPhysicalPrimary); DECLARE_SOA_EXTENDED_TABLE(McParticles_000, StoredMcParticles_000, "EXMCPARTICLE", 0, //! Basic MC particle properties mcparticle::Phi, diff --git a/Framework/Core/include/Framework/DataTypes.h b/Framework/Core/include/Framework/DataTypes.h index 3d49d6d3c03d0..821decf3e8a7a 100644 --- a/Framework/Core/include/Framework/DataTypes.h +++ b/Framework/Core/include/Framework/DataTypes.h @@ -148,6 +148,10 @@ enum ForwardTrackTypeEnum : uint8_t { }; } // namespace o2::aod::fwdtrack +namespace o2::aod::mcparticle{ +constexpr float maxRadiusForPhysicalPrimary{5.f}; +} + namespace o2::aod::mcparticle::enums { enum MCParticleFlags : uint8_t { From 3a0a37a6d8fd5b7542a151b6b9d382c7f805e3d6 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Fri, 17 Jul 2026 20:45:54 +0000 Subject: [PATCH 2/4] Please consider the following formatting changes --- .../Core/include/Framework/AnalysisDataModel.h | 16 +++++++--------- Framework/Core/include/Framework/DataTypes.h | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index d38f4355c786d..5e3f35e7d8fea 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -1918,8 +1918,6 @@ DECLARE_SOA_TABLE_VERSIONED(McCollisions_001, "AOD", "MCCOLLISION", 1, //! MC co using McCollisions = McCollisions_001; using McCollision = McCollisions::iterator; - - namespace mcparticle { DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! MC collision of this particle @@ -1987,24 +1985,24 @@ DECLARE_SOA_EXPRESSION_COLUMN(Y, y, float, //! Particle rapidity, conditionally } // namespace mcparticle namespace mcparticle_v2 -{ +{ // for improved getters with protection against incorrect physical primary tagging -// note: this has to be declared in a separate namespace so it does not conflict with existing -// derived data table declarations in O2Physics +// note: this has to be declared in a separate namespace so it does not conflict with existing +// derived data table declarations in O2Physics DECLARE_SOA_DYNAMIC_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, //! True if particle is considered a physical primary according to the ALICE definition - [](uint8_t flags, float vx, float vy) -> bool { + [](uint8_t flags, float vx, float vy) -> bool { if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; return (flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary; }); -// avoid that the stored flags are provided unprotected via +// avoid that the stored flags are provided unprotected via // the getter '.flags': analysers will get the correct bit map transparently -DECLARE_SOA_COLUMN(Flags, storedFlags, uint8_t); //! ALICE specific flags, see MCParticleFlags. Do not use directly. Use the dynamic columns, e.g. producedByGenerator() +DECLARE_SOA_COLUMN(Flags, storedFlags, uint8_t); //! ALICE specific flags, see MCParticleFlags. Do not use directly. Use the dynamic columns, e.g. producedByGenerator() DECLARE_SOA_DYNAMIC_COLUMN(McParticleFlags, flags, //! protected against [](uint8_t input_flags, float vx, float vy) -> uint8_t { if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; return input_flags; }); -} +} // namespace mcparticle_v2 DECLARE_SOA_TABLE_FULL(StoredMcParticles_000, "McParticles", "AOD", "MCPARTICLE", //! MC particle table, version 000 o2::soa::Index<>, mcparticle::McCollisionId, diff --git a/Framework/Core/include/Framework/DataTypes.h b/Framework/Core/include/Framework/DataTypes.h index 821decf3e8a7a..d62aa379bf53f 100644 --- a/Framework/Core/include/Framework/DataTypes.h +++ b/Framework/Core/include/Framework/DataTypes.h @@ -148,7 +148,8 @@ enum ForwardTrackTypeEnum : uint8_t { }; } // namespace o2::aod::fwdtrack -namespace o2::aod::mcparticle{ +namespace o2::aod::mcparticle +{ constexpr float maxRadiusForPhysicalPrimary{5.f}; } From 0eb94bda3c20c0e570107acf02d24723fc62a0b2 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Fri, 17 Jul 2026 21:28:51 +0000 Subject: [PATCH 3/4] Fix whitespace --- Framework/Core/include/Framework/AnalysisDataModel.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index 5e3f35e7d8fea..98ae44ad4c958 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -1990,16 +1990,16 @@ namespace mcparticle_v2 // note: this has to be declared in a separate namespace so it does not conflict with existing // derived data table declarations in O2Physics DECLARE_SOA_DYNAMIC_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, //! True if particle is considered a physical primary according to the ALICE definition - [](uint8_t flags, float vx, float vy) -> bool { - if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; + [](uint8_t flags, float vx, float vy) -> bool { + if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; return (flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary; }); // avoid that the stored flags are provided unprotected via // the getter '.flags': analysers will get the correct bit map transparently DECLARE_SOA_COLUMN(Flags, storedFlags, uint8_t); //! ALICE specific flags, see MCParticleFlags. Do not use directly. Use the dynamic columns, e.g. producedByGenerator() DECLARE_SOA_DYNAMIC_COLUMN(McParticleFlags, flags, //! protected against - [](uint8_t input_flags, float vx, float vy) -> uint8_t { - if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; + [](uint8_t input_flags, float vx, float vy) -> uint8_t { + if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; return input_flags; }); } // namespace mcparticle_v2 From afb61fa7cf96074d21590ae1ad737088b58d6fbf Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Sat, 18 Jul 2026 08:12:08 +0000 Subject: [PATCH 4/4] Address only the bug --- Framework/Core/include/Framework/AnalysisDataModel.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index 98ae44ad4c958..37bbe5b878733 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -1990,16 +1990,20 @@ namespace mcparticle_v2 // note: this has to be declared in a separate namespace so it does not conflict with existing // derived data table declarations in O2Physics DECLARE_SOA_DYNAMIC_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, //! True if particle is considered a physical primary according to the ALICE definition - [](uint8_t flags, float vx, float vy) -> bool { - if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; - return (flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary; }); + [](uint8_t input_flags, float vx, float vy) -> bool { + if((std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) && ((input_flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary)){ + return o2::aod::mcparticle::enums::FromBackgroundEvent; + } + return (input_flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary; }); // avoid that the stored flags are provided unprotected via // the getter '.flags': analysers will get the correct bit map transparently DECLARE_SOA_COLUMN(Flags, storedFlags, uint8_t); //! ALICE specific flags, see MCParticleFlags. Do not use directly. Use the dynamic columns, e.g. producedByGenerator() DECLARE_SOA_DYNAMIC_COLUMN(McParticleFlags, flags, //! protected against [](uint8_t input_flags, float vx, float vy) -> uint8_t { - if(std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) return o2::aod::mcparticle::enums::FromBackgroundEvent; + if((std::hypot(vx, vy) > o2::aod::mcparticle::maxRadiusForPhysicalPrimary) && ((input_flags & o2::aod::mcparticle::enums::PhysicalPrimary) == o2::aod::mcparticle::enums::PhysicalPrimary)){ + return o2::aod::mcparticle::enums::FromBackgroundEvent; + } return input_flags; }); } // namespace mcparticle_v2