1212// / \file HfMlResponseB0ToDPi.h
1313// / \brief Class to compute the ML response for B0 → D∓ π± analysis selections
1414// / \author Alexandre Bigot <alexandre.bigot@cern.ch>, IPHC Strasbourg
15+ // / \author Vít Kučera <vit.kucera@cern.ch>, Inha University
1516
1617#ifndef PWGHF_CORE_HFMLRESPONSEB0TODPI_H_
1718#define PWGHF_CORE_HFMLRESPONSEB0TODPI_H_
5960 break ; \
6061 }
6162
63+ //
64+ // Make FEATURE from an element of VECTOR at INDEX.
65+ #define CHECK_AND_FILL_VEC_B0_INDEX (FEATURE, VECTOR, INDEX ) \
66+ case static_cast <uint8_t >(InputFeaturesB0ToDPi::FEATURE): { \
67+ inputFeatures.emplace_back ((VECTOR)[INDEX]); \
68+ break ; \
69+ }
70+
6271namespace o2 ::analysis
6372{
6473
@@ -84,7 +93,7 @@ enum class InputFeaturesB0ToDPi : uint8_t {
8493 tpcTofNSigmaPi1
8594};
8695
87- template <typename TypeOutputScore = float >
96+ template <typename TypeOutputScore, bool reduced >
8897class HfMlResponseB0ToDPi : public HfMlResponse <TypeOutputScore>
8998{
9099 public:
@@ -99,57 +108,50 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
99108 // / \return inputFeatures vector
100109 template <bool withDmesMl, typename T1, typename T2>
101110 std::vector<float > getInputFeatures (T1 const & candidate,
102- T2 const & prong1)
111+ T2 const & prong1,
112+ std::optional<std::vector<float >> const & mlScoresD)
103113 {
104114 std::vector<float > inputFeatures;
105115
106116 for (const auto & idx : MlResponse<TypeOutputScore>::mCachedIndices ) {
117+ switch (idx) {
118+ CHECK_AND_FILL_VEC_B0 (ptProng0);
119+ CHECK_AND_FILL_VEC_B0 (ptProng1);
120+ CHECK_AND_FILL_VEC_B0 (impactParameter0);
121+ CHECK_AND_FILL_VEC_B0 (impactParameter1);
122+ CHECK_AND_FILL_VEC_B0 (impactParameterProduct);
123+ CHECK_AND_FILL_VEC_B0 (chi2PCA);
124+ CHECK_AND_FILL_VEC_B0 (decayLength);
125+ CHECK_AND_FILL_VEC_B0 (decayLengthXY);
126+ CHECK_AND_FILL_VEC_B0 (decayLengthNormalised);
127+ CHECK_AND_FILL_VEC_B0 (decayLengthXYNormalised);
128+ CHECK_AND_FILL_VEC_B0 (cpa);
129+ CHECK_AND_FILL_VEC_B0 (cpaXY);
130+ CHECK_AND_FILL_VEC_B0 (maxNormalisedDeltaIP);
131+ // TPC PID variable
132+ CHECK_AND_FILL_VEC_B0_FULL (prong1, tpcNSigmaPi1, tpcNSigmaPi);
133+ // TOF PID variable
134+ CHECK_AND_FILL_VEC_B0_FULL (prong1, tofNSigmaPi1, tofNSigmaPi);
135+ // Combined PID variables
136+ CHECK_AND_FILL_VEC_B0_FUNC (prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
137+ }
107138 if constexpr (withDmesMl) {
108- switch (idx) {
109- CHECK_AND_FILL_VEC_B0 (ptProng0);
110- CHECK_AND_FILL_VEC_B0 (ptProng1);
111- CHECK_AND_FILL_VEC_B0 (impactParameter0);
112- CHECK_AND_FILL_VEC_B0 (impactParameter1);
113- CHECK_AND_FILL_VEC_B0 (impactParameterProduct);
114- CHECK_AND_FILL_VEC_B0 (chi2PCA);
115- CHECK_AND_FILL_VEC_B0 (decayLength);
116- CHECK_AND_FILL_VEC_B0 (decayLengthXY);
117- CHECK_AND_FILL_VEC_B0 (decayLengthNormalised);
118- CHECK_AND_FILL_VEC_B0 (decayLengthXYNormalised);
119- CHECK_AND_FILL_VEC_B0 (cpa);
120- CHECK_AND_FILL_VEC_B0 (cpaXY);
121- CHECK_AND_FILL_VEC_B0 (maxNormalisedDeltaIP);
122- CHECK_AND_FILL_VEC_B0 (prong0MlScoreBkg);
123- CHECK_AND_FILL_VEC_B0 (prong0MlScorePrompt);
124- CHECK_AND_FILL_VEC_B0 (prong0MlScoreNonprompt);
125- // TPC PID variable
126- CHECK_AND_FILL_VEC_B0_FULL (prong1, tpcNSigmaPi1, tpcNSigmaPi);
127- // TOF PID variable
128- CHECK_AND_FILL_VEC_B0_FULL (prong1, tofNSigmaPi1, tofNSigmaPi);
129- // Combined PID variables
130- CHECK_AND_FILL_VEC_B0_FUNC (prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
131- }
132- } else {
133- switch (idx) {
134- CHECK_AND_FILL_VEC_B0 (ptProng0);
135- CHECK_AND_FILL_VEC_B0 (ptProng1);
136- CHECK_AND_FILL_VEC_B0 (impactParameter0);
137- CHECK_AND_FILL_VEC_B0 (impactParameter1);
138- CHECK_AND_FILL_VEC_B0 (impactParameterProduct);
139- CHECK_AND_FILL_VEC_B0 (chi2PCA);
140- CHECK_AND_FILL_VEC_B0 (decayLength);
141- CHECK_AND_FILL_VEC_B0 (decayLengthXY);
142- CHECK_AND_FILL_VEC_B0 (decayLengthNormalised);
143- CHECK_AND_FILL_VEC_B0 (decayLengthXYNormalised);
144- CHECK_AND_FILL_VEC_B0 (cpa);
145- CHECK_AND_FILL_VEC_B0 (cpaXY);
146- CHECK_AND_FILL_VEC_B0 (maxNormalisedDeltaIP);
147- // TPC PID variable
148- CHECK_AND_FILL_VEC_B0_FULL (prong1, tpcNSigmaPi1, tpcNSigmaPi);
149- // TOF PID variable
150- CHECK_AND_FILL_VEC_B0_FULL (prong1, tofNSigmaPi1, tofNSigmaPi);
151- // Combined PID variables
152- CHECK_AND_FILL_VEC_B0_FUNC (prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
139+ if constexpr (reduced) {
140+ switch (idx) {
141+ CHECK_AND_FILL_VEC_B0 (prong0MlScoreBkg);
142+ CHECK_AND_FILL_VEC_B0 (prong0MlScorePrompt);
143+ CHECK_AND_FILL_VEC_B0 (prong0MlScoreNonprompt);
144+ }
145+ } else {
146+ if (mlScoresD) {
147+ switch (idx) {
148+ CHECK_AND_FILL_VEC_B0_INDEX (prong0MlScoreBkg, mlScoresD.value (), 0 );
149+ CHECK_AND_FILL_VEC_B0_INDEX (prong0MlScorePrompt, mlScoresD.value (), 1 );
150+ CHECK_AND_FILL_VEC_B0_INDEX (prong0MlScoreNonprompt, mlScoresD.value (), 2 );
151+ }
152+ } else {
153+ LOG (fatal) << " ML scores of D not provided" ;
154+ }
153155 }
154156 }
155157 }
0 commit comments