Skip to content

Commit 2d57d25

Browse files
Update TrackSelectorPID.h
1 parent 14d9676 commit 2d57d25

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

Common/Core/TrackSelectorPID.h

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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,8 +44,8 @@ class TrackSelectorPidBase
4344
/// Default constructor
4445
TrackSelectorPidBase() = default;
4546

46-
static constexpr float NsigmaPidMin = -999.f;
47-
static constexpr float NsigmaPidMax = 999.f;
47+
static constexpr float NSigmaMinDefault{-999.f};
48+
static constexpr float NSigmaMaxDefault{999.f};
4849

4950
/// Conversion operator
5051
template <uint64_t pdgNew>
@@ -111,10 +112,10 @@ class TrackSelectorPidBase
111112
/// \param tpcNSigmaCustom custom TPC nσ value to be used for the selection, in case the desired value cannot be taken from the track table
112113
/// \return true if track satisfies TPC PID hypothesis for given TPC nσ range
113114
template <typename T>
114-
bool isSelectedByTpc(const T& track, bool& conditionalTof, float tpcNSigmaCustom = -999.f)
115+
bool isSelectedByTpc(const T& track, bool& conditionalTof, float tpcNSigmaCustom = NSigmaMinDefault)
115116
{
116117
// Accept if selection is disabled via large values.
117-
if (mNSigmaTpcMin < NsigmaPidMin && mNSigmaTpcMax > NsigmaPidMax) {
118+
if (mNSigmaTpcMin < NSigmaMinDefault && mNSigmaTpcMax > NSigmaMaxDefault) {
118119
return true;
119120
}
120121

@@ -137,11 +138,11 @@ class TrackSelectorPidBase
137138
}
138139

139140
/// use custom TPC nσ, if a valid value is provided
140-
if (tpcNSigmaCustom > NsigmaPidMin) {
141+
if (tpcNSigmaCustom > NSigmaMinDefault) {
141142
nSigma = tpcNSigmaCustom;
142143
}
143144

144-
if (mNSigmaTpcMinCondTof < NsigmaPidMin && mNSigmaTpcMaxCondTof > NsigmaPidMax) {
145+
if (mNSigmaTpcMinCondTof < NSigmaMinDefault && mNSigmaTpcMaxCondTof > NSigmaMaxDefault) {
145146
conditionalTof = true;
146147
} else {
147148
conditionalTof = mNSigmaTpcMinCondTof <= nSigma && nSigma <= mNSigmaTpcMaxCondTof;
@@ -153,7 +154,7 @@ class TrackSelectorPidBase
153154
/// \param track track
154155
/// \return TPC selection status (see TrackSelectorPID::Status)
155156
template <typename T>
156-
TrackSelectorPID::Status statusTpc(const T& track, float tpcNSigmaCustom = -999.f)
157+
TrackSelectorPID::Status statusTpc(const T& track, float tpcNSigmaCustom = NSigmaMinDefault)
157158
{
158159
if (!isValidForTpc(track)) {
159160
return TrackSelectorPID::NotApplicable;
@@ -207,10 +208,10 @@ class TrackSelectorPidBase
207208
/// \param tofNSigmaCustom custom TOF nσ value to be used for the selection, in case the desired value cannot be taken from the track table
208209
/// \return true if track satisfies TOF PID hypothesis for given TOF nσ range
209210
template <typename T>
210-
bool isSelectedByTof(const T& track, bool& conditionalTpc, float tofNSigmaCustom = -999.f)
211+
bool isSelectedByTof(const T& track, bool& conditionalTpc, float tofNSigmaCustom = NSigmaMinDefault)
211212
{
212213
// Accept if selection is disabled via large values.
213-
if (mNSigmaTofMin < NsigmaPidMin && mNSigmaTofMax > NsigmaPidMax) {
214+
if (mNSigmaTofMin < NSigmaMinDefault && mNSigmaTofMax > NSigmaMaxDefault) {
214215
return true;
215216
}
216217

@@ -233,11 +234,11 @@ class TrackSelectorPidBase
233234
}
234235

235236
/// use custom TOF nσ, if a valid value is provided
236-
if (tofNSigmaCustom > NsigmaPidMin) {
237+
if (tofNSigmaCustom > NSigmaMinDefault) {
237238
nSigma = tofNSigmaCustom;
238239
}
239240

240-
if (mNSigmaTofMinCondTpc < NsigmaPidMin && mNSigmaTofMaxCondTpc > NsigmaPidMax) {
241+
if (mNSigmaTofMinCondTpc < NSigmaMinDefault && mNSigmaTofMaxCondTpc > NSigmaMaxDefault) {
241242
conditionalTpc = true;
242243
} else {
243244
conditionalTpc = mNSigmaTofMinCondTpc <= nSigma && nSigma <= mNSigmaTofMaxCondTpc;
@@ -249,7 +250,7 @@ class TrackSelectorPidBase
249250
/// \param track track
250251
/// \return TOF selection status (see TrackSelectorPID::Status)
251252
template <typename T>
252-
TrackSelectorPID::Status statusTof(const T& track, float tofNSigmaCustom = -999.f)
253+
TrackSelectorPID::Status statusTof(const T& track, float tofNSigmaCustom = NSigmaMinDefault)
253254
{
254255
if (!isValidForTof(track)) {
255256
return TrackSelectorPID::NotApplicable;
@@ -308,7 +309,7 @@ class TrackSelectorPidBase
308309
bool isSelectedByRich(const T& track, bool& conditionalTof)
309310
{
310311
// Accept if selection is disabled via large values.
311-
if (mNSigmaRichMin < NsigmaPidMin && mNSigmaRichMax > NsigmaPidMax) {
312+
if (mNSigmaRichMin < NSigmaMinDefault && mNSigmaRichMax > NSigmaMaxDefault) {
312313
return true;
313314
}
314315

@@ -328,7 +329,7 @@ class TrackSelectorPidBase
328329
errorPdg();
329330
}
330331

331-
if (mNSigmaRichMinCondTof < NsigmaPidMin && mNSigmaRichMaxCondTof > NsigmaPidMax) {
332+
if (mNSigmaRichMinCondTof < NSigmaMinDefault && mNSigmaRichMaxCondTof > NSigmaMaxDefault) {
332333
conditionalTof = true;
333334
} else {
334335
conditionalTof = mNSigmaRichMinCondTof <= nSigma && nSigma <= mNSigmaRichMaxCondTof;
@@ -412,7 +413,7 @@ class TrackSelectorPidBase
412413
/// \param track track
413414
/// \return status of combined PID (TPC or TOF) (see TrackSelectorPID::Status)
414415
template <typename T>
415-
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)
416417
{
417418
int pidTpc = statusTpc(track, tpcNSigmaCustom);
418419
int pidTof = statusTof(track, tofNSigmaCustom);
@@ -433,7 +434,7 @@ class TrackSelectorPidBase
433434
/// \param track track
434435
/// \return status of combined PID (TPC and TOF) (see TrackSelectorPID::Status)
435436
template <typename T>
436-
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)
437438
{
438439
int pidTpc = TrackSelectorPID::NotApplicable;
439440
if (track.hasTPC()) {
@@ -471,29 +472,29 @@ class TrackSelectorPidBase
471472
template <typename T>
472473
bool isElectronAndNotPion(const T& track, bool useTof = true, bool useRich = true)
473474
{
474-
static constexpr float PidNsigmaInvalid = -1000.f;
475-
static constexpr float PidTofRichTransitionPMin = 0.4f;
476-
static constexpr float PidTofRichTransitionPMax = 0.6f;
477-
static constexpr float PidRichPionBandPMin = 1.0f;
478-
static constexpr float PidRichPionBandPMax = 2.0f;
475+
static constexpr float NSigmaInvalid{-1000.f};
476+
static constexpr float PTofRichTElectronMin{0.4f};
477+
static constexpr float PTofRichTElectronMax{0.6f};
478+
static constexpr float PRichPionBandMin{1.0f};
479+
static constexpr float PRichPionBandMax{2.0f};
479480

480481
bool isSelTof = false;
481482
bool isSelRich = false;
482483
bool hasRich = track.richId() > -1;
483484
bool hasTof = isValidForTof(track);
484485
auto nSigmaTofEl = track.tofNSigmaEl();
485486
auto nSigmaTofPi = track.tofNSigmaPi();
486-
auto nSigmaRichEl = hasRich ? track.rich().richNsigmaEl() : PidNsigmaInvalid;
487-
auto nSigmaRichPi = hasRich ? track.rich().richNsigmaPi() : PidNsigmaInvalid;
487+
auto nSigmaRichEl = hasRich ? track.rich().richNsigmaEl() : NSigmaInvalid;
488+
auto nSigmaRichPi = hasRich ? track.rich().richNsigmaPi() : NSigmaInvalid;
488489
auto p = track.p();
489490

490491
// TOF
491-
if (useTof && hasTof && (p < PidTofRichTransitionPMax)) {
492-
if (p > PidTofRichTransitionPMin && hasRich) {
492+
if (useTof && hasTof && (p < PTofRichTElectronMax)) {
493+
if (p > PTofRichTElectronMin && hasRich) {
493494
if ((std::abs(nSigmaTofEl) < mNSigmaTofMax) && (std::abs(nSigmaRichEl) < mNSigmaRichMax)) {
494495
isSelTof = true; // is selected as electron by TOF and RICH
495496
}
496-
} else if (p <= PidTofRichTransitionPMin) {
497+
} else if (p <= PTofRichTElectronMin) {
497498
if (std::abs(nSigmaTofEl) < mNSigmaTofMax) {
498499
isSelTof = true; // is selected as electron by TOF
499500
}
@@ -512,7 +513,7 @@ class TrackSelectorPidBase
512513
if (std::abs(nSigmaRichEl) < mNSigmaRichMax) {
513514
isSelRich = true; // is selected as electron by RICH
514515
}
515-
if ((std::abs(nSigmaRichPi) < mNSigmaRichMax) && (p > PidRichPionBandPMin) && (p < PidRichPionBandPMax)) {
516+
if ((std::abs(nSigmaRichPi) < mNSigmaRichMax) && (p > PRichPionBandMin) && (p < PRichPionBandMax)) {
516517
isSelRich = false; // is selected as pion by RICH
517518
}
518519
} else {

0 commit comments

Comments
 (0)