Skip to content

Commit f382873

Browse files
committed
Feat: implement wrong collision association
1 parent 7b9b5cf commit f382873

15 files changed

Lines changed: 101 additions & 89 deletions

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/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/kinkHistManager.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,19 @@ class KinkHistManager
386386
}
387387
}
388388

389-
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5>
390-
void fill(T1 const& kinkCandidate, T2 const& tracks, T3 const& mcParticles, T4 const& mcMothers, T5 const& mcPartonicMothers)
389+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
390+
void fill(T1 const& kinkCandidate, T2 const& tracks, T3 const& col, T4 const& mcParticles, T5 const& mcMothers, T6 const& mcPartonicMothers)
391391
{
392392
auto chaDaughter = tracks.rawIteratorAt(kinkCandidate.chaDauId() - tracks.offset());
393-
mChaDauManager.template fill<mode>(chaDaughter, tracks, mcParticles, mcMothers, mcPartonicMothers);
393+
mChaDauManager.template fill<mode>(chaDaughter, tracks, col, mcParticles, mcMothers, mcPartonicMothers);
394394
if constexpr (modes::isFlagSet(mode, modes::Mode::kReco)) {
395395
this->fillAnalysis(kinkCandidate);
396396
}
397397
if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) {
398398
this->fillQa(kinkCandidate);
399399
}
400400
if constexpr (modes::isFlagSet(mode, modes::Mode::kMc)) {
401-
this->template fillMc<mode>(kinkCandidate, mcParticles, mcMothers, mcPartonicMothers);
401+
this->template fillMc<mode>(kinkCandidate, col, mcParticles, mcMothers, mcPartonicMothers);
402402
}
403403
}
404404

@@ -530,8 +530,8 @@ class KinkHistManager
530530
}
531531
}
532532

533-
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4>
534-
void fillMc(T1 const& kinkCandidate, T2 const& /*mcParticles*/, T3 const& /*mcMothers*/, T4 const& /*mcPartonicMothers*/)
533+
template <modes::Mode mode, typename T1, typename T2, typename T3, typename T4, typename T5>
534+
void fillMc(T1 const& kinkCandidate, T2 const& col, T3 const& /*mcParticles*/, T4 const& /*mcMothers*/, T5 const& /*mcPartonicMothers*/)
535535
{
536536
// No MC Particle
537537
if (!kinkCandidate.has_fMcParticle()) {
@@ -546,42 +546,47 @@ class KinkHistManager
546546
}
547547

548548
// Retrieve MC particle
549-
auto mcParticle = kinkCandidate.template fMcParticle_as<T2>();
549+
auto mcParticle = kinkCandidate.template fMcParticle_as<T3>();
550+
551+
// whether a particle is associated to a wrong collision or not cannot be known by the producer so we check it here
552+
bool fromWrongCollision = mcParticle.fMcColId() != col.fMcColId();
550553

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

555557
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kTruePt, HistTable)), mcParticle.pt());
556558
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kTrueEta, HistTable)), mcParticle.eta());
557559
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kTruePhi, HistTable)), mcParticle.phi());
558-
if (isMissidentified) {
559-
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast<int>(modes::McOrigin::kMissidentified));
560+
if (fromWrongCollision) {
561+
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast<float>(modes::McOrigin::kFromWrongCollision));
562+
} else if (isMissidentified) {
563+
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), static_cast<float>(modes::McOrigin::kMissidentified));
560564
} else {
561565
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kOrigin, HistTable)), mcParticle.origin());
562566
}
563567
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kPdg, HistTable)), mcParticle.pdgCode());
564568

565569
// get mother
566570
if (mcParticle.has_fMcMother()) {
567-
auto mother = mcParticle.template fMcMother_as<T3>();
571+
auto mother = mcParticle.template fMcMother_as<T4>();
568572
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kPdgMother, HistTable)), mother.pdgCode());
569573
} else {
570574
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kPdgMother, HistTable)), 0);
571575
}
572576

573577
// get partonic mother
574578
if (mcParticle.has_fMcPartMoth()) {
575-
auto partonicMother = mcParticle.template fMcPartMoth_as<T4>();
579+
auto partonicMother = mcParticle.template fMcPartMoth_as<T5>();
576580
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kPdgPartonicMother, HistTable)), partonicMother.pdgCode());
577581
} else {
578582
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kPdgPartonicMother, HistTable)), 0);
579583
}
580584

581585
if constexpr (modes::isFlagSet(mode, modes::Mode::kQa)) {
582586
if (mPlotOrigins) {
583-
// check first if particle is missidentified
584-
if (isMissidentified) {
587+
if (fromWrongCollision) {
588+
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kFromWrongCollision, HistTable)), kinkCandidate.pt(), kinkCandidate.kinkAngle());
589+
} else if (isMissidentified) {
585590
// if it is, we fill it as such
586591
mHistogramRegistry->fill(HIST(kinkPrefix) + HIST(McDir) + HIST(getHistName(kMissidentified, HistTable)), kinkCandidate.pt(), kinkCandidate.kinkAngle());
587592
} else {
@@ -598,7 +603,7 @@ class KinkHistManager
598603
break;
599604
case modes::McOrigin::kFromSecondaryDecay:
600605
if (mcParticle.has_fMcMother()) {
601-
auto mother = mcParticle.template fMcMother_as<T3>();
606+
auto mother = mcParticle.template fMcMother_as<T4>();
602607
int motherPdgCode = std::abs(mother.pdgCode());
603608
// Switch on PDG of the mother
604609
if (mPlotNSecondaries >= histmanager::kSecondaryPlotLevel1 && motherPdgCode == mPdgCodesSecondaryMother[0]) {

PWGCF/Femto/Core/mcBuilder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
#include <TMCProcess.h>
3333
#include <TPDGCode.h>
34-
#include <TParticlePDG.h>
3534

3635
#include <array>
3736
#include <cmath>
@@ -172,7 +171,7 @@ class McBuilder
172171
}
173172

174173
template <modes::System system, typename T1, typename T2, typename T3>
175-
void fillMcCollisionWithLabel(T1 const& col, T2 const& /*mcCols*/, T3& mcProducts )
174+
void fillMcCollisionWithLabel(T1 const& col, T2 const& /*mcCols*/, T3& mcProducts)
176175
{
177176
if (!mProduceCollisionLabels) {
178177
mcProducts.producedCollisionLabels(-1);

PWGCF/Femto/Core/modes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ enum class Particle : o2::analysis::femto::datatypes::ParticleType {
101101
};
102102

103103
enum class McOrigin : o2::analysis::femto::datatypes::McOriginType {
104-
kNoMcParticle = 0, // no associated mc particle normally indicated a wrongly reconstruced partilce
105-
kFromWrongCollision = 1, // partilce originates from the wrong collision or a collision which was wrongly reconstructed (like a split vertex)
104+
kNoMcParticle = 0, // no associated mc particle, normally indicated by wrongly reconstructed particle
105+
kFromWrongCollision = 1, // particle originates from the wrong collision or a collision which was wrongly reconstructed (like a split vertex)
106106
kPhysicalPrimary = 2, // primary particle
107107
kFromSecondaryDecay = 3, // particle from secondary decay
108-
kFromMaterial = 4, // partilce orginates from material
109-
kMissidentified = 5, // partilce was kMissidentified (also know as fake)
108+
kFromMaterial = 4, // particle originates from material
109+
kMissidentified = 5, // particle was kMissidentified (also know as fake)
110110
kPrompt = 6, // HF only: charm hadron produced promptly (from c quark)
111111
kNonPrompt = 7, // HF only: charm hadron from beauty decay
112112
kMcOriginLast = 8

PWGCF/Femto/Core/pairProcessHelpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void processSameEvent(T1 const& SliceParticle,
119119
if (!ParticleCleaner.isClean(part, mcParticles, mcMothers, mcPartonicMothers)) {
120120
continue;
121121
}
122-
ParticleHistManager.template fill<mode>(part, TrackTable, mcParticles, mcMothers, mcPartonicMothers);
122+
ParticleHistManager.template fill<mode>(part, TrackTable, Collision, mcParticles, mcMothers, mcPartonicMothers);
123123
}
124124
for (auto const& [p1, p2] : o2::soa::combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(SliceParticle, SliceParticle))) {
125125
// check if particles are clean
@@ -246,13 +246,13 @@ void processSameEvent(T1 const& SliceParticle1,
246246
if (!ParticleCleaner1.isClean(part, mcParticles, mcMothers, mcPartonicMothers)) {
247247
continue;
248248
}
249-
ParticleHistManager1.template fill<mode>(part, TrackTable, mcParticles, mcMothers, mcPartonicMothers);
249+
ParticleHistManager1.template fill<mode>(part, TrackTable, Collision, mcParticles, mcMothers, mcPartonicMothers);
250250
}
251251
for (auto const& part : SliceParticle2) {
252252
if (!ParticleCleaner2.isClean(part, mcParticles, mcMothers, mcPartonicMothers)) {
253253
continue;
254254
}
255-
ParticleHistManager2.template fill<mode>(part, TrackTable, mcParticles, mcMothers, mcPartonicMothers);
255+
ParticleHistManager2.template fill<mode>(part, TrackTable, Collision, mcParticles, mcMothers, mcPartonicMothers);
256256
}
257257
for (auto const& [p1, p2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(SliceParticle1, SliceParticle2))) {
258258
// check if particles are clean

0 commit comments

Comments
 (0)