@@ -156,20 +156,51 @@ struct HfCandidateSelectorB0ToDPiReduced {
156156 }
157157 }
158158
159- // For D* channel
160- template <IsB0ToDstarPiChannel T>
161- auto getTrackBachPi (const T& candidate)
162- {
159+ // / Utility function to retrieve the bach pion track
160+ // /from the B0 candidate in the D*-pi decay channel
161+ // / \param candidate is the B0 candidate
162+ // / \return bach pion track
163+ template <IsB0ToDstarPiChannel T1>
164+ auto getTrackBachPi (const T1& candidate) {
163165 return candidate.template prongBachPi_as <TracksBachPion>();
164166 }
165167
166- // For non-D* channel
167- template <typename T>
168- auto getTrackBachPi (const T& candidate)
169- {
168+ // / Method to get the input features vector needed for ML inference
169+ // / \param candidate is the B0 candidate
170+ // / \param prongBachPi is the candidate's bachelor pion prong
171+ // / \note this method is used for B0 → D*- π+ candidates with D meson ML scores
172+ template <bool withDmesMl, IsB0ToDstarPiChannel T1, typename T2>
173+ auto getMlInputFeatures (const T1& candB0, const T2& prongBachPi) {
174+ auto prongSoftPi = candB0.template prongSoftPi_as <TracksSoftPions>();
175+ if constexpr (withDmesMl) {
176+ return hfMlResponse.getInputFeaturesDStarPi <true >(candB0, prongBachPi, prongSoftPi);
177+ } else {
178+ return hfMlResponse.getInputFeaturesDStarPi <false >(candB0, prongBachPi, prongSoftPi);
179+ }
180+ }
181+
182+ // / Utility function to retrieve the bach pion track
183+ // /from the B0 candidate in the D-pi decay channel
184+ // / \param candidate is the B0 candidate
185+ // / \return bach pion track
186+ template <typename T1>
187+ auto getTrackBachPi (const T1& candidate) {
170188 return candidate.template prong1_as <TracksBachPion>();
171189 }
172190
191+ // / Method to get the input features vector needed for ML inference
192+ // / \param candB0 is the B0 candidate
193+ // / \param prongBachPi is the candidate's bachelor pion prong
194+ // / \note this method is used for B0 → D- π+ candidates with D meson ML scores
195+ template <bool withDmesMl, typename T1, typename T2>
196+ auto getMlInputFeatures (const T1& candB0, const T2& prongBachPi) {
197+ if constexpr (withDmesMl) {
198+ return hfMlResponse.getInputFeatures <true >(candB0, prongBachPi);
199+ } else {
200+ return hfMlResponse.getInputFeatures <false >(candB0, prongBachPi);
201+ }
202+ }
203+
173204 // / Main function to perform B0 candidate creation
174205 // / \param withDmesMl is the flag to use the table with ML scores for the D- daughter (only possible if present in the derived data)
175206 // / \param hfCandsB0 B0 candidates
@@ -220,15 +251,15 @@ struct HfCandidateSelectorB0ToDPiReduced {
220251 registry.fill (HIST (" hSelections" ), 2 + SelectionStep::RecoTopol, ptCandB0);
221252 }
222253
223- auto trackPiBachPi = getTrackBachPi (hfCandB0);
254+ auto trackBachPi = getTrackBachPi (hfCandB0);
224255 if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) {
225- int pidTrackPiBachPi {TrackSelectorPID::Status::NotApplicable};
256+ int pidTrackBachPi {TrackSelectorPID::Status::NotApplicable};
226257 if (pionPidMethod == PidMethod::TpcOrTof) {
227- pidTrackPiBachPi = selectorPion.statusTpcOrTof (trackPiBachPi );
258+ pidTrackBachPi = selectorPion.statusTpcOrTof (trackBachPi );
228259 } else if (pionPidMethod == PidMethod::TpcAndTof) {
229- pidTrackPiBachPi = selectorPion.statusTpcAndTof (trackPiBachPi );
260+ pidTrackBachPi = selectorPion.statusTpcAndTof (trackBachPi );
230261 }
231- if (!hfHelper.selectionB0ToDPiPid (pidTrackPiBachPi , acceptPIDNotApplicable.value )) {
262+ if (!hfHelper.selectionB0ToDPiPid (pidTrackBachPi , acceptPIDNotApplicable.value )) {
232263 // LOGF(info, "B0 candidate selection failed at PID selection");
233264 hfSelB0ToDPiCandidate (statusB0ToDPi);
234265 if (applyB0Ml) {
@@ -243,7 +274,7 @@ struct HfCandidateSelectorB0ToDPiReduced {
243274 }
244275 if (applyB0Ml) {
245276 // B0 ML selections
246- std::vector<float > inputFeatures = hfMlResponse. getInputFeatures <withDmesMl>(hfCandB0, trackPiBachPi );
277+ std::vector<float > inputFeatures = getMlInputFeatures <withDmesMl>(hfCandB0, trackBachPi );
247278 bool isSelectedMl = hfMlResponse.isSelectedMl (inputFeatures, ptCandB0, outputMl);
248279 hfMlB0ToDPiCandidate (outputMl[1 ]); // storing ML score for signal class
249280
0 commit comments