6262#include < string>
6363#include < tuple>
6464#include < type_traits>
65+ #include < unordered_map>
6566#include < utility>
6667#include < vector>
6768
@@ -115,6 +116,7 @@ struct CorrelationTask {
115116 O2_DEFINE_CONFIGURABLE (cfgEfficiencyAssociated, std::string, " " , " CCDB path to efficiency object for associated particles" )
116117
117118 O2_DEFINE_CONFIGURABLE (cfgNoMixedEvents, int , 5 , " Number of mixed events per event" )
119+ O2_DEFINE_CONFIGURABLE (cfgRejectMixedPhiProngEvents, bool , true , " Reject associated hadrons from either mixed-phi prong event" )
118120
119121 O2_DEFINE_CONFIGURABLE (cfgVerbosity, int , 1 , " Verbosity level (0 = major, 1 = per collision)" )
120122
@@ -127,6 +129,9 @@ struct CorrelationTask {
127129 O2_DEFINE_CONFIGURABLE (cfgPtCentDepMLbkgSel, std::vector<float >, {}, " Bkg ML selection" )
128130 O2_DEFINE_CONFIGURABLE (cfgPtCentDepMLpromptSel, std::vector<float >, {}, " Prompt ML selection" )
129131
132+ std::unordered_map<int64_t , int64_t > cfTrackToCFCollision;
133+ bool rejectMixedPhiProngEventsNow = false ;
134+
130135 ConfigurableAxis axisVertex{" axisVertex" , {7 , -7 , 7 }, " vertex axis for histograms" };
131136 ConfigurableAxis axisDeltaPhi{" axisDeltaPhi" , {72 , -PIHalf, PIHalf * 3 }, " delta phi axis for histograms" };
132137 ConfigurableAxis axisDeltaEta{" axisDeltaEta" , {40 , -2 , 2 }, " delta eta axis for histograms" };
@@ -390,7 +395,7 @@ struct CorrelationTask {
390395 {
391396 for (const auto & track1 : tracks1) {
392397 if constexpr (std::experimental::is_detected<HasInvMass, typename TTracks1::iterator>::value && std::experimental::is_detected<HasDecay, typename TTracks1::iterator>::value) {
393- if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast <uint32_t >(track1.decay ()))) == 0u )
398+ if (cfgDecayParticleMask != 0 && (cfgDecayParticleMask & (1u << static_cast <uint64_t >(track1.decay ()))) == 0u )
394399 continue ;
395400 if constexpr (std::experimental::is_detected<HasMlProbD0, typename TTracks1::iterator>::value) {
396401 if (!passMLScore (track1))
@@ -511,6 +516,8 @@ struct CorrelationTask {
511516 using HasPartDaugh0Id = decltype (std::declval<T&>().cfParticleDaugh0Id());
512517 template <class T >
513518 using HasPartDaugh1Id = decltype (std::declval<T&>().cfParticleDaugh1Id());
519+ template <class T >
520+ using HasCFCollisionId = decltype (std::declval<T&>().cfCollisionId());
514521
515522 template <class CollType >
516523 bool passOutlier (CollType const & collision)
@@ -654,6 +661,29 @@ struct CorrelationTask {
654661 continue ;
655662 }
656663 }
664+
665+ if (rejectMixedPhiProngEventsNow && cfgRejectMixedPhiProngEvents) {
666+ if constexpr (std::experimental::is_detected<HasDecay, typename TTracks1::iterator>::value &&
667+ std::experimental::is_detected<HasProng0Id, typename TTracks1::iterator>::value &&
668+ std::experimental::is_detected<HasProng1Id, typename TTracks1::iterator>::value &&
669+ std::experimental::is_detected<HasCFCollisionId, typename TTracks2::iterator>::value) {
670+
671+ if (track1.decay () == aod::cf2prongtrack::PhiToKKPID3Mixed) {
672+ auto pr0 = cfTrackToCFCollision.find (track1.cfTrackProng0Id ());
673+ auto pr1 = cfTrackToCFCollision.find (track1.cfTrackProng1Id ());
674+
675+ if (pr0 != cfTrackToCFCollision.end () &&
676+ pr1 != cfTrackToCFCollision.end ()) {
677+ const auto assocColl = track2.cfCollisionId ();
678+
679+ if (assocColl == pr0->second || assocColl == pr1->second ) {
680+ continue ;
681+ }
682+ }
683+ }
684+ }
685+ }
686+
657687 if constexpr (std::experimental::is_detected<HasPDGCode, typename TTracks2::iterator>::value) { // skip those that are specifically chosen to be triggers
658688 if (!cfgMcTriggerPDGs->empty () && std::find (cfgMcTriggerPDGs->begin (), cfgMcTriggerPDGs->end (), track2.pdgCode ()) != cfgMcTriggerPDGs->end ())
659689 continue ; // TODO: fix cases like MC D0-D0
@@ -783,15 +813,16 @@ struct CorrelationTask {
783813 } // ML selection
784814
785815 // last param is the weight
786- if (cfgMassAxis && (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong || doprocessSame2Prong2ProngML || doprocessMixed2Prong2ProngML) && !(doprocessSame2ProngDerived || doprocessSame2ProngDerivedML || doprocessMixed2ProngDerived || doprocessMixed2ProngDerivedML)) {
816+ if (cfgMassAxis && (doprocessSame2Prong2Prong || doprocessMixed2Prong2Prong || doprocessSame2Prong2ProngML || doprocessMixed2Prong2ProngML) && !(doprocessSame2ProngDerived || doprocessSame2ProngDerivedML || doprocessMixed2ProngDerived || doprocessMixed2ProngDerivedML || doprocessMixed2ProngDerivedMixedPhi )) {
787817 if constexpr (std::experimental::is_detected<HasInvMass, typename TTracks1::iterator>::value && std::experimental::is_detected<HasInvMass, typename TTracks2::iterator>::value)
788818 target->getPairHist ()->Fill (step, track1.eta () - track2.eta (), track2.pt (), track1.pt (), multiplicity, deltaPhi, posZ, track2.invMass (), track1.invMass (), associatedWeight);
789819 else
790820 LOGF (fatal, " Can not fill mass axis without invMass column. \n no mass for two particles" );
791821 } else if (cfgMassAxis) {
792- if constexpr (std::experimental::is_detected<HasInvMass, typename TTracks1::iterator>::value)
822+ if constexpr (std::experimental::is_detected<HasInvMass, typename TTracks1::iterator>::value) {
823+ // LOGF(info, "Filling pair hist with mass: step %d, pt1 %f, pt2 %f, invMass %f", static_cast<int>(step), track1.pt(), track2.pt(), track1.invMass());
793824 target->getPairHist ()->Fill (step, track1.eta () - track2.eta (), track2.pt (), track1.pt (), multiplicity, deltaPhi, posZ, track1.invMass (), associatedWeight);
794- else if constexpr (std::experimental::is_detected<HasPDGCode, typename TTracks1::iterator>::value) {
825+ } else if constexpr (std::experimental::is_detected<HasPDGCode, typename TTracks1::iterator>::value) {
795826 // TParticlePDG *p = pdg->GetParticle(track1.pdgCode()); //TODO: get the mass for the PDG properly
796827 target->getPairHist ()->Fill (step, track1.eta () - track2.eta (), track2.pt (), track1.pt (), multiplicity, deltaPhi, posZ, 1.8 , associatedWeight); // p->Mass()
797828 } else {
@@ -1071,6 +1102,23 @@ struct CorrelationTask {
10711102 processMixedDerivedT (collisions, p2tracks, tracks);
10721103 }
10731104 PROCESS_SWITCH (CorrelationTask, processMixed2ProngDerived, " Process mixed events on derived data" , false );
1105+ void processMixed2ProngDerivedMixedPhi (DerivedCollisions const & collisions,
1106+ DerivedTracks const & tracks,
1107+ soa::Filtered<aod::CF2ProngTracks> const & p2tracks)
1108+ {
1109+ cfTrackToCFCollision.clear ();
1110+ cfTrackToCFCollision.reserve (tracks.size ());
1111+
1112+ for (const auto & trk : tracks) {
1113+ cfTrackToCFCollision.emplace (trk.globalIndex (), trk.cfCollisionId ());
1114+ }
1115+
1116+ rejectMixedPhiProngEventsNow = true ;
1117+ processMixedDerivedT (collisions, p2tracks, tracks);
1118+ rejectMixedPhiProngEventsNow = false ;
1119+ }
1120+
1121+ PROCESS_SWITCH (CorrelationTask, processMixed2ProngDerivedMixedPhi, " Process mixed events for mixed-phi triggers" , false );
10741122
10751123 void processMixed2ProngDerivedML (DerivedCollisions const & collisions, DerivedTracks const & tracks, soa::Filtered<soa::Join<aod::CF2ProngTracks, aod::CF2ProngTrackmls>> const & p2tracks)
10761124 {
0 commit comments