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..3a0030ed13a 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 @@ -316,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]++; @@ -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()]); } 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; }