Skip to content

Commit a793db1

Browse files
committed
Extend Omegac QA ML support to DCAFitter
1 parent b3cf2b2 commit a793db1

3 files changed

Lines changed: 42 additions & 51 deletions

File tree

‎PWGHF/Core/HfMlResponseOmegacToOmegaPiQa.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@
5252
inputFeatures.emplace_back(candidate.GETTER()); \
5353
break; \
5454
}
55-
56-
// Variation of CHECK_AND_FILL_VEC_OMEGAC0_FULL(OBJECT, FEATURE, GETTER)
57-
// where GETTER is a method of HfHelper
58-
#define CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER(OBJECT, FEATURE, GETTER) \
59-
case static_cast<uint8_t>(InputFeaturesOmegacToOmegaPi::FEATURE): { \
60-
inputFeatures.emplace_back(HfHelper::GETTER(OBJECT)); \
61-
break; \
62-
}
6355
namespace o2::analysis
6456
{
6557
enum class InputFeaturesOmegacToOmegaPi : uint8_t {
@@ -240,5 +232,4 @@ class HfMlResponseOmegacToOmegaPi : public HfMlResponse<TypeOutputScore>
240232
#undef FILL_MAP_OMEGAC0
241233
#undef CHECK_AND_FILL_VEC_OMEGAC0_FULL
242234
#undef CHECK_AND_FILL_VEC_OMEGAC0
243-
#undef CHECK_AND_FILL_VEC_OMEGAC0_HFHELPER
244235
#endif // PWGHF_CORE_HFMLRESPONSEOMEGACTOOMEGAPIQA_H_

‎PWGHF/D2H/Tasks/taskOmegac0ToOmegaPiQa.cxx‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,12 @@ using namespace o2;
5151
using namespace o2::framework;
5252
using namespace o2::framework::expressions;
5353

54-
namespace o2::aod
55-
{
56-
namespace ml
57-
{
58-
DECLARE_SOA_COLUMN(InvMassCharmBaryon, invMassCharmBaryon, float);
59-
DECLARE_SOA_COLUMN(KfptOmegac, kfptOmegac, float);
60-
DECLARE_SOA_COLUMN(KfptPiFromOmegac, kfptPiFromOmegac, float);
61-
DECLARE_SOA_COLUMN(MlProbOmegac, mlProbOmegac, float);
62-
DECLARE_SOA_COLUMN(Cent, cent, float);
63-
} // namespace ml
64-
DECLARE_SOA_TABLE(HfKfOmegacML, "AOD", "HFKFOMEGACML",
65-
ml::InvMassCharmBaryon, ml::KfptOmegac, ml::KfptPiFromOmegac, ml::MlProbOmegac, ml::Cent);
66-
} // namespace o2::aod
67-
6854
/// Omegac0 analysis task
6955
struct HfTaskOmegac0ToOmegaPiQa {
70-
Produces<o2::aod::HfKfOmegacML> kfCandMl;
7156

7257
Configurable<bool> selectionFlagOmegac0{"selectionFlagOmegac0", true, "Select Omegac0 candidates"};
7358
Configurable<double> yCandGenMax{"yCandGenMax", 0.5, "Max. gen particle rapidity"};
7459
Configurable<double> yCandRecoMax{"yCandRecoMax", 0.8, "Max. cand. rapidity"};
75-
Configurable<bool> fillTree{"fillTree", false, "Fill tree for local analysis (enabled only with ML)"};
7660

7761
SliceCache cache;
7862

@@ -227,13 +211,8 @@ struct HfTaskOmegac0ToOmegaPiQa {
227211
if constexpr (UseCentrality) {
228212
float const cent = o2::hf_centrality::getCentralityColl(collision);
229213
if constexpr (ApplyMl) {
230-
registry.fill(HIST("hReco"), candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), yOmegac,
214+
registry.fill(HIST("hReco"), candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), yOmegac,
231215
cent, numPvContributors, candidate.mlProbOmegac()[0]);
232-
if constexpr (UseKfParticle) {
233-
if (fillTree) {
234-
kfCandMl(candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), candidate.kfptPiFromOmegac(), candidate.mlProbOmegac()[0], cent);
235-
}
236-
}
237216
} else {
238217
registry.fill(HIST("hReco"), candidate.invMassCharmBaryon(), candidate.ptCharmBaryon(), yOmegac,
239218
cent, numPvContributors);

‎PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPiQa.cxx‎

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// \author Fabio Catalano <fabio.catalano@cern.ch>, University of Houston
1616
/// \author Maria Fernanda Torres Cabrera <maria.fernanda.torres.cabrera@cern.ch>, University of Houston
1717

18-
#include "PWGHF/Core/HfMlResponseOmegacToOmegaPi.h"
18+
#include "PWGHF/Core/HfMlResponseOmegacToOmegaPiQa.h"
1919
#include "PWGHF/Core/SelectorCuts.h"
2020
#include "PWGHF/DataModel/AliasTables.h"
2121
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
@@ -71,7 +71,7 @@ enum {
7171
struct HfCandidateSelectorToOmegaPiQa {
7272
// DCAFitter and KFParticle
7373
Produces<aod::HfSelToOmegaPi> hfSelToOmegaPi;
74-
// ML selection - currently filled only for KFParticle
74+
// ML selection - filled for both DCAFitter and KFParticle
7575
Produces<aod::HfMlSelOmegacToOmegaPi> hfMlSelToOmegaPi;
7676

7777
// cuts from SelectorCuts.h - pT dependent cuts
@@ -176,7 +176,9 @@ struct HfCandidateSelectorToOmegaPiQa {
176176
Configurable<int> nClustersItsInnBarrMin{"nClustersItsInnBarrMin", 1, "Minimum number of ITS clusters in inner barrel requirement for pi <- charm baryon"};
177177
Configurable<float> itsChi2PerClusterMax{"itsChi2PerClusterMax", 36, "Maximum value of chi2 fit over ITS clusters for pi <- charm baryon"};
178178

179-
o2::analysis::HfMlResponseOmegacToOmegaPi<float> hfMlResponse;
179+
// o2::analysis::HfMlResponseOmegacToOmegaPi<float> hfMlResponse;
180+
o2::analysis::HfMlResponseOmegacToOmegaPi<float, aod::hf_cand_casc_lf::ConstructMethod::DcaFitter> hfMlResponseDca;
181+
o2::analysis::HfMlResponseOmegacToOmegaPi<float, aod::hf_cand_casc_lf::ConstructMethod::KfParticle> hfMlResponseKf;
180182
std::vector<float> outputMlOmegac = {};
181183
o2::ccdb::CcdbApi ccdbApi;
182184

@@ -391,19 +393,27 @@ struct HfCandidateSelectorToOmegaPiQa {
391393
// HfMlResponse initialization
392394
if (applyMl) {
393395
if (doprocessOmegac0SelectorWithKFParticle) {
394-
registry.add("hBDTScoreTest1", "hBDTScoreTest1", {HistType::kTH1D, {{100, 0.0f, 1.0f, "score"}}});
395-
hfMlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl);
396+
registry.add("hBDTScoreKF", "hBDTScoreKF", {HistType::kTH1D, {{100, 0.0f, 1.0f, "score"}}});
397+
hfMlResponseKf.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl);
396398
if (loadModelsFromCCDB) {
397399
ccdbApi.init(ccdbUrl);
398-
hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
400+
hfMlResponseKf.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
399401
} else {
400-
hfMlResponse.setModelPathsLocal(onnxFileNames);
402+
hfMlResponseKf.setModelPathsLocal(onnxFileNames);
401403
}
402-
hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
403-
hfMlResponse.init();
404-
} else {
405-
// DCAFitter: ML is not yet implemented
406-
LOGP(warning, "ML selection is currently only supported for KFParticle.");
404+
hfMlResponseKf.cacheInputFeaturesIndices(namesInputFeatures);
405+
hfMlResponseKf.init();
406+
} else if (doprocessOmegac0SelectorWithDCAFitter) {
407+
registry.add("hBDTScoreDCA", "hBDTScoreDCA", {HistType::kTH1D, {{100, 0.0f, 1.0f, "score"}}});
408+
hfMlResponseDca.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl);
409+
if (loadModelsFromCCDB) {
410+
ccdbApi.init(ccdbUrl);
411+
hfMlResponseDca.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB);
412+
} else {
413+
hfMlResponseDca.setModelPathsLocal(onnxFileNames);
414+
}
415+
hfMlResponseDca.cacheInputFeaturesIndices(namesInputFeatures);
416+
hfMlResponseDca.init();
407417
}
408418
}
409419
}
@@ -1122,19 +1132,30 @@ struct HfCandidateSelectorToOmegaPiQa {
11221132
statusInvMassCharmBaryon = true;
11231133
}
11241134

1125-
// ML BDT selection - curently only for KFParticle
1126-
if constexpr (svReco == doKfParticle) {
1127-
if (applyMl) {
1128-
bool isSelectedMlOmegac = false;
1129-
std::vector<float> inputFeaturesOmegaC = hfMlResponse.getInputFeatures(candidate, trackPiFromLam, trackKaFromCasc, trackPiFromCharm);
1130-
isSelectedMlOmegac = hfMlResponse.isSelectedMl(inputFeaturesOmegaC, ptCandOmegac, outputMlOmegac);
1135+
// ML BDT selection
1136+
if (applyMl) {
1137+
bool isSelectedMlOmegac = false;
1138+
std::vector<float> inputFeaturesOmegaC = {};
1139+
1140+
if constexpr (svReco == doKfParticle) {
1141+
inputFeaturesOmegaC = hfMlResponseKf.getInputFeatures(candidate, trackPiFromLam, trackKaFromCasc, trackPiFromCharm);
1142+
isSelectedMlOmegac = hfMlResponseKf.isSelectedMl(inputFeaturesOmegaC, ptCandOmegac, outputMlOmegac);
11311143
if (isSelectedMlOmegac) {
1132-
registry.fill(HIST("hBDTScoreTest1"), outputMlOmegac[0]);
1144+
registry.fill(HIST("hBDTScoreKF"), outputMlOmegac[0]);
1145+
} else {
1146+
resultSelections = false;
1147+
}
1148+
} else if constexpr (svReco == doDcaFitter) {
1149+
inputFeaturesOmegaC = hfMlResponseDca.getInputFeatures(candidate, trackPiFromLam, trackKaFromCasc, trackPiFromCharm);
1150+
isSelectedMlOmegac = hfMlResponseDca.isSelectedMl(inputFeaturesOmegaC, ptCandOmegac, outputMlOmegac);
1151+
if (isSelectedMlOmegac) {
1152+
registry.fill(HIST("hBDTScoreDCA"), outputMlOmegac[0]);
11331153
} else {
11341154
resultSelections = false;
11351155
}
1136-
hfMlSelToOmegaPi(outputMlOmegac);
11371156
}
1157+
1158+
hfMlSelToOmegaPi(outputMlOmegac);
11381159
}
11391160

11401161
// Fill in selection result

0 commit comments

Comments
 (0)