diff --git a/PWGLF/Tasks/Resonances/phiphimcinjected.cxx b/PWGLF/Tasks/Resonances/phiphimcinjected.cxx index d484b0e2481..da403a5cf39 100644 --- a/PWGLF/Tasks/Resonances/phiphimcinjected.cxx +++ b/PWGLF/Tasks/Resonances/phiphimcinjected.cxx @@ -13,7 +13,10 @@ /// \brief Code for injected doublephi resonance MC /// \author Sawan +#include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -28,17 +31,22 @@ #include #include #include +#include #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include #include -#include // std::abs -#include // size_t / std::size_t +#include +#include +#include +#include #include using namespace o2; using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; struct PhiCandidateInjected { ROOT::Math::PxPyPzMVector p4; @@ -55,65 +63,115 @@ struct PhiPhiMCInjected { // Configurables struct : ConfigurableGroup { + + // Event selections Configurable isSel8{"isSel8", true, "Event selection sel8"}; + Configurable vertexZCut{"vertexZCut", 10.0f, "Vertex Z Cut"}; + + // Track selections + Configurable isGlobalTrack{"isGlobalTrack", true, "Select only global tracks"}; + Configurable isPVContributor{"isPVContributor", true, "Select only PV contributor tracks"}; + Configurable minKaonPt{"minKaonPt", 0.15f, "Kaon tracks pT Cut"}; + Configurable maxKaonPt{"maxKaonPt", 100.0, "maximum kaon pt cut"}; + Configurable trackEtaCut{"trackEtaCut", 0.8f, "Track Eta Cut"}; Configurable cutDCAxy{"cutDCAxy", 0.1f, "DCAxy max cut"}; Configurable cutDCAz{"cutDCAz", 0.1f, "DCAz max cut"}; - Configurable cutNsigmaTPC{"cutNsigmaTPC", 3.0f, "TPC Nsigma cut for Kaon"}; - Configurable isApplyPIDSelection{"isApplyPIDSelection", true, "Apply PID selection for Kaons"}; - Configurable trackEtaCut{"trackEtaCut", 0.8f, "Track Eta Cut"}; - Configurable phiMassCutLow{"phiMassCutLow", 0.9f, "Lower Cut for Phi Mass"}; - Configurable phiMassCutHigh{"phiMassCutHigh", 1.1f, "Upper Cut for Phi Mass"}; + Configurable cfgITSclusters{"cfgITSclusters", 0, "Minimum number of ITS clusters"}; + Configurable cfgTPCclusters{"cfgTPCclusters", 70, "Minimum number of TPC clusters"}; + Configurable isApplyITSPIDselection{"isApplyITSPIDselection", false, "Apply ITS PID selection"}; + + // PID selections + Configurable PIDStrategy{"PIDStrategy", 2003, "Use TPC+TOF PID selection"}; + Configurable cutMinNsigmaTPC{"cutMinNsigmaTPC", -2.5, "nsigma cut TPC"}; + Configurable cutNsigmaTPC{"cutNsigmaTPC", 2.5, "nsigma cut TPC"}; + Configurable cutNsigmaTOF{"cutNsigmaTOF", 2.5, "nsigma cut TOF"}; + Configurable momTOFCut{"momTOFCut", 1.8, "minimum pT cut for madnatory TOF"}; + + // Selections on phi candidates + Configurable minPhiPt{"minPhiPt", 0, "Minimum phi Pt"}; + Configurable maxPhiPt{"maxPhiPt", 100, "Maximum phi Pt"}; + Configurable minPhiMass{"minPhiMass", 0.9f, "Lower Cut for Phi Mass"}; + Configurable maxPhiMass{"maxPhiMass", 1.1f, "Upper Cut for Phi Mass"}; + // Configurable isDeepAngleCut{"isDeepAngleCut", false, "Apply Deep Angle Cut for Phi-Phi"}; + // Configurable deepAngleCut{"deepAngleCut", 0.4f, "Deep Angle Cut for Phi-Phi"}; + + // Selections on the phiphi candidates + Configurable minExoticPt{"minExoticPt", 6.0, "Minimum Exotic Pt"}; + Configurable minExoticMass{"minExoticMass", 2.2, "Minimum Exotic mass"}; + Configurable maxExoticMass{"maxExoticMass", 3.4, "Maximum Exotic mass"}; + Configurable isApplyRapidityCut{"isApplyRapidityCut", true, "Apply Rapidity Cut for Phi-Phi"}; + Configurable rapidityCut{"rapidityCut", 0.5, "Rapidity Cut for Phi-Phi"}; } config; const int injectedMotherPDG = 999999; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry eventTrkSelection{"eventTrkSelection", {}, OutputObjHandlingPolicy::AnalysisObject}; double normFactor = 1.0; + o2::aod::ITSResponse itsResponse; ConfigurableAxis phiMassAxis{"phiMassAxis", {200, 0.98, 1.22}, "Phi Mass Axis"}; ConfigurableAxis phiPtAxis{"phiPtAxis", {200, 0.0, 100.0}, "Phi Pt Axis"}; ConfigurableAxis phiPhiMassAxis{"phiPhiMassAxis", {200, 2.0, 4.0}, "Phi-Phi Mass Axis"}; ConfigurableAxis phiPhiPtAxis{"phiPhiPtAxis", {200, 0.0, 50.0}, "Phi-Phi Pt Axis"}; + ConfigurableAxis deltaMAxis{"deltaMAxis", {80, 0.0, 0.08}, "#it{M} (GeV/#it{c}^{2})"}; + + enum EventSelectionStep { + kEventAll = 0, + kEventSel8AndVertexZ, + kEventHasTwoPositiveAndTwoNegativeKaons, + kEventSelectionSteps + }; + + enum TrackSelectionStep { + kTrackHasMCParticle = 0, + kTrack1PassesTrackSelection, + kTrack1PassesPID, + kTrack2HasHigherIndex, + kTrack2HasMCParticle, + kTrack2PassesTrackSelection, + kTrack2PassesPID, + kTrackOppositeSign, + kBothTracksAreKaons, + kCommonMotherFound, + kMotherIsPhi, + kPhiPassesMassCut, + kPhiPassesPtCut, + kPhiHasInjectedMother, + kPhiPassesMotherPtCut, // Currently disabled + kPhiPassesMotherMassCut, // Currently disabled + kPhiPassesMotherRapidityCut, // Currently disabled + kAtLeastTwoPhiCandidates, + kTrackSelectionSteps + }; - enum RecoSelectionStage { - kLoop1Track = 0, - kLoop1DCA, - kLoop1PID, - kLoop1MCLabel, - kLoop1Eta, - kLoop2Track, - kLoop2Index, - kLoop2Eta, - kLoop2DCA, - kLoop2PID, - kLoop2MCLabel, - kLoop2Charge, - kLoop2KaonDaughters, - kCommonMotherLoop, - kCommonMother, - kPhiMother, - kPhiMassCut, - kInjectedMother, - kLoop2PhiPairs, - kUniqueTracks, - kValidPhiPhiPair + enum PhiPhiSelectionStep { + kPhiPhiUniqueKaonTracks = 0, + kPhiPhiBothValidPhi, + kPhiPhiPassesPtCut, + kPhiPhiPassesMassCut, + kPhiPhiPassesRapidityCut, + kPhiPhiSameInjectedMother, + kPhiPhiSelectionSteps }; void init(InitContext const&) { + // Event histograms + eventTrkSelection.add("h1MultiplicityGen", "Multiplicity;Multiplicity;Counts", kTH1F, {{100, 0.0f, 100.0f}}); + eventTrkSelection.add("h1MultiplicityRec", "Multiplicity;Multiplicity;Counts", kTH1F, {{100, 0.0f, 100.0f}}); + eventTrkSelection.add("h1_EventCount", "Event Count;Event Count;Counts", kTH1F, {{5, -0.5, 4.5}}); + eventTrkSelection.add("h1_TrackCount", "Track Count;Track Count;Counts", kTH1F, {{25, -0.5, 24.5}}); + eventTrkSelection.add("h1_PhiPhiTrack", "Phi-Phi Track Count;Track Count;Counts", kTH1F, {{10, -0.5, 9.5}}); - // Event histogram - registry.add("h1_TrackCount", "Track Count;Track Count;Counts", kTH1F, {{25, -0.5, 24.5}}); - registry.add("h1_EventCount", "Event Count;Event Count;Counts", kTH1F, {{5, -0.5, 4.5}}); // Generated MC Histograms registry.add("Generated/h2_InvMassPhiPhi", "Gen Phi-Phi: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiPhiMassAxis}, {phiPhiPtAxis}}); - registry.add("Generated/h2_InvMassPhiPhi2", "Gen Phi-Phi: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiPhiMassAxis}, {phiPhiPtAxis}}); registry.add("Generated/h1_PhiPhi_Phi", "Gen Phi-Phi: #phi Angle;#phi;Counts", kTH1F, {{100, -o2::constants::math::PI, o2::constants::math::PI}}); registry.add("Generated/h1_PhiPhi_Eta", "Gen Phi-Phi: #eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); registry.add("Generated/h1_PhiPhi_Y", "Gen Phi-Phi: Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Generated/hSparse_T4s", "invariant mass histogram for the exotic", kTHnSparseF, {phiPhiMassAxis, phiPhiPtAxis, deltaMAxis, phiMassAxis, phiMassAxis}); - registry.add("Generated/h2_InvMassPhiFromT4s", "Daughter phi from T4s decay: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiMassAxis}, {phiPtAxis}}); - registry.add("Generated/h2_InvMassPhiMinBias", "phi from minimum bias: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiMassAxis}, {phiPtAxis}}); + registry.add("Generated/h2_PhiFromT4s", "Daughter phi from T4s decay: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiMassAxis}, {phiPtAxis}}); // Reconstructed MC Histograms - 2D Mass vs pT of Mother Phi-Phi registry.add("Reconstructed/AllPhiPairs/h2_PhiPhi_All", "Rec Phi-Phi All Pairs: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiPhiMassAxis}, {phiPhiPtAxis}}); @@ -121,93 +179,185 @@ struct PhiPhiMCInjected { registry.add("Reconstructed/AllPhiPairs/h1_PhiPhi_Eta", "Rec Phi-Phi: #eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); registry.add("Reconstructed/AllPhiPairs/h1_PhiPhi_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); - registry.add("Reconstructed/AllPhiPairs/h1_Phi1_Mass", "Rec Phi Mass: Mass;Mass (GeV/#it{c}^{2});Counts", kTH1F, {{phiMassAxis}}); - registry.add("Reconstructed/AllPhiPairs/h1_Phi1_Pt", "Rec Phi pT: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); - registry.add("Reconstructed/AllPhiPairs/h1_Phi1_Eta", "Rec Phi Eta: Eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); - registry.add("Reconstructed/AllPhiPairs/h1_Phi1_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); - - registry.add("Reconstructed/PhiFromT4s/h2_PhiPhi_T4s", "Rec Phi-Phi Mother 999999: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiPhiMassAxis}, {phiPhiPtAxis}}); - registry.add("Reconstructed/PhiFromT4s/h1_PhiPhi_Pt", "Rec Phi-Phi: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); - registry.add("Reconstructed/PhiFromT4s/h1_PhiPhi_Eta", "Rec Phi-Phi: #eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); - registry.add("Reconstructed/PhiFromT4s/h1_PhiPhi_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); - - registry.add("Reconstructed/PhiFromT4s/h1_Phi1_Mass", "Rec Phi Mass: Mass;Mass (GeV/#it{c}^{2});Counts", kTH1F, {{phiMassAxis}}); - registry.add("Reconstructed/PhiFromT4s/h1_Phi1_Pt", "Rec Phi pT: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); - registry.add("Reconstructed/PhiFromT4s/h1_Phi1_Eta", "Rec Phi Eta: Eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); - registry.add("Reconstructed/PhiFromT4s/h1_Phi1_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); - - registry.add("Reconstructed/MinimumBiasPhi/h2_PhiPhi_MinBias", "Rec Phi-Phi Minimum Bias: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiPhiMassAxis}, {phiPhiPtAxis}}); - registry.add("Reconstructed/MinimumBiasPhi/h1_PhiPhi_Pt", "Rec Phi-Phi: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); - registry.add("Reconstructed/MinimumBiasPhi/h1_PhiPhi_Eta", "Rec Phi-Phi: #eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); - registry.add("Reconstructed/MinimumBiasPhi/h1_PhiPhi_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); - - registry.add("Reconstructed/MinimumBiasPhi/h1_Phi1_Mass", "Rec Phi Mass: Mass;Mass (GeV/#it{c}^{2});Counts", kTH1F, {{phiMassAxis}}); - registry.add("Reconstructed/MinimumBiasPhi/h1_Phi1_Pt", "Rec Phi pT: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); - registry.add("Reconstructed/MinimumBiasPhi/h1_Phi1_Eta", "Rec Phi Eta: Eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); - registry.add("Reconstructed/MinimumBiasPhi/h1_Phi1_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Mass", "Rec Phi Mass: Mass;Mass (GeV/#it{c}^{2});Counts", kTH1F, {{phiMassAxis}}); + registry.add("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Pt", "Rec Phi pT: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); + registry.add("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Eta", "Rec Phi Eta: Eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); + + registry.add("Reconstructed/Exotic/h2_PhiPhi_T4s", "Rec Phi-Phi Mother 999999: Mass vs pT;Mass (GeV/#it{c}^{2});p_{T} (GeV/#it{c})", kTHnSparseF, {{phiPhiMassAxis}, {phiPhiPtAxis}}); + registry.add("Reconstructed/Exotic/h1_PhiPhi_Pt", "Rec Phi-Phi: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); + registry.add("Reconstructed/Exotic/h1_PhiPhi_Eta", "Rec Phi-Phi: #eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Reconstructed/Exotic/h1_PhiPhi_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Reconstructed/Exotic/hSparse_PhiPhi_T4s", "invarinat mass histogram for the exotic", kTHnSparseF, {phiPhiMassAxis, phiPhiPtAxis, deltaMAxis, phiMassAxis, phiMassAxis}); + + registry.add("Reconstructed/Exotic/Phi/h1_Phi1_Mass", "Rec Phi Mass: Mass;Mass (GeV/#it{c}^{2});Counts", kTH1F, {{phiMassAxis}}); + registry.add("Reconstructed/Exotic/Phi/h1_Phi1_Pt", "Rec Phi pT: pT;p_{T} (GeV/#it{c});Counts", kTH1F, {{phiPtAxis}}); + registry.add("Reconstructed/Exotic/Phi/h1_Phi1_Eta", "Rec Phi Eta: Eta;#eta;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Reconstructed/Exotic/Phi/h1_Phi1_Y", "Rec Phi Rapidity y;y;Counts", kTH1F, {{100, -1.0, 1.0}}); + registry.add("Reconstructed/Exotic/Phi/h2_Phi", "Rec Phi Mass vs pT", kTH2F, {phiMassAxis, phiPtAxis}); + } + + template + bool selectionEvent(const T& collision) + { + if (config.isSel8 && !collision.sel8()) { + return false; + } + if (std::abs(collision.posZ()) > config.vertexZCut) { + return false; + } + return true; } // PID Selection function - bool checkPID(float ptcand, float nsigmaTPC, float nsigmaTOF, bool TOFHit) + bool selectionPID(float nsigmaTPC, float nsigmaTOF, int TOFHit, int PIDStrategy, float ptcand) { - constexpr float RadiusMax = 2.5f * 2.5f; - const bool hasTOF = (TOFHit == 1); - if (!hasTOF) { - if (ptcand < 0.5f) { - return std::abs(nsigmaTPC) < config.cutNsigmaTPC; - } else { - return nsigmaTPC > -2.0f && nsigmaTPC < config.cutNsigmaTPC; - } - } else { - const float radius2 = nsigmaTPC * nsigmaTPC + nsigmaTOF * nsigmaTOF; - if (radius2 >= RadiusMax) { - return false; - } - if (ptcand < 2.0f) { - return true; - } + if (PIDStrategy == 2003) { + constexpr float radius2Max = 2.5f * 2.5f; + const bool hasTOF = (TOFHit == 1); + + if (!hasTOF) { + // TPC-only branch + if (ptcand < 0.5f) { + return std::abs(nsigmaTPC) < config.cutNsigmaTPC; + } else { + return nsigmaTPC > -2.0f && + nsigmaTPC < config.cutNsigmaTPC; + } - float slope = 0.0f; - float intercept = 0.0f; - - if (ptcand < 2.5f) { - slope = 1.29f; - intercept = 3.34f; - } else if (ptcand < 3.0f) { - slope = 0.94f; - intercept = 2.45f; - } else if (ptcand < 4.0f) { - slope = 0.62f; - intercept = 1.55f; - } else if (ptcand < 5.0f) { - slope = 0.32f; - intercept = 1.45f; - } else if (ptcand < 7.0f) { - slope = 0.22f; - intercept = 1.35f; } else { - slope = 0.10f; - intercept = 1.25f; + // TPC+TOF branch + const float radius2 = + nsigmaTPC * nsigmaTPC + + nsigmaTOF * nsigmaTOF; + + if (radius2 >= radius2Max) { + return false; + } + + // Circle only below 2 GeV/c + if (ptcand < 2.0f) { + return true; + } + + float slope = 0.0f; + float intercept = 0.0f; + + if (ptcand < 2.5f) { + slope = 1.29f; + intercept = 3.34f; + } else if (ptcand < 3.0f) { + slope = 0.94f; + intercept = 2.45f; + } else if (ptcand < 4.0f) { + slope = 0.62f; + intercept = 1.55f; + } else if (ptcand < 5.0f) { + slope = 0.32f; + intercept = 1.45f; + } else if (ptcand < 7.0f) { + slope = 0.22f; + intercept = 1.35f; + } else { + slope = 0.10f; + intercept = 1.25f; + } + + return nsigmaTPC < + slope * nsigmaTOF + intercept; } + } + + return false; + } - return nsigmaTPC < slope * nsigmaTOF + intercept; + template + bool selectionTrack(const T& candidate) + { + if (config.isGlobalTrack && !candidate.isGlobalTrack()) { + return false; + } + if (config.isPVContributor && !candidate.isPVContributor()) { + return false; + } + if (candidate.pt() < config.minKaonPt || candidate.pt() > config.maxKaonPt) { + return false; + } + if (std::abs(candidate.eta()) > config.trackEtaCut) { + return false; } + if (std::abs(candidate.dcaXY()) > config.cutDCAxy || std::abs(candidate.dcaZ()) > config.cutDCAz) { + return false; + } + if (candidate.tpcNClsFound() < config.cfgTPCclusters) { + return false; + } + if (candidate.itsNCls() < config.cfgITSclusters) { + return false; + } + if (config.isApplyITSPIDselection && !(itsResponse.nSigmaITS(candidate) > -3.0 && itsResponse.nSigmaITS(candidate) < 3.0)) { + return false; + } + + return true; } + // float deepangle(const TLorentzVector& candidate1, + // const TLorentzVector& candidate2) + // { + // const double pt1 = candidate1.Pt(); + // const double pt2 = candidate2.Pt(); + // const double pz1 = candidate1.Pz(); + // const double pz2 = candidate2.Pz(); + // const double p1 = candidate1.P(); + // const double p2 = candidate2.P(); + // const double angle = TMath::ACos((pt1 * pt2 + pz1 * pz2) / (p1 * p2)); + // return angle; + // } + // Define data table bindings - using EventCandidatesMC = soa::Join; + using EventMCGenerated = soa::Join; + using EventCandidatesMC = soa::Join; using TrackCandidatesMC = soa::Join; - ROOT::Math::PxPyPzEVector vecGen, vecDau1, vecDau2; + ROOT::Math::PxPyPzEVector vecGen, vecDau1, vecDau2, grandMotherRec; ROOT::Math::PxPyPzMVector daughter1Gen, daughter2Gen, motherGen, daughter1Rec, daughter2Rec, motherRec; // Process Generated MC - void processGen(aod::McCollision const&, aod::McParticles const& mcParticles) + void processGen(EventMCGenerated::iterator const& mcCollision, aod::McParticles const& mcParticles, const soa::SmallGroups& collisions) { + + std::vector selectedEvents(collisions.size()); + int nevts = 0; + + double genMultiplicity = -1.0; + + for (const auto& collision : collisions) { + if (!selectionEvent(collision)) { + continue; + } + selectedEvents[nevts++] = collision.mcCollision_as().globalIndex(); + + genMultiplicity = collision.centFT0M(); + } + selectedEvents.resize(nevts); + + const auto evtReconstructedAndSelected = std::find(selectedEvents.begin(), selectedEvents.end(), mcCollision.globalIndex()) != selectedEvents.end(); + + if (!evtReconstructedAndSelected) { + return; + } + + eventTrkSelection.fill(HIST("h1MultiplicityGen"), genMultiplicity); + for (const auto& mcParticle : mcParticles) { if (mcParticle.pdgCode() == injectedMotherPDG) { + if (config.isApplyRapidityCut && std::abs(mcParticle.y()) > config.rapidityCut) { + continue; + } + auto phiPhiDaughters = mcParticle.daughters_as(); if (phiPhiDaughters.size() != 2) { continue; @@ -221,66 +371,36 @@ struct PhiPhiMCInjected { } if (phiCount == 0) { - vecDau1 = ROOT::Math::PxPyPzEVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), kCurrentDaughter.e()); // Phi meson mass - daughter1Gen = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassPhi); // Phi meson mass + daughter1Gen = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassPhi); phiCount++; - registry.fill(HIST("Generated/h2_InvMassPhiFromT4s"), vecDau1.M(), daughter1Gen.Pt()); } else if (phiCount == 1) { - daughter2Gen = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassPhi); // Phi meson mass + daughter2Gen = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassPhi); phiCount++; } } - if (phiCount != 2) { + if (phiCount < 2) { continue; } - motherGen = daughter1Gen + daughter2Gen; - vecGen = ROOT::Math::PxPyPzEVector(motherGen.Px(), motherGen.Py(), motherGen.Pz(), motherGen.E()); - registry.fill(HIST("Generated/h2_InvMassPhiPhi"), motherGen.M(), motherGen.Pt()); - registry.fill(HIST("Generated/h2_InvMassPhiPhi2"), vecGen.M(), mcParticle.pt()); - - registry.fill(HIST("Generated/h1_PhiPhi_Phi"), vecGen.Phi()); - registry.fill(HIST("Generated/h1_PhiPhi_Eta"), vecGen.Eta()); - registry.fill(HIST("Generated/h1_PhiPhi_Y"), vecGen.Rapidity()); - } + motherGen = daughter1Gen + daughter2Gen; - if (mcParticle.pdgCode() == o2::constants::physics::kPhi) { + double deltaM = std::hypot(daughter1Gen.M() - o2::constants::physics::MassPhi, daughter2Gen.M() - o2::constants::physics::MassPhi); - auto phiDaughters = mcParticle.daughters_as(); - if (phiDaughters.size() != 2) { + if (motherGen.M() < config.minExoticMass || motherGen.M() > config.maxExoticMass) { continue; } - bool passPosKaon = false; - bool passNegKaon = false; - for (const auto& kCurrentDaughter : phiDaughters) { - - if (kCurrentDaughter.pdgCode() == PDG_t::kKPlus) { - passPosKaon = true; - daughter1Gen = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassKPlus); - - } else if (kCurrentDaughter.pdgCode() == PDG_t::kKMinus) { - passNegKaon = true; - daughter2Gen = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassKPlus); - } - } - - // Ensure that the mother is not 999999 - auto mothers = mcParticle.mothers_as(); - bool isFrom999999 = false; - for (const auto& mother : mothers) { - if (mother.pdgCode() == injectedMotherPDG) { - isFrom999999 = true; - break; - } + if (motherGen.Pt() < config.minExoticPt) { + continue; } - if (passPosKaon && passNegKaon && !isFrom999999) { - motherGen = daughter1Gen + daughter2Gen; - vecGen = ROOT::Math::PxPyPzEVector(motherGen.px(), motherGen.py(), motherGen.pz(), motherGen.E()); + registry.fill(HIST("Generated/h2_InvMassPhiPhi"), motherGen.M(), motherGen.Pt()); + registry.fill(HIST("Generated/h1_PhiPhi_Phi"), motherGen.Phi()); + registry.fill(HIST("Generated/h1_PhiPhi_Eta"), motherGen.Eta()); + registry.fill(HIST("Generated/h1_PhiPhi_Y"), motherGen.Rapidity()); - registry.fill(HIST("Generated/h2_InvMassPhiMinBias"), vecGen.M(), mcParticle.pt()); - } + registry.fill(HIST("Generated/hSparse_T4s"), motherGen.M(), mcParticle.pt(), deltaM, daughter1Gen.M(), daughter2Gen.M()); + registry.fill(HIST("Generated/h2_PhiFromT4s"), daughter1Gen.M(), daughter1Gen.Pt()); } } } @@ -288,75 +408,103 @@ struct PhiPhiMCInjected { void processRec(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const&) { + eventTrkSelection.fill(HIST("h1_EventCount"), kEventAll); - registry.fill(HIST("h1_EventCount"), 0.0); - - if (collision.sel8()) { - registry.fill(HIST("h1_EventCount"), 1.0); + if (!collision.has_mcCollision()) { + return; } - if (!collision.sel8() && config.isSel8) { + // Event selection + if (!selectionEvent(collision)) { return; } + double multiplicityRec = collision.centFT0M(); + eventTrkSelection.fill(HIST("h1MultiplicityRec"), multiplicityRec); + eventTrkSelection.fill(HIST("h1_EventCount"), kEventSel8AndVertexZ); std::vector phiCandidates; - // STEP 1: Reconstruct individual Phi candidates (Kaon track pairs) - for (const auto& t1 : tracks) { - registry.fill(HIST("h1_TrackCount"), kLoop1Track); + int nPosKaons = 0; + int nNegKaons = 0; + + // Count kaon tracks passing all track and PID selections + for (const auto& track : tracks) { + + if (!track.has_mcParticle()) { + continue; + } - if (std::abs(t1.dcaXY()) > config.cutDCAxy || std::abs(t1.dcaZ()) > config.cutDCAz) { + if (!selectionTrack(track)) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop1DCA); - if (config.isApplyPIDSelection && !checkPID(t1.pt(), t1.tpcNSigmaKa(), t1.tofNSigmaKa(), t1.hasTOF())) { + if (!selectionPID(track.tpcNSigmaKa(), track.tofNSigmaKa(), track.hasTOF(), config.PIDStrategy, track.pt())) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop1PID); + + auto mcTrack = track.mcParticle(); + + if (std::abs(mcTrack.pdgCode()) != PDG_t::kKPlus) { + continue; + } + + if (track.sign() > 0) { + nPosKaons++; + } else if (track.sign() < 0) { + nNegKaons++; + } + } + + // Require at least 2 positive and 2 negative kaons + if (nPosKaons < 2 || nNegKaons < 2) { + return; + } + eventTrkSelection.fill(HIST("h1_EventCount"), kEventHasTwoPositiveAndTwoNegativeKaons); + + // STEP 1: Reconstruct individual Phi candidates (Kaon track pairs) + for (const auto& t1 : tracks) { if (!t1.has_mcParticle()) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop1MCLabel); + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kTrackHasMCParticle); - if (std::abs(t1.eta()) > config.trackEtaCut) { + if (!selectionTrack(t1)) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop1Eta); + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrack1PassesTrackSelection); + + if (!selectionPID(t1.tpcNSigmaKa(), t1.tofNSigmaKa(), t1.hasTOF(), config.PIDStrategy, t1.pt())) { + continue; + } + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrack1PassesPID); for (const auto& t2 : tracks) { - registry.fill(HIST("h1_TrackCount"), kLoop2Track); if (t2.index() <= t1.index()) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop2Index); - - if (std::abs(t2.eta()) > config.trackEtaCut) { - continue; - } - registry.fill(HIST("h1_TrackCount"), kLoop2Eta); + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrack2HasHigherIndex); - if (std::abs(t2.dcaXY()) > config.cutDCAxy || std::abs(t2.dcaZ()) > config.cutDCAz) { + if (!t2.has_mcParticle()) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop2DCA); + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrack2HasMCParticle); - if (config.isApplyPIDSelection && !checkPID(t2.pt(), t2.tpcNSigmaKa(), t2.tofNSigmaKa(), t2.hasTOF())) { + if (!selectionTrack(t2)) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop2PID); + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrack2PassesTrackSelection); - if (!t2.has_mcParticle()) { + if (!selectionPID(t2.tpcNSigmaKa(), t2.tofNSigmaKa(), t2.hasTOF(), config.PIDStrategy, t2.pt())) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop2MCLabel); + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrack2PassesPID); - if (t1.sign() * t2.sign() > 0) { + if (t1.sign() * t2.sign() >= 0) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop2Charge); + eventTrkSelection.fill(HIST("h1_TrackCount"), kTrackOppositeSign); auto mcKaTrk1 = t1.mcParticle(); auto mcKaTrk2 = t2.mcParticle(); @@ -365,36 +513,41 @@ struct PhiPhiMCInjected { std::abs(mcKaTrk2.pdgCode()) != PDG_t::kKPlus) { continue; } - registry.fill(HIST("h1_TrackCount"), kLoop2KaonDaughters); + eventTrkSelection.fill(HIST("h1_TrackCount"), kBothTracksAreKaons); bool foundMother = false; - // Search for common mother + // Mother (phi) from the kaon pairs for (const auto& KaMotherPhi1 : mcKaTrk1.template mothers_as()) { - for (const auto& KaMotherPhi2 : mcKaTrk2.template mothers_as()) { - registry.fill(HIST("h1_TrackCount"), kCommonMotherLoop); - if (KaMotherPhi1.globalIndex() != KaMotherPhi2.globalIndex()) continue; - registry.fill(HIST("h1_TrackCount"), kCommonMother); + + eventTrkSelection.fill(HIST("h1_TrackCount"), kCommonMotherFound); int motherPdg = KaMotherPhi1.pdgCode(); if (motherPdg != o2::constants::physics::kPhi) continue; - registry.fill(HIST("h1_TrackCount"), kPhiMother); + + eventTrkSelection.fill(HIST("h1_TrackCount"), kMotherIsPhi); daughter1Rec = ROOT::Math::PxPyPzMVector(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassKPlus); daughter2Rec = ROOT::Math::PxPyPzMVector(t2.px(), t2.py(), t2.pz(), o2::constants::physics::MassKPlus); motherRec = daughter1Rec + daughter2Rec; // Phi invariant mass window cut (0.9 - 1.1 GeV/c^2) - if (motherRec.M() < config.phiMassCutLow || motherRec.M() > config.phiMassCutHigh) { + if (motherRec.M() < config.minPhiMass || motherRec.M() > config.maxPhiMass) { continue; } - registry.fill(HIST("h1_TrackCount"), kPhiMassCut); + eventTrkSelection.fill(HIST("h1_TrackCount"), kPhiPassesMassCut); + + // Phi pT cut + if (motherRec.Pt() < config.minPhiPt || motherRec.Pt() > config.maxPhiPt) { + continue; + } + eventTrkSelection.fill(HIST("h1_TrackCount"), kPhiPassesPtCut); PhiCandidateInjected phiCand; @@ -403,13 +556,36 @@ struct PhiPhiMCInjected { phiCand.t2Index = t2.globalIndex(); phiCand.isValidMcPhi = true; + ////mother (exotic) from the phi-phi pairs for (const auto& gm : KaMotherPhi1.template mothers_as()) { - if (gm.pdgCode() == injectedMotherPDG) { - phiCand.isFrom999999 = true; - phiCand.mc999999Index = gm.globalIndex(); - registry.fill(HIST("h1_TrackCount"), kInjectedMother); + if (gm.pdgCode() != injectedMotherPDG) { + continue; } + eventTrkSelection.fill(HIST("h1_TrackCount"), kPhiHasInjectedMother); + + // grandMotherRec = ROOT::Math::PxPyPzEVector(gm.px(), gm.py(), gm.pz(), gm.e()); + + // // pT cut for the mother particle + // if (grandMotherRec.Pt() < config.minExoticPt) { + // continue; + // } + // eventTrkSelection.fill(HIST("h1_TrackCount"), 14); + + // // mass cut for the mother particle + // if (grandMotherRec.M() < config.minExoticMass || grandMotherRec.M() > config.maxExoticMass) { + // continue; + // } + // eventTrkSelection.fill(HIST("h1_TrackCount"), 15); + + // // rapidity cut for the mother particle + // if (config.isApplyRapidityCut && std::abs(grandMotherRec.Rapidity()) > config.rapidityCut) { + // continue; + // } + // eventTrkSelection.fill(HIST("h1_TrackCount"), 16); + + phiCand.isFrom999999 = true; + phiCand.mc999999Index = gm.globalIndex(); } phiCandidates.push_back(phiCand); @@ -423,58 +599,70 @@ struct PhiPhiMCInjected { } } + if (phiCandidates.size() < 2) { + return; + } + // Fill Single Reconstructed Phi Histograms (Loop ONCE per candidate) for (const auto& phi : phiCandidates) { // All Reconstructed Phi Candidates if (phi.isValidMcPhi) { - registry.fill(HIST("Reconstructed/AllPhiPairs/h1_Phi1_Mass"), phi.p4.M()); - registry.fill(HIST("Reconstructed/AllPhiPairs/h1_Phi1_Pt"), phi.p4.Pt()); - registry.fill(HIST("Reconstructed/AllPhiPairs/h1_Phi1_Eta"), phi.p4.Eta()); - registry.fill(HIST("Reconstructed/AllPhiPairs/h1_Phi1_Y"), phi.p4.Rapidity()); + registry.fill(HIST("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Mass"), phi.p4.M()); + registry.fill(HIST("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Pt"), phi.p4.Pt()); + registry.fill(HIST("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Eta"), phi.p4.Eta()); + registry.fill(HIST("Reconstructed/AllPhiPairs/Phi/h1_Phi1_Y"), phi.p4.Rapidity()); } // Phis from Mother 999999 if (phi.isFrom999999 && phi.isValidMcPhi) { - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_Phi1_Mass"), phi.p4.M()); - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_Phi1_Pt"), phi.p4.Pt()); - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_Phi1_Eta"), phi.p4.Eta()); - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_Phi1_Y"), phi.p4.Rapidity()); - } - - // Minimum Bias Phis (not from 999999) - if (!phi.isFrom999999 && phi.isValidMcPhi) { - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_Phi1_Mass"), phi.p4.M()); - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_Phi1_Pt"), phi.p4.Pt()); - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_Phi1_Eta"), phi.p4.Eta()); - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_Phi1_Y"), phi.p4.Rapidity()); + registry.fill(HIST("Reconstructed/Exotic/Phi/h1_Phi1_Mass"), phi.p4.M()); + registry.fill(HIST("Reconstructed/Exotic/Phi/h1_Phi1_Pt"), phi.p4.Pt()); + registry.fill(HIST("Reconstructed/Exotic/Phi/h1_Phi1_Eta"), phi.p4.Eta()); + registry.fill(HIST("Reconstructed/Exotic/Phi/h1_Phi1_Y"), phi.p4.Rapidity()); } } + constexpr double mPhiPDG = o2::constants::physics::MassPhi; + // Reconstruct Phi-Phi Mother Candidates (Double Loop for Pairs Only) for (size_t i = 0; i < phiCandidates.size(); ++i) { + const auto& phi1 = phiCandidates[i]; for (size_t j = i + 1; j < phiCandidates.size(); ++j) { const auto& phi2 = phiCandidates[j]; - registry.fill(HIST("h1_TrackCount"), kLoop2PhiPairs); - // Ensure all 4 kaon tracks are unique if (phi1.t1Index == phi2.t1Index || phi1.t1Index == phi2.t2Index || phi1.t2Index == phi2.t1Index || phi1.t2Index == phi2.t2Index) { continue; } - registry.fill(HIST("h1_TrackCount"), kUniqueTracks); + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kPhiPhiUniqueKaonTracks); if (!phi1.isValidMcPhi || !phi2.isValidMcPhi) { continue; } - - registry.fill(HIST("h1_TrackCount"), kValidPhiPhiPair); + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kPhiPhiBothValidPhi); // Combined 4-momentum of the Mother Phi-Phi System ROOT::Math::PxPyPzMVector phiPhiMother = phi1.p4 + phi2.p4; + double deltaM = std::hypot(phi1.p4.M() - mPhiPDG, phi2.p4.M() - mPhiPDG); + + if (phiPhiMother.Pt() < config.minExoticPt) { + continue; + } + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kPhiPhiPassesPtCut); + + if (phiPhiMother.M() < config.minExoticMass || phiPhiMother.M() > config.maxExoticMass) { + continue; + } + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kPhiPhiPassesMassCut); + + if (config.isApplyRapidityCut && std::abs(phiPhiMother.Rapidity()) > config.rapidityCut) { + continue; + } + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kPhiPhiPassesRapidityCut); // All available Phi-Phi pairs registry.fill(HIST("Reconstructed/AllPhiPairs/h2_PhiPhi_All"), phiPhiMother.M(), phiPhiMother.Pt()); @@ -484,17 +672,15 @@ struct PhiPhiMCInjected { // Phi-Phi pairs from same Mother 999999 if (phi1.isFrom999999 && phi2.isFrom999999 && (phi1.mc999999Index == phi2.mc999999Index)) { - registry.fill(HIST("Reconstructed/PhiFromT4s/h2_PhiPhi_T4s"), phiPhiMother.M(), phiPhiMother.Pt()); - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_PhiPhi_Pt"), phiPhiMother.Pt()); - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_PhiPhi_Eta"), phiPhiMother.Eta()); - registry.fill(HIST("Reconstructed/PhiFromT4s/h1_PhiPhi_Y"), phiPhiMother.Rapidity()); - } + registry.fill(HIST("Reconstructed/Exotic/h2_PhiPhi_T4s"), phiPhiMother.M(), phiPhiMother.Pt()); + registry.fill(HIST("Reconstructed/Exotic/h1_PhiPhi_Pt"), phiPhiMother.Pt()); + registry.fill(HIST("Reconstructed/Exotic/h1_PhiPhi_Eta"), phiPhiMother.Eta()); + registry.fill(HIST("Reconstructed/Exotic/h1_PhiPhi_Y"), phiPhiMother.Rapidity()); + + registry.fill(HIST("Reconstructed/Exotic/hSparse_PhiPhi_T4s"), phiPhiMother.M(), phiPhiMother.Pt(), deltaM, phi1.p4.M(), phi2.p4.M()); + registry.fill(HIST("Reconstructed/Exotic/Phi/h2_Phi"), phi1.p4.M(), phi1.p4.Pt()); - if (!phi1.isFrom999999 && !phi2.isFrom999999) { - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h2_PhiPhi_MinBias"), phiPhiMother.M(), phiPhiMother.Pt()); - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_PhiPhi_Pt"), phiPhiMother.Pt()); - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_PhiPhi_Eta"), phiPhiMother.Eta()); - registry.fill(HIST("Reconstructed/MinimumBiasPhi/h1_PhiPhi_Y"), phiPhiMother.Rapidity()); + eventTrkSelection.fill(HIST("h1_PhiPhiTrack"), kPhiPhiSameInjectedMother); } } }