Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions Analysis/Core/include/AnalysisCore/MC.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool isStable(int pdg)
}

// Ported from AliRoot AliStack::IsPhysicalPrimary
template <typename Particles, typename Particle>
template <typename Particle>
bool isPhysicalPrimary(Particle const& particle)
{
// Test if a particle is a physical primary according to the following definition:
Expand Down Expand Up @@ -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<Particles>();
auto mother = particle.template mother0_as<typename Particle::parent_t>();
if (std::abs(mother.pdgCode()) == 130) {
LOGF(debug, "isPhysicalPrimary F4");
return false;
Expand All @@ -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<Particles>();
auto daughter = particle.template daughter0_as<typename Particle::parent_t>();
if (daughter.pdgCode() == 22) {
LOGF(debug, "isPhysicalPrimary F5");
return false;
Expand All @@ -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<Particles>();
auto mother = particle.template mother0_as<typename Particle::parent_t>();
int mpdg = std::abs(mother.pdgCode());

// Check for Sigma0
Expand Down Expand Up @@ -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<Particles>();
mother = mother.template mother0_as<typename Particle::parent_t>();
LOGF(debug, "M+ %d %d", mother.producedByGenerator(), mother.mother0Id());
mpdg = std::abs(mother.pdgCode());
mfl = int(mpdg / std::pow(10, int(std::log10(mpdg))));
Expand All @@ -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<o2::aod::McParticles>(particle);
}

}; // namespace MC

#endif
2 changes: 1 addition & 1 deletion Analysis/Tasks/PWGCF/dptdptcorrelations-simchl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParticleListObject, ParticleObject>(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;
Expand Down
4 changes: 2 additions & 2 deletions Analysis/Tasks/PWGLF/mcspectraefficiency.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct GeneratedTask {
if (abs(mcParticle.eta()) > 0.8) {
continue;
}
if (isPhysicalPrimary<aod::McParticles>(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));
Expand Down Expand Up @@ -115,7 +115,7 @@ struct ReconstructedTask {
for (auto& track : tracks) {
const auto particle = track.mcParticle();
const auto pdg = Form("%i", particle.pdgCode());
if (!isPhysicalPrimary<aod::McParticles>(particle)) {
if (!isPhysicalPrimary(particle)) {
pdgsecH->Fill(pdg, 1);
const float pdgbinsec = pdgH->GetXaxis()->GetBinCenter(pdgsecH->GetXaxis()->FindBin(pdg));
dcaxysecH->Fill(track.dcaXY(), pdgbinsec);
Expand Down
19 changes: 11 additions & 8 deletions Analysis/Tutorials/src/mcHistograms.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
4 changes: 3 additions & 1 deletion Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down