Skip to content

Commit e6d8477

Browse files
authored
[PWGCF] Implement passThrough mode in femto producer for MC processing (#17321)
1 parent 482a8d6 commit e6d8477

23 files changed

Lines changed: 757 additions & 525 deletions

PWGCF/Femto/Core/baseSelection.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ class BaseSelection
165165
std::string const& selectionName,
166166
int mode)
167167
{
168+
int selectionMode = mode;
169+
168170
if (mPassThrough) {
169-
mSelectionContainers.at(observableIndex) = selectioncontainer::SelectionContainer<T, BitmaskType>(selectionName, std::vector<T>{1}, limits::LimitType::kEqual, false, false, false);
170-
return;
171+
selectionMode = 2;
171172
}
172-
173-
switch (mode) {
173+
switch (selectionMode) {
174174
case -1: // cut is optional and we store a bit for it
175175
mSelectionContainers.at(observableIndex) = selectioncontainer::SelectionContainer<T, BitmaskType>(selectionName, std::vector<T>{1}, limits::LimitType::kEqual, false, false, true);
176176
break;

PWGCF/Femto/Core/cascadeBuilder.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,20 +636,20 @@ class CascadeBuilder
636636
collisionBuilder.template fillMcCollision<system>(collisionProducts, col, mcCols, mcProducts, mcBuilder);
637637

638638
auto bachelor = cascade.template bachelor_as<T8>();
639-
bachelorIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCascadeBachelor>(col, collisionBuilder, mcCols, bachelor, trackProducts, mcParticles, mcBuilder, mcProducts);
639+
bachelorIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCascadeBachelor>(bachelor, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
640640

641641
auto posDaughter = cascade.template posTrack_as<T8>();
642-
posDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kV0Daughter>(col, collisionBuilder, mcCols, posDaughter, trackProducts, mcParticles, mcBuilder, mcProducts);
642+
posDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kV0Daughter>(posDaughter, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
643643

644644
auto negDaughter = cascade.template negTrack_as<T8>();
645-
negDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kV0Daughter>(col, collisionBuilder, mcCols, negDaughter, trackProducts, mcParticles, mcBuilder, mcProducts);
645+
negDaughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kV0Daughter>(negDaughter, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
646646

647647
fillCascade(collisionBuilder, cascadeProducts, cascade, col, bachelorIndex, posDaughterIndex, negDaughterIndex);
648648
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kXi)) {
649-
mcBuilder.template fillMcXiWithLabel<system>(col, mcCols, cascade, mcParticles, mcProducts);
649+
mcBuilder.template fillMcXiWithLabel<system>(cascade, mcParticles, mcCols, mcProducts);
650650
}
651651
if constexpr (modes::isEqual(cascadeType, modes::Cascade::kOmega)) {
652-
mcBuilder.template fillMcOmegaWithLabel<system>(col, mcCols, cascade, mcParticles, mcProducts);
652+
mcBuilder.template fillMcOmegaWithLabel<system>(cascade, mcParticles, mcCols, mcProducts);
653653
}
654654
}
655655
}
@@ -733,7 +733,8 @@ class CascadeBuilder
733733
}
734734
}
735735

736-
bool fillAnyTable() { return mFillAnyTable; }
736+
[[nodiscard]] bool fillAnyTable() const { return mFillAnyTable; }
737+
[[nodiscard]] bool isPassThrough() const { return mCascadeSelection.isPassThrough(); }
737738

738739
private:
739740
CascadeSelection<cascadeType, SelectionHistName, FilterHistName> mCascadeSelection;

PWGCF/Femto/Core/cascadeHistManager.h

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,15 @@ class CascadeHistManager
435435
}
436436
}
437437

438-
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5>
439-
void fill(T1 const& cascadeCandidate, T2 const& tracks, T3 const& mcParticles, T4 const& mcMothers, T5 const& mcPartonicMothers)
438+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
439+
void fill(T1 const& cascadeCandidate, T2 const& tracks, T3 const& col, T4 const& mcParticles, T5 const& mcMothers, T6 const& mcPartonicMothers)
440440
{
441441
auto posDaughter = tracks.rawIteratorAt(cascadeCandidate.posDauId() - tracks.offset());
442-
mPosDauManager.template fill<mode>(posDaughter, tracks, mcParticles, mcMothers, mcPartonicMothers);
442+
mPosDauManager.template fill<mode>(posDaughter, tracks, col, mcParticles, mcMothers, mcPartonicMothers);
443443
auto negDaughter = tracks.rawIteratorAt(cascadeCandidate.negDauId() - tracks.offset());
444-
mNegDauManager.template fill<mode>(negDaughter, tracks, mcParticles, mcMothers, mcPartonicMothers);
444+
mNegDauManager.template fill<mode>(negDaughter, tracks, col, mcParticles, mcMothers, mcPartonicMothers);
445445
auto bachelor = tracks.rawIteratorAt(cascadeCandidate.bachelorId() - tracks.offset());
446-
mBachelorManager.template fill<mode>(bachelor, tracks, mcParticles, mcMothers, mcPartonicMothers);
446+
mBachelorManager.template fill<mode>(bachelor, tracks, col, mcParticles, mcMothers, mcPartonicMothers);
447447

448448
if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) {
449449
this->fillAnalysis(cascadeCandidate);
@@ -452,7 +452,7 @@ class CascadeHistManager
452452
this->fillQa(cascadeCandidate);
453453
}
454454
if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) {
455-
this->template fillMc<mode>(cascadeCandidate, mcParticles, mcMothers, mcPartonicMothers);
455+
this->template fillMc<mode>(cascadeCandidate, col, mcParticles, mcMothers, mcPartonicMothers);
456456
}
457457
}
458458

@@ -598,8 +598,8 @@ class CascadeHistManager
598598
}
599599
}
600600

601-
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4>
602-
void fillMc(T1 const& cascadeCandidate, T2 const& /*mcParticles*/, T3 const& /*mcMothers*/, T4 const& /*mcPartonicMothers*/)
601+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5>
602+
void fillMc(T1 const& cascadeCandidate, T2 const& col, T3 const& /*mcParticles*/, T4 const& /*mcMothers*/, T5 const& /*mcPartonicMothers*/)
603603
{
604604
// No MC Particle
605605
if (!cascadeCandidate.has_fMcParticle()) {
@@ -614,42 +614,47 @@ class CascadeHistManager
614614
}
615615

616616
// Retrieve MC particle
617-
auto mcParticle = cascadeCandidate.template fMcParticle_as<T2>();
617+
auto mcParticle = cascadeCandidate.template fMcParticle_as<T3>();
618+
619+
// whether a particle is associated to a wrong collision or not cannot be known by the producer so we check it here
620+
bool fromWrongCollision = mcParticle.fMcColId() != col.fMcColId();
618621

619-
// missidentifed particles are special case
620622
// whether a particle is missidentfied or not cannot be known by the producer so we check it here
621623
bool isMissidentified = mcParticle.pdgCode() != mPdgCode;
622624

623625
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kTruePtVsPt, HistTable)), mcParticle.pt(), cascadeCandidate.pt());
624626
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kTrueEtaVsEta, HistTable)), mcParticle.eta(), cascadeCandidate.eta());
625627
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kTruePhiVsPhi, HistTable)), mcParticle.phi(), cascadeCandidate.phi());
626-
if (isMissidentified) {
627-
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast<int>(modes::McOrigin::kMissidentified));
628+
if (fromWrongCollision) {
629+
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast<float>(modes::McOrigin::kFromWrongCollision));
630+
} else if (isMissidentified) {
631+
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast<float>(modes::McOrigin::kMissidentified));
628632
} else {
629633
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), mcParticle.origin());
630634
}
631635
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kPdg, HistTable)), mcParticle.pdgCode());
632636

633637
// get mother
634638
if (mcParticle.has_fMcMother()) {
635-
auto mother = mcParticle.template fMcMother_as<T3>();
639+
auto mother = mcParticle.template fMcMother_as<T4>();
636640
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kPdgMother, HistTable)), mother.pdgCode());
637641
} else {
638642
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kPdgMother, HistTable)), 0);
639643
}
640644

641645
// get partonic mother
642646
if (mcParticle.has_fMcPartMoth()) {
643-
auto partonicMother = mcParticle.template fMcPartMoth_as<T4>();
647+
auto partonicMother = mcParticle.template fMcPartMoth_as<T5>();
644648
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kPdgPartonicMother, HistTable)), partonicMother.pdgCode());
645649
} else {
646650
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kPdgPartonicMother, HistTable)), 0);
647651
}
648652

649653
if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) {
650654
if (mPlotOrigins) {
651-
// check first if particle is missidentified
652-
if (isMissidentified) {
655+
if (fromWrongCollision) {
656+
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kFromWrongCollision, HistTable)), cascadeCandidate.pt(), cascadeCandidate.cascadeCosPa());
657+
} else if (isMissidentified) {
653658
// if it is, we fill it as such
654659
mHistogramRegistry->fill(HIST(cascadePrefix) + HIST(McDir) + HIST(getHistName(kMissidentified, HistTable)), cascadeCandidate.pt(), cascadeCandidate.cascadeCosPa());
655660
} else {
@@ -666,7 +671,7 @@ class CascadeHistManager
666671
break;
667672
case modes::McOrigin::kFromSecondaryDecay:
668673
if (mcParticle.has_fMcMother()) {
669-
auto mother = mcParticle.template fMcMother_as<T3>();
674+
auto mother = mcParticle.template fMcMother_as<T4>();
670675
int motherPdgCode = std::abs(mother.pdgCode());
671676
// Switch on PDG of the mother
672677
if (mPlotNSecondaries >= histmanager::kSecondaryPlotLevel1 && motherPdgCode == mPdgCodesSecondaryMother[0]) {

PWGCF/Femto/Core/charmHadronBuilder.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,18 +442,21 @@ class CharmHadronBuilder
442442

443443
auto prong0 = candidate.template prong0_as<T8>();
444444
auto prong1 = candidate.template prong1_as<T8>();
445-
posDauIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCharmDaughter>(col, collisionBuilder, mcCols, prong0, trackProducts, mcParticles, mcBuilder, mcProducts);
446-
negDauIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCharmDaughter>(col, collisionBuilder, mcCols, prong1, trackProducts, mcParticles, mcBuilder, mcProducts);
445+
posDauIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCharmDaughter>(prong0, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
446+
negDauIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kCharmDaughter>(prong1, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
447447

448448
if constexpr (modes::isEqual(hadronType, modes::CharmHadron::kD0)) {
449449
this->fillD0Tables(collisionProducts, d0Products, candidate, candidate.pt(), mHfHelper.invMassD0ToPiK(candidate), posDauIndex, negDauIndex);
450450
} else {
451451
this->fillD0Tables(collisionProducts, d0Products, candidate, -candidate.pt(), mHfHelper.invMassD0barToKPi(candidate), posDauIndex, negDauIndex);
452452
}
453-
mcBuilder.template fillMcD0WithLabel<system>(col, mcCols, candidate, tracks, mcParticles, mcProducts);
453+
mcBuilder.template fillMcD0WithLabel<system>(candidate, tracks, mcParticles, mcCols, mcProducts);
454454
}
455455
}
456456

457+
[[nodiscard]] bool fillAnyTable() const { return mFillAnyTable; }
458+
[[nodiscard]] bool isPassThrough() const { return mD0Selection.isPassThrough(); }
459+
457460
private:
458461
D0Selection<hadronType, SelectionHistName, FilterHistName> mD0Selection;
459462
HfHelper mHfHelper;

PWGCF/Femto/Core/charmHadronHistManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,13 @@ class CharmHadronHistManager
308308
}
309309
}
310310

311-
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5>
312-
void fill(T1 const& charmHadronCandidate, T2 const& tracks, T3 const& mcParticles, T4 const& mcMothers, T5 const& mcPartonicMothers)
311+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
312+
void fill(T1 const& charmHadronCandidate, T2 const& tracks, T3 const& col, T4 const& mcParticles, T5 const& mcMothers, T6 const& mcPartonicMothers)
313313
{
314314
auto prong0 = tracks.rawIteratorAt(charmHadronCandidate.posDauId() - tracks.offset());
315-
mProng0Manager.template fill<mode>(prong0, tracks, mcParticles, mcMothers, mcPartonicMothers);
315+
mProng0Manager.template fill<mode>(prong0, tracks, col, mcParticles, mcMothers, mcPartonicMothers);
316316
auto prong1 = tracks.rawIteratorAt(charmHadronCandidate.negDauId() - tracks.offset());
317-
mProng1Manager.template fill<mode>(prong1, tracks, mcParticles, mcMothers, mcPartonicMothers);
317+
mProng1Manager.template fill<mode>(prong1, tracks, col, mcParticles, mcMothers, mcPartonicMothers);
318318

319319
if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) {
320320
this->fillAnalysis(charmHadronCandidate);

PWGCF/Femto/Core/collisionBuilder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ class CollisionBuilder
694694
return;
695695
}
696696
this->template fillCollision<system>(collisionProducts, col);
697-
mcBuilder.template fillMcCollisionWithLabel<system>(mcProducts, col, mcCols);
697+
mcBuilder.template fillMcCollisionWithLabel<system>(col, mcCols, mcProducts);
698698
}
699699

700700
[[nodiscard]] int64_t collisionIndex() const { return mCurrentCollisionIndex; }
@@ -704,6 +704,8 @@ class CollisionBuilder
704704
mCurrentCollisionIndex = -1;
705705
}
706706

707+
[[nodiscard]] bool fillAnyTable() const { return mFillAnyTable; }
708+
[[nodiscard]] bool isPassThrough() const { return mCollisionSelection.isPassThrough(); }
707709
[[nodiscard]] bool producingCollisions() const { return mProducedCollisions; }
708710
[[nodiscard]] bool producingLiteCollisions() const { return mProducedLiteCollisions; }
709711

PWGCF/Femto/Core/kinkBuilder.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,15 @@ class KinkBuilder
619619
collisionBuilder.template fillMcCollision<system>(collisionProducts, col, mcCols, mcProducts, mcBuilder);
620620

621621
auto daughter = kink.template trackDaug_as<T8>();
622-
daughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kKinkDaughter>(col, collisionBuilder, mcCols, daughter, trackProducts, mcParticles, mcBuilder, mcProducts);
622+
daughterIndex = trackBuilder.template getDaughterIndex<system, modes::Track::kKinkDaughter>(daughter, trackProducts, mcCols, collisionBuilder, mcParticles, mcBuilder, mcProducts);
623623

624624
if constexpr (modes::isEqual(kinkType, modes::Kink::kSigma)) {
625625
fillSigma(collisionBuilder, kinkProducts, kink, daughterIndex);
626-
mcBuilder.template fillMcSigmaWithLabel<system>(col, mcCols, daughter, mcParticles, mcProducts);
626+
mcBuilder.template fillMcSigmaWithLabel<system>(daughter, mcParticles, mcCols, mcProducts);
627627
}
628628
if constexpr (modes::isEqual(kinkType, modes::Kink::kSigmaPlus)) {
629629
fillSigmaPlus(collisionBuilder, kinkProducts, kink, daughterIndex);
630-
mcBuilder.template fillMcSigmaPlusWithLabel<system>(col, mcCols, daughter, mcParticles, mcProducts);
630+
mcBuilder.template fillMcSigmaPlusWithLabel<system>(daughter, mcParticles, mcCols, mcProducts);
631631
}
632632
}
633633
}
@@ -707,7 +707,8 @@ class KinkBuilder
707707
}
708708
}
709709

710-
bool fillAnyTable() { return mFillAnyTable; }
710+
[[nodiscard]] bool fillAnyTable() const { return mFillAnyTable; }
711+
[[nodiscard]] bool isPassThrough() const { return mKinkSelection.isPassThrough(); }
711712

712713
private:
713714
KinkSelection<kinkType, SelectionHistName, FilterHistName> mKinkSelection;

0 commit comments

Comments
 (0)