Skip to content

Commit 4b84398

Browse files
authored
[PWGHF] pidCreator: Use combineNSigma from utilsPid.h (#13519)
1 parent 76880f6 commit 4b84398

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

PWGHF/TableProducer/pidCreator.cxx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
/// \author Vít Kučera <vit.kucera@cern.ch>, Inha University
1616

1717
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
18+
#include "PWGHF/Utils/utilsPid.h"
1819

1920
#include "Common/Core/TableHelper.h"
20-
#include "Common/DataModel/PIDResponseTOF.h"
21-
#include "Common/DataModel/PIDResponseTPC.h"
2221

2322
#include <Framework/AnalysisDataModel.h>
2423
#include <Framework/AnalysisHelpers.h>
@@ -32,6 +31,7 @@
3231

3332
using namespace o2;
3433
using namespace o2::framework;
34+
using namespace o2::aod::pid_tpc_tof_utils;
3535

3636
struct HfPidCreator {
3737
Produces<aod::PidTpcTofFullEl> trackPidFullEl;
@@ -47,9 +47,6 @@ struct HfPidCreator {
4747
Produces<aod::PidTpcTofFullDe> trackPidFullDe;
4848
Produces<aod::PidTpcTofTinyDe> trackPidTinyDe;
4949

50-
static constexpr float NSigmaToleranceDefault = .1f;
51-
static constexpr float NSigmaDefault = -999.f + NSigmaToleranceDefault; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h
52-
5350
/// Function to check whether the process function flag matches the need for filling the table
5451
/// \param initContext workflow context (argument of the init function)
5552
/// \param table name of the table
@@ -85,30 +82,6 @@ struct HfPidCreator {
8582
checkTableSwitch(initContext, "PidTpcTofTinyDe", doprocessTinyDe);
8683
}
8784

88-
/// Function to combine TPC and TOF NSigma
89-
/// \param tiny switch between full and tiny (binned) PID tables
90-
/// \param tpcNSigma is the (binned) NSigma separation in TPC (if tiny = true)
91-
/// \param tofNSigma is the (binned) NSigma separation in TOF (if tiny = true)
92-
/// \return combined NSigma of TPC and TOF
93-
template <bool Tiny, typename T1>
94-
T1 combineNSigma(T1 tpcNSigma, T1 tofNSigma)
95-
{
96-
if constexpr (Tiny) {
97-
tpcNSigma *= aod::pidtpc_tiny::binning::bin_width;
98-
tofNSigma *= aod::pidtof_tiny::binning::bin_width;
99-
}
100-
if ((tpcNSigma > NSigmaDefault) && (tofNSigma > NSigmaDefault)) { // TPC and TOF
101-
return std::sqrt(.5f * (tpcNSigma * tpcNSigma + tofNSigma * tofNSigma));
102-
}
103-
if (tpcNSigma > NSigmaDefault) { // only TPC
104-
return std::abs(tpcNSigma);
105-
}
106-
if (tofNSigma > NSigmaDefault) { // only TOF
107-
return std::abs(tofNSigma);
108-
}
109-
return tofNSigma; // no TPC nor TOF
110-
}
111-
11285
void processDummy(aod::Collisions const&) {}
11386
PROCESS_SWITCH(HfPidCreator, processDummy, "Process nothing", true);
11487

PWGHF/Utils/utilsPid.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@ enum PidMethod {
4343
NPidMethods
4444
};
4545

46-
/// Function to combine TPC and TOF NSigma
47-
/// \param tiny switch between full and tiny (binned) PID tables
48-
/// \param nSigmaTpc is the (binned) NSigma separation in TPC (if tiny = true)
49-
/// \param nSigmaTof is the (binned) NSigma separation in TOF (if tiny = true)
50-
/// \return combined NSigma of TPC and TOF
46+
/// Function to combine TPC and TOF nSigma
47+
/// \tparam Tiny switch between full and tiny (binned) PID tables
48+
/// \param nSigmaTpc is the (binned) nSigma separation in TPC (if Tiny = true)
49+
/// \param nSigmaTof is the (binned) nSigma separation in TOF (if Tiny = true)
50+
/// \return combined nSigma of TPC and TOF
5151
template <bool Tiny, typename TNumber>
5252
TNumber combineNSigma(TNumber nSigmaTpc, TNumber nSigmaTof)
5353
{
54-
static constexpr float DefaultNSigmaTolerance = .1f;
55-
static constexpr float DefaultNSigma = -999.f + DefaultNSigmaTolerance; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h
54+
static constexpr float NSigmaToleranceDefault = .1f;
55+
static constexpr float NSigmaDefault = -999.f + NSigmaToleranceDefault; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h
5656

5757
if constexpr (Tiny) {
5858
nSigmaTpc *= aod::pidtpc_tiny::binning::bin_width;
5959
nSigmaTof *= aod::pidtof_tiny::binning::bin_width;
6060
}
6161

62-
if ((nSigmaTpc > DefaultNSigma) && (nSigmaTof > DefaultNSigma)) { // TPC and TOF
62+
if ((nSigmaTpc > NSigmaDefault) && (nSigmaTof > NSigmaDefault)) { // TPC and TOF
6363
return std::sqrt(.5f * (nSigmaTpc * nSigmaTpc + nSigmaTof * nSigmaTof));
6464
}
65-
if (nSigmaTpc > DefaultNSigma) { // only TPC
65+
if (nSigmaTpc > NSigmaDefault) { // only TPC
6666
return std::abs(nSigmaTpc);
6767
}
68-
if (nSigmaTof > DefaultNSigma) { // only TOF
68+
if (nSigmaTof > NSigmaDefault) { // only TOF
6969
return std::abs(nSigmaTof);
7070
}
7171
return nSigmaTof; // no TPC nor TOF

0 commit comments

Comments
 (0)