From 5118cf05f30e3c8c7e533bd9174d9a6ecae19c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Jos=C3=A9?= <52935244+lucasjsilva@users.noreply.github.com> Date: Thu, 9 Apr 2026 18:06:17 +0200 Subject: [PATCH 1/2] Improvements regarding track criteria selection Monte Carlo Process function was updated to better evaluate the different criteria for track selection. Moreover, histograms for dca were included --- .../Tasks/GlobalEventProperties/studyPnch.cxx | 125 ++++++++++-------- 1 file changed, 72 insertions(+), 53 deletions(-) diff --git a/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx b/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx index 62f5e93d830..9ce3d6d2617 100644 --- a/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx +++ b/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx @@ -76,6 +76,7 @@ AxisSpec axisEvent{10, 0.5, 10.5, "#Event", "EventAxis"}; AxisSpec axisVtxZ{40, -20, 20, "Vertex Z", "VzAxis"}; AxisSpec axisEta{40, -2, 2, "#eta", "EtaAxis"}; AxisSpec axisPhi{629, 0, o2::constants::math::TwoPI, "#phi"}; +AxisSpec axisCollSel{5, 0.5, 5.5, "#Event", "CollSelAxis"}; auto static constexpr kMinCharge = 3.f; struct StudyPnch { @@ -97,6 +98,7 @@ struct StudyPnch { ConfigurableAxis ft0aMultHistBin{"ft0aMultHistBin", {501, -0.5, 500.5}, ""}; ConfigurableAxis ft0cMultHistBin{"ft0cMultHistBin", {501, -0.5, 500.5}, ""}; ConfigurableAxis ptHistBin{"ptHistBin", {200, 0., 20.}, ""}; + ConfigurableAxis binsDCA{"binsDCA", {500, -10.0f, 10.0f}, ""}; ConfigurableAxis countNumberTracks{"countNumberTracks", {10, -0.5, 9.5}, ""}; Configurable isApplyTFcut{"isApplyTFcut", true, "Enable TimeFrameBorder cut"}; @@ -105,6 +107,9 @@ struct StudyPnch { Configurable isApplyInelgt0{"isApplyInelgt0", false, "Enable INEL > 0 condition"}; Configurable isApplyExtraPhiCut{"isApplyExtraPhiCut", false, "Enable extra phi cut"}; Configurable isApplyTVX{"isApplyTVX", false, "Enable TVX trigger sel"}; + Configurable isApplyNoTrackSel{"isApplyNoTrackSel", false, "Do not consider any criteria for track selection"}; + Configurable isApplyCheckID{"isApplyCheckID", true, "Select Tracks evaluating Collision ID"}; + Configurable isApplyDuplicatedTrack{"isApplyDuplicatedTrack", true, "Select tracks that are not duplicated"}; void init(InitContext const&) { @@ -115,6 +120,7 @@ struct StudyPnch { AxisSpec axisFt0cMult = {ft0cMultHistBin, "ft0c", "FT0CMultAxis"}; AxisSpec axisPt = {ptHistBin, "pT", "pTAxis"}; AxisSpec axisCountNumberTracks = {countNumberTracks, "Count", "CountAxis"}; + AxisSpec dcaAxis = {binsDCA, "DCA vs PV"}; histos.add("EventHist", "EventHist", kTH1D, {axisEvent}, false); histos.add("VtxZHist", "VtxZHist", kTH1D, {axisVtxZ}, false); @@ -129,8 +135,19 @@ struct StudyPnch { x->SetBinLabel(6, "INEL > 0"); x->SetBinLabel(7, "|vz| < 10"); - if (doprocessData || doprocessCorrelation || doprocessMonteCarlo || doprocessModifiedMonteCarlo) { + histos.add("SelCollsHist", "SelCollsHist", kTH1D, {axisCollSel}, false); + auto hstat_colls = histos.get(HIST("SelCollsHist")); + auto* xColls = hstat_colls->GetXaxis(); + xColls->SetBinLabel(1, "All collisions"); + xColls->SetBinLabel(2, "Best Collision Selection"); + xColls->SetBinLabel(3, "Has MC Collision Selection"); + + if (doprocessData || doprocessCorrelation || doprocessMonteCarlo) { histos.add("PhiVsEtaHist", "PhiVsEtaHist", kTH2F, {axisPhi, axisEta}, false); + histos.add("EtaHist", "EtaHist", kTH1D, {axisEta}, false); + histos.add("PhiHist", "PhiHist", kTH1D, {axisPhi}, false); + histos.add("hdcaxy", "dca to pv in the xy plane", kTH1D, {dcaAxis}, false); + histos.add("hdcaz", "dca to pv in the z axis", kTH1D, {dcaAxis}, false); } if (doprocessData) { histos.add("hMultiplicityData", "hMultiplicityData", kTH1F, {axisMult}, true); @@ -143,17 +160,14 @@ struct StudyPnch { histos.add("NPVtracks_vs_GlobalMult", "NPVtracks_vs_GlobalMult", kTH2F, {axisPV, axisMult}, true); } if (doprocessMonteCarlo) { + histos.add("PhiVsEtaGenHist", "PhiVsEtaGenHist", kTH2F, {axisPhi, axisEta}, false); + histos.add("EtaGenHist", "EtaGenHist", kTH1D, {axisEta}, false); + histos.add("PhiGenHist", "PhiGenHist", kTH1D, {axisPhi}, false); histos.add("hMultiplicityMCrec", "hMultiplicityMCrec", kTH1F, {axisMult}, true); histos.add("hMultiplicityMCgen", "hMultiplicityMCgen", kTH1F, {axisMult}, true); histos.add("hResponseMatrix", "hResponseMatrix", kTH2F, {axisMult, axisMult}, true); histos.add("hCountNTracks", "hCountNTracks", kTH1F, {axisCountNumberTracks}, true); } - if (doprocessModifiedMonteCarlo) { - histos.add("hMultiplicityMCrecMod", "hMultiplicityMCrecMod", kTH1F, {axisMult}, true); - histos.add("hMultiplicityMCgenMod", "hMultiplicityMCgenMod", kTH1F, {axisMult}, true); - histos.add("hResponseMatrixMod", "hResponseMatrixMod", kTH2F, {axisMult, axisMult}, true); - histos.add("hCountNTracksMod", "hCountNTracksMod", kTH1F, {axisCountNumberTracks}, true); - } if (doprocessEvtLossSigLossMC) { histos.add("MCEventHist", "MCEventHist", kTH1F, {axisEvent}, false); auto hstat = histos.get(HIST("MCEventHist")); @@ -242,6 +256,10 @@ struct StudyPnch { if (!isTrackSelected(track)) { continue; } + histos.fill(HIST("hdcaxy"), track.dcaXY()); + histos.fill(HIST("hdcaz"), track.dcaZ()); + histos.fill(HIST("EtaHist"), track.eta()); + histos.fill(HIST("PhiHist"), track.phi()); histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); nTrk++; } @@ -256,11 +274,12 @@ struct StudyPnch { if (!isGenTrackSelected(track)) { continue; } - if (track.mcCollisionId() != McCol.globalIndex()) { + if (track.mcCollisionId() != McCol.mcCollisionId()) { continue; } - - histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); + histos.fill(HIST("EtaGenHist"), track.eta()); + histos.fill(HIST("PhiGenHist"), track.phi()); + histos.fill(HIST("PhiVsEtaGenHist"), track.phi(), track.eta()); nTrk++; } return nTrk; @@ -271,29 +290,33 @@ struct StudyPnch { { auto nTrk = 0; std::unordered_map recoFrequencies; // Map that stores globalIndex and the times it appears + std::vector mcRecIDs; for (const auto& track : tracks) { if (!isTrackSelected(track)) { continue; } - if (track.has_mcParticle()) { + if (isApplyNoTrackSel) { + nTrk++; + } + if (isApplyCheckID && track.has_mcParticle()) { auto particle = track.mcParticle(); if (particle.mcCollisionId() != McCol.mcCollisionId()) { continue; } - auto globalIndex = particle.globalIndex(); - recoFrequencies[globalIndex]++; // Increment the count for this globalIndex - } - histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); - } - // Loop to fill the histogram without cloned tracks - for (const auto& [globalIndex, frequency] : recoFrequencies) { - histos.fill(HIST("hCountNTracks"), frequency); - // Fill histogram with not cloned tracks - if (frequency == 1) { + if (isApplyDuplicatedTrack) { + if (find(mcRecIDs.begin(), mcRecIDs.end(), particle.globalIndex()) != mcRecIDs.end()) { + continue; + } + } + mcRecIDs.push_back(particle.globalIndex()); nTrk++; } + histos.fill(HIST("hdcaxy"), track.dcaXY()); + histos.fill(HIST("hdcaz"), track.dcaZ()); + histos.fill(HIST("EtaHist"), track.eta()); + histos.fill(HIST("PhiHist"), track.phi()); + histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); } - // return recoFrequencies; return nTrk; } @@ -328,47 +351,32 @@ struct StudyPnch { histos.fill(HIST("NPVtracks_vs_GlobalMult"), cols.multNTracksPV(), mult); } - void processMonteCarlo(ColMCTrueTable::iterator const& mcCollision, ColMCRecTable const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) - { - for (const auto& RecCol : RecCols) { - if (!isEventSelected(RecCol)) { - continue; - } - auto recTracksPart = RecTracks.sliceBy(perCollision, RecCol.globalIndex()); - auto multrec = countNTracksMcCol(recTracksPart, RecCol); - if (multrec > 0) { - histos.fill(HIST("hMultiplicityMCrec"), multrec); - } - auto multgen = countGenTracks(GenParticles, mcCollision); - if (multgen > 0 && multrec > 0) { - histos.fill(HIST("hMultiplicityMCgen"), multgen); - histos.fill(HIST("hResponseMatrix"), multrec, multgen); - } - } - } - - void processModifiedMonteCarlo(soa::Join::iterator const& mcCollision, ColMCRecTable const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + void processMonteCarlo(soa::Join::iterator const& mcCollision, ColMCRecTable const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) { + std::vector mclabels; for (const auto& RecCol : RecCols) { if (!isEventSelected(RecCol)) { continue; } + histos.fill(HIST("SelCollsHist"), 1); // Evaluation of reconstructed collisions with more than 1 contributor if (RecCol.globalIndex() != mcCollision.bestCollisionIndex()) { continue; } + histos.fill(HIST("SelCollsHist"), 2); if (!RecCol.has_mcCollision()) { continue; } + histos.fill(HIST("SelCollsHist"), 3); auto recTracksPart = RecTracks.sliceBy(perCollision, RecCol.globalIndex()); auto multrec = countNTracksMcCol(recTracksPart, RecCol); if (multrec > 0) { - histos.fill(HIST("hMultiplicityMCrecMod"), multrec); + histos.fill(HIST("hMultiplicityMCrec"), multrec); } - auto multgen = countGenTracks(GenParticles, mcCollision); + auto multgen = countGenTracks(GenParticles, RecCol); if (multgen > 0 && multrec > 0) { - histos.fill(HIST("hMultiplicityMCgenMod"), multgen); - histos.fill(HIST("hResponseMatrixMod"), multrec, multgen); + histos.fill(HIST("hMultiplicityMCgen"), multgen); + histos.fill(HIST("hResponseMatrix"), multrec, multgen); } } } @@ -386,9 +394,15 @@ struct StudyPnch { } // All generated events histos.fill(HIST("MCEventHist"), 1); - auto multAll = countGenTracks(GenParticles, mcCollision); - if (multAll > 0) { - histos.fill(HIST("hMultiplicityMCgenAll"), multAll); + auto nTrk_multAll = 0; + for (const auto& GenParticle : GenParticles) { + if (!isGenTrackSelected(GenParticle)) { + continue; + } + nTrk_multAll++; + } + if (nTrk_multAll > 0) { + histos.fill(HIST("hMultiplicityMCgenAll"), nTrk_multAll); } bool atLeastOne = false; @@ -407,9 +421,15 @@ struct StudyPnch { if (atLeastOne) { histos.fill(HIST("MCEventHist"), 2); - auto multSel = countGenTracks(GenParticles, mcCollision); - if (multSel > 0) { - histos.fill(HIST("hMultiplicityMCgenSel"), multSel); + auto nTrk_multSel = 0; + for (const auto& GenParticle : GenParticles) { + if (!isGenTrackSelected(GenParticle)) { + continue; + } + nTrk_multSel++; + } + if (nTrk_multSel > 0) { + histos.fill(HIST("hMultiplicityMCgenSel"), nTrk_multSel); } } } @@ -417,7 +437,6 @@ struct StudyPnch { PROCESS_SWITCH(StudyPnch, processData, "process data CentFT0C", false); PROCESS_SWITCH(StudyPnch, processCorrelation, "do correlation study in data", false); PROCESS_SWITCH(StudyPnch, processMonteCarlo, "process MC CentFT0C", false); - PROCESS_SWITCH(StudyPnch, processModifiedMonteCarlo, "process MC CentFT0C", false); PROCESS_SWITCH(StudyPnch, processEvtLossSigLossMC, "process Signal Loss, Event Loss", false); }; From 1d99fa53bef7e2bb0d3052a09f0dc125fd2a7acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Jos=C3=A9?= <52935244+lucasjsilva@users.noreply.github.com> Date: Thu, 9 Apr 2026 18:40:58 +0200 Subject: [PATCH 2/2] Improvements in the track criteria selection and exclusion of unused variables --- PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx b/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx index 9ce3d6d2617..35ad555d467 100644 --- a/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx +++ b/PWGLF/Tasks/GlobalEventProperties/studyPnch.cxx @@ -107,7 +107,6 @@ struct StudyPnch { Configurable isApplyInelgt0{"isApplyInelgt0", false, "Enable INEL > 0 condition"}; Configurable isApplyExtraPhiCut{"isApplyExtraPhiCut", false, "Enable extra phi cut"}; Configurable isApplyTVX{"isApplyTVX", false, "Enable TVX trigger sel"}; - Configurable isApplyNoTrackSel{"isApplyNoTrackSel", false, "Do not consider any criteria for track selection"}; Configurable isApplyCheckID{"isApplyCheckID", true, "Select Tracks evaluating Collision ID"}; Configurable isApplyDuplicatedTrack{"isApplyDuplicatedTrack", true, "Select tracks that are not duplicated"}; @@ -289,24 +288,18 @@ struct StudyPnch { int countNTracksMcCol(countTrk const& tracks, McColType const& McCol) { auto nTrk = 0; - std::unordered_map recoFrequencies; // Map that stores globalIndex and the times it appears std::vector mcRecIDs; for (const auto& track : tracks) { if (!isTrackSelected(track)) { continue; } - if (isApplyNoTrackSel) { - nTrk++; - } - if (isApplyCheckID && track.has_mcParticle()) { + if (track.has_mcParticle()) { auto particle = track.mcParticle(); - if (particle.mcCollisionId() != McCol.mcCollisionId()) { + if (isApplyCheckID && particle.mcCollisionId() != McCol.mcCollisionId()) { continue; } - if (isApplyDuplicatedTrack) { - if (find(mcRecIDs.begin(), mcRecIDs.end(), particle.globalIndex()) != mcRecIDs.end()) { - continue; - } + if (isApplyDuplicatedTrack && find(mcRecIDs.begin(), mcRecIDs.end(), particle.globalIndex()) != mcRecIDs.end()) { + continue; } mcRecIDs.push_back(particle.globalIndex()); nTrk++; @@ -353,7 +346,6 @@ struct StudyPnch { void processMonteCarlo(soa::Join::iterator const& mcCollision, ColMCRecTable const& RecCols, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) { - std::vector mclabels; for (const auto& RecCol : RecCols) { if (!isEventSelected(RecCol)) { continue;