1212// / \file studyPnch.cxx
1313// /
1414// / \brief task for analysis of charged-particle multiplicity distributions
15- // / \author Abhi Modak (abhi.modak@cern.ch)
15+ // / \author Abhi Modak (abhi.modak@cern.ch), Lucas José (lucas.jose.franco.da.silva@cern.ch)
1616// / \since September 10, 2025
1717
1818#include " PWGLF/DataModel/LFStrangenessTables.h"
4242
4343#include < cmath>
4444#include < cstdlib>
45+ #include < unordered_map>
4546#include < vector>
4647
4748using namespace o2 ;
@@ -96,6 +97,7 @@ struct StudyPnch {
9697 ConfigurableAxis ft0aMultHistBin{" ft0aMultHistBin" , {501 , -0.5 , 500.5 }, " " };
9798 ConfigurableAxis ft0cMultHistBin{" ft0cMultHistBin" , {501 , -0.5 , 500.5 }, " " };
9899 ConfigurableAxis ptHistBin{" ptHistBin" , {200 , 0 ., 20 .}, " " };
100+ ConfigurableAxis countNumberTracks{" countNumberTracks" , {10 , -0.5 , 9.5 }, " " };
99101
100102 Configurable<bool > isApplyTFcut{" isApplyTFcut" , true , " Enable TimeFrameBorder cut" };
101103 Configurable<bool > isApplyITSROcut{" isApplyITSROcut" , true , " Enable ITS ReadOutFrameBorder cut" };
@@ -112,6 +114,7 @@ struct StudyPnch {
112114 AxisSpec axisFt0aMult = {ft0aMultHistBin, " ft0a" , " FT0AMultAxis" };
113115 AxisSpec axisFt0cMult = {ft0cMultHistBin, " ft0c" , " FT0CMultAxis" };
114116 AxisSpec axisPt = {ptHistBin, " pT" , " pTAxis" };
117+ AxisSpec axisCountNumberTracks = {countNumberTracks, " Count" , " CountAxis" };
115118
116119 histos.add (" EventHist" , " EventHist" , kTH1D , {axisEvent}, false );
117120 histos.add (" VtxZHist" , " VtxZHist" , kTH1D , {axisVtxZ}, false );
@@ -143,6 +146,7 @@ struct StudyPnch {
143146 histos.add (" hMultiplicityMCrec" , " hMultiplicityMCrec" , kTH1F , {axisMult}, true );
144147 histos.add (" hMultiplicityMCgen" , " hMultiplicityMCgen" , kTH1F , {axisMult}, true );
145148 histos.add (" hResponseMatrix" , " hResponseMatrix" , kTH2F , {axisMult, axisMult}, true );
149+ histos.add (" hCountNTracks" , " hCountNTracks" , kTH1F , {axisCountNumberTracks}, true );
146150 }
147151 if (doprocessEvtLossSigLossMC) {
148152 histos.add (" MCEventHist" , " MCEventHist" , kTH1F , {axisEvent}, false );
@@ -261,6 +265,7 @@ struct StudyPnch {
261265 int countNTracksMcCol (countTrk const & tracks, McColType const & McCol)
262266 {
263267 auto nTrk = 0 ;
268+ std::unordered_map<int , int > recoFrequencies; // Map that stores globalIndex and the times it appears
264269 for (const auto & track : tracks) {
265270 if (!isTrackSelected (track)) {
266271 continue ;
@@ -271,18 +276,23 @@ struct StudyPnch {
271276 if (particle.mcCollisionId () != McCol.mcCollisionId ()) {
272277 continue ;
273278 }
279+ auto globalIndex = particle.globalIndex ();
280+ recoFrequencies[globalIndex]++; // Increment the count for this globalIndex
274281 }
275282 histos.fill (HIST (" PhiVsEtaHist" ), track.phi (), track.eta ());
276- nTrk++;
277283 }
284+ // Once all the frequencies have been counted, a loop can be made to fill the histogram
285+ for (const auto & [globalIndex, frequency] : recoFrequencies) {
286+ histos.fill (HIST (" hCountNTracks" ), frequency);
287+ // Fill histogram with not cloned tracks
288+ if (frequency == 1 ) {
289+ nTrk++;
290+ }
291+ }
292+ // return recoFrequencies;
278293 return nTrk;
279294 }
280295
281- bool isINELgt0 (auto nTrk)
282- {
283- return nTrk > 0 ;
284- }
285-
286296 Filter fTrackSelectionITS = ncheckbit(aod::track::v001::detectorMap, (uint8_t )o2::aod::track::ITS) &&
287297 ncheckbit (aod::track::trackCutFlag, TrackSelectionIts);
288298 Filter fTrackSelectionTPC = ifnode(ncheckbit(aod::track::v001::detectorMap, (uint8_t )o2::aod::track::TPC),
@@ -296,7 +306,7 @@ struct StudyPnch {
296306 return ;
297307 }
298308 auto mult = countNTracks (tracks);
299- if (isINELgt0 ( mult) ) {
309+ if (mult > 0 ) {
300310 histos.fill (HIST (" hMultiplicityData" ), mult);
301311 }
302312 }
0 commit comments