Skip to content

Commit 53e33cb

Browse files
authored
[PWGCF/FemtoUniverse] Properly filter by PDG and charge in track-track-extended task (AliceO2Group#10401)
1 parent 7bd1075 commit 53e33cb

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackExtended.cxx

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/// \author Anton Riedel, TU München, [email protected]
1717
/// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, [email protected]
1818

19+
#include <Framework/O2DatabasePDGPlugin.h>
1920
#include <string>
2021
#include <vector>
2122

@@ -53,6 +54,8 @@ static const float cutsTable[NPart][NCuts]{
5354
} // namespace
5455

5556
struct FemtoUniversePairTaskTrackTrackExtended {
57+
Service<o2::framework::O2DatabasePDG> pdgMC;
58+
5659
/// Particle selection part
5760

5861
/// Table for both particles
@@ -97,7 +100,6 @@ struct FemtoUniversePairTaskTrackTrackExtended {
97100

98101
Partition<soa::Join<FilteredFemtoFullParticles, aod::FDMCLabels>> partsOneMCTruth =
99102
aod::femtouniverseparticle::partType == static_cast<uint8_t>(aod::femtouniverseparticle::ParticleType::kMCTruthTrack) &&
100-
aod::femtouniverseparticle::pidCut == static_cast<uint32_t>(trackonefilter.confPDGCodePartOne) &&
101103
aod::femtouniverseparticle::pt < trackonefilter.confPtHighPart1 &&
102104
aod::femtouniverseparticle::pt > trackonefilter.confPtLowPart1;
103105

@@ -122,7 +124,6 @@ struct FemtoUniversePairTaskTrackTrackExtended {
122124

123125
Partition<soa::Join<FilteredFemtoFullParticles, aod::FDMCLabels>> partsTwoMCTruth =
124126
aod::femtouniverseparticle::partType == static_cast<uint8_t>(aod::femtouniverseparticle::ParticleType::kMCTruthTrack) &&
125-
aod::femtouniverseparticle::pidCut == static_cast<uint32_t>(tracktwofilter.confPDGCodePartTwo) &&
126127
aod::femtouniverseparticle::pt < tracktwofilter.confPtHighPart2 &&
127128
aod::femtouniverseparticle::pt > tracktwofilter.confPtLowPart2;
128129

@@ -313,6 +314,12 @@ struct FemtoUniversePairTaskTrackTrackExtended {
313314
return false;
314315
}
315316

317+
/// @returns 1 if positive, -1 if negative, 0 if zero
318+
auto sign(auto number) -> int8_t
319+
{
320+
return (number > 0) - (number < 0);
321+
}
322+
316323
void init(InitContext&)
317324
{
318325
if (twotracksconfigs.confIsMC) {
@@ -353,6 +360,38 @@ struct FemtoUniversePairTaskTrackTrackExtended {
353360
eventHisto.fillQA(col);
354361
}
355362

363+
template <uint8_t N>
364+
requires isOneOrTwo<N>
365+
auto doMCTruth(FemtoUniverseParticleHisto<aod::femtouniverseparticle::ParticleType::kMCTruthTrack, N> hist, auto parts) -> void
366+
{
367+
auto expectedPDG = 0;
368+
auto expectedCharge = 0.0l;
369+
370+
if constexpr (N == ParticleNo::ONE) {
371+
expectedPDG = trackonefilter.confPDGCodePartOne;
372+
expectedCharge = trackonefilter.confChargePart1;
373+
} else if constexpr (N == ParticleNo::TWO) {
374+
expectedPDG = tracktwofilter.confPDGCodePartTwo;
375+
expectedCharge = tracktwofilter.confChargePart2;
376+
}
377+
378+
for (const auto& particle : parts) {
379+
auto pdgCode = static_cast<int>(particle.pidCut());
380+
if (pdgCode != expectedPDG) {
381+
continue;
382+
}
383+
384+
const auto& pdgParticle = pdgMC->GetParticle(pdgCode);
385+
if (!pdgParticle) {
386+
continue;
387+
}
388+
389+
if (sign(pdgParticle->Charge()) == sign(expectedCharge)) {
390+
hist.template fillQA<false, false>(particle);
391+
}
392+
}
393+
}
394+
356395
/// This function processes the same event and takes care of all the histogramming
357396
/// \todo the trivial loops over the tracks should be factored out since they will be common to all combinations of T-T, T-V0, V0-V0, ...
358397
/// @tparam PartitionType
@@ -563,15 +602,11 @@ struct FemtoUniversePairTaskTrackTrackExtended {
563602
fillCollision(col);
564603

565604
auto groupMCTruth1 = partsOneMCTruth->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
566-
for (const auto& particle : groupMCTruth1) {
567-
hMCTruth1.fillQA<false, false>(particle);
568-
}
605+
doMCTruth<1>(hMCTruth1, groupMCTruth1);
569606

570607
if (!confIsSame) {
571608
auto groupMCTruth2 = partsTwoMCTruth->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);
572-
for (const auto& particle : groupMCTruth1) {
573-
hMCTruth2.fillQA<false, false>(particle);
574-
}
609+
doMCTruth<2>(hMCTruth2, groupMCTruth2);
575610
}
576611

577612
auto groupMCReco1 = partsOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache);

0 commit comments

Comments
 (0)