diff --git a/PWGLF/Tasks/Nuspex/spectraTOF.cxx b/PWGLF/Tasks/Nuspex/spectraTOF.cxx index 82aa3de2e14..414b3588e9f 100644 --- a/PWGLF/Tasks/Nuspex/spectraTOF.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTOF.cxx @@ -19,6 +19,7 @@ // O2 includes #include +#include #include "ReconstructionDataFormats/Track.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -69,7 +70,8 @@ std::array, NpCharge> hDecayLengthMCBeauty; // Decay Length std::array, NpCharge> hDecayLengthMCNotHF; // Decay Length in the MC for particles from not a HF // Spectra task -struct tofSpectra { +// o2-linter: disable=name/workflow-file +struct tofSpectra { // o2-linter: disable=name/struct struct : ConfigurableGroup { Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgINELCut{"cfgINELCut", 0, "INEL event selection: 0 no sel, 1 INEL>0, 2 INEL>1"}; @@ -84,6 +86,7 @@ struct tofSpectra { struct : ConfigurableGroup { Configurable cfgCutEtaMax{"cfgCutEtaMax", 0.8f, "Max eta range for tracks"}; + Configurable cfgCutNsigma{"cfgCutNsigma", 10.0f, "nsigma cut range for tracks"}; Configurable cfgCutEtaMin{"cfgCutEtaMin", -0.8f, "Min eta range for tracks"}; Configurable cfgCutY{"cfgCutY", 0.5f, "Y range for tracks"}; Configurable lastRequiredTrdCluster{"lastRequiredTrdCluster", 5, "Last cluster to require in TRD for track selection. -1 does not require any TRD cluster"}; @@ -335,6 +338,8 @@ struct tofSpectra { histos.add("Mult/TPC", "MultTPC", HistType::kTH1D, {{binsOptions.binsMultiplicity, "MultTPC"}}); histos.add("Mult/NTracksPV", "MultNTracksPV", HistType::kTH1D, {{binsOptions.binsMultiplicity, "MultNTracksPV"}}); histos.add("Mult/NTracksPVeta1", "MultNTracksPVeta1", HistType::kTH1D, {{binsOptions.binsMultiplicity, "MultNTracksPVeta1"}}); + histos.add("test_occupancy/tpcCount", "TPC Track Count", HistType::kTH1F, {{100, 0, 10000, "Number of TPC Tracks"}}); + histos.add("test_occupancy/tofCount", "TOF Track Count", HistType::kTH1F, {{100, 0, 10000, "Number of TOF Tracks"}}); const AxisSpec dcaXyAxis{binsOptions.binsDca, "DCA_{xy} (cm)"}; const AxisSpec phiAxis{200, 0, 7, "#it{#varphi} (rad)"}; @@ -461,12 +466,18 @@ struct tofSpectra { histos.add("MC/test/pr/pos/prm/pt/den", "generated MC p", kTHnSparseD, {ptAxis, impParamAxis}); histos.add("MC/test/pr/neg/prm/pt/den", "generated MC #bar{p}", kTHnSparseD, {ptAxis, impParamAxis}); if (doprocessMCgen_RecoEvs) { - histos.add("MC/test/RecoEvs/pi/pos/prm/pt/den", "generated MC #pi^{+} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); - histos.add("MC/test/RecoEvs/pi/neg/prm/pt/den", "generated MC #pi^{-} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); - histos.add("MC/test/RecoEvs/ka/pos/prm/pt/den", "generated MC K^{+} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); - histos.add("MC/test/RecoEvs/ka/neg/prm/pt/den", "generated MC K^{-} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); - histos.add("MC/test/RecoEvs/pr/pos/prm/pt/den", "generated MC p from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); - histos.add("MC/test/RecoEvs/pr/neg/prm/pt/den", "generated MC #bar{p} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pi/pos/prm/pt/num", "generated MC #pi^{+} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pi/neg/prm/pt/num", "generated MC #pi^{-} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/ka/pos/prm/pt/num", "generated MC K^{+} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/ka/neg/prm/pt/num", "generated MC K^{-} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pr/pos/prm/pt/num", "generated MC p from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pr/neg/prm/pt/num", "generated MC #bar{p} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pi/pos/prm/pt/numtof", "generated MC #pi^{+} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pi/neg/prm/pt/numtof", "generated MC #pi^{-} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/ka/pos/prm/pt/numtof", "generated MC K^{+} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/ka/neg/prm/pt/numtof", "generated MC K^{-} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pr/pos/prm/pt/numtof", "generated MC p from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); + histos.add("MC/test/RecoEvs/pr/neg/prm/pt/numtof", "generated MC #bar{p} from recons. events", kTHnSparseD, {ptAxis, impParamAxis}); } } auto hh = histos.add("MC/GenRecoCollisions", "Generated and Reconstructed MC Collisions", kTH1D, {{10, 0.5, 10.5}}); @@ -1097,7 +1108,7 @@ struct tofSpectra { return false; } } - return (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)))); + return (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)))); // o2-linter: disable=std-prefix } return track.isGlobalTrack(); } @@ -1334,71 +1345,97 @@ struct tofSpectra { aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr> const& tracks) { - if (!isEventSelected(collision)) { + // Event selection criteria + if (!collision.sel8() || std::abs(collision.posZ()) > 10 || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || + !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || + !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || + !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { return; } + histos.fill(HIST("test_occupancy/event/vertexz"), collision.posZ()); + + // Multiplicity and occupancy int occupancy = collision.trackOccupancyInTimeRange(); - const float multiplicity = collision.centFT0C(); + const float multiplicity = getMultiplicity(collision); histos.fill(HIST("nsigmatpc/test_occupancy/Mult_vs_Occupancy"), multiplicity, occupancy); + + int tpcCount = 0, tofCount = 0; + for (const auto& track : tracks) { - if (!isTrackSelected(track, collision)) { + // Track selection criteria + if (track.tpcNClsCrossedRows() < 70 || track.tpcChi2NCl() > 4 || track.tpcChi2NCl() < 0.5 || + track.itsChi2NCl() > 36 || std::abs(track.dcaXY()) > 0.05 || std::abs(track.dcaZ()) > 2.0 || + std::abs(track.eta()) > 0.8 || track.tpcCrossedRowsOverFindableCls() < 0.8 || track.tpcNClsFound() < 100 || + !(o2::aod::track::ITSrefit) || !(o2::aod::track::TPCrefit)) { continue; } - if (std::abs(track.rapidity(PID::getMass(2))) > trkselOptions.cfgCutY) { - return; - } - if (std::abs(track.rapidity(PID::getMass(3))) > trkselOptions.cfgCutY) { - return; - } - if (std::abs(track.rapidity(PID::getMass(4))) > trkselOptions.cfgCutY) { - return; - } - if (includeCentralityToTracks) { + const auto& nsigmaTPCPi = o2::aod::pidutils::tpcNSigma<2>(track); + ; + const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); + const auto& nsigmaTPCPr = o2::aod::pidutils::tpcNSigma<4>(track); + + bool isTPCPion = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; + bool isTPCKaon = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; + bool isTPCProton = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; + + const auto& nsigmaTOFPi = o2::aod::pidutils::tofNSigma<2>(track); + const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); + const auto& nsigmaTOFPr = o2::aod::pidutils::tofNSigma<4>(track); + bool isTOFPion = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; + bool isTOFKaon = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; + bool isTOFProton = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; + + // Apply rapidity cut for identified particles + if (isTPCPion && std::abs(track.rapidity(PID::getMass(2))) < trkselOptions.cfgCutY) { + tpcCount++; if (track.sign() > 0) { - if (track.hasITS() && track.hasTPC() && track.hasTOF()) { - histos.fill(HIST("Data/cent/pos/pt/its_tpc_tof"), track.pt(), collision.centFT0C(), occupancy); - } - if (track.hasITS() && track.hasTOF()) { - histos.fill(HIST("Data/cent/pos/pt/its_tof"), track.pt(), collision.centFT0C(), occupancy); - } - if (track.hasITS() && track.hasTPC()) { - histos.fill(HIST("Data/cent/pos/pt/its_tpc"), track.pt(), collision.centFT0C(), occupancy); - } + histos.fill(HIST("nsigmatpc/test_occupancy/pos/pi"), track.pt(), nsigmaTPCPi, multiplicity, occupancy); } else { - if (track.hasITS() && track.hasTPC() && track.hasTOF()) { - histos.fill(HIST("Data/cent/neg/pt/its_tpc_tof"), track.pt(), collision.centFT0C(), occupancy); - } - if (track.hasITS() && track.hasTPC()) { - histos.fill(HIST("Data/cent/neg/pt/its_tpc"), track.pt(), collision.centFT0C(), occupancy); - } - if (track.hasITS() && track.hasTOF()) { - histos.fill(HIST("Data/cent/neg/pt/its_tof"), track.pt(), collision.centFT0C(), occupancy); - } + histos.fill(HIST("nsigmatpc/test_occupancy/neg/pi"), track.pt(), nsigmaTPCPi, multiplicity, occupancy); + } + } else if (isTPCKaon && std::abs(track.rapidity(PID::getMass(3))) < trkselOptions.cfgCutY) { + tpcCount++; + if (track.sign() > 0) { + histos.fill(HIST("nsigmatpc/test_occupancy/pos/ka"), track.pt(), nsigmaTPCKa, multiplicity, occupancy); + } else { + histos.fill(HIST("nsigmatpc/test_occupancy/neg/ka"), track.pt(), nsigmaTPCKa, multiplicity, occupancy); + } + } else if (isTPCProton && std::abs(track.rapidity(PID::getMass(4))) < trkselOptions.cfgCutY) { + tpcCount++; + if (track.sign() > 0) { + histos.fill(HIST("nsigmatpc/test_occupancy/pos/pr"), track.pt(), nsigmaTPCPr, multiplicity, occupancy); + } else { + histos.fill(HIST("nsigmatpc/test_occupancy/neg/pr"), track.pt(), nsigmaTPCPr, multiplicity, occupancy); } } - if (track.sign() > 0) { - histos.fill(HIST("nsigmatpc/test_occupancy/pos/pi"), track.pt(), track.tpcNSigmaPi(), multiplicity, occupancy); - histos.fill(HIST("nsigmatpc/test_occupancy/pos/ka"), track.pt(), track.tpcNSigmaKa(), multiplicity, occupancy); - histos.fill(HIST("nsigmatpc/test_occupancy/pos/pr"), track.pt(), track.tpcNSigmaPr(), multiplicity, occupancy); - } else if (track.sign() < 0) { - histos.fill(HIST("nsigmatpc/test_occupancy/neg/pi"), track.pt(), track.tpcNSigmaPi(), multiplicity, occupancy); - histos.fill(HIST("nsigmatpc/test_occupancy/neg/ka"), track.pt(), track.tpcNSigmaKa(), multiplicity, occupancy); - histos.fill(HIST("nsigmatpc/test_occupancy/neg/pr"), track.pt(), track.tpcNSigmaPr(), multiplicity, occupancy); - } - if (!track.hasTOF()) { - return; + + // TOF PID histograms + if (isTOFPion && std::abs(track.rapidity(PID::getMass(2))) < trkselOptions.cfgCutY) { + tofCount++; + if (track.sign() > 0) { + histos.fill(HIST("nsigmatof/test_occupancy/pos/pi"), track.pt(), nsigmaTOFPi, multiplicity, occupancy); + } else { + histos.fill(HIST("nsigmatof/test_occupancy/neg/pi"), track.pt(), nsigmaTOFPi, multiplicity, occupancy); + } + } else if (isTOFKaon && std::abs(track.rapidity(PID::getMass(3))) < trkselOptions.cfgCutY) { + tofCount++; + if (track.sign() > 0) { + histos.fill(HIST("nsigmatof/test_occupancy/pos/ka"), track.pt(), nsigmaTOFKa, multiplicity, occupancy); + } else { + histos.fill(HIST("nsigmatof/test_occupancy/neg/ka"), track.pt(), nsigmaTOFKa, multiplicity, occupancy); + } + } else if (isTOFProton && std::abs(track.rapidity(PID::getMass(4))) < trkselOptions.cfgCutY) { + tofCount++; + if (track.sign() > 0) { + histos.fill(HIST("nsigmatof/test_occupancy/pos/pr"), track.pt(), nsigmaTOFPr, multiplicity, occupancy); + } else { + histos.fill(HIST("nsigmatof/test_occupancy/neg/pr"), track.pt(), nsigmaTOFPr, multiplicity, occupancy); + } } - if (track.sign() > 0) { - histos.fill(HIST("nsigmatof/test_occupancy/pos/pi"), track.pt(), track.tofNSigmaPi(), multiplicity, occupancy); - histos.fill(HIST("nsigmatof/test_occupancy/pos/ka"), track.pt(), track.tofNSigmaKa(), multiplicity, occupancy); - histos.fill(HIST("nsigmatof/test_occupancy/pos/pr"), track.pt(), track.tofNSigmaPr(), multiplicity, occupancy); - } else if (track.sign() < 0) { - histos.fill(HIST("nsigmatof/test_occupancy/neg/pi"), track.pt(), track.tofNSigmaPi(), multiplicity, occupancy); - histos.fill(HIST("nsigmatof/test_occupancy/neg/ka"), track.pt(), track.tofNSigmaKa(), multiplicity, occupancy); - histos.fill(HIST("nsigmatof/test_occupancy/neg/pr"), track.pt(), track.tofNSigmaPr(), multiplicity, occupancy); - } - } // track + } + histos.fill(HIST("test_occupancy/tpcCount"), tpcCount); + histos.fill(HIST("test_occupancy/tofCount"), tofCount); } // process function PROCESS_SWITCH(tofSpectra, processOccupancy, "check for occupancy plots", false); @@ -1458,7 +1495,7 @@ struct tofSpectra { PROCESS_SWITCH(tofSpectra, process##processorName##inputPid, Form("Process for the %s hypothesis from %s tables", #particleId, #processorName), false); // Full tables -#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(Full, inputPid, particleId, true, TOFFull, TPCFull) +#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(Full, inputPid, particleId, true, TOFFull, TPCFull) // o2-linter: disable=name/macro makeProcessFunctionFull(El, Electron); makeProcessFunctionFull(Mu, Muon); @@ -1472,7 +1509,7 @@ struct tofSpectra { #undef makeProcessFunctionFull // Full LF tables -#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(LfFull, inputPid, particleId, true, TOFFull, TPCLfFull) +#define makeProcessFunctionFull(inputPid, particleId) makeProcessFunction(LfFull, inputPid, particleId, true, TOFFull, TPCLfFull) // o2-linter: disable=name/macro makeProcessFunctionFull(El, Electron); makeProcessFunctionFull(Mu, Muon); @@ -1610,7 +1647,7 @@ struct tofSpectra { using RecoMCCollisions = soa::Join; // RD template - void fillTrackHistograms_MC(TrackType const& track, + void fillTrackHistograms_MC(TrackType const& track, // o2-linter: disable=name/function-variable ParticleType::iterator const& mcParticle, RecoMCCollisions::iterator const& collision, ParticleType const& mcParticles) @@ -1685,11 +1722,10 @@ struct tofSpectra { } if (enableDCAvsmotherHistograms) { - bool IsD0Mother = false; - bool IsCharmMother = false; - bool IsBeautyMother = false; - bool IsNotHFMother = false; - + bool IsD0Mother = false; // o2-linter: disable=name/function-variable + bool IsCharmMother = false; // o2-linter: disable=name/function-variable + bool IsBeautyMother = false; // o2-linter: disable=name/function-variable + bool IsNotHFMother = false; // o2-linter: disable=name/function-variable if (mcParticle.has_mothers()) { const int charmOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, false); for (const auto& mother : mcParticle.template mothers_as()) { @@ -1699,15 +1735,15 @@ struct tofSpectra { } if (charmOrigin == RecoDecay::OriginType::NonPrompt) { IsBeautyMother = true; - std::cout << "Charm Origin for Beauty:" << charmOrigin << std::endl; + LOG(info) << "Charm Origin for Beauty: " << charmOrigin; } if (charmOrigin == RecoDecay::OriginType::Prompt) { IsCharmMother = true; - std::cout << "Charm Origin for Charm:" << charmOrigin << std::endl; + LOG(info) << "Charm Origin for Charm: " << charmOrigin; } if (charmOrigin == RecoDecay::OriginType::None) { IsNotHFMother = true; - std::cout << "Charm Origin for NotHF:" << charmOrigin << std::endl; + LOG(info) << "Charm Origin for NotHF: " << charmOrigin; } } } @@ -1845,7 +1881,7 @@ struct tofSpectra { } template - void fillParticleHistograms_MC(const float multiplicity, ParticleType const& mcParticle) + void fillParticleHistograms_MC(const float multiplicity, ParticleType const& mcParticle) // o2-linter: disable=name/function-variable { if (!isParticleEnabled()) { // Check if the particle is enabled return; @@ -1867,7 +1903,7 @@ struct tofSpectra { } template - void fillParticleHistograms_MCRecoEvs(ParticleType const& mcParticle, RecoMCCollisions::iterator const& collision) + void fillParticleHistograms_MCRecoEvs(ParticleType const& mcParticle, RecoMCCollisions::iterator const& collision) // o2-linter: disable=name/function-variable { if (!isParticleEnabled()) { // Check if the particle is enabled return; @@ -1925,7 +1961,7 @@ struct tofSpectra { } template - void fillParticleHistograms_MCGenEvs(ParticleType const& mcParticle, GenMCCollisions::iterator const& mcCollision) + void fillParticleHistograms_MCGenEvs(ParticleType const& mcParticle, GenMCCollisions::iterator const& mcCollision) // o2-linter: disable=name/function-variable { if (!isParticleEnabled()) { // Check if the particle is enabled @@ -2108,81 +2144,120 @@ struct tofSpectra { int pdgCode = mcParticleGen.pdgCode(); float pt = mcParticleGen.pt(); float absY = std::abs(mcParticleGen.y()); - // Apply rapidity cut if (absY > trkselOptions.cfgCutY) { continue; } - // Fill histograms based on particle type - switch (pdgCode) { - case 2212: - histos.fill(HIST("MC/test/pr/pos/prm/pt/den"), pt, multiplicity); - break; - case -2212: - histos.fill(HIST("MC/test/pr/neg/prm/pt/den"), pt, multiplicity); - break; - case 211: - histos.fill(HIST("MC/test/pi/pos/prm/pt/den"), pt, multiplicity); - break; - case -211: - histos.fill(HIST("MC/test/pi/neg/prm/pt/den"), pt, multiplicity); - break; - case 321: - histos.fill(HIST("MC/test/ka/pos/prm/pt/den"), pt, multiplicity); - break; - case -321: - histos.fill(HIST("MC/test/ka/neg/prm/pt/den"), pt, multiplicity); - break; - default: - break; + if (pdgCode == 2212) { + histos.fill(HIST("MC/test/pr/pos/prm/pt/den"), pt, multiplicity); + } else if (pdgCode == -2212) { + histos.fill(HIST("MC/test/pr/neg/prm/pt/den"), pt, multiplicity); + } else if (pdgCode == 211) { + histos.fill(HIST("MC/test/pi/pos/prm/pt/den"), pt, multiplicity); + } else if (pdgCode == -211) { + histos.fill(HIST("MC/test/pi/neg/prm/pt/den"), pt, multiplicity); + } else if (pdgCode == 321) { + histos.fill(HIST("MC/test/ka/pos/prm/pt/den"), pt, multiplicity); + } else if (pdgCode == -321) { + histos.fill(HIST("MC/test/ka/neg/prm/pt/den"), pt, multiplicity); } } } PROCESS_SWITCH(tofSpectra, processMCgen, "process generated MC", false); - void processMCgen_RecoEvs(GenMCCollisions const&, RecoMCCollisions const& collisions, aod::McParticles const& mcParticles) + void processMCgen_RecoEvs(soa::Join const& tracks, + aod::McTrackLabels const& mcTrackLabels, + RecoMCCollisions const& collisions, + aod::McParticles const& mcParticles) { for (const auto& collision : collisions) { if (!collision.has_mcCollision()) { continue; } + const auto& mcCollision = collision.mcCollision_as(); - const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); histos.fill(HIST("Vertex/RecoEvs/histGenVtxMC"), mcCollision.posZ()); histos.fill(HIST("Centrality/RecoEvs/ImpParm"), mcCollision.impactParameter()); const float multiplicity = mcCollision.impactParameter(); - for (const auto& mcParticleGen : particlesInCollision) { - if (!mcParticleGen.isPhysicalPrimary()) + + for (const auto& track : tracks) { + if (track.tpcNClsCrossedRows() < 70 || + track.tpcChi2NCl() > 4 || + track.tpcChi2NCl() < 0.5 || + track.itsChi2NCl() > 36 || + std::abs(track.dcaXY()) > 0.05 || + std::abs(track.dcaZ()) > 2.0 || + std::abs(track.eta()) > 0.8 || + track.tpcCrossedRowsOverFindableCls() < 0.8 || + track.tpcNClsFound() < 100 || + !(o2::aod::track::TPCrefit) || + !(o2::aod::track::ITSrefit)) { continue; - int pdgCode = mcParticleGen.pdgCode(); - float pt = mcParticleGen.pt(); - float absY = std::abs(mcParticleGen.y()); - // Apply rapidity cut + } + const auto& mcLabel = mcTrackLabels.iteratorAt(track.globalIndex()); + if (mcLabel.mcParticleId() < 0 || mcLabel.mcParticleId() >= mcParticles.size()) { + continue; + } + const auto& mcParticle = mcParticles.iteratorAt(mcLabel.mcParticleId()); + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + + int pdgCode = mcParticle.pdgCode(); + float pt = mcParticle.pt(); + float absY = std::abs(mcParticle.y()); if (absY > trkselOptions.cfgCutY) { continue; } - // Fill histograms based on particle type - switch (pdgCode) { - case 2212: - histos.fill(HIST("MC/test/RecoEvs/pr/pos/prm/pt/den"), pt, multiplicity); - break; - case -2212: - histos.fill(HIST("MC/test/RecoEvs/pr/neg/prm/pt/den"), pt, multiplicity); - break; - case 211: - histos.fill(HIST("MC/test/RecoEvs/pi/pos/prm/pt/den"), pt, multiplicity); - break; - case -211: - histos.fill(HIST("MC/test/RecoEvs/pi/neg/prm/pt/den"), pt, multiplicity); - break; - case 321: - histos.fill(HIST("MC/test/RecoEvs/ka/pos/prm/pt/den"), pt, multiplicity); - break; - case -321: - histos.fill(HIST("MC/test/RecoEvs/ka/neg/prm/pt/den"), pt, multiplicity); - break; - default: - break; + const auto& nsigmaTPCPi = o2::aod::pidutils::tpcNSigma<2>(track); + ; + const auto& nsigmaTPCKa = o2::aod::pidutils::tpcNSigma<3>(track); + const auto& nsigmaTPCPr = o2::aod::pidutils::tpcNSigma<4>(track); + + bool isPionTPC = std::abs(nsigmaTPCPi) < trkselOptions.cfgCutNsigma; + bool isKaonTPC = std::abs(nsigmaTPCKa) < trkselOptions.cfgCutNsigma; + bool isProtonTPC = std::abs(nsigmaTPCPr) < trkselOptions.cfgCutNsigma; + + const auto& nsigmaTOFPi = o2::aod::pidutils::tofNSigma<2>(track); + const auto& nsigmaTOFKa = o2::aod::pidutils::tofNSigma<3>(track); + const auto& nsigmaTOFPr = o2::aod::pidutils::tofNSigma<4>(track); + + bool isPionTOF = track.hasTOF() && std::abs(nsigmaTOFPi) < trkselOptions.cfgCutNsigma; + bool isKaonTOF = track.hasTOF() && std::abs(nsigmaTOFKa) < trkselOptions.cfgCutNsigma; + bool isProtonTOF = track.hasTOF() && std::abs(nsigmaTOFPr) < trkselOptions.cfgCutNsigma; + + if (isPionTPC || isKaonTPC || isProtonTPC) { + if (pdgCode == 2212) { + histos.fill(HIST("MC/test/RecoEvs/pr/pos/prm/pt/num"), pt, multiplicity); + } else if (pdgCode == -2212) { + histos.fill(HIST("MC/test/RecoEvs/pr/neg/prm/pt/num"), pt, multiplicity); + } else if (pdgCode == 211) { + histos.fill(HIST("MC/test/RecoEvs/pi/pos/prm/pt/num"), pt, multiplicity); + } else if (pdgCode == -211) { + histos.fill(HIST("MC/test/RecoEvs/pi/neg/prm/pt/num"), pt, multiplicity); + } else if (pdgCode == 321) { + histos.fill(HIST("MC/test/RecoEvs/ka/pos/prm/pt/num"), pt, multiplicity); + } else if (pdgCode == -321) { + histos.fill(HIST("MC/test/RecoEvs/ka/neg/prm/pt/num"), pt, multiplicity); + } + } + + if (isPionTOF || isKaonTOF || isProtonTOF) { + if (pdgCode == 2212) { + histos.fill(HIST("MC/test/RecoEvs/pr/pos/prm/pt/numtof"), pt, multiplicity); + } else if (pdgCode == -2212) { + histos.fill(HIST("MC/test/RecoEvs/pr/neg/prm/pt/numtof"), pt, multiplicity); + } else if (pdgCode == 211) { + histos.fill(HIST("MC/test/RecoEvs/pi/pos/prm/pt/numtof"), pt, multiplicity); + } else if (pdgCode == -211) { + histos.fill(HIST("MC/test/RecoEvs/pi/neg/prm/pt/numtof"), pt, multiplicity); + } else if (pdgCode == 321) { + histos.fill(HIST("MC/test/RecoEvs/ka/pos/prm/pt/numtof"), pt, multiplicity); + } else if (pdgCode == -321) { + histos.fill(HIST("MC/test/RecoEvs/ka/neg/prm/pt/numtof"), pt, multiplicity); + } } } }