Skip to content

Commit 6b68792

Browse files
hfribertHenrik Fribert
andauthored
[PWGCF] Femto: Add MC derived-to-derived processing for Sigmas (#18315)
Co-authored-by: Henrik Fribert <ge35huh@nidoqueen.ktas.ph.tum.de>
1 parent d0dc689 commit 6b68792

4 files changed

Lines changed: 147 additions & 1 deletion

File tree

‎PWGCF/Femto/Core/kinkBuilder.h‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,58 @@ class KinkBuilderDerivedToDerived
846846
}
847847
}
848848

849+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15>
850+
void processSigmaWithMc(T1 const& col, T2 const& /*sigmaTable*/, T3 const& oldTrackTable, T4& partitionSigma, T5& trackBuilder, T6& cache, T7& newSigmaTable, T8& newTrackTable, T9& newCollisionTable,
851+
T10& mcBuilder, T11 const& mcCols, T12 const& mcParticles, T13 const& mcMothers, T14 const& mcPartonicMothers, T15& mcProducts)
852+
{
853+
if (mLimitSigma == 0) {
854+
return;
855+
}
856+
857+
auto sigmaSlice = partitionSigma->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
858+
859+
for (auto const& sigma : sigmaSlice) {
860+
auto chaDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(sigma.chaDauId(), oldTrackTable));
861+
862+
int64_t chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable, mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts);
863+
864+
newSigmaTable.producedSigmas(newCollisionTable.producedCollision.lastIndex(),
865+
sigma.signedPt(),
866+
sigma.eta(),
867+
sigma.phi(),
868+
sigma.mass(),
869+
chaDaughterIndex);
870+
newSigmaTable.producedSigmaMasks(sigma.mask());
871+
mcBuilder.fillSigmaWithLabel(sigma, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts);
872+
}
873+
}
874+
875+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15>
876+
void processSigmaPlusWithMc(T1 const& col, T2 const& /*sigmaPlusTable*/, T3 const& oldTrackTable, T4& partitionSigmaPlus, T5& trackBuilder, T6& cache, T7& newSigmaPlusTable, T8& newTrackTable, T9& newCollisionTable,
877+
T10& mcBuilder, T11 const& mcCols, T12 const& mcParticles, T13 const& mcMothers, T14 const& mcPartonicMothers, T15& mcProducts)
878+
{
879+
if (mLimitSigmaPlus == 0) {
880+
return;
881+
}
882+
883+
auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
884+
885+
for (auto const& sigmaPlus : sigmaPlusSlice) {
886+
auto chaDaughter = oldTrackTable.rawIteratorAt(utils::daughterRow(sigmaPlus.chaDauId(), oldTrackTable));
887+
888+
int64_t chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable, mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts);
889+
890+
newSigmaPlusTable.producedSigmaPluses(newCollisionTable.producedCollision.lastIndex(),
891+
sigmaPlus.signedPt(),
892+
sigmaPlus.eta(),
893+
sigmaPlus.phi(),
894+
sigmaPlus.mass(),
895+
chaDaughterIndex);
896+
newSigmaPlusTable.producedSigmaPlusMasks(sigmaPlus.mask());
897+
mcBuilder.fillSigmaPlusWithLabel(sigmaPlus, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts);
898+
}
899+
}
900+
849901
private:
850902
int mLimitSigma = 0;
851903
int mLimitSigmaPlus = 0;

‎PWGCF/Femto/Core/mcBuilder.h‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ struct McBuilderDerivedToDerivedProducts : o2::framework::ProducesGroup {
765765

766766
o2::framework::Produces<o2::aod::StoredFColLabels> producedCollisionLabels;
767767
o2::framework::Produces<o2::aod::StoredFTrackLabels> producedTrackLabels;
768+
o2::framework::Produces<o2::aod::StoredFSigmaLabels> producedSigmaLabels;
769+
o2::framework::Produces<o2::aod::StoredFSigmaPlusLabels> producedSigmaPlusLabels;
768770
};
769771

770772
struct ConfMcTablesDerivedToDerived : o2::framework::ConfigurableGroup {
@@ -824,6 +826,30 @@ class McBuilderDerivedToDerived
824826
this->getOrCreateMcParticleRow(mcParticle, mcCols, mcMothers, mcPartonicMothers, mcProducts));
825827
}
826828

829+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
830+
void fillSigmaWithLabel(T1 const& sigma, T2 const& mcCols, T3 const& /*mcParticles*/, T4 const& mcMothers, T5 const& mcPartonicMothers, T6& mcProducts)
831+
{
832+
if (!sigma.has_fMcParticle()) {
833+
mcProducts.producedSigmaLabels(-1);
834+
return;
835+
}
836+
auto mcParticle = sigma.template fMcParticle_as<T3>();
837+
mcProducts.producedSigmaLabels(
838+
this->getOrCreateMcParticleRow(mcParticle, mcCols, mcMothers, mcPartonicMothers, mcProducts));
839+
}
840+
841+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
842+
void fillSigmaPlusWithLabel(T1 const& sigmaPlus, T2 const& mcCols, T3 const& /*mcParticles*/, T4 const& mcMothers, T5 const& mcPartonicMothers, T6& mcProducts)
843+
{
844+
if (!sigmaPlus.has_fMcParticle()) {
845+
mcProducts.producedSigmaPlusLabels(-1);
846+
return;
847+
}
848+
auto mcParticle = sigmaPlus.template fMcParticle_as<T3>();
849+
mcProducts.producedSigmaPlusLabels(
850+
this->getOrCreateMcParticleRow(mcParticle, mcCols, mcMothers, mcPartonicMothers, mcProducts));
851+
}
852+
827853
template <typename T1, typename T2>
828854
void reset(T1 const& mcCols, T2 const& mcParticles)
829855
{

‎PWGCF/Femto/Core/trackBuilder.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,13 @@ class TrackBuilderDerivedToDerived
998998
return this->fillTrack(daughter, trackProducts, collisionProducts);
999999
}
10001000

1001+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
1002+
int64_t getDaughterIndex(const T1& daughter, T2& trackProducts, T3& collisionProducts,
1003+
T4& mcBuilder, T5 const& mcCols, T6 const& mcParticles, T7 const& mcMothers, T8 const& mcPartonicMothers, T9& mcProducts)
1004+
{
1005+
return this->fillTrackWithMcLabel(daughter, trackProducts, collisionProducts, mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcProducts);
1006+
}
1007+
10011008
template <typename T>
10021009
void reset(T const& tracks)
10031010
{

‎PWGCF/Femto/TableProducer/femtoProducerDerivedToDerived.cxx‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ struct FemtoProducerDerivedToDerived {
5353
using FemtoSigmaPlus = o2::soa::Join<o2::aod::FSigmaPlus, o2::aod::FSigmaPlusMasks>;
5454

5555
using FemtoMcTracks = o2::soa::Join<FemtoTracks, o2::aod::FTrackLabels>;
56+
using FemtoMcSigma = o2::soa::Join<FemtoSigma, o2::aod::FSigmaLabels>;
57+
using FemtoMcSigmaPlus = o2::soa::Join<FemtoSigmaPlus, o2::aod::FSigmaPlusLabels>;
5658
using FemtoMcParticles = o2::soa::Join<o2::aod::FMcParticles, o2::aod::FMcMotherLabels>;
5759

5860
o2::framework::SliceCache cache;
@@ -126,6 +128,12 @@ struct FemtoProducerDerivedToDerived {
126128
o2::framework::Partition<FemtoMcTracks> mcTrackPartition2 = MAKE_TRACK_PARTITION(trackSelections2);
127129
o2::framework::Preslice<FemtoMcTracks> perColMcTracks = o2::aod::femtobase::stored::fColId;
128130

131+
o2::framework::Partition<FemtoMcSigma> mcSigmaPartition = MAKE_SIGMA_PARTITION(sigmaSelection1);
132+
o2::framework::Preslice<FemtoMcSigma> perColMcSigma = o2::aod::femtobase::stored::fColId;
133+
134+
o2::framework::Partition<FemtoMcSigmaPlus> mcSigmaPlusPartition = MAKE_SIGMAPLUS_PARTITION(sigmaPlusSelection1);
135+
o2::framework::Preslice<FemtoMcSigmaPlus> perColMcSigmaPlus = o2::aod::femtobase::stored::fColId;
136+
129137
void init(o2::framework::InitContext& /*context*/)
130138
{
131139
const int activeProcesses =
@@ -135,7 +143,8 @@ struct FemtoProducerDerivedToDerived {
135143
static_cast<int>(doprocessTracksXis) + static_cast<int>(doprocessTracksOmegas) +
136144
static_cast<int>(doprocessTracksK0shorts) + static_cast<int>(doprocessTracksSigma) +
137145
static_cast<int>(doprocessTracksSigmaPlus) +
138-
static_cast<int>(doprocessTracksMc);
146+
static_cast<int>(doprocessTracksMc) + static_cast<int>(doprocessTracksSigmaMc) +
147+
static_cast<int>(doprocessTracksSigmaPlusMc);
139148
if (activeProcesses != 1) {
140149
LOG(fatal) << "Exactly one process function must be activated (got " << activeProcesses << ").";
141150
}
@@ -293,6 +302,58 @@ struct FemtoProducerDerivedToDerived {
293302
}
294303
}
295304
PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksMc, "Process tracks with MC information", false);
305+
306+
void processTracksSigmaMc(FilteredFemtoMcCollisions const& cols,
307+
FemtoMcTracks const& tracks,
308+
FemtoMcSigma const& sigma,
309+
o2::aod::FMcCols const& mcCols,
310+
FemtoMcParticles const& mcParticles,
311+
o2::aod::FMcMothers const& mcMothers,
312+
o2::aod::FMcPartMoths const& mcPartonicMothers)
313+
{
314+
mcBuilder.reset(mcCols, mcParticles);
315+
316+
for (auto const& col : cols) {
317+
if (trackBuilder.collisionHasTooFewTracks(col, tracks, mcTrackPartition1, mcTrackPartition2, cache) || kinkBuilder.collisionHasTooFewSigma(col, sigma, mcSigmaPartition, cache)) {
318+
continue;
319+
}
320+
trackBuilder.reset(tracks);
321+
collisionBuilder.processCollision(col, collisionBuilderProducts);
322+
mcBuilder.fillCollisionWithLabel(col, mcCols, mcBuilderProducts);
323+
trackBuilder.processTracksWithMc(col, tracks, mcTrackPartition1, mcTrackPartition2, cache,
324+
trackBuilderProducts, collisionBuilderProducts,
325+
mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts);
326+
kinkBuilder.processSigmaWithMc(col, sigma, tracks, mcSigmaPartition, trackBuilder, cache, kinkBuilderProducts, trackBuilderProducts, collisionBuilderProducts,
327+
mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts);
328+
}
329+
}
330+
PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksSigmaMc, "Process sigma and tracks with MC information", false);
331+
332+
void processTracksSigmaPlusMc(FilteredFemtoMcCollisions const& cols,
333+
FemtoMcTracks const& tracks,
334+
FemtoMcSigmaPlus const& sigmaplus,
335+
o2::aod::FMcCols const& mcCols,
336+
FemtoMcParticles const& mcParticles,
337+
o2::aod::FMcMothers const& mcMothers,
338+
o2::aod::FMcPartMoths const& mcPartonicMothers)
339+
{
340+
mcBuilder.reset(mcCols, mcParticles);
341+
342+
for (auto const& col : cols) {
343+
if (trackBuilder.collisionHasTooFewTracks(col, tracks, mcTrackPartition1, mcTrackPartition2, cache) || kinkBuilder.collisionHasTooFewSigmaPlus(col, sigmaplus, mcSigmaPlusPartition, cache)) {
344+
continue;
345+
}
346+
trackBuilder.reset(tracks);
347+
collisionBuilder.processCollision(col, collisionBuilderProducts);
348+
mcBuilder.fillCollisionWithLabel(col, mcCols, mcBuilderProducts);
349+
trackBuilder.processTracksWithMc(col, tracks, mcTrackPartition1, mcTrackPartition2, cache,
350+
trackBuilderProducts, collisionBuilderProducts,
351+
mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts);
352+
kinkBuilder.processSigmaPlusWithMc(col, sigmaplus, tracks, mcSigmaPlusPartition, trackBuilder, cache, kinkBuilderProducts, trackBuilderProducts, collisionBuilderProducts,
353+
mcBuilder, mcCols, mcParticles, mcMothers, mcPartonicMothers, mcBuilderProducts);
354+
}
355+
}
356+
PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksSigmaPlusMc, "Process sigmaPlus and tracks with MC information", false);
296357
};
297358

298359
o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& context)

0 commit comments

Comments
 (0)