From 34a1c40a7d230e11605478d20810bf78dfff685c Mon Sep 17 00:00:00 2001 From: bghanley1995 Date: Tue, 29 Oct 2024 23:59:24 -0400 Subject: [PATCH 1/2] added PID for MC particles --- .../TableProducer/identifiedBfFilter.cxx | 41 ++++++++++++- .../TableProducer/identifiedBfFilter.h | 59 ++++--------------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx index 734b1b1185c..ea4baccdb0d 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx @@ -938,6 +938,8 @@ struct IdentifiedBfFilterTracks { MatchRecoGenSpecies trackIdentification(TrackObject const& track); template int8_t AcceptTrack(TrackObject const& track); + template + int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const&); template int8_t selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track); template @@ -1182,7 +1184,6 @@ template inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyParticle(ParticleObject const& particle) { using namespace identifiedbffilter; - constexpr int pdgcodeEl = 11; constexpr int pdgcodePi = 211; constexpr int pdgcodeKa = 321; @@ -1361,7 +1362,6 @@ template MatchRecoGenSpecies IdentifiedBfFilterTracks::trackIdentification(TrackObject const& track) { using namespace identifiedbffilter; - MatchRecoGenSpecies sp = kWrongSpecies; if (recoIdMethod == 0) { sp = kIdBfCharged; @@ -1424,6 +1424,43 @@ inline int8_t IdentifiedBfFilterTracks::AcceptTrack(TrackObject const& track) return -1; } +/// \brief Accepts or not the passed generated particle +/// \param track the particle of interest +/// \return `true` if the particle is accepted, `false` otherwise +template +inline int8_t IdentifiedBfFilterTracks::AcceptParticle(ParticleObject& particle, MCCollisionObject const&) +{ + /* overall momentum cut */ + if (!(overallminp < particle.p())) { + return kWrongSpecies; + } + + float charge = getCharge(particle); + + if (particle.isPhysicalPrimary()) { + if ((particle.mcCollisionId() == 0) && traceCollId0) { + LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex()); + } + + if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) { + MatchRecoGenSpecies sp = IdentifyParticle(particle); + if(charge == 1){ + return speciesChargeValue1[sp]; + + } + else if(charge == -1){ + return speciesChargeValue1[sp] + 1; + + } + } + } else { + if ((particle.mcCollisionId() == 0) && traceCollId0) { + LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex()); + } + } + return kWrongSpecies; +} + template int8_t IdentifiedBfFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track) { diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h index a502101a818..a4030abbab6 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h @@ -45,6 +45,8 @@ namespace analysis namespace identifiedbffilter { +const std::vector pdgcodes = {11, 211, 321, 2212}; + /// \enum MatchRecoGenSpecies /// \brief The species considered by the matching test enum MatchRecoGenSpecies { @@ -128,6 +130,8 @@ enum CentMultEstimatorType { knCentMultEstimators ///< number of centrality/mutiplicity estimator }; +float overallminp = 0.0f; + /// \enum TriggerSelectionType /// \brief The type of trigger to apply for event selection enum TriggerSelectionType { @@ -716,56 +720,19 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision) } } -/// \brief Accepts or not the passed generated particle -/// \param track the particle of interest -/// \return the internal particle id, -1 if not accepted -/// TODO: the PID implementation -/// For the time being we keep the convention -/// - positive particle pid even -/// - negative particle pid odd -/// - charged hadron 0/1 -template -inline int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const& collision) +template +inline float getCharge(ParticleObject& particle) { - float charge = (fPDG->GetParticle(particle.pdgCode())->Charge() / 3 >= 1) ? 1.0 : ((fPDG->GetParticle(particle.pdgCode())->Charge() / 3 <= -1) ? -1.0 : 0.0); - - if (particle.isPhysicalPrimary()) { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex()); - } - if (useOwnParticleSelection) { - float dcaxy = TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + - (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())); - float dcaz = TMath::Abs(particle.vz() - collision.posZ()); - if (!((dcaxy < particleMaxDCAxy) && (dcaz < particleMaxDCAZ))) { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Rejecting particle with dcaxy: %.2f and dcaz: %.2f", dcaxy, dcaz); - LOGF(info, " assigned collision Id: %d, looping on collision Id: %d", particle.mcCollisionId(), collision.globalIndex()); - LOGF(info, " Collision x: %.5f, y: %.5f, z: %.5f", collision.posX(), collision.posY(), collision.posZ()); - LOGF(info, " Particle x: %.5f, y: %.5f, z: %.5f", particle.vx(), particle.vy(), particle.vz()); - LOGF(info, " index: %d, pdg code: %d", particle.globalIndex(), particle.pdgCode()); - - exploreMothers(particle, collision); - } - return -1; - } - } - if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) { - if (charge > 0) { - return 0; - } - if (charge < 0) { - return 1; - } - } - } else { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex()); - } + float charge = 0.0; + TParticlePDG* pdgparticle = fPDG->GetParticle(particle.pdgCode()); + if (pdgparticle != nullptr) { + charge = (pdgparticle->Charge() / 3 >= 1) ? 1.0 : ((pdgparticle->Charge() / 3 <= -1) ? -1.0 : 0); } - return -1; + return charge; } + + } // namespace identifiedbffilter } // namespace analysis } // namespace o2 From b49a1d937cd46e703050055a048493dc2bab673f Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 30 Oct 2024 13:34:39 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- .../TableProducer/identifiedBfFilter.cxx | 6 ++---- .../TableProducer/identifiedBfFilter.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx index ea4baccdb0d..fb6355c55b2 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx @@ -1444,13 +1444,11 @@ inline int8_t IdentifiedBfFilterTracks::AcceptParticle(ParticleObject& particle, if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) { MatchRecoGenSpecies sp = IdentifyParticle(particle); - if(charge == 1){ + if (charge == 1) { return speciesChargeValue1[sp]; - } - else if(charge == -1){ + } else if (charge == -1) { return speciesChargeValue1[sp] + 1; - } } } else { diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h index a4030abbab6..392bcd73afe 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h @@ -731,8 +731,6 @@ inline float getCharge(ParticleObject& particle) return charge; } - - } // namespace identifiedbffilter } // namespace analysis } // namespace o2