@@ -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 ]) {
0 commit comments