diff --git a/PWGCF/Femto/Core/kinkBuilder.h b/PWGCF/Femto/Core/kinkBuilder.h index 009be2f6dd4..015bedaac97 100644 --- a/PWGCF/Femto/Core/kinkBuilder.h +++ b/PWGCF/Femto/Core/kinkBuilder.h @@ -821,6 +821,58 @@ class KinkBuilderDerivedToDerived } } + template + void processSigmaWithMc(T1 const& col, T2 const& /*sigmaTable*/, T3 const& oldTrackTable, T4& partitionSigma, T5& trackBuilder, T6& cache, T7& newSigmaTable, T8& newTrackTable, T9& newCollisionTable, + T10& mcBuilder, T11 const& mcCols, T12 const& mcParticles, T13 const& mcMothers, T14 const& mcPartonicMothers, T15& mcProducts) + { + if (mLimitSigma == 0) { + return; + } + + auto sigmaSlice = partitionSigma->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + + for (auto const& sigma : sigmaSlice) { + auto chaDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(sigma.chaDauId(), oldTrackTable)); + + int64_t chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable, mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts); + + newSigmaTable.producedSigmas(newCollisionTable.producedCollision.lastIndex(), + sigma.signedPt(), + sigma.eta(), + sigma.phi(), + sigma.mass(), + chaDaughterIndex); + newSigmaTable.producedSigmaMasks(sigma.mask()); + mcBuilder.fillSigmaWithLabel(sigma, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts); + } + } + + template + void processSigmaPlusWithMc(T1 const& col, T2 const& /*sigmaPlusTable*/, T3 const& oldTrackTable, T4& partitionSigmaPlus, T5& trackBuilder, T6& cache, T7& newSigmaPlusTable, T8& newTrackTable, T9& newCollisionTable, + T10& mcBuilder, T11 const& mcCols, T12 const& mcParticles, T13 const& mcMothers, T14 const& mcPartonicMothers, T15& mcProducts) + { + if (mLimitSigmaPlus == 0) { + return; + } + + auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache); + + for (auto const& sigmaPlus : sigmaPlusSlice) { + auto chaDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(sigmaPlus.chaDauId(), oldTrackTable)); + + int64_t chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable, mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts); + + newSigmaPlusTable.producedSigmaPluses(newCollisionTable.producedCollision.lastIndex(), + sigmaPlus.signedPt(), + sigmaPlus.eta(), + sigmaPlus.phi(), + sigmaPlus.mass(), + chaDaughterIndex); + newSigmaPlusTable.producedSigmaPlusMasks(sigmaPlus.mask()); + mcBuilder.fillSigmaPlusWithLabel(sigmaPlus, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts); + } + } + private: int mLimitSigma = 0; int mLimitSigmaPlus = 0; diff --git a/PWGCF/Femto/Core/mcBuilder.h b/PWGCF/Femto/Core/mcBuilder.h index 4b9526d4ae9..8aa1da6d971 100644 --- a/PWGCF/Femto/Core/mcBuilder.h +++ b/PWGCF/Femto/Core/mcBuilder.h @@ -765,6 +765,8 @@ struct McBuilderDerivedToDerivedProducts : o2::framework::ProducesGroup { o2::framework::Produces producedCollisionLabels; o2::framework::Produces producedTrackLabels; + o2::framework::Produces producedSigmaLabels; + o2::framework::Produces producedSigmaPlusLabels; }; struct ConfMcTablesDerivedToDerived : o2::framework::ConfigurableGroup { @@ -824,6 +826,30 @@ class McBuilderDerivedToDerived this->getOrCreateMcParticleRow(mcParticle, mcCols, mcMothers, mcPartonicMothers, mcProducts)); } + template + void fillSigmaWithLabel(T1 const& sigma, T2 const& mcCols, T3 const& /*mcParticles*/, T4 const& mcMothers, T5 const& mcPartonicMothers, T6& mcProducts) + { + if (!sigma.has_fMcParticle()) { + mcProducts.producedSigmaLabels(-1); + return; + } + auto mcParticle = sigma.template fMcParticle_as(); + mcProducts.producedSigmaLabels( + this->getOrCreateMcParticleRow(mcParticle, mcCols, mcMothers, mcPartonicMothers, mcProducts)); + } + + template + void fillSigmaPlusWithLabel(T1 const& sigmaPlus, T2 const& mcCols, T3 const& /*mcParticles*/, T4 const& mcMothers, T5 const& mcPartonicMothers, T6& mcProducts) + { + if (!sigmaPlus.has_fMcParticle()) { + mcProducts.producedSigmaPlusLabels(-1); + return; + } + auto mcParticle = sigmaPlus.template fMcParticle_as(); + mcProducts.producedSigmaPlusLabels( + this->getOrCreateMcParticleRow(mcParticle, mcCols, mcMothers, mcPartonicMothers, mcProducts)); + } + template void reset(T1 const& mcCols, T2 const& mcParticles) { diff --git a/PWGCF/Femto/Core/trackBuilder.h b/PWGCF/Femto/Core/trackBuilder.h index e499cd26381..b38d031de05 100644 --- a/PWGCF/Femto/Core/trackBuilder.h +++ b/PWGCF/Femto/Core/trackBuilder.h @@ -984,6 +984,13 @@ class TrackBuilderDerivedToDerived return this->fillTrack(daughter, trackProducts, collisionProducts); } + template + int64_t getDaughterIndex(const T1& daughter, T2& trackProducts, T3& collisionProducts, + T4& mcBuilder, T5 const& mcCols, T6 const& mcParticles, T7 const& mcMothers, T8 const& mcPartonicMothers, T9& mcProducts) + { + return this->fillTrackWithMcLabel(daughter, trackProducts, collisionProducts, mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts); + } + template void reset(T const& tracks) { diff --git a/PWGCF/Femto/TableProducer/femtoProducerDerivedToDerived.cxx b/PWGCF/Femto/TableProducer/femtoProducerDerivedToDerived.cxx index 0168d308901..3ca85915f55 100644 --- a/PWGCF/Femto/TableProducer/femtoProducerDerivedToDerived.cxx +++ b/PWGCF/Femto/TableProducer/femtoProducerDerivedToDerived.cxx @@ -53,6 +53,8 @@ struct FemtoProducerDerivedToDerived { using FemtoSigmaPlus = o2::soa::Join; using FemtoMcTracks = o2::soa::Join; + using FemtoMcSigma = o2::soa::Join; + using FemtoMcSigmaPlus = o2::soa::Join; using FemtoMcParticles = o2::soa::Join; o2::framework::SliceCache cache; @@ -126,6 +128,12 @@ struct FemtoProducerDerivedToDerived { o2::framework::Partition mcTrackPartition2 = MAKE_TRACK_PARTITION(trackSelections2); o2::framework::Preslice perColMcTracks = o2::aod::femtobase::stored::fColId; + o2::framework::Partition mcSigmaPartition = MAKE_SIGMA_PARTITION(sigmaSelection1); + o2::framework::Preslice perColMcSigma = o2::aod::femtobase::stored::fColId; + + o2::framework::Partition mcSigmaPlusPartition = MAKE_SIGMAPLUS_PARTITION(sigmaPlusSelection1); + o2::framework::Preslice perColMcSigmaPlus = o2::aod::femtobase::stored::fColId; + void init(o2::framework::InitContext& /*context*/) { const int activeProcesses = @@ -135,7 +143,8 @@ struct FemtoProducerDerivedToDerived { static_cast(doprocessTracksXis) + static_cast(doprocessTracksOmegas) + static_cast(doprocessTracksK0shorts) + static_cast(doprocessTracksSigma) + static_cast(doprocessTracksSigmaPlus) + - static_cast(doprocessTracksMc); + static_cast(doprocessTracksMc) + static_cast(doprocessTracksSigmaMc) + + static_cast(doprocessTracksSigmaPlusMc); if (activeProcesses != 1) { LOG(fatal) << "Exactly one process function must be activated (got " << activeProcesses << ")."; } @@ -293,6 +302,58 @@ struct FemtoProducerDerivedToDerived { } } PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksMc, "Process tracks with MC information", false); + + void processTracksSigmaMc(FilteredFemtoMcCollisions const& cols, + FemtoMcTracks const& tracks, + FemtoMcSigma const& sigma, + o2::aod::FMcCols const& mcCols, + FemtoMcParticles const& mcParticles, + o2::aod::FMcMothers const& mcMothers, + o2::aod::FMcPartMoths const& mcPartonicMothers) + { + mcBuilder.reset(mcCols, mcParticles); + + for (auto const& col : cols) { + if (trackBuilder.collisionHasTooFewTracks(col, tracks, mcTrackPartition1, mcTrackPartition2, cache) || kinkBuilder.collisionHasTooFewSigma(col, sigma, mcSigmaPartition, cache)) { + continue; + } + trackBuilder.reset(tracks); + collisionBuilder.processCollision(col, collisionBuilderProducts); + mcBuilder.fillCollisionWithLabel(col, mcCols, mcBuilderProducts); + trackBuilder.processTracksWithMc(col, tracks, mcTrackPartition1, mcTrackPartition2, cache, + trackBuilderProducts, collisionBuilderProducts, + mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts); + kinkBuilder.processSigmaWithMc(col, sigma, tracks, mcSigmaPartition, trackBuilder, cache, kinkBuilderProducts, trackBuilderProducts, collisionBuilderProducts, + mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts); + } + } + PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksSigmaMc, "Process sigma and tracks with MC information", false); + + void processTracksSigmaPlusMc(FilteredFemtoMcCollisions const& cols, + FemtoMcTracks const& tracks, + FemtoMcSigmaPlus const& sigmaplus, + o2::aod::FMcCols const& mcCols, + FemtoMcParticles const& mcParticles, + o2::aod::FMcMothers const& mcMothers, + o2::aod::FMcPartMoths const& mcPartonicMothers) + { + mcBuilder.reset(mcCols, mcParticles); + + for (auto const& col : cols) { + if (trackBuilder.collisionHasTooFewTracks(col, tracks, mcTrackPartition1, mcTrackPartition2, cache) || kinkBuilder.collisionHasTooFewSigmaPlus(col, sigmaplus, mcSigmaPlusPartition, cache)) { + continue; + } + trackBuilder.reset(tracks); + collisionBuilder.processCollision(col, collisionBuilderProducts); + mcBuilder.fillCollisionWithLabel(col, mcCols, mcBuilderProducts); + trackBuilder.processTracksWithMc(col, tracks, mcTrackPartition1, mcTrackPartition2, cache, + trackBuilderProducts, collisionBuilderProducts, + mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts); + kinkBuilder.processSigmaPlusWithMc(col, sigmaplus, tracks, mcSigmaPlusPartition, trackBuilder, cache, kinkBuilderProducts, trackBuilderProducts, collisionBuilderProducts, + mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts); + } + } + PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksSigmaPlusMc, "Process sigmaPlus and tracks with MC information", false); }; o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& context)