Skip to content

Commit a4fa8ea

Browse files
ChiaraDeMartin95Chiara De Martin
andauthored
simplification which makes it work also on older MC AO2D files (#2472)
* simplification which makes it work also on older MC AO2D files * swap blocks to obtain logical order --------- Co-authored-by: Chiara De Martin <chiara.de.martin@cern.ch>
1 parent d916d95 commit a4fa8ea

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

Tutorials/PWGLF/strangeness_step3.cxx

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,12 @@ struct strangeness_tutorial {
7171
Filter preFilterV0 = nabs(aod::v0data::dcapostopv) > v0setting_dcapostopv&& nabs(aod::v0data::dcanegtopv) > v0setting_dcanegtopv&& aod::v0data::dcaV0daughters < v0setting_dcav0dau;
7272

7373
// Defining the type of the daughter tracks
74-
using DaughterTracks = soa::Join<aod::TracksIU, aod::TracksExtra, aod::pidTPCPi>;
75-
76-
// Defining the type of the daughter tracks with MC matching
77-
using DaughterTracksMC = soa::Join<DaughterTracks, aod::McTrackLabels>;
74+
using DaughterTracks = soa::Join<aod::TracksIU, aod::TracksExtra, aod::pidTPCPi, aod::McTrackLabels>;
7875

7976
void process(soa::Filtered<soa::Join<aod::Collisions, aod::EvSels>>::iterator const& collision,
80-
soa::Filtered<aod::V0Datas> const& V0s,
77+
soa::Filtered<soa::Join<aod::V0Datas, aod::McV0Labels>> const& V0s,
8178
DaughterTracks const&, // no need to define a variable for tracks, if we don't access them directly
82-
aod::McParticles const& mcParticles,
83-
soa::Join<DaughterTracks, aod::McTrackLabels> const&,
84-
soa::Filtered<soa::Join<aod::V0Datas, aod::McV0Labels>> const& mcV0s)
79+
aod::McParticles const& mcParticles)
8580
{
8681
// Fill the event counter
8782
registry.fill(HIST("hVertexZ"), collision.posZ());
@@ -114,26 +109,19 @@ struct strangeness_tutorial {
114109
registry.fill(HIST("hNSigmaNegPionFromK0s"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam());
115110
}
116111

117-
// Checking that the daughter tracks are true pions in the MC
118-
const auto& posDaughterTrackMC = v0.posTrack_as<DaughterTracksMC>();
119-
const auto& negDaughterTrackMC = v0.negTrack_as<DaughterTracksMC>();
120-
121-
if (posDaughterTrackMC.has_mcParticle() && negDaughterTrackMC.has_mcParticle()) { // Checking that the daughter tracks come from particles and are not fake
122-
const auto& posParticle = posDaughterTrackMC.mcParticle();
123-
const auto& negParticle = negDaughterTrackMC.mcParticle();
112+
if (posDaughterTrack.has_mcParticle() && negDaughterTrack.has_mcParticle()) { // Checking that the daughter tracks come from particles and are not fake
113+
auto posParticle = posDaughterTrack.mcParticle();
114+
auto negParticle = negDaughterTrack.mcParticle();
124115
if (posParticle.pdgCode() == 211 && negParticle.pdgCode() == -211) { // Checking that the daughter tracks are true pions
125116
registry.fill(HIST("hMassK0ShortTruePions"), v0.mK0Short());
126117
}
127118
}
128-
}
129119

130-
// Looping over the V0s with the MC info attached
131-
for (const auto& mcv0 : mcV0s) {
132120
// Checking that the V0 is a true K0s in the MC
133-
if (mcv0.has_mcParticle()) {
134-
auto v0mcparticle = mcv0.mcParticle();
121+
if (v0.has_mcParticle()) {
122+
auto v0mcparticle = v0.mcParticle();
135123
if (v0mcparticle.pdgCode() == 310) {
136-
registry.fill(HIST("hMassK0ShortMCTrue"), mcv0.mK0Short());
124+
registry.fill(HIST("hMassK0ShortMCTrue"), v0.mK0Short());
137125
}
138126
}
139127
}

0 commit comments

Comments
 (0)