From a540747b9cf43803197ba46e411ef824081151f6 Mon Sep 17 00:00:00 2001 From: Preet Pati Date: Wed, 3 Dec 2025 14:39:04 +0100 Subject: [PATCH 1/3] Addition of MC truth process --- .../Tasks/pidDiHadron.cxx | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx index 8ff601aabb9..551809ece8d 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx @@ -183,9 +183,11 @@ struct PidDiHadron { // make the filters and cuts. Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex); - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + using FilteredCollisions = soa::Filtered>; using FilteredTracks = soa::Filtered>; + using FilteredMcTracks = soa::Filtered>; using V0TrackCandidate = aod::V0Datas; Preslice perCollision = aod::track::collisionId; @@ -356,7 +358,7 @@ struct PidDiHadron { massAxisReso = {resoSwitchVals[kMassBins][iPhi], resoCutVals[kMassMin][iPhi], resoCutVals[kMassMax][iPhi], "M_{K^{+}K^{-}} (GeV/c^{2})"}; // Event Counter - if ((doprocessSame || doprocessSameReso) && cfgUseAdditionalEventCut) { + if ((doprocessSame || doprocessSameReso || doprocessMC) && cfgUseAdditionalEventCut) { histos.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{15, -0.5, 14.5}}}); histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFilteredEvents + 1, "Filtered event"); histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAfterSel8 + 1, "After sel8"); @@ -512,6 +514,15 @@ struct PidDiHadron { if (doprocessMixed || doprocessMixedReso) { histos.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); } + if (doprocessMC) { + histos.add("hNsigmaPionSelected", "hNsigmaPionSelected", {HistType::kTH1D, {axisPt}}); + histos.add("hNsigmaKaonSelected", "hNsigmaKaonSelected", {HistType::kTH1D, {axisPt}}); + histos.add("hNsigmaProtonSelected", "hNsigmaProtonSelected", {HistType::kTH1D, {axisPt}}); + + histos.add("hNsigmaPionTrue", "hNsigmaPionTrue", {HistType::kTH1D, {axisPt}}); + histos.add("hNsigmaKaonTrue", "hNsigmaKaonTrue", {HistType::kTH1D, {axisPt}}); + histos.add("hNsigmaProtonTrue", "hNsigmaProtonTrue", {HistType::kTH1D, {axisPt}}); + } histos.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event @@ -1467,6 +1478,58 @@ struct PidDiHadron { } } PROCESS_SWITCH(PidDiHadron, processMixedReso, "Process mixed events", true); + + void processMC(FilteredCollisions::iterator const& collision, FilteredMcTracks const& tracksmc, aod::BCsWithTimestamps const&, aod::McParticles const&) + { + float cent = -1.; + if (!cfgCentTableUnavailable) + cent = getCentrality(collision); + if (cfgUseAdditionalEventCut && !selectionEvent(collision, tracksmc.size(), cent, true)) + return; + + if (cfgSelCollByNch && (tracksmc.size() < cfgCutMultMin || tracksmc.size() >= cfgCutMultMax)) { + return; + } + if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) { + return; + } + + // loop over all tracks + for (auto const& track : tracksmc) { + + if (!trackSelected(track)) + continue; + + int pidIndex = getNsigmaPID(track); + + // Check the PDG code for the particles (MC truth) and match with analysed Nsigma PID + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kPiPlus) { + histos.fill(HIST("hNsigmaPionTrue"), track.pt()); + + if (pidIndex == kPions) { + histos.fill(HIST("hNsigmaPionSelected"), track.pt()); + } + } // Pion condition + + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kKPlus) { + histos.fill(HIST("hNsigmaKaonTrue"), track.pt()); + + if (pidIndex == kKaons) { + histos.fill(HIST("hNsigmaKaonSelected"), track.pt()); + } + } // Kaon condition + + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kProton) { + histos.fill(HIST("hNsigmaProtonTrue"), track.pt()); + + if (pidIndex == kProtons) { + histos.fill(HIST("hNsigmaProtonSelected"), track.pt()); + } + } // Proton condition + + } // end of tracks MC loop + } // end of process MC + PROCESS_SWITCH(PidDiHadron, processMC, "Process Monte Carlo", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 3fc160a96ed5b169ff0903cd6631931421405693 Mon Sep 17 00:00:00 2001 From: Preet Pati Date: Wed, 3 Dec 2025 18:12:04 +0100 Subject: [PATCH 2/3] Addition of nsigma particle count histograms --- .../Tasks/pidDiHadron.cxx | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx index 551809ece8d..4217223d461 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx @@ -515,13 +515,17 @@ struct PidDiHadron { histos.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}}); } if (doprocessMC) { + histos.add("hNsigmaPionTruePositives", "hNsigmaPionTruePositives", {HistType::kTH1D, {axisPt}}); // Fraction of particles that are pions and selected as pions + histos.add("hNsigmaKaonTruePositives", "hNsigmaKaonTruePositives", {HistType::kTH1D, {axisPt}}); // Fraction of particles that are kaons and selected as kaons + histos.add("hNsigmaProtonTruePositives", "hNsigmaProtonTruePositives", {HistType::kTH1D, {axisPt}}); // Fraction of particles that are protons and selected as protons + histos.add("hNsigmaPionSelected", "hNsigmaPionSelected", {HistType::kTH1D, {axisPt}}); histos.add("hNsigmaKaonSelected", "hNsigmaKaonSelected", {HistType::kTH1D, {axisPt}}); histos.add("hNsigmaProtonSelected", "hNsigmaProtonSelected", {HistType::kTH1D, {axisPt}}); - histos.add("hNsigmaPionTrue", "hNsigmaPionTrue", {HistType::kTH1D, {axisPt}}); - histos.add("hNsigmaKaonTrue", "hNsigmaKaonTrue", {HistType::kTH1D, {axisPt}}); - histos.add("hNsigmaProtonTrue", "hNsigmaProtonTrue", {HistType::kTH1D, {axisPt}}); + histos.add("hNsigmaPionTrue", "hNsigmaPionTrue", {HistType::kTH1D, {axisPt}}); // All true pions from MC + histos.add("hNsigmaKaonTrue", "hNsigmaKaonTrue", {HistType::kTH1D, {axisPt}}); // All true kaons from MC + histos.add("hNsigmaProtonTrue", "hNsigmaProtonTrue", {HistType::kTH1D, {axisPt}}); // All true protons from MC } histos.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event @@ -1502,12 +1506,20 @@ struct PidDiHadron { int pidIndex = getNsigmaPID(track); + // Fill Counts for selection through Nsigma cuts + if (pidIndex == kPions) + histos.fill(HIST("hNsigmaPionSelected"), track.pt()); + if (pidIndex == kKaons) + histos.fill(HIST("hNsigmaKaonSelected"), track.pt()); + if (pidIndex == kProtons) + histos.fill(HIST("hNsigmaProtonSelected"), track.pt()); + // Check the PDG code for the particles (MC truth) and match with analysed Nsigma PID if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kPiPlus) { histos.fill(HIST("hNsigmaPionTrue"), track.pt()); if (pidIndex == kPions) { - histos.fill(HIST("hNsigmaPionSelected"), track.pt()); + histos.fill(HIST("hNsigmaPionTruePositives"), track.pt()); } } // Pion condition @@ -1515,7 +1527,7 @@ struct PidDiHadron { histos.fill(HIST("hNsigmaKaonTrue"), track.pt()); if (pidIndex == kKaons) { - histos.fill(HIST("hNsigmaKaonSelected"), track.pt()); + histos.fill(HIST("hNsigmaKaonTruePositives"), track.pt()); } } // Kaon condition @@ -1523,7 +1535,7 @@ struct PidDiHadron { histos.fill(HIST("hNsigmaProtonTrue"), track.pt()); if (pidIndex == kProtons) { - histos.fill(HIST("hNsigmaProtonSelected"), track.pt()); + histos.fill(HIST("hNsigmaProtonTruePositives"), track.pt()); } } // Proton condition From 54c30b1fc968f1502cbc4fa077698fa8b34352b9 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 3 Dec 2025 17:13:06 +0000 Subject: [PATCH 3/3] Please consider the following formatting changes --- PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx index 4217223d461..40e73e8ee0e 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx @@ -183,7 +183,7 @@ struct PidDiHadron { // make the filters and cuts. Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex); - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz); using FilteredCollisions = soa::Filtered>; using FilteredTracks = soa::Filtered>;