From 5c0a94031566d00ecfceaf9dfcc013264207fad8 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Fri, 30 Jul 2021 09:10:44 +0200 Subject: [PATCH 1/3] simplify isPhysicalPrimary --- Analysis/Core/include/AnalysisCore/MC.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Analysis/Core/include/AnalysisCore/MC.h b/Analysis/Core/include/AnalysisCore/MC.h index 5c5e725e5a33d..e6e262e3dfc09 100644 --- a/Analysis/Core/include/AnalysisCore/MC.h +++ b/Analysis/Core/include/AnalysisCore/MC.h @@ -61,7 +61,7 @@ bool isStable(int pdg) } // Ported from AliRoot AliStack::IsPhysicalPrimary -template +template bool isPhysicalPrimary(Particle const& particle) { // Test if a particle is a physical primary according to the following definition: @@ -96,7 +96,7 @@ bool isPhysicalPrimary(Particle const& particle) // Solution for K0L decayed by Pythia6 // -> if (particle.has_mother0()) { - auto mother = particle.template mother0_as(); + auto mother = particle.template mother0_as(); if (std::abs(mother.pdgCode()) == 130) { LOGF(debug, "isPhysicalPrimary F4"); return false; @@ -107,7 +107,7 @@ bool isPhysicalPrimary(Particle const& particle) // -> if (pdg == 22 && particle.has_daughter0()) { LOGF(debug, "D %d", particle.daughter0Id()); - auto daughter = particle.template daughter0_as(); + auto daughter = particle.template daughter0_as(); if (daughter.pdgCode() == 22) { LOGF(debug, "isPhysicalPrimary F5"); return false; @@ -121,7 +121,7 @@ bool isPhysicalPrimary(Particle const& particle) // Particle produced during transport LOGF(debug, "M0 %d %d", particle.producedByGenerator(), particle.mother0Id()); - auto mother = particle.template mother0_as(); + auto mother = particle.template mother0_as(); int mpdg = std::abs(mother.pdgCode()); // Check for Sigma0 @@ -155,7 +155,7 @@ bool isPhysicalPrimary(Particle const& particle) // Loop back to the generated mother LOGF(debug, "M0 %d %d", mother.producedByGenerator(), mother.mother0Id()); while (mother.has_mother0() && !mother.producedByGenerator()) { - mother = mother.template mother0_as(); + mother = mother.template mother0_as(); LOGF(debug, "M+ %d %d", mother.producedByGenerator(), mother.mother0Id()); mpdg = std::abs(mother.pdgCode()); mfl = int(mpdg / std::pow(10, int(std::log10(mpdg)))); @@ -169,13 +169,6 @@ bool isPhysicalPrimary(Particle const& particle) return true; } } - -// Short hand for the standard type -bool isPhysicalPrimary(o2::aod::McParticle const& particle) -{ - return isPhysicalPrimary(particle); -} - }; // namespace MC #endif From 94cae374f6f915c6188e4e6818c0f46cf84020d8 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Fri, 30 Jul 2021 10:52:24 +0200 Subject: [PATCH 2/3] transfer self-index bindings on iterator copying --- Analysis/Tutorials/src/mcHistograms.cxx | 19 +++++++++++-------- Framework/Core/include/Framework/ASoA.h | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Analysis/Tutorials/src/mcHistograms.cxx b/Analysis/Tutorials/src/mcHistograms.cxx index 740a202f89c03..189d0dccc3128 100644 --- a/Analysis/Tutorials/src/mcHistograms.cxx +++ b/Analysis/Tutorials/src/mcHistograms.cxx @@ -71,15 +71,18 @@ struct AccessMcTruth { // continue; //if (track.labelMask() != 0) // continue; - etaDiff->Fill(track.mcParticle().eta() - track.eta()); - auto delta = track.mcParticle().phi() - track.phi(); - if (delta > M_PI) { - delta -= 2 * M_PI; + auto particle = track.mcParticle(); + if (MC::isPhysicalPrimary(particle)) { + etaDiff->Fill(particle.eta() - track.eta()); + auto delta = particle.phi() - track.phi(); + if (delta > M_PI) { + delta -= 2 * M_PI; + } + if (delta < -M_PI) { + delta += 2 * M_PI; + } + phiDiff->Fill(delta); } - if (delta < -M_PI) { - delta += 2 * M_PI; - } - phiDiff->Fill(delta); //LOGF(info, "eta: %.2f %.2f \t phi: %.2f %.2f | %d", track.mcParticle().eta(), track.eta(), track.mcParticle().phi(), track.phi(), track.mcParticle().index()); } } diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index fe5f6f9a00717..f1e7574d6944d 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1075,7 +1075,9 @@ class Table unfiltered_iterator rawIteratorAt(uint64_t i) const { - return mBegin + (i - mOffset); + auto it = mBegin + (i - mOffset); + it.bindInternalIndices((void*)this); + return it; } unfiltered_const_iterator begin() const From af7ddb2a0f76c6d181799dc8a6274f1b2db06825 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Fri, 30 Jul 2021 12:27:47 +0200 Subject: [PATCH 3/3] remove unnecessary template arguments --- Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx | 2 +- Analysis/Tasks/PWGLF/mcspectraefficiency.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx b/Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx index 1d20624fd8e9a..9eeee733a6b63 100644 --- a/Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx +++ b/Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx @@ -409,7 +409,7 @@ inline void AcceptTrueTrack(ParticleObject& particle, ParticleListObject& partic float charge = (fPDG->GetParticle(particle.pdgCode())->Charge() / 3 >= 1) ? 1.0 : ((fPDG->GetParticle(particle.pdgCode())->Charge() / 3 <= -1) ? -1.0 : 0.0); /* TODO: matchTrackType will not work. We need at least is physical primary */ - if (MC::isPhysicalPrimary(particle)) { + if (MC::isPhysicalPrimary(particle)) { if (ptlow < particle.pt() and particle.pt() < ptup and etalow < particle.eta() and particle.eta() < etaup) { if (((charge > 0) and (trackonecharge > 0)) or ((charge < 0) and (trackonecharge < 0))) { asone = true; diff --git a/Analysis/Tasks/PWGLF/mcspectraefficiency.cxx b/Analysis/Tasks/PWGLF/mcspectraefficiency.cxx index 9a57ca982e40f..d200e8a5b3650 100644 --- a/Analysis/Tasks/PWGLF/mcspectraefficiency.cxx +++ b/Analysis/Tasks/PWGLF/mcspectraefficiency.cxx @@ -68,7 +68,7 @@ struct GeneratedTask { if (abs(mcParticle.eta()) > 0.8) { continue; } - if (isPhysicalPrimary(mcParticle)) { + if (isPhysicalPrimary(mcParticle)) { const auto pdg = Form("%i", mcParticle.pdgCode()); pdgH->Fill(pdg, 1); const float pdgbin = pdgH->GetXaxis()->GetBinCenter(pdgH->GetXaxis()->FindBin(pdg)); @@ -115,7 +115,7 @@ struct ReconstructedTask { for (auto& track : tracks) { const auto particle = track.mcParticle(); const auto pdg = Form("%i", particle.pdgCode()); - if (!isPhysicalPrimary(particle)) { + if (!isPhysicalPrimary(particle)) { pdgsecH->Fill(pdg, 1); const float pdgbinsec = pdgH->GetXaxis()->GetBinCenter(pdgsecH->GetXaxis()->FindBin(pdg)); dcaxysecH->Fill(track.dcaXY(), pdgbinsec);