@@ -468,6 +468,14 @@ struct Kstar892LightIon {
468468 hMC.add (" CorrelatedBG/hK2_1770" , " Wrong pair distribution for K*(1410)" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
469469 hMC.add (" CorrelatedBG/hK2_1820" , " Wrong pair distribution for K*(1410)" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
470470 }
471+ if (doprocessTemplateMC) {
472+ hMC.add (" Template/hSignal" , " True K*0 signal" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
473+ hMC.add (" Template/hKstarReflection" , " K*0 signal due to mis-identification" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
474+ hMC.add (" Template/hSameMotherOther" , " Kpi pair from same mother other than K*0" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
475+ hMC.add (" Template/hDifferentMother" , " Kpi pair from different mothers" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
476+ hMC.add (" Template/hPrimaryResonance" , " Kpi pair one primary another from decay" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
477+ hMC.add (" Template/hPrimaryPrimary" , " Primary Kpi pair" , kTH3F , {ptAxis, centralityAxis, invmassAxis});
478+ }
471479
472480 if (doprocessRecKinematics) {
473481 hMC.add (" Kinematics/h1RecCent" , " centrality reconstructed" , kTH1F , {centralityAxis});
@@ -2583,6 +2591,121 @@ struct Kstar892LightIon {
25832591
25842592 PROCESS_SWITCH (Kstar892LightIon, processRecCorrelatedBackground, " Process correlated background" , false );
25852593
2594+ void processTemplateMC (EventCandidatesMC::iterator const & collision, TrackCandidatesMC const & tracks, aod::McParticles const &, EventMCGenerated const &)
2595+ {
2596+ if (!collision.has_mcCollision ())
2597+ return ;
2598+
2599+ if (!selectionEvent (collision, false ))
2600+ return ;
2601+
2602+ centrality = -1 .f ;
2603+ if (selectCentEstimator == kFT0M ) {
2604+ centrality = collision.centFT0M ();
2605+ } else if (selectCentEstimator == kFT0A ) {
2606+ centrality = collision.centFT0A ();
2607+ } else if (selectCentEstimator == kFT0C ) {
2608+ centrality = collision.centFT0C ();
2609+ } else if (selectCentEstimator == kFV0A ) {
2610+ centrality = collision.centFV0A ();
2611+ } else {
2612+ centrality = collision.centFT0M ();
2613+ }
2614+
2615+ auto classifyOrigin = [](const aod::McParticle& part, int64_t & motherIdx) -> int {
2616+ motherIdx = -1 ;
2617+ if (!part.has_mothers ())
2618+ return 0 ;
2619+ for (const auto & mom : part.mothers_as <aod::McParticles>()) {
2620+ if (!mom.producedByGenerator ())
2621+ continue ;
2622+ motherIdx = mom.globalIndex ();
2623+ if (std::abs (mom.pdgCode ()) == o2::constants::physics::kK0Star892 )
2624+ return 1 ;
2625+ return 2 ;
2626+ }
2627+ return 0 ;
2628+ };
2629+
2630+ for (const auto & [track1, track2] : combinations (CombinationsFullIndexPolicy (tracks, tracks))) {
2631+
2632+ if (!selectionTrack (track1) || !selectionTrack (track2))
2633+ continue ;
2634+
2635+ if (track1.globalIndex () == track2.globalIndex ())
2636+ continue ;
2637+
2638+ if (!selectionPair (track1, track2))
2639+ continue ;
2640+
2641+ if (!selectionPID (track1, PIDParticle::kKaon ))
2642+ continue ;
2643+ if (!selectionPID (track2, PIDParticle::kPion ))
2644+ continue ;
2645+
2646+ if (isMisidentified (track1, PIDParticle::kKaon ))
2647+ continue ;
2648+ if (isMisidentified (track2, PIDParticle::kPion ))
2649+ continue ;
2650+
2651+ if (selectionConfig.isApplyFakeTrack && (isFakeTrack (track1, PIDParticle::kKaon ) || isFakeTrack (track2, PIDParticle::kPion )))
2652+ continue ;
2653+
2654+ if (!track1.has_mcParticle () || !track2.has_mcParticle ())
2655+ continue ;
2656+
2657+ daughter1 = ROOT::Math::PxPyPzMVector (track1.px (), track1.py (), track1.pz (), massKa);
2658+ daughter2 = ROOT::Math::PxPyPzMVector (track2.px (), track2.py (), track2.pz (), massPi);
2659+ mother = daughter1 + daughter2;
2660+
2661+ if (mother.Rapidity () < selectionConfig.motherRapidityMin ||
2662+ mother.Rapidity () > selectionConfig.motherRapidityMax )
2663+ continue ;
2664+
2665+ const float recMass = mother.M ();
2666+ const float recPt = mother.Pt ();
2667+
2668+ const auto mcKa = track1.mcParticle ();
2669+ const auto mcPi = track2.mcParticle ();
2670+
2671+ if (selectionConfig.isPrimaryTrack && (!mcKa.isPhysicalPrimary () || !mcPi.isPhysicalPrimary ()))
2672+ continue ;
2673+
2674+ int64_t kaMotherIdx = -1 ;
2675+ int64_t piMotherIdx = -1 ;
2676+ const int kaOrigin = classifyOrigin (mcKa, kaMotherIdx);
2677+ const int piOrigin = classifyOrigin (mcPi, piMotherIdx);
2678+
2679+ const bool kaIsKstar = (kaOrigin == 1 );
2680+ const bool piIsKstar = (piOrigin == 1 );
2681+ const bool kaHasParent = (kaOrigin != 0 );
2682+ const bool piHasParent = (piOrigin != 0 );
2683+ const bool sameMother = (kaMotherIdx >= 0 ) && (piMotherIdx >= 0 ) && (kaMotherIdx == piMotherIdx);
2684+
2685+ if (kaIsKstar && piIsKstar && sameMother) {
2686+ const bool correctAssignment = (std::abs (mcKa.pdgCode ()) == PDG_t::kKPlus ) && (std::abs (mcPi.pdgCode ()) == PDG_t::kPiPlus );
2687+ if (correctAssignment) {
2688+ hMC.fill (HIST (" Template/hSignal" ), recPt, centrality, recMass);
2689+ } else {
2690+ hMC.fill (HIST (" Template/hKstarReflection" ), recPt, centrality, recMass);
2691+ }
2692+
2693+ } else if (sameMother && kaHasParent && piHasParent) {
2694+ hMC.fill (HIST (" Template/hSameMotherOther" ), recPt, centrality, recMass);
2695+
2696+ } else if (!sameMother && kaHasParent && piHasParent) {
2697+ hMC.fill (HIST (" Template/hDifferentMother" ), recPt, centrality, recMass);
2698+
2699+ } else if (kaHasParent != piHasParent) {
2700+ hMC.fill (HIST (" Template/hPrimaryResonance" ), recPt, centrality, recMass);
2701+
2702+ } else {
2703+ hMC.fill (HIST (" Template/hPrimaryPrimary" ), recPt, centrality, recMass);
2704+ }
2705+ }
2706+ }
2707+ PROCESS_SWITCH (Kstar892LightIon, processTemplateMC, " Process MC Template Background" , false );
2708+
25862709 void processRecKinematics (EventCandidatesMC::iterator const & collision, TrackCandidatesMC const & tracks, aod::McParticles const &, EventMCGenerated const &)
25872710 {
25882711 if (!collision.has_mcCollision ()) {
0 commit comments