@@ -471,6 +471,7 @@ struct HfCandidateCreator3ProngExpressions {
471471 PresliceUnsorted<McCollisionsNoCents> colPerMcCollision = aod::mccollisionlabel::mcCollisionId;
472472 PresliceUnsorted<McCollisionsFT0Cs> colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId;
473473 PresliceUnsorted<McCollisionsFT0Ms> colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId;
474+ Preslice<aod::McParticles> mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId;
474475
475476 void init (InitContext& initContext)
476477 {
@@ -513,7 +514,7 @@ struct HfCandidateCreator3ProngExpressions {
513514 void runCreator3ProngMc (aod::TracksWMc const & tracks,
514515 aod::McParticles const & mcParticles,
515516 CCs const & collInfos,
516- aod::McCollisions const &,
517+ aod::McCollisions const & mcCollisions ,
517518 BCsInfo const &)
518519 {
519520 rowCandidateProng3->bindExternalIndices (&tracks);
@@ -647,21 +648,11 @@ struct HfCandidateCreator3ProngExpressions {
647648 }
648649 }
649650
650- // Match generated particles.
651- for (const auto & particle : mcParticles) {
652- flag = 0 ;
653- origin = 0 ;
654- channel = 0 ;
655- arrDaughIndex.clear ();
656- std::vector<int > idxBhadMothers{};
657- // Reject particles from background events
658- if (particle.fromBackgroundEvent () && rejectBackground) {
659- rowMcMatchGen (flag, origin, channel, -1 );
660- continue ;
661- }
651+ for (const auto & mcCollision : mcCollisions) {
662652
653+ // Slice the particles table to get the particles for the current MC collision
654+ const auto mcParticlesPerMcColl = mcParticles.sliceBy (mcParticlesPerMcCollision, mcCollision.globalIndex ());
663655 // Slice the collisions table to get the collision info for the current MC collision
664- auto mcCollision = particle.mcCollision ();
665656 float centrality{-1 .f };
666657 uint16_t rejectionMask{0 };
667658 if constexpr (centEstimator == CentralityEstimator::FT0C) {
@@ -676,85 +667,101 @@ struct HfCandidateCreator3ProngExpressions {
676667 }
677668 hfEvSelMc.fillHistograms (rejectionMask);
678669 if (rejectionMask != 0 ) {
679- // / at least one event selection not satisfied --> reject the gen particle
680- rowMcMatchGen (flag, origin, channel, -1 );
670+ // at least one event selection not satisfied --> reject all gen particles from this collision
671+ for (unsigned int i = 0 ; i < mcParticlesPerMcColl.size (); ++i) {
672+ rowMcMatchGen (0 , 0 , 0 , -1 );
673+ }
681674 continue ;
682675 }
683676
684- // D± → π± K∓ π±
685- if (createDplus) {
686- if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kDPlus , std::array{+kPiPlus , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
687- flag = sign * (1 << DecayType::DplusToPiKPi);
677+ // Match generated particles.
678+ for (const auto & particle : mcParticlesPerMcColl) {
679+ flag = 0 ;
680+ origin = 0 ;
681+ channel = 0 ;
682+ arrDaughIndex.clear ();
683+ std::vector<int > idxBhadMothers{};
684+ // Reject particles from background events
685+ if (particle.fromBackgroundEvent () && rejectBackground) {
686+ rowMcMatchGen (flag, origin, channel, -1 );
687+ continue ;
688688 }
689- }
690689
691- // Ds± → K± K∓ π± and D± → K± K∓ π±
692- if (flag == 0 && createDs) {
693- bool isDplus = false ;
694- if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kDS , std::array{+kKPlus , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
695- // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
696- // TODO: move to different and explicit flags
697- flag = sign * (1 << DecayType::DsToKKPi);
698- } else if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kDPlus , std::array{+kKPlus , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
699- // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
700- // TODO: move to different and explicit flags
701- flag = sign * (1 << DecayType::DsToKKPi);
702- isDplus = true ;
690+ // D± → π± K∓ π±
691+ if (createDplus) {
692+ if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kDPlus , std::array{+kPiPlus , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
693+ flag = sign * (1 << DecayType::DplusToPiKPi);
694+ }
703695 }
704- if (flag != 0 ) {
705- RecoDecay::getDaughters (particle, &arrDaughIndex, std::array{0 }, 1 );
706- if (arrDaughIndex.size () == 2 ) {
707- for (auto jProng = 0u ; jProng < arrDaughIndex.size (); ++jProng) {
708- auto daughJ = mcParticles.rawIteratorAt (arrDaughIndex[jProng]);
709- arrPDGDaugh[jProng] = std::abs (daughJ.pdgCode ());
710- }
711- if ((arrPDGDaugh[0 ] == arrPDGResonantDPhiPi[0 ] && arrPDGDaugh[1 ] == arrPDGResonantDPhiPi[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonantDPhiPi[1 ] && arrPDGDaugh[1 ] == arrPDGResonantDPhiPi[0 ])) {
712- channel = isDplus ? DecayChannelDToKKPi::DplusToPhiPi : DecayChannelDToKKPi::DsToPhiPi;
713- } else if ((arrPDGDaugh[0 ] == arrPDGResonantDKstarK[0 ] && arrPDGDaugh[1 ] == arrPDGResonantDKstarK[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonantDKstarK[1 ] && arrPDGDaugh[1 ] == arrPDGResonantDKstarK[0 ])) {
714- channel = isDplus ? DecayChannelDToKKPi::DplusToK0starK : DecayChannelDToKKPi::DsToK0starK;
696+
697+ // Ds± → K± K∓ π± and D± → K± K∓ π±
698+ if (flag == 0 && createDs) {
699+ bool isDplus = false ;
700+ if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kDS , std::array{+kKPlus , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
701+ // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
702+ // TODO: move to different and explicit flags
703+ flag = sign * (1 << DecayType::DsToKKPi);
704+ } else if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kDPlus , std::array{+kKPlus , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
705+ // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
706+ // TODO: move to different and explicit flags
707+ flag = sign * (1 << DecayType::DsToKKPi);
708+ isDplus = true ;
709+ }
710+ if (flag != 0 ) {
711+ RecoDecay::getDaughters (particle, &arrDaughIndex, std::array{0 }, 1 );
712+ if (arrDaughIndex.size () == 2 ) {
713+ for (auto jProng = 0u ; jProng < arrDaughIndex.size (); ++jProng) {
714+ auto daughJ = mcParticles.rawIteratorAt (arrDaughIndex[jProng]);
715+ arrPDGDaugh[jProng] = std::abs (daughJ.pdgCode ());
716+ }
717+ if ((arrPDGDaugh[0 ] == arrPDGResonantDPhiPi[0 ] && arrPDGDaugh[1 ] == arrPDGResonantDPhiPi[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonantDPhiPi[1 ] && arrPDGDaugh[1 ] == arrPDGResonantDPhiPi[0 ])) {
718+ channel = isDplus ? DecayChannelDToKKPi::DplusToPhiPi : DecayChannelDToKKPi::DsToPhiPi;
719+ } else if ((arrPDGDaugh[0 ] == arrPDGResonantDKstarK[0 ] && arrPDGDaugh[1 ] == arrPDGResonantDKstarK[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonantDKstarK[1 ] && arrPDGDaugh[1 ] == arrPDGResonantDKstarK[0 ])) {
720+ channel = isDplus ? DecayChannelDToKKPi::DplusToK0starK : DecayChannelDToKKPi::DsToK0starK;
721+ }
715722 }
716723 }
717724 }
718- }
719-
720- // Λc± → p± K∓ π±
721- if (flag == 0 && createLc) {
722- if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kLambdaCPlus , std::array{+kProton , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
723- flag = sign * (1 << DecayType::LcToPKPi);
724725
725- // Flagging the different Λc± → p± K∓ π± decay channels
726- RecoDecay::getDaughters (particle, &arrDaughIndex, std::array{0 }, 1 );
727- if (arrDaughIndex.size () == 2 ) {
728- for (auto jProng = 0u ; jProng < arrDaughIndex.size (); ++jProng) {
729- auto daughJ = mcParticles.rawIteratorAt (arrDaughIndex[jProng]);
730- arrPDGDaugh[jProng] = std::abs (daughJ.pdgCode ());
731- }
732- if ((arrPDGDaugh[0 ] == arrPDGResonant1[0 ] && arrPDGDaugh[1 ] == arrPDGResonant1[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonant1[1 ] && arrPDGDaugh[1 ] == arrPDGResonant1[0 ])) {
733- channel = 1 ;
734- } else if ((arrPDGDaugh[0 ] == arrPDGResonant2[0 ] && arrPDGDaugh[1 ] == arrPDGResonant2[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonant2[1 ] && arrPDGDaugh[1 ] == arrPDGResonant2[0 ])) {
735- channel = 2 ;
736- } else if ((arrPDGDaugh[0 ] == arrPDGResonant3[0 ] && arrPDGDaugh[1 ] == arrPDGResonant3[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonant3[1 ] && arrPDGDaugh[1 ] == arrPDGResonant3[0 ])) {
737- channel = 3 ;
726+ // Λc± → p± K∓ π±
727+ if (flag == 0 && createLc) {
728+ if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kLambdaCPlus , std::array{+kProton , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
729+ flag = sign * (1 << DecayType::LcToPKPi);
730+
731+ // Flagging the different Λc± → p± K∓ π± decay channels
732+ RecoDecay::getDaughters (particle, &arrDaughIndex, std::array{0 }, 1 );
733+ if (arrDaughIndex.size () == 2 ) {
734+ for (auto jProng = 0u ; jProng < arrDaughIndex.size (); ++jProng) {
735+ auto daughJ = mcParticles.rawIteratorAt (arrDaughIndex[jProng]);
736+ arrPDGDaugh[jProng] = std::abs (daughJ.pdgCode ());
737+ }
738+ if ((arrPDGDaugh[0 ] == arrPDGResonant1[0 ] && arrPDGDaugh[1 ] == arrPDGResonant1[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonant1[1 ] && arrPDGDaugh[1 ] == arrPDGResonant1[0 ])) {
739+ channel = 1 ;
740+ } else if ((arrPDGDaugh[0 ] == arrPDGResonant2[0 ] && arrPDGDaugh[1 ] == arrPDGResonant2[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonant2[1 ] && arrPDGDaugh[1 ] == arrPDGResonant2[0 ])) {
741+ channel = 2 ;
742+ } else if ((arrPDGDaugh[0 ] == arrPDGResonant3[0 ] && arrPDGDaugh[1 ] == arrPDGResonant3[1 ]) || (arrPDGDaugh[0 ] == arrPDGResonant3[1 ] && arrPDGDaugh[1 ] == arrPDGResonant3[0 ])) {
743+ channel = 3 ;
744+ }
738745 }
739746 }
740747 }
741- }
742748
743- // Ξc± → p± K∓ π±
744- if (flag == 0 && createXic) {
745- if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kXiCPlus , std::array{+kProton , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
746- flag = sign * (1 << DecayType::XicToPKPi);
749+ // Ξc± → p± K∓ π±
750+ if (flag == 0 && createXic) {
751+ if (RecoDecay::isMatchedMCGen (mcParticles, particle, Pdg::kXiCPlus , std::array{+kProton , -kKPlus , +kPiPlus }, true , &sign, 2 )) {
752+ flag = sign * (1 << DecayType::XicToPKPi);
753+ }
747754 }
748- }
749755
750- // Check whether the particle is non-prompt (from a b quark).
751- if (flag != 0 ) {
752- origin = RecoDecay::getCharmHadronOrigin (mcParticles, particle, false , &idxBhadMothers);
753- }
754- if (origin == RecoDecay::OriginType::NonPrompt) {
755- rowMcMatchGen (flag, origin, channel, idxBhadMothers[0 ]);
756- } else {
757- rowMcMatchGen (flag, origin, channel, -1 );
756+ // Check whether the particle is non-prompt (from a b quark).
757+ if (flag != 0 ) {
758+ origin = RecoDecay::getCharmHadronOrigin (mcParticles, particle, false , &idxBhadMothers);
759+ }
760+ if (origin == RecoDecay::OriginType::NonPrompt) {
761+ rowMcMatchGen (flag, origin, channel, idxBhadMothers[0 ]);
762+ } else {
763+ rowMcMatchGen (flag, origin, channel, -1 );
764+ }
758765 }
759766 }
760767 }
0 commit comments