From 1ea825ec08d3ad0fb7bc686b9b4522723c933068 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 27 Nov 2026 09:57:08 +0100 Subject: [PATCH 1/2] [PWGLF] strangederivedbuilder: StraCollisions index of each AO2D collision for other tasks A table joinable with aod::Collisions, StraCollisionLink, holding for each AO2D collision its row in StraCollisions (straCollisionId), -1 if the collision was not written (not selected, or no V0/cascade with fillEmptyCollisions off). It is filled from products.strangeColl.lastIndex() where StraCollisions is written, and emitted with the other references. For a builder running in the same derivation train that writes tables of its own (e.g. tracks) and must point them to the same collisions as the strangeness tables: the mapping exists only inside strangederivedbuilder, and rebuilding it elsewhere would mean replicating its acceptance logic. One int per collision; not meant to be saved. Co-Authored-By: Claude Opus 5.5 --- PWGLF/DataModel/LFStrangenessTables.h | 6 ++++++ PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/PWGLF/DataModel/LFStrangenessTables.h b/PWGLF/DataModel/LFStrangenessTables.h index 768040feab4..0d2fd13cd7b 100644 --- a/PWGLF/DataModel/LFStrangenessTables.h +++ b/PWGLF/DataModel/LFStrangenessTables.h @@ -950,6 +950,12 @@ DECLARE_SOA_TABLE(V0Indices, "AOD", "V0INDEX", //! index table when using AO2Ds DECLARE_SOA_TABLE(V0CollRefs, "AOD", "V0COLLREF", //! optional table to refer back to a collision o2::soa::Index<>, v0data::StraCollisionId); +// Joinable with aod::Collisions: the StraCollisions row of each AO2D collision, -1 for a collision not written. For the +// other tasks of a derivation train, which write tables of their own next to the strangeness ones (e.g. tracks) and +// need to point them to the same collisions; not meant to be saved. +DECLARE_SOA_TABLE(StraCollisionLink, "AOD", "STRACOLLLINK", //! AO2D collision -> StraCollisions + o2::soa::Index<>, v0data::StraCollisionId); + DECLARE_SOA_TABLE_STAGED(V0Extras, "V0EXTRA", //! optional table to refer to custom track extras o2::soa::Index<>, v0data::PosTrackExtraId, v0data::NegTrackExtraId); diff --git a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx index 8007e538f89..6ac65914919 100644 --- a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx @@ -100,6 +100,7 @@ struct strangederivedbuilder { Produces strangeStamps; // provides timestamps, run numbers Produces straEvTimes; // provides event times (FT0, TOF) Produces v0collref; // references collisions from V0s + Produces strangeCollLink; // references StraCollisions from AO2D collisions, for other tasks Produces casccollref; // references collisions from cascades Produces kfcasccollref; // references collisions from KF cascades Produces tracasccollref; // references collisions from tracked cascades @@ -265,6 +266,7 @@ struct strangederivedbuilder { // create collision indices beforehand std::vector TrackGlobalBc; + std::vector StraCollIndices; // per AO2D collision; index -1: not written std::vector V0CollIndices; // index -1: no collision std::vector CascadeCollIndices; // index -1: no collision std::vector KFCascadeCollIndices; // index -1: no collision @@ -553,12 +555,14 @@ struct strangederivedbuilder { { // create collision indices beforehand TrackGlobalBc.clear(); + StraCollIndices.clear(); V0CollIndices.clear(); CascadeCollIndices.clear(); KFCascadeCollIndices.clear(); TraCascadeCollIndices.clear(); TrackGlobalBc.resize(Tracks.size(), 0); + StraCollIndices.resize(collisions.size(), -1); // index -1: not written V0CollIndices.resize(V0s.size(), -1); // index -1: no collision CascadeCollIndices.resize(Cascades.size(), -1); // index -1: no collision KFCascadeCollIndices.resize(KFCascades.size(), -1); // index -1: no collision @@ -656,6 +660,7 @@ struct strangederivedbuilder { if (strange || fillEmptyCollisions) { products.strangeStamps(bc.runNumber(), bc.timestamp(), bc.globalBC()); products.strangeColl(collision.posX(), collision.posY(), collision.posZ()); + StraCollIndices[collision.globalIndex()] = products.strangeColl.lastIndex(); if constexpr (requires { collision.mcCollisionId(); }) { // check if MC information is available and if so fill labels products.strangeCollLabels(collision.mcCollisionId()); } @@ -767,6 +772,9 @@ struct strangederivedbuilder { // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ // populate references, including those that might not be assigned + for (const auto& collision : collisions) { + products.strangeCollLink(StraCollIndices[collision.globalIndex()]); + } for (const auto& v0 : V0s) { products.v0collref(V0CollIndices[v0.globalIndex()]); } From 43ccb8464eb22fa26200ccb36a29b78f2cbe3153 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 27 Nov 2026 09:57:08 +0100 Subject: [PATCH 2/2] [PWGLF] Strangeness event preselection: RCT requirement applied when requested isCollisionAccepted, in strangederivedbuilder and in the strangeness builder module of the propagation service, tested !cfgApplyRCTrequirement, while the RCTFlagsChecker is initialised only when cfgApplyRCTrequirement is true. So: - requirement on: the condition is always false, the RCT flags are never checked; - requirement off, with fillOnlySelectedCollisions: the uninitialised checker is called and throws (empty RCTSelectionFlags mask) at the first collision passing the other selections. Introduced in 90ebdcce7 (#17066). Co-Authored-By: Claude Opus 5.5 --- PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx | 2 +- PWGLF/Utils/strangenessBuilderModule.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx index 6ac65914919..3a0030ed13a 100644 --- a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx @@ -318,7 +318,7 @@ struct strangederivedbuilder { } nSelected[o2::aod::straselections::kNoSameBunchPileup]++; - if (!cfgApplyRCTrequirement && !rctFlagsChecker(collision)) { + if (cfgApplyRCTrequirement && !rctFlagsChecker(collision)) { return false; } nSelected[o2::aod::straselections::kIsGoodRCT]++; diff --git a/PWGLF/Utils/strangenessBuilderModule.h b/PWGLF/Utils/strangenessBuilderModule.h index 45b28701685..2ca63cbd940 100644 --- a/PWGLF/Utils/strangenessBuilderModule.h +++ b/PWGLF/Utils/strangenessBuilderModule.h @@ -483,7 +483,7 @@ class BuilderModule return false; } - if (!eventSelectOpts.cfgApplyRCTrequirement && !rctFlagsChecker(collision)) { + if (eventSelectOpts.cfgApplyRCTrequirement && !rctFlagsChecker(collision)) { return false; }