diff --git a/PWGHF/TableProducer/pidCreator.cxx b/PWGHF/TableProducer/pidCreator.cxx index e914c4f1c38..0f1e455313b 100644 --- a/PWGHF/TableProducer/pidCreator.cxx +++ b/PWGHF/TableProducer/pidCreator.cxx @@ -15,10 +15,9 @@ /// \author Vít Kučera , Inha University #include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsPid.h" #include "Common/Core/TableHelper.h" -#include "Common/DataModel/PIDResponseTOF.h" -#include "Common/DataModel/PIDResponseTPC.h" #include #include @@ -32,6 +31,7 @@ using namespace o2; using namespace o2::framework; +using namespace o2::aod::pid_tpc_tof_utils; struct HfPidCreator { Produces trackPidFullEl; @@ -47,9 +47,6 @@ struct HfPidCreator { Produces trackPidFullDe; Produces trackPidTinyDe; - static constexpr float NSigmaToleranceDefault = .1f; - static constexpr float NSigmaDefault = -999.f + NSigmaToleranceDefault; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h - /// Function to check whether the process function flag matches the need for filling the table /// \param initContext workflow context (argument of the init function) /// \param table name of the table @@ -85,30 +82,6 @@ struct HfPidCreator { checkTableSwitch(initContext, "PidTpcTofTinyDe", doprocessTinyDe); } - /// Function to combine TPC and TOF NSigma - /// \param tiny switch between full and tiny (binned) PID tables - /// \param tpcNSigma is the (binned) NSigma separation in TPC (if tiny = true) - /// \param tofNSigma is the (binned) NSigma separation in TOF (if tiny = true) - /// \return combined NSigma of TPC and TOF - template - T1 combineNSigma(T1 tpcNSigma, T1 tofNSigma) - { - if constexpr (Tiny) { - tpcNSigma *= aod::pidtpc_tiny::binning::bin_width; - tofNSigma *= aod::pidtof_tiny::binning::bin_width; - } - if ((tpcNSigma > NSigmaDefault) && (tofNSigma > NSigmaDefault)) { // TPC and TOF - return std::sqrt(.5f * (tpcNSigma * tpcNSigma + tofNSigma * tofNSigma)); - } - if (tpcNSigma > NSigmaDefault) { // only TPC - return std::abs(tpcNSigma); - } - if (tofNSigma > NSigmaDefault) { // only TOF - return std::abs(tofNSigma); - } - return tofNSigma; // no TPC nor TOF - } - void processDummy(aod::Collisions const&) {} PROCESS_SWITCH(HfPidCreator, processDummy, "Process nothing", true); diff --git a/PWGHF/Utils/utilsPid.h b/PWGHF/Utils/utilsPid.h index 629db2a0325..fc1d0d18940 100644 --- a/PWGHF/Utils/utilsPid.h +++ b/PWGHF/Utils/utilsPid.h @@ -43,29 +43,29 @@ enum PidMethod { NPidMethods }; -/// Function to combine TPC and TOF NSigma -/// \param tiny switch between full and tiny (binned) PID tables -/// \param nSigmaTpc is the (binned) NSigma separation in TPC (if tiny = true) -/// \param nSigmaTof is the (binned) NSigma separation in TOF (if tiny = true) -/// \return combined NSigma of TPC and TOF +/// Function to combine TPC and TOF nSigma +/// \tparam Tiny switch between full and tiny (binned) PID tables +/// \param nSigmaTpc is the (binned) nSigma separation in TPC (if Tiny = true) +/// \param nSigmaTof is the (binned) nSigma separation in TOF (if Tiny = true) +/// \return combined nSigma of TPC and TOF template TNumber combineNSigma(TNumber nSigmaTpc, TNumber nSigmaTof) { - static constexpr float DefaultNSigmaTolerance = .1f; - static constexpr float DefaultNSigma = -999.f + DefaultNSigmaTolerance; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h + static constexpr float NSigmaToleranceDefault = .1f; + static constexpr float NSigmaDefault = -999.f + NSigmaToleranceDefault; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h if constexpr (Tiny) { nSigmaTpc *= aod::pidtpc_tiny::binning::bin_width; nSigmaTof *= aod::pidtof_tiny::binning::bin_width; } - if ((nSigmaTpc > DefaultNSigma) && (nSigmaTof > DefaultNSigma)) { // TPC and TOF + if ((nSigmaTpc > NSigmaDefault) && (nSigmaTof > NSigmaDefault)) { // TPC and TOF return std::sqrt(.5f * (nSigmaTpc * nSigmaTpc + nSigmaTof * nSigmaTof)); } - if (nSigmaTpc > DefaultNSigma) { // only TPC + if (nSigmaTpc > NSigmaDefault) { // only TPC return std::abs(nSigmaTpc); } - if (nSigmaTof > DefaultNSigma) { // only TOF + if (nSigmaTof > NSigmaDefault) { // only TOF return std::abs(nSigmaTof); } return nSigmaTof; // no TPC nor TOF