Skip to content

Commit c177e4c

Browse files
PWGCF: IdentifiedBF added PID for MC particles (#8236)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent ba8ac2c commit c177e4c

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ struct IdentifiedBfFilterTracks {
938938
MatchRecoGenSpecies trackIdentification(TrackObject const& track);
939939
template <typename TrackObject>
940940
int8_t AcceptTrack(TrackObject const& track);
941+
template <typename ParticleObject, typename MCCollisionObject>
942+
int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const&);
941943
template <typename CollisionObjects, typename TrackObject>
942944
int8_t selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track);
943945
template <typename ParticleObject>
@@ -1182,7 +1184,6 @@ template <typename ParticleObject>
11821184
inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyParticle(ParticleObject const& particle)
11831185
{
11841186
using namespace identifiedbffilter;
1185-
11861187
constexpr int pdgcodeEl = 11;
11871188
constexpr int pdgcodePi = 211;
11881189
constexpr int pdgcodeKa = 321;
@@ -1361,7 +1362,6 @@ template <typename TrackObject>
13611362
MatchRecoGenSpecies IdentifiedBfFilterTracks::trackIdentification(TrackObject const& track)
13621363
{
13631364
using namespace identifiedbffilter;
1364-
13651365
MatchRecoGenSpecies sp = kWrongSpecies;
13661366
if (recoIdMethod == 0) {
13671367
sp = kIdBfCharged;
@@ -1424,6 +1424,41 @@ inline int8_t IdentifiedBfFilterTracks::AcceptTrack(TrackObject const& track)
14241424
return -1;
14251425
}
14261426

1427+
/// \brief Accepts or not the passed generated particle
1428+
/// \param track the particle of interest
1429+
/// \return `true` if the particle is accepted, `false` otherwise
1430+
template <typename ParticleObject, typename MCCollisionObject>
1431+
inline int8_t IdentifiedBfFilterTracks::AcceptParticle(ParticleObject& particle, MCCollisionObject const&)
1432+
{
1433+
/* overall momentum cut */
1434+
if (!(overallminp < particle.p())) {
1435+
return kWrongSpecies;
1436+
}
1437+
1438+
float charge = getCharge(particle);
1439+
1440+
if (particle.isPhysicalPrimary()) {
1441+
if ((particle.mcCollisionId() == 0) && traceCollId0) {
1442+
LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex());
1443+
}
1444+
1445+
if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) {
1446+
MatchRecoGenSpecies sp = IdentifyParticle(particle);
1447+
if (charge == 1) {
1448+
return speciesChargeValue1[sp];
1449+
1450+
} else if (charge == -1) {
1451+
return speciesChargeValue1[sp] + 1;
1452+
}
1453+
}
1454+
} else {
1455+
if ((particle.mcCollisionId() == 0) && traceCollId0) {
1456+
LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex());
1457+
}
1458+
}
1459+
return kWrongSpecies;
1460+
}
1461+
14271462
template <typename CollisionObjects, typename TrackObject>
14281463
int8_t IdentifiedBfFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track)
14291464
{

PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace analysis
4545
namespace identifiedbffilter
4646
{
4747

48+
const std::vector<int> pdgcodes = {11, 211, 321, 2212};
49+
4850
/// \enum MatchRecoGenSpecies
4951
/// \brief The species considered by the matching test
5052
enum MatchRecoGenSpecies {
@@ -128,6 +130,8 @@ enum CentMultEstimatorType {
128130
knCentMultEstimators ///< number of centrality/mutiplicity estimator
129131
};
130132

133+
float overallminp = 0.0f;
134+
131135
/// \enum TriggerSelectionType
132136
/// \brief The type of trigger to apply for event selection
133137
enum TriggerSelectionType {
@@ -716,54 +720,15 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision)
716720
}
717721
}
718722

719-
/// \brief Accepts or not the passed generated particle
720-
/// \param track the particle of interest
721-
/// \return the internal particle id, -1 if not accepted
722-
/// TODO: the PID implementation
723-
/// For the time being we keep the convention
724-
/// - positive particle pid even
725-
/// - negative particle pid odd
726-
/// - charged hadron 0/1
727-
template <typename ParticleObject, typename MCCollisionObject>
728-
inline int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const& collision)
723+
template <typename ParticleObject>
724+
inline float getCharge(ParticleObject& particle)
729725
{
730-
float charge = (fPDG->GetParticle(particle.pdgCode())->Charge() / 3 >= 1) ? 1.0 : ((fPDG->GetParticle(particle.pdgCode())->Charge() / 3 <= -1) ? -1.0 : 0.0);
731-
732-
if (particle.isPhysicalPrimary()) {
733-
if ((particle.mcCollisionId() == 0) && traceCollId0) {
734-
LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex());
735-
}
736-
if (useOwnParticleSelection) {
737-
float dcaxy = TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) +
738-
(particle.vy() - collision.posY()) * (particle.vy() - collision.posY()));
739-
float dcaz = TMath::Abs(particle.vz() - collision.posZ());
740-
if (!((dcaxy < particleMaxDCAxy) && (dcaz < particleMaxDCAZ))) {
741-
if ((particle.mcCollisionId() == 0) && traceCollId0) {
742-
LOGF(info, "Rejecting particle with dcaxy: %.2f and dcaz: %.2f", dcaxy, dcaz);
743-
LOGF(info, " assigned collision Id: %d, looping on collision Id: %d", particle.mcCollisionId(), collision.globalIndex());
744-
LOGF(info, " Collision x: %.5f, y: %.5f, z: %.5f", collision.posX(), collision.posY(), collision.posZ());
745-
LOGF(info, " Particle x: %.5f, y: %.5f, z: %.5f", particle.vx(), particle.vy(), particle.vz());
746-
LOGF(info, " index: %d, pdg code: %d", particle.globalIndex(), particle.pdgCode());
747-
748-
exploreMothers(particle, collision);
749-
}
750-
return -1;
751-
}
752-
}
753-
if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) {
754-
if (charge > 0) {
755-
return 0;
756-
}
757-
if (charge < 0) {
758-
return 1;
759-
}
760-
}
761-
} else {
762-
if ((particle.mcCollisionId() == 0) && traceCollId0) {
763-
LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex());
764-
}
726+
float charge = 0.0;
727+
TParticlePDG* pdgparticle = fPDG->GetParticle(particle.pdgCode());
728+
if (pdgparticle != nullptr) {
729+
charge = (pdgparticle->Charge() / 3 >= 1) ? 1.0 : ((pdgparticle->Charge() / 3 <= -1) ? -1.0 : 0);
765730
}
766-
return -1;
731+
return charge;
767732
}
768733

769734
} // namespace identifiedbffilter

0 commit comments

Comments
 (0)