Skip to content

Commit b8a220f

Browse files
committed
Fixed reco phi w pdg filter function
1 parent dc6624f commit b8a220f

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

PWGLF/Tasks/Strangeness/phik0shortanalysis.cxx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,8 @@ struct Phik0shortanalysis {
979979
return false;
980980
}
981981

982-
template <typename T1, typename T2>
983-
bool eventHasRecoPhiWPDG(const T1& posTracks, const T2& negTracks)
982+
template <typename T1, typename T2, typename T3>
983+
bool eventHasRecoPhiWPDG(const T1& posTracks, const T2& negTracks, const T3& mcParticles)
984984
{
985985
int nPhi = 0;
986986

@@ -992,7 +992,7 @@ struct Phik0shortanalysis {
992992

993993
if (!track1.has_mcParticle())
994994
continue;
995-
auto mcTrack1 = track1.template mcParticle_as<aod::McParticles>();
995+
auto mcTrack1 = mcParticles.rawIteratorAt(track1.mcParticleId());
996996
if (mcTrack1.pdgCode() != PDG_t::kKPlus || !mcTrack1.isPhysicalPrimary())
997997
continue;
998998

@@ -1006,24 +1006,28 @@ struct Phik0shortanalysis {
10061006

10071007
if (!track2.has_mcParticle())
10081008
continue;
1009-
auto mcTrack2 = track2.template mcParticle_as<aod::McParticles>();
1009+
auto mcTrack2 = mcParticles.rawIteratorAt(track2.mcParticleId());
10101010
if (mcTrack2.pdgCode() != PDG_t::kKMinus || !mcTrack2.isPhysicalPrimary())
10111011
continue;
10121012

1013+
const auto mcTrack1MotherIndexes = mcTrack1.mothersIds();
1014+
const auto mcTrack2MotherIndexes = mcTrack2.mothersIds();
1015+
10131016
float pTMother = -1.0f;
10141017
float yMother = -1.0f;
10151018
bool isMCMotherPhi = false;
1016-
for (const auto& motherOfMcTrack1 : mcTrack1.template mothers_as<aod::McParticles>()) {
1017-
for (const auto& motherOfMcTrack2 : mcTrack2.template mothers_as<aod::McParticles>()) {
1018-
if (motherOfMcTrack1.pdgCode() != motherOfMcTrack2.pdgCode())
1019-
continue;
1020-
if (motherOfMcTrack1.globalIndex() != motherOfMcTrack2.globalIndex())
1019+
1020+
for (const auto& mcTrack1MotherIndex : mcTrack1MotherIndexes) {
1021+
for (const auto& mcTrack2MotherIndex : mcTrack2MotherIndexes) {
1022+
if (mcTrack1MotherIndex != mcTrack2MotherIndex)
10211023
continue;
1022-
if (motherOfMcTrack1.pdgCode() != o2::constants::physics::Pdg::kPhi)
1024+
1025+
const auto mother = mcParticles.rawIteratorAt(mcTrack1MotherIndex);
1026+
if (mother.pdgCode() != o2::constants::physics::Pdg::kPhi)
10231027
continue;
10241028

1025-
pTMother = motherOfMcTrack1.pt();
1026-
yMother = motherOfMcTrack1.y();
1029+
pTMother = mother.pt();
1030+
yMother = mother.y();
10271031
isMCMotherPhi = true;
10281032
}
10291033
}
@@ -2668,9 +2672,9 @@ struct Phik0shortanalysis {
26682672
auto mcParticlesThisMcColl = mcParticles.sliceBy(preslices.perMCColl, mcCollision.globalIndex());
26692673

26702674
if (!pwglf::isINELgtNmc(mcParticlesThisMcColl, 0, pdgDB))
2671-
return;
2675+
continue;
26722676
if (filterOnGenPhi && !eventHasGenPhi(mcParticlesThisMcColl))
2673-
return;
2677+
continue;
26742678

26752679
uint64_t numberAssocColl = 0;
26762680
std::vector<float> zVtxs;
@@ -2688,7 +2692,7 @@ struct Phik0shortanalysis {
26882692
Partition<FilteredMCTracks> negFiltMCTracks = aod::track::signed1Pt < trackConfigs.cfgCutCharge;
26892693
negFiltMCTracks.bindTable(filteredMCTracksThisColl);
26902694

2691-
if (filterOnRecoPhiWPDG && !eventHasRecoPhiWPDG(posFiltMCTracks, negFiltMCTracks))
2695+
if (filterOnRecoPhiWPDG && !eventHasRecoPhiWPDG(posFiltMCTracks, negFiltMCTracks, mcParticles))
26922696
continue;
26932697

26942698
mcEventHist.fill(HIST("hGenMCRecoMultiplicityPercent"), mcCollision.centFT0M());

0 commit comments

Comments
 (0)