2424
2525#include < cstdint>
2626
27- using namespace o2 ::constants::physics;
28-
2927// / Class for track selection using PID detectors
3028
3129struct TrackSelectorPID {
@@ -45,6 +43,9 @@ class TrackSelectorPidBase
4543 // / Default constructor
4644 TrackSelectorPidBase () = default ;
4745
46+ static constexpr float kPidNsigmaMin = -999 .f;
47+ static constexpr float kPidNsigmaMax = 999 .f;
48+
4849 // / Conversion operator
4950 template <uint64_t pdgNew>
5051 operator TrackSelectorPidBase<pdgNew>() const
@@ -113,7 +114,7 @@ class TrackSelectorPidBase
113114 bool isSelectedByTpc (const T& track, bool & conditionalTof, float tpcNSigmaCustom = -999 .f)
114115 {
115116 // Accept if selection is disabled via large values.
116- if (mNSigmaTpcMin < - 999 . && mNSigmaTpcMax > 999 . ) {
117+ if (mNSigmaTpcMin < kPidNsigmaMin && mNSigmaTpcMax > kPidNsigmaMax ) {
117118 return true ;
118119 }
119120
@@ -129,18 +130,18 @@ class TrackSelectorPidBase
129130 nSigma = track.tpcNSigmaKa ();
130131 } else if constexpr (pdg == kProton ) {
131132 nSigma = track.tpcNSigmaPr ();
132- } else if constexpr (pdg == kDeuteron ) {
133+ } else if constexpr (pdg == o2::constants::physics:: kDeuteron ) {
133134 nSigma = track.tpcNSigmaDe ();
134135 } else {
135136 errorPdg ();
136137 }
137138
138139 // / use custom TPC nσ, if a valid value is provided
139- if (tpcNSigmaCustom > - 999 . f ) {
140+ if (tpcNSigmaCustom > kPidNsigmaMin ) {
140141 nSigma = tpcNSigmaCustom;
141142 }
142143
143- if (mNSigmaTpcMinCondTof < - 999 . && mNSigmaTpcMaxCondTof > 999 . ) {
144+ if (mNSigmaTpcMinCondTof < kPidNsigmaMin && mNSigmaTpcMaxCondTof > kPidNsigmaMax ) {
144145 conditionalTof = true ;
145146 } else {
146147 conditionalTof = mNSigmaTpcMinCondTof <= nSigma && nSigma <= mNSigmaTpcMaxCondTof ;
@@ -209,7 +210,7 @@ class TrackSelectorPidBase
209210 bool isSelectedByTof (const T& track, bool & conditionalTpc, float tofNSigmaCustom = -999 .f)
210211 {
211212 // Accept if selection is disabled via large values.
212- if (mNSigmaTofMin < - 999 . && mNSigmaTofMax > 999 . ) {
213+ if (mNSigmaTofMin < kPidNsigmaMin && mNSigmaTofMax > kPidNsigmaMax ) {
213214 return true ;
214215 }
215216
@@ -225,18 +226,18 @@ class TrackSelectorPidBase
225226 nSigma = track.tofNSigmaKa ();
226227 } else if constexpr (pdg == kProton ) {
227228 nSigma = track.tofNSigmaPr ();
228- } else if constexpr (pdg == kDeuteron ) {
229+ } else if constexpr (pdg == o2::constants::physics:: kDeuteron ) {
229230 nSigma = track.tofNSigmaDe ();
230231 } else {
231232 errorPdg ();
232233 }
233234
234235 // / use custom TOF nσ, if a valid value is provided
235- if (tofNSigmaCustom > - 999 . f ) {
236+ if (tofNSigmaCustom > kPidNsigmaMin ) {
236237 nSigma = tofNSigmaCustom;
237238 }
238239
239- if (mNSigmaTofMinCondTpc < - 999 . && mNSigmaTofMaxCondTpc > 999 . ) {
240+ if (mNSigmaTofMinCondTpc < kPidNsigmaMin && mNSigmaTofMaxCondTpc > kPidNsigmaMax ) {
240241 conditionalTpc = true ;
241242 } else {
242243 conditionalTpc = mNSigmaTofMinCondTpc <= nSigma && nSigma <= mNSigmaTofMaxCondTpc ;
@@ -307,7 +308,7 @@ class TrackSelectorPidBase
307308 bool isSelectedByRich (const T& track, bool & conditionalTof)
308309 {
309310 // Accept if selection is disabled via large values.
310- if (mNSigmaRichMin < - 999 . && mNSigmaRichMax > 999 . ) {
311+ if (mNSigmaRichMin < kPidNsigmaMin && mNSigmaRichMax > kPidNsigmaMax ) {
311312 return true ;
312313 }
313314
@@ -327,7 +328,7 @@ class TrackSelectorPidBase
327328 errorPdg ();
328329 }
329330
330- if (mNSigmaRichMinCondTof < - 999 . && mNSigmaRichMaxCondTof > 999 . ) {
331+ if (mNSigmaRichMinCondTof < kPidNsigmaMin && mNSigmaRichMaxCondTof > kPidNsigmaMax ) {
331332 conditionalTof = true ;
332333 } else {
333334 conditionalTof = mNSigmaRichMinCondTof <= nSigma && nSigma <= mNSigmaRichMaxCondTof ;
@@ -470,23 +471,29 @@ class TrackSelectorPidBase
470471 template <typename T>
471472 bool isElectronAndNotPion (const T& track, bool useTof = true , bool useRich = true )
472473 {
474+ static constexpr float kPidNsigmaInvalid = -1000 .f ;
475+ static constexpr float kPidTofRichTransitionPMin = 0 .4f ;
476+ static constexpr float kPidTofRichTransitionPMax = 0 .6f ;
477+ static constexpr float kPidRichPionBandPMin = 1 .0f ;
478+ static constexpr float kPidRichPionBandPMax = 2 .0f ;
479+
473480 bool isSelTof = false ;
474481 bool isSelRich = false ;
475482 bool hasRich = track.richId () > -1 ;
476483 bool hasTof = isValidForTof (track);
477484 auto nSigmaTofEl = track.tofNSigmaEl ();
478485 auto nSigmaTofPi = track.tofNSigmaPi ();
479- auto nSigmaRichEl = hasRich ? track.rich ().richNsigmaEl () : - 1000 . ;
480- auto nSigmaRichPi = hasRich ? track.rich ().richNsigmaPi () : - 1000 . ;
486+ auto nSigmaRichEl = hasRich ? track.rich ().richNsigmaEl () : kPidNsigmaInvalid ;
487+ auto nSigmaRichPi = hasRich ? track.rich ().richNsigmaPi () : kPidNsigmaInvalid ;
481488 auto p = track.p ();
482489
483490 // TOF
484- if (useTof && hasTof && (p < 0.6 )) {
485- if (p > 0.4 && hasRich) {
491+ if (useTof && hasTof && (p < kPidTofRichTransitionPMax )) {
492+ if (p > kPidTofRichTransitionPMin && hasRich) {
486493 if ((std::abs (nSigmaTofEl) < mNSigmaTofMax ) && (std::abs (nSigmaRichEl) < mNSigmaRichMax )) {
487494 isSelTof = true ; // is selected as electron by TOF and RICH
488495 }
489- } else if (p <= 0.4 ) {
496+ } else if (p <= kPidTofRichTransitionPMin ) {
490497 if (std::abs (nSigmaTofEl) < mNSigmaTofMax ) {
491498 isSelTof = true ; // is selected as electron by TOF
492499 }
@@ -505,7 +512,7 @@ class TrackSelectorPidBase
505512 if (std::abs (nSigmaRichEl) < mNSigmaRichMax ) {
506513 isSelRich = true ; // is selected as electron by RICH
507514 }
508- if ((std::abs (nSigmaRichPi) < mNSigmaRichMax ) && (p > 1.0 ) && (p < 2.0 )) {
515+ if ((std::abs (nSigmaRichPi) < mNSigmaRichMax ) && (p > kPidRichPionBandPMin ) && (p < kPidRichPionBandPMax )) {
509516 isSelRich = false ; // is selected as pion by RICH
510517 }
511518 } else {
@@ -557,7 +564,7 @@ class TrackSelectorPidBase
557564 return track.bayesID () == o2::track::PID::Kaon;
558565 } else if constexpr (pdg == kProton ) {
559566 return track.bayesID () == o2::track::PID::Proton;
560- } else if constexpr (pdg == kDeuteron ) {
567+ } else if constexpr (pdg == o2::constants::physics:: kDeuteron ) {
561568 return track.bayesID () == o2::track::PID::Deuteron;
562569 } else {
563570 errorPdg ();
@@ -587,7 +594,7 @@ class TrackSelectorPidBase
587594 prob = track.bayesKa ();
588595 } else if constexpr (pdg == kProton ) {
589596 prob = track.bayesPr ();
590- } else if constexpr (pdg == kDeuteron ) {
597+ } else if constexpr (pdg == o2::constants::physics:: kDeuteron ) {
591598 prob = track.bayesDe ();
592599 } else {
593600 errorPdg ();
@@ -666,11 +673,11 @@ class TrackSelectorPidBase
666673};
667674
668675// Predefined types
669- using TrackSelectorEl = TrackSelectorPidBase<kElectron >; // El
670- using TrackSelectorMu = TrackSelectorPidBase<kMuonMinus >; // Mu
671- using TrackSelectorPi = TrackSelectorPidBase<kPiPlus >; // Pi
672- using TrackSelectorKa = TrackSelectorPidBase<kKPlus >; // Ka
673- using TrackSelectorPr = TrackSelectorPidBase<kProton >; // Pr
674- using TrackSelectorDe = TrackSelectorPidBase<kDeuteron >; // De
676+ using TrackSelectorEl = TrackSelectorPidBase<kElectron >; // El
677+ using TrackSelectorMu = TrackSelectorPidBase<kMuonMinus >; // Mu
678+ using TrackSelectorPi = TrackSelectorPidBase<kPiPlus >; // Pi
679+ using TrackSelectorKa = TrackSelectorPidBase<kKPlus >; // Ka
680+ using TrackSelectorPr = TrackSelectorPidBase<kProton >; // Pr
681+ using TrackSelectorDe = TrackSelectorPidBase<o2::constants::physics:: kDeuteron >; // De
675682
676683#endif // COMMON_CORE_TRACKSELECTORPID_H_
0 commit comments