1717#ifndef COMMON_CORE_TRACKSELECTORPID_H_
1818#define COMMON_CORE_TRACKSELECTORPID_H_
1919
20+ #include < CommonConstants/PhysicsConstants.h>
2021#include < Framework/Logger.h>
2122#include < ReconstructionDataFormats/PID.h>
2223
@@ -43,6 +44,9 @@ class TrackSelectorPidBase
4344 // / Default constructor
4445 TrackSelectorPidBase () = default ;
4546
47+ static constexpr float NSigmaMinDefault{-999 .f };
48+ static constexpr float NSigmaMaxDefault{999 .f };
49+
4650 // / Conversion operator
4751 template <uint64_t pdgNew>
4852 operator TrackSelectorPidBase<pdgNew>() const
@@ -108,10 +112,10 @@ class TrackSelectorPidBase
108112 // / \param tpcNSigmaCustom custom TPC nσ value to be used for the selection, in case the desired value cannot be taken from the track table
109113 // / \return true if track satisfies TPC PID hypothesis for given TPC nσ range
110114 template <typename T>
111- bool isSelectedByTpc (const T& track, bool & conditionalTof, float tpcNSigmaCustom = - 999 .f )
115+ bool isSelectedByTpc (const T& track, bool & conditionalTof, float tpcNSigmaCustom = NSigmaMinDefault )
112116 {
113117 // Accept if selection is disabled via large values.
114- if (mNSigmaTpcMin < - 999 . && mNSigmaTpcMax > 999 . ) {
118+ if (mNSigmaTpcMin < NSigmaMinDefault && mNSigmaTpcMax > NSigmaMaxDefault ) {
115119 return true ;
116120 }
117121
@@ -127,16 +131,18 @@ class TrackSelectorPidBase
127131 nSigma = track.tpcNSigmaKa ();
128132 } else if constexpr (pdg == kProton ) {
129133 nSigma = track.tpcNSigmaPr ();
134+ } else if constexpr (pdg == o2::constants::physics::Pdg::kDeuteron ) {
135+ nSigma = track.tpcNSigmaDe ();
130136 } else {
131137 errorPdg ();
132138 }
133139
134140 // / use custom TPC nσ, if a valid value is provided
135- if (tpcNSigmaCustom > - 999 . f ) {
141+ if (tpcNSigmaCustom > NSigmaMinDefault ) {
136142 nSigma = tpcNSigmaCustom;
137143 }
138144
139- if (mNSigmaTpcMinCondTof < - 999 . && mNSigmaTpcMaxCondTof > 999 . ) {
145+ if (mNSigmaTpcMinCondTof < NSigmaMinDefault && mNSigmaTpcMaxCondTof > NSigmaMaxDefault ) {
140146 conditionalTof = true ;
141147 } else {
142148 conditionalTof = mNSigmaTpcMinCondTof <= nSigma && nSigma <= mNSigmaTpcMaxCondTof ;
@@ -148,7 +154,7 @@ class TrackSelectorPidBase
148154 // / \param track track
149155 // / \return TPC selection status (see TrackSelectorPID::Status)
150156 template <typename T>
151- TrackSelectorPID::Status statusTpc (const T& track, float tpcNSigmaCustom = - 999 .f )
157+ TrackSelectorPID::Status statusTpc (const T& track, float tpcNSigmaCustom = NSigmaMinDefault )
152158 {
153159 if (!isValidForTpc (track)) {
154160 return TrackSelectorPID::NotApplicable;
@@ -202,10 +208,10 @@ class TrackSelectorPidBase
202208 // / \param tofNSigmaCustom custom TOF nσ value to be used for the selection, in case the desired value cannot be taken from the track table
203209 // / \return true if track satisfies TOF PID hypothesis for given TOF nσ range
204210 template <typename T>
205- bool isSelectedByTof (const T& track, bool & conditionalTpc, float tofNSigmaCustom = - 999 .f )
211+ bool isSelectedByTof (const T& track, bool & conditionalTpc, float tofNSigmaCustom = NSigmaMinDefault )
206212 {
207213 // Accept if selection is disabled via large values.
208- if (mNSigmaTofMin < - 999 . && mNSigmaTofMax > 999 . ) {
214+ if (mNSigmaTofMin < NSigmaMinDefault && mNSigmaTofMax > NSigmaMaxDefault ) {
209215 return true ;
210216 }
211217
@@ -221,16 +227,18 @@ class TrackSelectorPidBase
221227 nSigma = track.tofNSigmaKa ();
222228 } else if constexpr (pdg == kProton ) {
223229 nSigma = track.tofNSigmaPr ();
230+ } else if constexpr (pdg == o2::constants::physics::Pdg::kDeuteron ) {
231+ nSigma = track.tofNSigmaDe ();
224232 } else {
225233 errorPdg ();
226234 }
227235
228236 // / use custom TOF nσ, if a valid value is provided
229- if (tofNSigmaCustom > - 999 . f ) {
237+ if (tofNSigmaCustom > NSigmaMinDefault ) {
230238 nSigma = tofNSigmaCustom;
231239 }
232240
233- if (mNSigmaTofMinCondTpc < - 999 . && mNSigmaTofMaxCondTpc > 999 . ) {
241+ if (mNSigmaTofMinCondTpc < NSigmaMinDefault && mNSigmaTofMaxCondTpc > NSigmaMaxDefault ) {
234242 conditionalTpc = true ;
235243 } else {
236244 conditionalTpc = mNSigmaTofMinCondTpc <= nSigma && nSigma <= mNSigmaTofMaxCondTpc ;
@@ -242,7 +250,7 @@ class TrackSelectorPidBase
242250 // / \param track track
243251 // / \return TOF selection status (see TrackSelectorPID::Status)
244252 template <typename T>
245- TrackSelectorPID::Status statusTof (const T& track, float tofNSigmaCustom = - 999 .f )
253+ TrackSelectorPID::Status statusTof (const T& track, float tofNSigmaCustom = NSigmaMinDefault )
246254 {
247255 if (!isValidForTof (track)) {
248256 return TrackSelectorPID::NotApplicable;
@@ -301,7 +309,7 @@ class TrackSelectorPidBase
301309 bool isSelectedByRich (const T& track, bool & conditionalTof)
302310 {
303311 // Accept if selection is disabled via large values.
304- if (mNSigmaRichMin < - 999 . && mNSigmaRichMax > 999 . ) {
312+ if (mNSigmaRichMin < NSigmaMinDefault && mNSigmaRichMax > NSigmaMaxDefault ) {
305313 return true ;
306314 }
307315
@@ -321,7 +329,7 @@ class TrackSelectorPidBase
321329 errorPdg ();
322330 }
323331
324- if (mNSigmaRichMinCondTof < - 999 . && mNSigmaRichMaxCondTof > 999 . ) {
332+ if (mNSigmaRichMinCondTof < NSigmaMinDefault && mNSigmaRichMaxCondTof > NSigmaMaxDefault ) {
325333 conditionalTof = true ;
326334 } else {
327335 conditionalTof = mNSigmaRichMinCondTof <= nSigma && nSigma <= mNSigmaRichMaxCondTof ;
@@ -405,7 +413,7 @@ class TrackSelectorPidBase
405413 // / \param track track
406414 // / \return status of combined PID (TPC or TOF) (see TrackSelectorPID::Status)
407415 template <typename T>
408- TrackSelectorPID::Status statusTpcOrTof (const T& track, float tpcNSigmaCustom = - 999 .f , float tofNSigmaCustom = - 999 .f )
416+ TrackSelectorPID::Status statusTpcOrTof (const T& track, float tpcNSigmaCustom = NSigmaMinDefault , float tofNSigmaCustom = NSigmaMinDefault )
409417 {
410418 int pidTpc = statusTpc (track, tpcNSigmaCustom);
411419 int pidTof = statusTof (track, tofNSigmaCustom);
@@ -426,7 +434,7 @@ class TrackSelectorPidBase
426434 // / \param track track
427435 // / \return status of combined PID (TPC and TOF) (see TrackSelectorPID::Status)
428436 template <typename T>
429- TrackSelectorPID::Status statusTpcAndTof (const T& track, float tpcNSigmaCustom = - 999 .f , float tofNSigmaCustom = - 999 .f )
437+ TrackSelectorPID::Status statusTpcAndTof (const T& track, float tpcNSigmaCustom = NSigmaMinDefault , float tofNSigmaCustom = NSigmaMinDefault )
430438 {
431439 int pidTpc = TrackSelectorPID::NotApplicable;
432440 if (track.hasTPC ()) {
@@ -464,23 +472,29 @@ class TrackSelectorPidBase
464472 template <typename T>
465473 bool isElectronAndNotPion (const T& track, bool useTof = true , bool useRich = true )
466474 {
475+ constexpr float NSigmaInvalid{-1000 .f };
476+ constexpr float PTofRichTElectronMin{0 .4f };
477+ constexpr float PTofRichTElectronMax{0 .6f };
478+ constexpr float PRichPionBandMin{1 .0f };
479+ constexpr float PRichPionBandMax{2 .0f };
480+
467481 bool isSelTof = false ;
468482 bool isSelRich = false ;
469483 bool hasRich = track.richId () > -1 ;
470484 bool hasTof = isValidForTof (track);
471485 auto nSigmaTofEl = track.tofNSigmaEl ();
472486 auto nSigmaTofPi = track.tofNSigmaPi ();
473- auto nSigmaRichEl = hasRich ? track.rich ().richNsigmaEl () : - 1000 . ;
474- auto nSigmaRichPi = hasRich ? track.rich ().richNsigmaPi () : - 1000 . ;
487+ auto nSigmaRichEl = hasRich ? track.rich ().richNsigmaEl () : NSigmaInvalid ;
488+ auto nSigmaRichPi = hasRich ? track.rich ().richNsigmaPi () : NSigmaInvalid ;
475489 auto p = track.p ();
476490
477491 // TOF
478- if (useTof && hasTof && (p < 0.6 )) {
479- if (p > 0.4 && hasRich) {
492+ if (useTof && hasTof && (p < PTofRichTElectronMax )) {
493+ if (p > PTofRichTElectronMin && hasRich) {
480494 if ((std::abs (nSigmaTofEl) < mNSigmaTofMax ) && (std::abs (nSigmaRichEl) < mNSigmaRichMax )) {
481495 isSelTof = true ; // is selected as electron by TOF and RICH
482496 }
483- } else if (p <= 0.4 ) {
497+ } else if (p <= PTofRichTElectronMin ) {
484498 if (std::abs (nSigmaTofEl) < mNSigmaTofMax ) {
485499 isSelTof = true ; // is selected as electron by TOF
486500 }
@@ -499,7 +513,7 @@ class TrackSelectorPidBase
499513 if (std::abs (nSigmaRichEl) < mNSigmaRichMax ) {
500514 isSelRich = true ; // is selected as electron by RICH
501515 }
502- if ((std::abs (nSigmaRichPi) < mNSigmaRichMax ) && (p > 1.0 ) && (p < 2.0 )) {
516+ if ((std::abs (nSigmaRichPi) < mNSigmaRichMax ) && (p > PRichPionBandMin ) && (p < PRichPionBandMax )) {
503517 isSelRich = false ; // is selected as pion by RICH
504518 }
505519 } else {
@@ -551,6 +565,8 @@ class TrackSelectorPidBase
551565 return track.bayesID () == o2::track::PID::Kaon;
552566 } else if constexpr (pdg == kProton ) {
553567 return track.bayesID () == o2::track::PID::Proton;
568+ } else if constexpr (pdg == o2::constants::physics::Pdg::kDeuteron ) {
569+ return track.bayesID () == o2::track::PID::Deuteron;
554570 } else {
555571 errorPdg ();
556572 return false ;
@@ -579,6 +595,8 @@ class TrackSelectorPidBase
579595 prob = track.bayesKa ();
580596 } else if constexpr (pdg == kProton ) {
581597 prob = track.bayesPr ();
598+ } else if constexpr (pdg == o2::constants::physics::Pdg::kDeuteron ) {
599+ prob = track.bayesDe ();
582600 } else {
583601 errorPdg ();
584602 }
@@ -656,10 +674,11 @@ class TrackSelectorPidBase
656674};
657675
658676// Predefined types
659- using TrackSelectorEl = TrackSelectorPidBase<kElectron >; // El
660- using TrackSelectorMu = TrackSelectorPidBase<kMuonMinus >; // Mu
661- using TrackSelectorPi = TrackSelectorPidBase<kPiPlus >; // Pi
662- using TrackSelectorKa = TrackSelectorPidBase<kKPlus >; // Ka
663- using TrackSelectorPr = TrackSelectorPidBase<kProton >; // Pr
677+ using TrackSelectorEl = TrackSelectorPidBase<kElectron >; // El
678+ using TrackSelectorMu = TrackSelectorPidBase<kMuonMinus >; // Mu
679+ using TrackSelectorPi = TrackSelectorPidBase<kPiPlus >; // Pi
680+ using TrackSelectorKa = TrackSelectorPidBase<kKPlus >; // Ka
681+ using TrackSelectorPr = TrackSelectorPidBase<kProton >; // Pr
682+ using TrackSelectorDe = TrackSelectorPidBase<o2::constants::physics::Pdg::kDeuteron >; // De
664683
665684#endif // COMMON_CORE_TRACKSELECTORPID_H_
0 commit comments