Skip to content

Commit 1c2381a

Browse files
Preet-BhanjanPreet Patialibuild
authored
[PWGCF] Addition of MC truth process (#14074)
Co-authored-by: Preet Pati <preet@preet-6.local> Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 60ee71a commit 1c2381a

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

PWGCF/TwoParticleCorrelations/Tasks/pidDiHadron.cxx

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ struct PidDiHadron {
184184
// make the filters and cuts.
185185
Filter collisionFilter = (nabs(aod::collision::posZ) < cfgCutVertex);
186186
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);
187+
187188
using FilteredCollisions = soa::Filtered<soa::Join<aod::Collisions, aod::EvSel, aod::CentFT0Cs, aod::CentFT0CVariant1s, aod::CentFT0Ms, aod::CentFV0As, aod::Mults>>;
188189
using FilteredTracks = soa::Filtered<soa::Join<aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTOFbeta, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>>;
190+
using FilteredMcTracks = soa::Filtered<soa::Join<aod::Tracks, aod::McTrackLabels, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, aod::pidTOFbeta, aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>>;
189191
using V0TrackCandidate = aod::V0Datas;
190192

191193
Preslice<aod::Tracks> perCollision = aod::track::collisionId;
@@ -356,7 +358,7 @@ struct PidDiHadron {
356358
massAxisReso = {resoSwitchVals[kMassBins][iPhi], resoCutVals[kMassMin][iPhi], resoCutVals[kMassMax][iPhi], "M_{K^{+}K^{-}} (GeV/c^{2})"};
357359

358360
// Event Counter
359-
if ((doprocessSame || doprocessSameReso) && cfgUseAdditionalEventCut) {
361+
if ((doprocessSame || doprocessSameReso || doprocessMC) && cfgUseAdditionalEventCut) {
360362
histos.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{15, -0.5, 14.5}}});
361363
histos.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFilteredEvents + 1, "Filtered event");
362364
histos.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAfterSel8 + 1, "After sel8");
@@ -512,6 +514,19 @@ struct PidDiHadron {
512514
if (doprocessMixed || doprocessMixedReso) {
513515
histos.add("deltaEta_deltaPhi_mixed", "", {HistType::kTH2D, {axisDeltaPhi, axisDeltaEta}});
514516
}
517+
if (doprocessMC) {
518+
histos.add("hNsigmaPionTruePositives", "hNsigmaPionTruePositives", {HistType::kTH1D, {axisPt}}); // Fraction of particles that are pions and selected as pions
519+
histos.add("hNsigmaKaonTruePositives", "hNsigmaKaonTruePositives", {HistType::kTH1D, {axisPt}}); // Fraction of particles that are kaons and selected as kaons
520+
histos.add("hNsigmaProtonTruePositives", "hNsigmaProtonTruePositives", {HistType::kTH1D, {axisPt}}); // Fraction of particles that are protons and selected as protons
521+
522+
histos.add("hNsigmaPionSelected", "hNsigmaPionSelected", {HistType::kTH1D, {axisPt}});
523+
histos.add("hNsigmaKaonSelected", "hNsigmaKaonSelected", {HistType::kTH1D, {axisPt}});
524+
histos.add("hNsigmaProtonSelected", "hNsigmaProtonSelected", {HistType::kTH1D, {axisPt}});
525+
526+
histos.add("hNsigmaPionTrue", "hNsigmaPionTrue", {HistType::kTH1D, {axisPt}}); // All true pions from MC
527+
histos.add("hNsigmaKaonTrue", "hNsigmaKaonTrue", {HistType::kTH1D, {axisPt}}); // All true kaons from MC
528+
histos.add("hNsigmaProtonTrue", "hNsigmaProtonTrue", {HistType::kTH1D, {axisPt}}); // All true protons from MC
529+
}
515530

516531
histos.add("eventcount", "bin", {HistType::kTH1F, {{4, 0, 4, "bin"}}}); // histogram to see how many events are in the same and mixed event
517532

@@ -1467,6 +1482,66 @@ struct PidDiHadron {
14671482
}
14681483
}
14691484
PROCESS_SWITCH(PidDiHadron, processMixedReso, "Process mixed events", true);
1485+
1486+
void processMC(FilteredCollisions::iterator const& collision, FilteredMcTracks const& tracksmc, aod::BCsWithTimestamps const&, aod::McParticles const&)
1487+
{
1488+
float cent = -1.;
1489+
if (!cfgCentTableUnavailable)
1490+
cent = getCentrality(collision);
1491+
if (cfgUseAdditionalEventCut && !selectionEvent(collision, tracksmc.size(), cent, true))
1492+
return;
1493+
1494+
if (cfgSelCollByNch && (tracksmc.size() < cfgCutMultMin || tracksmc.size() >= cfgCutMultMax)) {
1495+
return;
1496+
}
1497+
if (!cfgSelCollByNch && !cfgCentTableUnavailable && (cent < cfgCutCentMin || cent >= cfgCutCentMax)) {
1498+
return;
1499+
}
1500+
1501+
// loop over all tracks
1502+
for (auto const& track : tracksmc) {
1503+
1504+
if (!trackSelected(track))
1505+
continue;
1506+
1507+
int pidIndex = getNsigmaPID(track);
1508+
1509+
// Fill Counts for selection through Nsigma cuts
1510+
if (pidIndex == kPions)
1511+
histos.fill(HIST("hNsigmaPionSelected"), track.pt());
1512+
if (pidIndex == kKaons)
1513+
histos.fill(HIST("hNsigmaKaonSelected"), track.pt());
1514+
if (pidIndex == kProtons)
1515+
histos.fill(HIST("hNsigmaProtonSelected"), track.pt());
1516+
1517+
// Check the PDG code for the particles (MC truth) and match with analysed Nsigma PID
1518+
if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kPiPlus) {
1519+
histos.fill(HIST("hNsigmaPionTrue"), track.pt());
1520+
1521+
if (pidIndex == kPions) {
1522+
histos.fill(HIST("hNsigmaPionTruePositives"), track.pt());
1523+
}
1524+
} // Pion condition
1525+
1526+
if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kKPlus) {
1527+
histos.fill(HIST("hNsigmaKaonTrue"), track.pt());
1528+
1529+
if (pidIndex == kKaons) {
1530+
histos.fill(HIST("hNsigmaKaonTruePositives"), track.pt());
1531+
}
1532+
} // Kaon condition
1533+
1534+
if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kProton) {
1535+
histos.fill(HIST("hNsigmaProtonTrue"), track.pt());
1536+
1537+
if (pidIndex == kProtons) {
1538+
histos.fill(HIST("hNsigmaProtonTruePositives"), track.pt());
1539+
}
1540+
} // Proton condition
1541+
1542+
} // end of tracks MC loop
1543+
} // end of process MC
1544+
PROCESS_SWITCH(PidDiHadron, processMC, "Process Monte Carlo", true);
14701545
};
14711546

14721547
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)