Skip to content

Commit 67dc6ae

Browse files
committed
candidateSelectorXicToXiPiPi: enable BDT eval in KF mode
1 parent 27f8d14 commit 67dc6ae

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

‎PWGHF/Core/HfMlResponseXicToXiPiPi.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ enum class InputFeaturesXicToXiPiPi : uint8_t {
9595
kfDecayLengthNormalised,
9696
kfDecayLengthXY,
9797
kfDecayLengthXYNormalised,
98-
kfCascadechi2,
98+
kfCascadeChi2,
9999
kfV0Chi2,
100100
chi2XicPlusToPV,
101101
chi2TopoXicPlusToPV,
@@ -175,7 +175,7 @@ class HfMlResponseXicToXiPiPi : public HfMlResponse<TypeOutputScore>
175175
CHECK_AND_FILL_VEC_XICTOXIPIPI(kfDecayLengthNormalised);
176176
CHECK_AND_FILL_VEC_XICTOXIPIPI(kfDecayLengthXY);
177177
CHECK_AND_FILL_VEC_XICTOXIPIPI(kfDecayLengthXYNormalised);
178-
CHECK_AND_FILL_VEC_XICTOXIPIPI(kfCascadechi2);
178+
CHECK_AND_FILL_VEC_XICTOXIPIPI(kfCascadeChi2);
179179
CHECK_AND_FILL_VEC_XICTOXIPIPI(kfV0Chi2);
180180
CHECK_AND_FILL_VEC_XICTOXIPIPI(chi2XicPlusToPV);
181181
CHECK_AND_FILL_VEC_XICTOXIPIPI(chi2TopoXicPlusToPV);
@@ -245,7 +245,7 @@ class HfMlResponseXicToXiPiPi : public HfMlResponse<TypeOutputScore>
245245
FILL_MAP_XICTOXIPIPI(kfDecayLengthNormalised),
246246
FILL_MAP_XICTOXIPIPI(kfDecayLengthXY),
247247
FILL_MAP_XICTOXIPIPI(kfDecayLengthXYNormalised),
248-
FILL_MAP_XICTOXIPIPI(kfCascadechi2),
248+
FILL_MAP_XICTOXIPIPI(kfCascadeChi2),
249249
FILL_MAP_XICTOXIPIPI(kfV0Chi2),
250250
FILL_MAP_XICTOXIPIPI(chi2XicPlusToPV),
251251
FILL_MAP_XICTOXIPIPI(chi2TopoXicPlusToPV),

‎PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ struct HfCandidateSelectorXicToXiPiPi {
9292
Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"};
9393
Configurable<bool> loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"};
9494

95-
o2::analysis::HfMlResponseXicToXiPiPi<float> hfMlResponse;
95+
o2::analysis::HfMlResponseXicToXiPiPi<float, aod::hf_cand::VertexerType::DCAFitter> hfMlResponseDca;
96+
o2::analysis::HfMlResponseXicToXiPiPi<float, aod::hf_cand::VertexerType::KfParticle> hfMlResponseKf;
9697
std::vector<float> outputMlXicToXiPiPi;
9798
o2::ccdb::CcdbApi ccdbApi;
9899
TrackSelectorPi selectorPion;
@@ -126,6 +127,8 @@ struct HfCandidateSelectorXicToXiPiPi {
126127
}
127128
const bool doprocessData = doprocessDataWithDCAFitter || doprocessDataWithKFParticle;
128129
const bool doprocessMc = doprocessMcWithDCAFitter || doprocessMcWithKFParticle;
130+
const bool doprocessDCAFitter = doprocessDataWithDCAFitter || doprocessMcWithDCAFitter;
131+
[[maybe_unused]] const bool doprocessKFParticle = doprocessDataWithKFParticle || doprocessMcWithKFParticle;
129132

130133
if (usePid) {
131134
// pion
@@ -253,15 +256,22 @@ struct HfCandidateSelectorXicToXiPiPi {
253256
}
254257

255258
if (applyMl) {
256-
hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl);
257-
if (loadModelsFromCCDB) {
258-
ccdbApi.init(ccdbUrl);
259-
hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
259+
auto initMlResponse = [&](auto& hfMlResponseGeneric) {
260+
hfMlResponseGeneric.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl);
261+
if (loadModelsFromCCDB) {
262+
ccdbApi.init(ccdbUrl);
263+
hfMlResponseGeneric.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
264+
} else {
265+
hfMlResponseGeneric.setModelPathsLocal(onnxFileNames);
266+
}
267+
hfMlResponseGeneric.cacheInputFeaturesIndices(namesInputFeatures);
268+
hfMlResponseGeneric.init();
269+
};
270+
if (doprocessDCAFitter) {
271+
initMlResponse(hfMlResponseDca);
260272
} else {
261-
hfMlResponse.setModelPathsLocal(onnxFileNames);
273+
initMlResponse(hfMlResponseKf);
262274
}
263-
hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
264-
hfMlResponse.init();
265275
}
266276
}
267277

@@ -671,16 +681,21 @@ struct HfCandidateSelectorXicToXiPiPi {
671681
/// \param hfCandXic Xic candidate
672682
/// \param statusXicToXiPiPi Flag to store selection status as defined in hf_sel_candidate_xic::XicToXiPiPiSelectionStep
673683
/// \param isMatchedSignal Flag to indicate if the candidate is matched to a genereated XiCplus MC particle
674-
template <bool IsMc, typename XicCandidate>
684+
template <bool IsMc, aod::hf_cand::VertexerType ReconstructionType, typename XicCandidate>
675685
void isBdtSelected(XicCandidate const& hfCandXic,
676686
int& statusXicToXiPiPi,
677687
bool const isMatchedSignal = false)
678688
{
679689
bool isSelectedMlXicToXiPiPi = false;
680690
float const ptCandXic = hfCandXic.pt();
681691

682-
std::vector<float> inputFeaturesXicToXiPiPi = hfMlResponse.getInputFeatures(hfCandXic);
683-
isSelectedMlXicToXiPiPi = hfMlResponse.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi);
692+
if constexpr (ReconstructionType == aod::hf_cand::VertexerType::DCAFitter) {
693+
std::vector<float> inputFeaturesXicToXiPiPi = hfMlResponseDca.getInputFeatures(hfCandXic);
694+
isSelectedMlXicToXiPiPi = hfMlResponseDca.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi);
695+
} else {
696+
std::vector<float> inputFeaturesXicToXiPiPi = hfMlResponseKf.getInputFeatures(hfCandXic);
697+
isSelectedMlXicToXiPiPi = hfMlResponseKf.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi);
698+
}
684699

685700
hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi);
686701

@@ -721,7 +736,7 @@ struct HfCandidateSelectorXicToXiPiPi {
721736

722737
// ML selection
723738
if (applyMl) {
724-
isBdtSelected<false>(hfCandXic, statusXicToXiPiPi);
739+
isBdtSelected<false, ReconstructionType>(hfCandXic, statusXicToXiPiPi);
725740
} else {
726741
registry.fill(HIST("hSelCandidates"), BdtSelected);
727742
}
@@ -755,7 +770,7 @@ struct HfCandidateSelectorXicToXiPiPi {
755770

756771
// ML selection
757772
if (applyMl) {
758-
isBdtSelected<true>(hfCandXic, statusXicToXiPiPi, isMatchedCandidate);
773+
isBdtSelected<true, ReconstructionType>(hfCandXic, statusXicToXiPiPi, isMatchedCandidate);
759774
} else if (isMatchedCandidate) {
760775
registry.fill(HIST("hSelCandidatesRecSig"), BdtSelected);
761776
} else {

0 commit comments

Comments
 (0)