Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 49 additions & 47 deletions PWGHF/Core/HfMlResponseB0ToDPi.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/// \file HfMlResponseB0ToDPi.h
/// \brief Class to compute the ML response for B0 → D∓ π± analysis selections
/// \author Alexandre Bigot <alexandre.bigot@cern.ch>, IPHC Strasbourg
/// \author Vít Kučera <vit.kucera@cern.ch>, Inha University

#ifndef PWGHF_CORE_HFMLRESPONSEB0TODPI_H_
#define PWGHF_CORE_HFMLRESPONSEB0TODPI_H_
Expand Down Expand Up @@ -59,6 +60,14 @@
break; \
}

//
// Make FEATURE from an element of VECTOR at INDEX.
#define CHECK_AND_FILL_VEC_B0_INDEX(FEATURE, VECTOR, INDEX) \
case static_cast<uint8_t>(InputFeaturesB0ToDPi::FEATURE): { \
inputFeatures.emplace_back((VECTOR)[INDEX]); \
break; \
}

namespace o2::analysis
{

Expand All @@ -84,7 +93,7 @@ enum class InputFeaturesB0ToDPi : uint8_t {
tpcTofNSigmaPi1
};

template <typename TypeOutputScore = float>
template <typename TypeOutputScore, bool reduced>
class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
{
public:
Expand All @@ -99,57 +108,50 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
/// \return inputFeatures vector
template <bool withDmesMl, typename T1, typename T2>
std::vector<float> getInputFeatures(T1 const& candidate,
T2 const& prong1)
T2 const& prong1,
const std::vector<float>* mlScoresD = nullptr)
{
std::vector<float> inputFeatures;

for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
switch (idx) {
CHECK_AND_FILL_VEC_B0(ptProng0);
CHECK_AND_FILL_VEC_B0(ptProng1);
CHECK_AND_FILL_VEC_B0(impactParameter0);
CHECK_AND_FILL_VEC_B0(impactParameter1);
CHECK_AND_FILL_VEC_B0(impactParameterProduct);
CHECK_AND_FILL_VEC_B0(chi2PCA);
CHECK_AND_FILL_VEC_B0(decayLength);
CHECK_AND_FILL_VEC_B0(decayLengthXY);
CHECK_AND_FILL_VEC_B0(decayLengthNormalised);
CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised);
CHECK_AND_FILL_VEC_B0(cpa);
CHECK_AND_FILL_VEC_B0(cpaXY);
CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP);
// TPC PID variable
CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
// TOF PID variable
CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
// Combined PID variables
CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
}
if constexpr (withDmesMl) {
switch (idx) {
CHECK_AND_FILL_VEC_B0(ptProng0);
CHECK_AND_FILL_VEC_B0(ptProng1);
CHECK_AND_FILL_VEC_B0(impactParameter0);
CHECK_AND_FILL_VEC_B0(impactParameter1);
CHECK_AND_FILL_VEC_B0(impactParameterProduct);
CHECK_AND_FILL_VEC_B0(chi2PCA);
CHECK_AND_FILL_VEC_B0(decayLength);
CHECK_AND_FILL_VEC_B0(decayLengthXY);
CHECK_AND_FILL_VEC_B0(decayLengthNormalised);
CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised);
CHECK_AND_FILL_VEC_B0(cpa);
CHECK_AND_FILL_VEC_B0(cpaXY);
CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP);
CHECK_AND_FILL_VEC_B0(prong0MlScoreBkg);
CHECK_AND_FILL_VEC_B0(prong0MlScorePrompt);
CHECK_AND_FILL_VEC_B0(prong0MlScoreNonprompt);
// TPC PID variable
CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
// TOF PID variable
CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
// Combined PID variables
CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
}
} else {
switch (idx) {
CHECK_AND_FILL_VEC_B0(ptProng0);
CHECK_AND_FILL_VEC_B0(ptProng1);
CHECK_AND_FILL_VEC_B0(impactParameter0);
CHECK_AND_FILL_VEC_B0(impactParameter1);
CHECK_AND_FILL_VEC_B0(impactParameterProduct);
CHECK_AND_FILL_VEC_B0(chi2PCA);
CHECK_AND_FILL_VEC_B0(decayLength);
CHECK_AND_FILL_VEC_B0(decayLengthXY);
CHECK_AND_FILL_VEC_B0(decayLengthNormalised);
CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised);
CHECK_AND_FILL_VEC_B0(cpa);
CHECK_AND_FILL_VEC_B0(cpaXY);
CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP);
// TPC PID variable
CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
// TOF PID variable
CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
// Combined PID variables
CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
if constexpr (reduced) {
switch (idx) {
CHECK_AND_FILL_VEC_B0(prong0MlScoreBkg);
CHECK_AND_FILL_VEC_B0(prong0MlScorePrompt);
CHECK_AND_FILL_VEC_B0(prong0MlScoreNonprompt);
}
} else {
if (mlScoresD) {
switch (idx) {
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreBkg, *mlScoresD, 0);
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScorePrompt, *mlScoresD, 1);
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreNonprompt, *mlScoresD, 2);
}
} else {
LOG(fatal) << "ML scores of D not provided";
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
// variable that will store the value of selectionFlagD (defined in dataCreatorDplusPiReduced.cxx)
int mySelectionFlagD = -1;

o2::analysis::HfMlResponseB0ToDPi<float> hfMlResponse;
o2::analysis::HfMlResponseB0ToDPi<float, true> hfMlResponse;
float outputMlNotPreselected = -1.;
std::vector<float> outputMl = {};
o2::ccdb::CcdbApi ccdbApi;
Expand All @@ -97,7 +97,7 @@
LOGP(fatal, "Only one process function for data should be enabled at a time.");
}

if (pionPidMethod < 0 || pionPidMethod > 2) {

Check failure on line 100 in PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)");
}

Expand Down
41 changes: 21 additions & 20 deletions PWGHF/DataModel/CandidateReconstructionTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! Collision
DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, Tracks, "_0"); //! Index to first prong
DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, Tracks, "_1"); //! Index to second prong
DECLARE_SOA_INDEX_COLUMN_FULL(Prong2, prong2, int, Tracks, "_2"); //! Index to third prong
DECLARE_SOA_INDEX_COLUMN_FULL(Prong3, prong3, int, Tracks, "_3"); //! Index to fourth prong
DECLARE_SOA_INDEX_COLUMN(V0, v0); //! Index to V0 prong
DECLARE_SOA_INDEX_COLUMN(Cascade, cascade); //! Index to cascade prong
DECLARE_SOA_COLUMN(HFflag, hfflag, uint8_t); //! Bitmap to store selection results, o2-linter: disable=name/o2-column (written to disk)
Expand Down Expand Up @@ -483,28 +484,28 @@ DECLARE_SOA_COLUMN(ImpactParameterZ2, impactParameterZ2, float);
DECLARE_SOA_COLUMN(ErrorImpactParameterZ2, errorImpactParameterZ2, float); //!
DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterZNormalised2, impactParameterZNormalised2, //!
[](float dca, float err) -> float { return dca / err; });
/// prong PID nsigma
DECLARE_SOA_COLUMN(NProngsContributorsPV, nProngsContributorsPV, uint8_t); //! number of prongs contributing to the primary-vertex reconstruction
DECLARE_SOA_COLUMN(BitmapProngsContributorsPV, bitmapProngsContributorsPV, uint8_t); //! bitmap with booleans indicating prongs contributing to the primary-vertex reconstruction
DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); //! TPC nSigma for pion hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float); //! TPC nSigma for pion hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); //! TPC nSigma for pion hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float); //! TPC nSigma for kaon hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTpcKa1, nSigTpcKa1, float); //! TPC nSigma for kaon hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTpcKa2, nSigTpcKa2, float); //! TPC nSigma for kaon hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTpcPr0, nSigTpcPr0, float); //! TPC nSigma for proton hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTpcPr1, nSigTpcPr1, float); //! TPC nSigma for proton hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); //! TPC nSigma for proton hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float); //! TOF nSigma for pion hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); //! TOF nSigma for pion hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); //! TOF nSigma for pion hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float); //! TOF nSigma for kaon hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float); //! TOF nSigma for kaon hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTofKa2, nSigTofKa2, float); //! TOF nSigma for kaon hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTofPr0, nSigTofPr0, float); //! TOF nSigma for proton hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTofPr1, nSigTofPr1, float); //! TOF nSigma for proton hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); //! TOF nSigma for proton hypothesis - prong 2
DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi0, tpcTofNSigmaPi0, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 0
/// prong PID nsigma
DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); //! TPC nSigma for pion hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float); //! TPC nSigma for pion hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); //! TPC nSigma for pion hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float); //! TPC nSigma for kaon hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTpcKa1, nSigTpcKa1, float); //! TPC nSigma for kaon hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTpcKa2, nSigTpcKa2, float); //! TPC nSigma for kaon hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTpcPr0, nSigTpcPr0, float); //! TPC nSigma for proton hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTpcPr1, nSigTpcPr1, float); //! TPC nSigma for proton hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); //! TPC nSigma for proton hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float); //! TOF nSigma for pion hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); //! TOF nSigma for pion hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); //! TOF nSigma for pion hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float); //! TOF nSigma for kaon hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float); //! TOF nSigma for kaon hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTofKa2, nSigTofKa2, float); //! TOF nSigma for kaon hypothesis - prong 2
DECLARE_SOA_COLUMN(NSigTofPr0, nSigTofPr0, float); //! TOF nSigma for proton hypothesis - prong 0
DECLARE_SOA_COLUMN(NSigTofPr1, nSigTofPr1, float); //! TOF nSigma for proton hypothesis - prong 1
DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); //! TOF nSigma for proton hypothesis - prong 2
DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi0, tpcTofNSigmaPi0, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 0
[](float tpcNSigmaPi0, float tofNSigmaPi0) -> float { return pid_tpc_tof_utils::combineNSigma<false /*tiny*/>(tpcNSigmaPi0, tofNSigmaPi0); });
DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi1, tpcTofNSigmaPi1, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 1
[](float tpcNSigmaPi1, float tofNSigmaPi1) -> float { return pid_tpc_tof_utils::combineNSigma<false /*tiny*/>(tpcNSigmaPi1, tofNSigmaPi1); });
Expand Down
Loading
Loading