From 49c08ef5665d088468ce1dd7a575cec63cc54bf4 Mon Sep 17 00:00:00 2001 From: Tonmoy Sharma Date: Tue, 23 Dec 2025 22:43:06 +0530 Subject: [PATCH 1/2] update --- PWGLF/Tasks/Nuspex/spectraTOF.cxx | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/PWGLF/Tasks/Nuspex/spectraTOF.cxx b/PWGLF/Tasks/Nuspex/spectraTOF.cxx index 978542c2c69..10fadd5c6e6 100644 --- a/PWGLF/Tasks/Nuspex/spectraTOF.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTOF.cxx @@ -78,6 +78,8 @@ std::array, NpCharge> hDecayLengthMCNotHF; // Decay Length std::array, NpCharge> hPtNumTOFMatchWithPIDSignalPrm; // Pt distribution of particles with a hit in the TOF and a compatible signal +std::array, NpCharge>, 3> hMCpdg_nsigmaTPC; //2D array of nsigmaTPC histograms [Selection: pi,K,p][True PDG: 18 species] + // Spectra task struct tofSpectra { struct : ConfigurableGroup { @@ -585,6 +587,14 @@ struct tofSpectra { histos.add("MC/MultiplicityMCINELgt0", "MC multiplicity", kTH1D, {multAxis}); histos.add("MC/MultiplicityMCINELgt1", "MC multiplicity", kTH1D, {multAxis}); } + + if (doprocessTrackMCLabels){ + for (int par = 2; par <= 4; par++){ + for (int i = 0; i < NpCharge; i++){ + hMCpdg_nsigmaTPC[par-2][i] = histos.add(Form("test_mclabels/nsigmatpc/%s/%s/pdg_%i", (i < Np) ? "pos" : "neg", pN[par], PDGs[i%Np]), Form("True %s (%i) in %s selection", pTCharge[i], PDGs[i], (i < Np) ? pTCharge[par] : pTCharge[par+Np]), kTH3D, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + } + } + } hMultiplicityvsPercentile = histos.add("Mult/vsPercentile", "Multiplicity vs percentile", HistType::kTH2D, {{150, 0, 150}, {100, 0, 100, "Track multiplicity"}}); @@ -2785,6 +2795,47 @@ struct tofSpectra { } } PROCESS_SWITCH(tofSpectra, processMCgen_RecoEvs, "process generated MC (reconstructed events)", false); + + void processTrackMCLabels(CollisionCandidates::iterator const& collisions, + soa::Join const& tracks, + aod::McTrackLabels const& mcTrackLabels, aod::McParticles const& mcParticles) + { + const float multiplicity = getMultiplicity(collisions); + + for (const auto& track : tracks) { + if (!track.has_collision()) { + continue; + } + const auto& collision = track.collision_as(); + if (!isEventSelected(collision)) { + continue; + } + if (!isTrackSelected(track, collision)) { + continue; + } + const auto& mcLabel = mcTrackLabels.iteratorAt(track.globalIndex()); + const auto& mcParticle = mcParticles.iteratorAt(mcLabel.mcParticleId()); + int pdgCode = mcParticle.pdgCode(); + + static_for<2,4>([&](auto par){ + const auto& nsigmaTPCpar = o2::aod::pidutils::tpcNSigma(track); + bool isTPCpar = std::abs(nsigmaTPCpar) < trkselOptions.cfgCutNsigma; + // Precompute rapidity values to avoid redundant calculations + double rapiditypar = std::abs(track.rapidity(PID::getMass(par))); + //TPC Selection and histogram filling + if (isTPCpar && rapiditypar <= trkselOptions.cfgCutY){ + static_for<0, 17>([&](auto i){ + if (pdgCode == PDGs[i]){ + hMCpdg_nsigmaTPC[par-2][i]->Fill(track.pt(), nsigmaTPCpar, multiplicity); + } + }); + } + }); + } + } + PROCESS_SWITCH(tofSpectra, processTrackMCLabels, "Fill track histograms using MC matched PDG labels", false); }; // end of spectra task From 492e76a623c1b205c57b5690f0ab47d96dca4478 Mon Sep 17 00:00:00 2001 From: Tonmoy Sharma Date: Wed, 24 Dec 2025 13:45:26 +0530 Subject: [PATCH 2/2] Fix whitespace and comma formatting issues in spectraTOF.cxx --- PWGLF/Tasks/Nuspex/spectraTOF.cxx | 36 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/PWGLF/Tasks/Nuspex/spectraTOF.cxx b/PWGLF/Tasks/Nuspex/spectraTOF.cxx index 10fadd5c6e6..3a24f382bff 100644 --- a/PWGLF/Tasks/Nuspex/spectraTOF.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTOF.cxx @@ -78,7 +78,7 @@ std::array, NpCharge> hDecayLengthMCNotHF; // Decay Length std::array, NpCharge> hPtNumTOFMatchWithPIDSignalPrm; // Pt distribution of particles with a hit in the TOF and a compatible signal -std::array, NpCharge>, 3> hMCpdg_nsigmaTPC; //2D array of nsigmaTPC histograms [Selection: pi,K,p][True PDG: 18 species] +std::array, NpCharge>, 3> hMCpdg_nsigmaTPC; // 2D array of nsigmaTPC histograms [Selection: pi,K,p][True PDG: 18 species] // Spectra task struct tofSpectra { @@ -587,12 +587,11 @@ struct tofSpectra { histos.add("MC/MultiplicityMCINELgt0", "MC multiplicity", kTH1D, {multAxis}); histos.add("MC/MultiplicityMCINELgt1", "MC multiplicity", kTH1D, {multAxis}); } - - if (doprocessTrackMCLabels){ - for (int par = 2; par <= 4; par++){ - for (int i = 0; i < NpCharge; i++){ - hMCpdg_nsigmaTPC[par-2][i] = histos.add(Form("test_mclabels/nsigmatpc/%s/%s/pdg_%i", (i < Np) ? "pos" : "neg", pN[par], PDGs[i%Np]), Form("True %s (%i) in %s selection", pTCharge[i], PDGs[i], (i < Np) ? pTCharge[par] : pTCharge[par+Np]), kTH3D, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); - } + if (doprocessTrackMCLabels) { + for (int par = 2; par <= 4; par++) { + for (int i = 0; i < NpCharge; i++) { + hMCpdg_nsigmaTPC[par - 2][i] = histos.add(Form("test_mclabels/nsigmatpc/%s/%s/pdg_%i", (i < Np) ? "pos" : "neg", pN[par], PDGs[i % Np]), Form("True %s (%i) in %s selection", pTCharge[i], PDGs[i], (i < Np) ? pTCharge[par] : pTCharge[par + Np]), kTH3D, {ptAxis, nsigmaTPCAxisOccupancy, multAxis}); + } } } @@ -2795,15 +2794,13 @@ struct tofSpectra { } } PROCESS_SWITCH(tofSpectra, processMCgen_RecoEvs, "process generated MC (reconstructed events)", false); - void processTrackMCLabels(CollisionCandidates::iterator const& collisions, - soa::Join const& tracks, - aod::McTrackLabels const& mcTrackLabels, aod::McParticles const& mcParticles) + soa::Join const& tracks, + aod::McTrackLabels const& mcTrackLabels, aod::McParticles const& mcParticles) { const float multiplicity = getMultiplicity(collisions); - for (const auto& track : tracks) { if (!track.has_collision()) { continue; @@ -2818,17 +2815,16 @@ struct tofSpectra { const auto& mcLabel = mcTrackLabels.iteratorAt(track.globalIndex()); const auto& mcParticle = mcParticles.iteratorAt(mcLabel.mcParticleId()); int pdgCode = mcParticle.pdgCode(); - - static_for<2,4>([&](auto par){ + static_for<2, 4>([&](auto par) { const auto& nsigmaTPCpar = o2::aod::pidutils::tpcNSigma(track); bool isTPCpar = std::abs(nsigmaTPCpar) < trkselOptions.cfgCutNsigma; // Precompute rapidity values to avoid redundant calculations double rapiditypar = std::abs(track.rapidity(PID::getMass(par))); - //TPC Selection and histogram filling - if (isTPCpar && rapiditypar <= trkselOptions.cfgCutY){ - static_for<0, 17>([&](auto i){ - if (pdgCode == PDGs[i]){ - hMCpdg_nsigmaTPC[par-2][i]->Fill(track.pt(), nsigmaTPCpar, multiplicity); + // TPC Selection and histogram filling + if (isTPCpar && rapiditypar <= trkselOptions.cfgCutY) { + static_for<0, 17>([&](auto i) { + if (pdgCode == PDGs[i]) { + hMCpdg_nsigmaTPC[par - 2][i]->Fill(track.pt(), nsigmaTPCpar, multiplicity); } }); }