Skip to content

Commit 0be73ba

Browse files
authored
DPL Analysis: Iterator binding fix (#6778)
* simplify isPhysicalPrimary * transfer self-index bindings on iterator copying * remove unnecessary template arguments
1 parent 47bc15b commit 0be73ba

5 files changed

Lines changed: 22 additions & 24 deletions

File tree

Analysis/Core/include/AnalysisCore/MC.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool isStable(int pdg)
6161
}
6262

6363
// Ported from AliRoot AliStack::IsPhysicalPrimary
64-
template <typename Particles, typename Particle>
64+
template <typename Particle>
6565
bool isPhysicalPrimary(Particle const& particle)
6666
{
6767
// Test if a particle is a physical primary according to the following definition:
@@ -96,7 +96,7 @@ bool isPhysicalPrimary(Particle const& particle)
9696
// Solution for K0L decayed by Pythia6
9797
// ->
9898
if (particle.has_mother0()) {
99-
auto mother = particle.template mother0_as<Particles>();
99+
auto mother = particle.template mother0_as<typename Particle::parent_t>();
100100
if (std::abs(mother.pdgCode()) == 130) {
101101
LOGF(debug, "isPhysicalPrimary F4");
102102
return false;
@@ -107,7 +107,7 @@ bool isPhysicalPrimary(Particle const& particle)
107107
// ->
108108
if (pdg == 22 && particle.has_daughter0()) {
109109
LOGF(debug, "D %d", particle.daughter0Id());
110-
auto daughter = particle.template daughter0_as<Particles>();
110+
auto daughter = particle.template daughter0_as<typename Particle::parent_t>();
111111
if (daughter.pdgCode() == 22) {
112112
LOGF(debug, "isPhysicalPrimary F5");
113113
return false;
@@ -121,7 +121,7 @@ bool isPhysicalPrimary(Particle const& particle)
121121
// Particle produced during transport
122122

123123
LOGF(debug, "M0 %d %d", particle.producedByGenerator(), particle.mother0Id());
124-
auto mother = particle.template mother0_as<Particles>();
124+
auto mother = particle.template mother0_as<typename Particle::parent_t>();
125125
int mpdg = std::abs(mother.pdgCode());
126126

127127
// Check for Sigma0
@@ -155,7 +155,7 @@ bool isPhysicalPrimary(Particle const& particle)
155155
// Loop back to the generated mother
156156
LOGF(debug, "M0 %d %d", mother.producedByGenerator(), mother.mother0Id());
157157
while (mother.has_mother0() && !mother.producedByGenerator()) {
158-
mother = mother.template mother0_as<Particles>();
158+
mother = mother.template mother0_as<typename Particle::parent_t>();
159159
LOGF(debug, "M+ %d %d", mother.producedByGenerator(), mother.mother0Id());
160160
mpdg = std::abs(mother.pdgCode());
161161
mfl = int(mpdg / std::pow(10, int(std::log10(mpdg))));
@@ -169,13 +169,6 @@ bool isPhysicalPrimary(Particle const& particle)
169169
return true;
170170
}
171171
}
172-
173-
// Short hand for the standard type
174-
bool isPhysicalPrimary(o2::aod::McParticle const& particle)
175-
{
176-
return isPhysicalPrimary<o2::aod::McParticles>(particle);
177-
}
178-
179172
}; // namespace MC
180173

181174
#endif

Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ inline void AcceptTrueTrack(ParticleObject& particle, ParticleListObject& partic
409409
float charge = (fPDG->GetParticle(particle.pdgCode())->Charge() / 3 >= 1) ? 1.0 : ((fPDG->GetParticle(particle.pdgCode())->Charge() / 3 <= -1) ? -1.0 : 0.0);
410410

411411
/* TODO: matchTrackType will not work. We need at least is physical primary */
412-
if (MC::isPhysicalPrimary<ParticleListObject, ParticleObject>(particle)) {
412+
if (MC::isPhysicalPrimary(particle)) {
413413
if (ptlow < particle.pt() and particle.pt() < ptup and etalow < particle.eta() and particle.eta() < etaup) {
414414
if (((charge > 0) and (trackonecharge > 0)) or ((charge < 0) and (trackonecharge < 0))) {
415415
asone = true;

Analysis/Tasks/PWGLF/mcspectraefficiency.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct GeneratedTask {
6868
if (abs(mcParticle.eta()) > 0.8) {
6969
continue;
7070
}
71-
if (isPhysicalPrimary<aod::McParticles>(mcParticle)) {
71+
if (isPhysicalPrimary(mcParticle)) {
7272
const auto pdg = Form("%i", mcParticle.pdgCode());
7373
pdgH->Fill(pdg, 1);
7474
const float pdgbin = pdgH->GetXaxis()->GetBinCenter(pdgH->GetXaxis()->FindBin(pdg));
@@ -115,7 +115,7 @@ struct ReconstructedTask {
115115
for (auto& track : tracks) {
116116
const auto particle = track.mcParticle();
117117
const auto pdg = Form("%i", particle.pdgCode());
118-
if (!isPhysicalPrimary<aod::McParticles>(particle)) {
118+
if (!isPhysicalPrimary(particle)) {
119119
pdgsecH->Fill(pdg, 1);
120120
const float pdgbinsec = pdgH->GetXaxis()->GetBinCenter(pdgsecH->GetXaxis()->FindBin(pdg));
121121
dcaxysecH->Fill(track.dcaXY(), pdgbinsec);

Analysis/Tutorials/src/mcHistograms.cxx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,18 @@ struct AccessMcTruth {
7171
// continue;
7272
//if (track.labelMask() != 0)
7373
// continue;
74-
etaDiff->Fill(track.mcParticle().eta() - track.eta());
75-
auto delta = track.mcParticle().phi() - track.phi();
76-
if (delta > M_PI) {
77-
delta -= 2 * M_PI;
74+
auto particle = track.mcParticle();
75+
if (MC::isPhysicalPrimary(particle)) {
76+
etaDiff->Fill(particle.eta() - track.eta());
77+
auto delta = particle.phi() - track.phi();
78+
if (delta > M_PI) {
79+
delta -= 2 * M_PI;
80+
}
81+
if (delta < -M_PI) {
82+
delta += 2 * M_PI;
83+
}
84+
phiDiff->Fill(delta);
7885
}
79-
if (delta < -M_PI) {
80-
delta += 2 * M_PI;
81-
}
82-
phiDiff->Fill(delta);
8386
//LOGF(info, "eta: %.2f %.2f \t phi: %.2f %.2f | %d", track.mcParticle().eta(), track.eta(), track.mcParticle().phi(), track.phi(), track.mcParticle().index());
8487
}
8588
}

Framework/Core/include/Framework/ASoA.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,9 @@ class Table
10751075

10761076
unfiltered_iterator rawIteratorAt(uint64_t i) const
10771077
{
1078-
return mBegin + (i - mOffset);
1078+
auto it = mBegin + (i - mOffset);
1079+
it.bindInternalIndices((void*)this);
1080+
return it;
10791081
}
10801082

10811083
unfiltered_const_iterator begin() const

0 commit comments

Comments
 (0)