From 899a1baccf471f7fe3ad51d2850cb211f80832be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:51:13 +0000 Subject: [PATCH 1/9] First version of addition of ML response class for D0s --- PWGHF/Core/HfMlResponseD0ToKPi.h | 265 ++++++++++++++++++++ PWGHF/TableProducer/candidateSelectorD0.cxx | 13 +- 2 files changed, 268 insertions(+), 10 deletions(-) create mode 100644 PWGHF/Core/HfMlResponseD0ToKPi.h diff --git a/PWGHF/Core/HfMlResponseD0ToKPi.h b/PWGHF/Core/HfMlResponseD0ToKPi.h new file mode 100644 index 00000000000..66770353297 --- /dev/null +++ b/PWGHF/Core/HfMlResponseD0ToKPi.h @@ -0,0 +1,265 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file HfMlResponseD0ToKPi.h +/// \brief Class to compute the ML response for D0 → K∓ π± analysis selections +/// \author Alexandre Bigot , IPHC Strasbourg +/// \author Andrea Tavira García , IJCLab Orsay + +#ifndef PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ +#define PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ + +#include +#include +#include + +#include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponse.h" + +// Fill the map of available input features +// the key is the feature's name (std::string) +// the value is the corresponding value in EnumInputFeatures +#define FILL_MAP_D0(FEATURE) \ + { \ +#FEATURE, static_cast < uint8_t>(InputFeaturesD0ToKPi::FEATURE) \ + } + +// Check if the index of mCachedIndices (index associated to a FEATURE) +// matches the entry in EnumInputFeatures associated to this FEATURE +// if so, the inputFeatures vector is filled with the FEATURE's value +// by calling the corresponding GETTER from OBJECT +#define CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_D0(GETTER) \ + case static_cast(InputFeaturesD0ToKPi::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +// Variation of CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) +// where GETTER is a method of hfHelper +#define CHECK_AND_FILL_VEC_D0_HFHELPER(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + inputFeatures.emplace_back(hfHelper.GETTER(OBJECT)); \ + break; \ + } + +namespace o2::analysis +{ +enum class InputFeaturesD0ToKPi : uint8_t { + collisionId = 0, + posX, + posY, + posZ, + xSecondaryVertex, + ySecondaryVertex, + zSecondaryVertex, + errorDecayLength, + errorDecayLengthXY, + chi2PCA, + rSecondaryVertex, + decayLength, + decayLengthXY, + decayLengthNormalised, + decayLengthXYNormalised, + impactParameterNormalised0, + ptProng0, + pt2Prong0, + ptProng1, + pt2Prong1, + pxProng0, + pyProng0, + pzProng0, + pxProng1, + pyProng1, + pzProng1, + impactParameter0, + impactParameter1, + errorImpactParameter0, + errorImpactParameter1, + nSigTpcPi0, + nSigTpcKa0, + nSigTofPi0, + nSigTofKa0, + nSigTpcPi1, + nSigTpcKa1, + nSigTofPi1, + nSigTofKa1, + m, + maxNormalisedDeltaIP, + impactParameterProduct, + cosThetaStar, + pt, + p, + cpa, + cpaXY, + ct, + eta, + phi, + y, + e +}; + +template +class HfMlResponseD0ToKPi : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseD0ToKPi() = default; + /// Default destructor + virtual ~HfMlResponseD0ToKPi() = default; + + HfHelper hfHelper; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the Dplus candidate + /// \param prong0 is the candidate's prong0 + /// \param prong1 is the candidate's prong1 + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate, + T2 const& prong0, T2 const& prong1) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_D0(collisionId); + CHECK_AND_FILL_VEC_D0(posX); + CHECK_AND_FILL_VEC_D0(posY); + CHECK_AND_FILL_VEC_D0(posZ); + CHECK_AND_FILL_VEC_D0(xSecondaryVertex); + CHECK_AND_FILL_VEC_D0(ySecondaryVertex); + CHECK_AND_FILL_VEC_D0(zSecondaryVertex); + CHECK_AND_FILL_VEC_D0(errorDecayLength); + CHECK_AND_FILL_VEC_D0(errorDecayLengthXY); + CHECK_AND_FILL_VEC_D0(chi2PCA); + CHECK_AND_FILL_VEC_D0(rSecondaryVertex); + CHECK_AND_FILL_VEC_D0(decayLength); + CHECK_AND_FILL_VEC_D0(decayLengthXY); + CHECK_AND_FILL_VEC_D0(decayLengthNormalised); + CHECK_AND_FILL_VEC_D0(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_D0(ptProng0); + CHECK_AND_FILL_VEC_D0(ptProng1); + CHECK_AND_FILL_VEC_D0(pxProng0); + CHECK_AND_FILL_VEC_D0(pyProng0); + CHECK_AND_FILL_VEC_D0(pzProng0); + CHECK_AND_FILL_VEC_D0(pxProng1); + CHECK_AND_FILL_VEC_D0(pyProng1); + CHECK_AND_FILL_VEC_D0(pzProng1); + CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameter0, impactParameter0); + CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameter1, impactParameter1); + CHECK_AND_FILL_VEC_D0_FULL(candidate, errorImpactParameter0, errorImpactParameter0); + CHECK_AND_FILL_VEC_D0_FULL(candidate, errorImpactParameter1, errorImpactParameter1); + // TPC PID variables + CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcPi0, tpcNSigmaPi); + CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcKa0, tpcNSigmaKa); + CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcPi1, tpcNSigmaPi); + CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcKa1, tpcNSigmaKa); + // TOF PID variables + CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTofPi0, tofNSigmaPi); + CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTofKa0, tofNSigmaKa); + CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTofPi1, tofNSigmaPi); + CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTofKa1, tofNSigmaKa); + + CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, m, invMassD0ToPiK); + CHECK_AND_FILL_VEC_D0(maxNormalisedDeltaIP); + CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameterProduct, impactParameterProduct); + CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, cosThetaStar, cosThetaStarD0); + CHECK_AND_FILL_VEC_D0(pt); + CHECK_AND_FILL_VEC_D0(p); + CHECK_AND_FILL_VEC_D0(cpa); + CHECK_AND_FILL_VEC_D0(cpaXY); + CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, ct, ctD0); + CHECK_AND_FILL_VEC_D0(eta); + CHECK_AND_FILL_VEC_D0(phi); + CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, y, yD0); + CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, e, eD0); + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_D0(collisionId), + FILL_MAP_D0(posX), + FILL_MAP_D0(posY), + FILL_MAP_D0(posZ), + FILL_MAP_D0(xSecondaryVertex), + FILL_MAP_D0(ySecondaryVertex), + FILL_MAP_D0(zSecondaryVertex), + FILL_MAP_D0(errorDecayLength), + FILL_MAP_D0(errorDecayLengthXY), + FILL_MAP_D0(chi2PCA), + FILL_MAP_D0(rSecondaryVertex), + FILL_MAP_D0(decayLength), + FILL_MAP_D0(decayLengthXY), + FILL_MAP_D0(decayLengthNormalised), + FILL_MAP_D0(decayLengthXYNormalised), + FILL_MAP_D0(ptProng0), + FILL_MAP_D0(ptProng1), + FILL_MAP_D0(pxProng0), + FILL_MAP_D0(pyProng0), + FILL_MAP_D0(pzProng0), + FILL_MAP_D0(pxProng1), + FILL_MAP_D0(pyProng1), + FILL_MAP_D0(pzProng1), + FILL_MAP_D0(impactParameter0), + FILL_MAP_D0(impactParameter1), + FILL_MAP_D0(errorImpactParameter0), + FILL_MAP_D0(errorImpactParameter1), + // TPC PID variables + FILL_MAP_D0(nSigTpcPi0), + FILL_MAP_D0(nSigTpcKa0), + FILL_MAP_D0(nSigTpcPi1), + FILL_MAP_D0(nSigTpcKa1), + // TOF PID variables + FILL_MAP_D0(nSigTofPi0), + FILL_MAP_D0(nSigTofKa0), + FILL_MAP_D0(nSigTofPi1), + FILL_MAP_D0(nSigTofKa1), + + FILL_MAP_D0(m), + FILL_MAP_D0(maxNormalisedDeltaIP), + FILL_MAP_D0(impactParameterProduct), + FILL_MAP_D0(cosThetaStar), + FILL_MAP_D0(pt), + FILL_MAP_D0(p), + FILL_MAP_D0(cpa), + FILL_MAP_D0(cpaXY), + FILL_MAP_D0(ct), + FILL_MAP_D0(eta), + FILL_MAP_D0(phi), + FILL_MAP_D0(y), + FILL_MAP_D0(e) + }; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_D0 +#undef CHECK_AND_FILL_VEC_D0_FULL +#undef CHECK_AND_FILL_VEC_D0 +#undef CHECK_AND_FILL_VEC_D0_HFHELPER + +#endif // PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ \ No newline at end of file diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 497704bc7e5..49e88ed6eb4 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -22,6 +22,7 @@ #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/Core/HfMlResponseD0ToKPi.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" @@ -68,7 +69,7 @@ struct HfCandidateSelectorD0 { Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; - o2::analysis::HfMlResponse hfMlResponse; + o2::analysis::HfMlResponseD0ToKPi hfMlResponse; std::vector outputMl = {}; o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; @@ -357,15 +358,7 @@ struct HfCandidateSelectorD0 { if (applyMl) { // ML selections - - std::vector inputFeatures{candidate.cpa(), - candidate.cpaXY(), - candidate.decayLength(), - candidate.decayLengthXY(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameterProduct()}; - + std::vector inputFeatures = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg); bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCand, outputMl); hfMlD0Candidate(outputMl); From 50649ea93491508abae63cfba361000601dc58d8 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 6 Nov 2023 11:03:49 +0000 Subject: [PATCH 2/9] Please consider the following formatting changes --- PWGHF/Core/HfMlResponseD0ToKPi.h | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/PWGHF/Core/HfMlResponseD0ToKPi.h b/PWGHF/Core/HfMlResponseD0ToKPi.h index 66770353297..ec63b0263e8 100644 --- a/PWGHF/Core/HfMlResponseD0ToKPi.h +++ b/PWGHF/Core/HfMlResponseD0ToKPi.h @@ -27,8 +27,8 @@ // Fill the map of available input features // the key is the feature's name (std::string) // the value is the corresponding value in EnumInputFeatures -#define FILL_MAP_D0(FEATURE) \ - { \ +#define FILL_MAP_D0(FEATURE) \ + { \ #FEATURE, static_cast < uint8_t>(InputFeaturesD0ToKPi::FEATURE) \ } @@ -36,26 +36,26 @@ // matches the entry in EnumInputFeatures associated to this FEATURE // if so, the inputFeatures vector is filled with the FEATURE's value // by calling the corresponding GETTER from OBJECT -#define CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) \ +#define CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) \ case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ - inputFeatures.emplace_back(OBJECT.GETTER()); \ - break; \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ } // Specific case of CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) // where OBJECT is named candidate and FEATURE = GETTER -#define CHECK_AND_FILL_VEC_D0(GETTER) \ +#define CHECK_AND_FILL_VEC_D0(GETTER) \ case static_cast(InputFeaturesD0ToKPi::GETTER): { \ - inputFeatures.emplace_back(candidate.GETTER()); \ - break; \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ } // Variation of CHECK_AND_FILL_VEC_D0_FULL(OBJECT, FEATURE, GETTER) // where GETTER is a method of hfHelper #define CHECK_AND_FILL_VEC_D0_HFHELPER(OBJECT, FEATURE, GETTER) \ - case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ - inputFeatures.emplace_back(hfHelper.GETTER(OBJECT)); \ - break; \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + inputFeatures.emplace_back(hfHelper.GETTER(OBJECT)); \ + break; \ } namespace o2::analysis @@ -165,7 +165,7 @@ class HfMlResponseD0ToKPi : public HfMlResponse CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameter1, impactParameter1); CHECK_AND_FILL_VEC_D0_FULL(candidate, errorImpactParameter0, errorImpactParameter0); CHECK_AND_FILL_VEC_D0_FULL(candidate, errorImpactParameter1, errorImpactParameter1); - // TPC PID variables + // TPC PID variables CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcPi0, tpcNSigmaPi); CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcKa0, tpcNSigmaKa); CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcPi1, tpcNSigmaPi); @@ -250,8 +250,7 @@ class HfMlResponseD0ToKPi : public HfMlResponse FILL_MAP_D0(eta), FILL_MAP_D0(phi), FILL_MAP_D0(y), - FILL_MAP_D0(e) - }; + FILL_MAP_D0(e)}; } }; From 84a1888f85a71031fdeba601c204774caae89f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:11:32 +0000 Subject: [PATCH 3/9] Fix MegaLinter --- PWGHF/Core/HfMlResponseD0ToKPi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/Core/HfMlResponseD0ToKPi.h b/PWGHF/Core/HfMlResponseD0ToKPi.h index ec63b0263e8..5bcdf38810f 100644 --- a/PWGHF/Core/HfMlResponseD0ToKPi.h +++ b/PWGHF/Core/HfMlResponseD0ToKPi.h @@ -261,4 +261,4 @@ class HfMlResponseD0ToKPi : public HfMlResponse #undef CHECK_AND_FILL_VEC_D0 #undef CHECK_AND_FILL_VEC_D0_HFHELPER -#endif // PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ \ No newline at end of file +#endif // PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ From a8c56044f78b76fe703d2ac7dd487457b9c7d47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:09:53 +0000 Subject: [PATCH 4/9] Add Alexandre's comments --- PWGHF/TableProducer/candidateSelectorD0.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 49e88ed6eb4..fd753af34cc 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -62,6 +62,7 @@ struct HfCandidateSelectorD0 { Configurable> cutsMl{"cutsMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsCutScore}, "ML selections per pT bin"}; Configurable nClassesMl{"nClassesMl", (int8_t)hf_cuts_ml::nCutScores, "Number of classes in ML model"}; Configurable enableDebugMl{"enableDebugMl", false, "Flag to enable histograms to monitor BDT application"}; + Configurable> namesInputFeatures{"namesInputFeatures", std::vector{"feature1", "feature2"}, "Names of ML model input features"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable modelPathsCCDB{"modelPathsCCDB", "EventFiltering/PWGHF/BDTD0", "Path on CCDB"}; @@ -71,6 +72,7 @@ struct HfCandidateSelectorD0 { o2::analysis::HfMlResponseD0ToKPi hfMlResponse; std::vector outputMl = {}; + std::vector outputMlNotPreselected = {}; o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorKa selectorKaon; @@ -114,6 +116,7 @@ struct HfCandidateSelectorD0 { } else { hfMlResponse.setModelPathsLocal(onnxFileNames); } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); hfMlResponse.init(); outputMl.assign(((std::vector)cutDirMl).size(), -1.f); // dummy value for ML output } @@ -264,7 +267,7 @@ struct HfCandidateSelectorD0 { if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMl); + hfMlD0Candidate(outputMlNotPreselected); } continue; } @@ -278,7 +281,7 @@ struct HfCandidateSelectorD0 { if (!selectionTopol(candidate)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMl); + hfMlD0Candidate(outputMlNotPreselected); } continue; } @@ -295,7 +298,7 @@ struct HfCandidateSelectorD0 { if (!topolD0 && !topolD0bar) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMl); + hfMlD0Candidate(outputMlNotPreselected); } continue; } @@ -343,7 +346,7 @@ struct HfCandidateSelectorD0 { if (pidD0 == 0 && pidD0bar == 0) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMl); + hfMlD0Candidate(outputMlNotPreselected); } continue; } From e20571954d3778e80f704720315c3f15c9303425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:27:12 +0000 Subject: [PATCH 5/9] Remove dummy value of outputMl --- PWGHF/TableProducer/candidateSelectorD0.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index fd753af34cc..80e36aa59dc 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -118,7 +118,6 @@ struct HfCandidateSelectorD0 { } hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); hfMlResponse.init(); - outputMl.assign(((std::vector)cutDirMl).size(), -1.f); // dummy value for ML output } } From 460d421def54882b35a50e7fc52a7201255ba5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:58:42 +0000 Subject: [PATCH 6/9] Add Fabrizio's suggestions --- PWGHF/Core/HfMlResponseD0ToKPi.h | 118 ++++++-------------- PWGHF/DataModel/CandidateSelectionTables.h | 4 +- PWGHF/TableProducer/candidateSelectorD0.cxx | 38 ++++--- 3 files changed, 59 insertions(+), 101 deletions(-) diff --git a/PWGHF/Core/HfMlResponseD0ToKPi.h b/PWGHF/Core/HfMlResponseD0ToKPi.h index 5bcdf38810f..62e8c201e6b 100644 --- a/PWGHF/Core/HfMlResponseD0ToKPi.h +++ b/PWGHF/Core/HfMlResponseD0ToKPi.h @@ -23,6 +23,7 @@ #include "PWGHF/Core/HfHelper.h" #include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/Core/PDG.h" // Fill the map of available input features // the key is the feature's name (std::string) @@ -58,60 +59,50 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_D0_HFHELPER(OBJECT, FEATURE, GETTER) +// where GETTER1 and GETTER2 are methods of hfHelper, and the variable +// is filled depending on whether it is a D0 or a D0bar +#define CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + if (pdgCode == o2::analysis::pdg::kD0) { \ + inputFeatures.emplace_back(hfHelper.GETTER1(OBJECT)); \ + } else { \ + inputFeatures.emplace_back(hfHelper.GETTER2(OBJECT)); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesD0ToKPi : uint8_t { - collisionId = 0, - posX, - posY, - posZ, - xSecondaryVertex, - ySecondaryVertex, - zSecondaryVertex, - errorDecayLength, - errorDecayLengthXY, - chi2PCA, - rSecondaryVertex, + chi2PCA = 0, decayLength, decayLengthXY, decayLengthNormalised, decayLengthXYNormalised, impactParameterNormalised0, ptProng0, - pt2Prong0, ptProng1, - pt2Prong1, - pxProng0, - pyProng0, - pzProng0, - pxProng1, - pyProng1, - pzProng1, impactParameter0, impactParameter1, - errorImpactParameter0, - errorImpactParameter1, nSigTpcPi0, nSigTpcKa0, nSigTofPi0, nSigTofKa0, + nSigTpcTofPi0, + nSigTpcTofKa0, nSigTpcPi1, nSigTpcKa1, nSigTofPi1, nSigTofKa1, - m, + nSigTpcTofPi1, + nSigTpcTofKa1, maxNormalisedDeltaIP, impactParameterProduct, cosThetaStar, - pt, - p, cpa, cpaXY, - ct, - eta, - phi, - y, - e + ct }; template @@ -126,45 +117,27 @@ class HfMlResponseD0ToKPi : public HfMlResponse HfHelper hfHelper; /// Method to get the input features vector needed for ML inference - /// \param candidate is the Dplus candidate + /// \param candidate is the D0 candidate /// \param prong0 is the candidate's prong0 /// \param prong1 is the candidate's prong1 /// \return inputFeatures vector template std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1) + T2 const& prong0, T2 const& prong1, int const& pdgCode) { std::vector inputFeatures; for (const auto& idx : MlResponse::mCachedIndices) { switch (idx) { - CHECK_AND_FILL_VEC_D0(collisionId); - CHECK_AND_FILL_VEC_D0(posX); - CHECK_AND_FILL_VEC_D0(posY); - CHECK_AND_FILL_VEC_D0(posZ); - CHECK_AND_FILL_VEC_D0(xSecondaryVertex); - CHECK_AND_FILL_VEC_D0(ySecondaryVertex); - CHECK_AND_FILL_VEC_D0(zSecondaryVertex); - CHECK_AND_FILL_VEC_D0(errorDecayLength); - CHECK_AND_FILL_VEC_D0(errorDecayLengthXY); CHECK_AND_FILL_VEC_D0(chi2PCA); - CHECK_AND_FILL_VEC_D0(rSecondaryVertex); CHECK_AND_FILL_VEC_D0(decayLength); CHECK_AND_FILL_VEC_D0(decayLengthXY); CHECK_AND_FILL_VEC_D0(decayLengthNormalised); CHECK_AND_FILL_VEC_D0(decayLengthXYNormalised); CHECK_AND_FILL_VEC_D0(ptProng0); CHECK_AND_FILL_VEC_D0(ptProng1); - CHECK_AND_FILL_VEC_D0(pxProng0); - CHECK_AND_FILL_VEC_D0(pyProng0); - CHECK_AND_FILL_VEC_D0(pzProng0); - CHECK_AND_FILL_VEC_D0(pxProng1); - CHECK_AND_FILL_VEC_D0(pyProng1); - CHECK_AND_FILL_VEC_D0(pzProng1); CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameter0, impactParameter0); CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameter1, impactParameter1); - CHECK_AND_FILL_VEC_D0_FULL(candidate, errorImpactParameter0, errorImpactParameter0); - CHECK_AND_FILL_VEC_D0_FULL(candidate, errorImpactParameter1, errorImpactParameter1); // TPC PID variables CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcPi0, tpcNSigmaPi); CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcKa0, tpcNSigmaKa); @@ -175,20 +148,18 @@ class HfMlResponseD0ToKPi : public HfMlResponse CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTofKa0, tofNSigmaKa); CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTofPi1, tofNSigmaPi); CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTofKa1, tofNSigmaKa); + // Combined PID variables + CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcTofPi0, tpcTofNSigmaPi); + CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcTofKa0, tpcTofNSigmaKa); + CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcTofPi1, tpcTofNSigmaPi); + CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcTofKa1, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, m, invMassD0ToPiK); CHECK_AND_FILL_VEC_D0(maxNormalisedDeltaIP); CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameterProduct, impactParameterProduct); - CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, cosThetaStar, cosThetaStarD0); - CHECK_AND_FILL_VEC_D0(pt); - CHECK_AND_FILL_VEC_D0(p); + CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED(candidate, cosThetaStar, cosThetaStarD0, cosThetaStarD0bar); CHECK_AND_FILL_VEC_D0(cpa); CHECK_AND_FILL_VEC_D0(cpaXY); CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, ct, ctD0); - CHECK_AND_FILL_VEC_D0(eta); - CHECK_AND_FILL_VEC_D0(phi); - CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, y, yD0); - CHECK_AND_FILL_VEC_D0_HFHELPER(candidate, e, eD0); } } @@ -200,33 +171,15 @@ class HfMlResponseD0ToKPi : public HfMlResponse void setAvailableInputFeatures() { MlResponse::mAvailableInputFeatures = { - FILL_MAP_D0(collisionId), - FILL_MAP_D0(posX), - FILL_MAP_D0(posY), - FILL_MAP_D0(posZ), - FILL_MAP_D0(xSecondaryVertex), - FILL_MAP_D0(ySecondaryVertex), - FILL_MAP_D0(zSecondaryVertex), - FILL_MAP_D0(errorDecayLength), - FILL_MAP_D0(errorDecayLengthXY), FILL_MAP_D0(chi2PCA), - FILL_MAP_D0(rSecondaryVertex), FILL_MAP_D0(decayLength), FILL_MAP_D0(decayLengthXY), FILL_MAP_D0(decayLengthNormalised), FILL_MAP_D0(decayLengthXYNormalised), FILL_MAP_D0(ptProng0), FILL_MAP_D0(ptProng1), - FILL_MAP_D0(pxProng0), - FILL_MAP_D0(pyProng0), - FILL_MAP_D0(pzProng0), - FILL_MAP_D0(pxProng1), - FILL_MAP_D0(pyProng1), - FILL_MAP_D0(pzProng1), FILL_MAP_D0(impactParameter0), FILL_MAP_D0(impactParameter1), - FILL_MAP_D0(errorImpactParameter0), - FILL_MAP_D0(errorImpactParameter1), // TPC PID variables FILL_MAP_D0(nSigTpcPi0), FILL_MAP_D0(nSigTpcKa0), @@ -237,20 +190,18 @@ class HfMlResponseD0ToKPi : public HfMlResponse FILL_MAP_D0(nSigTofKa0), FILL_MAP_D0(nSigTofPi1), FILL_MAP_D0(nSigTofKa1), + // Combined PID variables + FILL_MAP_D0(nSigTpcTofPi0), + FILL_MAP_D0(nSigTpcTofKa0), + FILL_MAP_D0(nSigTpcTofPi1), + FILL_MAP_D0(nSigTpcTofKa1), - FILL_MAP_D0(m), FILL_MAP_D0(maxNormalisedDeltaIP), FILL_MAP_D0(impactParameterProduct), FILL_MAP_D0(cosThetaStar), - FILL_MAP_D0(pt), - FILL_MAP_D0(p), FILL_MAP_D0(cpa), FILL_MAP_D0(cpaXY), - FILL_MAP_D0(ct), - FILL_MAP_D0(eta), - FILL_MAP_D0(phi), - FILL_MAP_D0(y), - FILL_MAP_D0(e)}; + FILL_MAP_D0(ct)}; } }; @@ -260,5 +211,6 @@ class HfMlResponseD0ToKPi : public HfMlResponse #undef CHECK_AND_FILL_VEC_D0_FULL #undef CHECK_AND_FILL_VEC_D0 #undef CHECK_AND_FILL_VEC_D0_HFHELPER +#undef CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED #endif // PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ diff --git a/PWGHF/DataModel/CandidateSelectionTables.h b/PWGHF/DataModel/CandidateSelectionTables.h index b27dacb5113..5d8436f47e4 100644 --- a/PWGHF/DataModel/CandidateSelectionTables.h +++ b/PWGHF/DataModel/CandidateSelectionTables.h @@ -43,6 +43,7 @@ DECLARE_SOA_COLUMN(IsRecoTopol, isRecoTopol, int); //! DECLARE_SOA_COLUMN(IsRecoCand, isRecoCand, int); //! DECLARE_SOA_COLUMN(IsRecoPid, isRecoPid, int); DECLARE_SOA_COLUMN(MlProbD0, mlProbD0, std::vector); //! +DECLARE_SOA_COLUMN(MlProbD0bar, mlProbD0bar, std::vector); //! } // namespace hf_sel_candidate_d0 DECLARE_SOA_TABLE(HfSelD0, "AOD", "HFSELD0", //! @@ -54,7 +55,8 @@ DECLARE_SOA_TABLE(HfSelD0, "AOD", "HFSELD0", //! hf_sel_candidate_d0::IsRecoPid); DECLARE_SOA_TABLE(HfMlD0, "AOD", "HFMLD0", //! - hf_sel_candidate_d0::MlProbD0); + hf_sel_candidate_d0::MlProbD0, + hf_sel_candidate_d0::MlProbD0bar); namespace hf_sel_candidate_d0_parametrized_pid { diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 80e36aa59dc..1f3492fdac9 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -71,14 +71,16 @@ struct HfCandidateSelectorD0 { Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; o2::analysis::HfMlResponseD0ToKPi hfMlResponse; - std::vector outputMl = {}; - std::vector outputMlNotPreselected = {}; + std::vector outputMlD0 = {}; + std::vector outputMlD0bar = {}; + std::vector outputMlNotPreselectedD0 = {}; + std::vector outputMlNotPreselectedD0bar = {}; o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorKa selectorKaon; HfHelper hfHelper; - using TracksSel = soa::Join; + using TracksSel = soa::Join; // Define histograms AxisSpec axisMassDmeson{200, 1.7f, 2.1f}; @@ -266,7 +268,7 @@ struct HfCandidateSelectorD0 { if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselected); + hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); } continue; } @@ -280,7 +282,7 @@ struct HfCandidateSelectorD0 { if (!selectionTopol(candidate)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselected); + hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); } continue; } @@ -297,7 +299,7 @@ struct HfCandidateSelectorD0 { if (!topolD0 && !topolD0bar) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselected); + hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); } continue; } @@ -345,7 +347,7 @@ struct HfCandidateSelectorD0 { if (pidD0 == 0 && pidD0bar == 0) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselected); + hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); } continue; } @@ -360,21 +362,23 @@ struct HfCandidateSelectorD0 { if (applyMl) { // ML selections - std::vector inputFeatures = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg); - bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCand, outputMl); - hfMlD0Candidate(outputMl); + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::analysis::pdg::kD0); + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::analysis::pdg::kD0Bar); + bool isSelectedMlD0 = hfMlResponse.isSelectedMl(inputFeaturesD0, ptCand, outputMlD0); + bool isSelectedMlD0bar = hfMlResponse.isSelectedMl(inputFeaturesD0bar, ptCand, outputMlD0bar); + hfMlD0Candidate(outputMlD0, outputMlD0bar); - if (!isSelectedMl) { + if (!isSelectedMlD0 && !isSelectedMlD0bar) { statusD0 = 0; statusD0bar = 0; } if (enableDebugMl) { - registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMl[0], statusD0); - registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMl[0], statusD0bar); - registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMl[1], statusD0); - registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMl[1], statusD0bar); - registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMl[2], statusD0); - registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMl[2], statusD0bar); + registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMlD0[0], statusD0); + registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMlD0bar[0], statusD0bar); + registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMlD0[1], statusD0); + registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMlD0bar[1], statusD0bar); + registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMlD0[2], statusD0); + registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMlD0bar[2], statusD0bar); if (statusD0 > 0) { registry.fill(HIST("DebugBdt/hMassDmesonSel"), hfHelper.invMassD0ToPiK(candidate)); } From ab7dbb8c62dbbc4315d055d030b4556b9b44b152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:33:43 +0000 Subject: [PATCH 7/9] Add new suggestions --- PWGHF/TableProducer/candidateSelectorD0.cxx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 1f3492fdac9..cf45d327ea6 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -73,8 +73,6 @@ struct HfCandidateSelectorD0 { o2::analysis::HfMlResponseD0ToKPi hfMlResponse; std::vector outputMlD0 = {}; std::vector outputMlD0bar = {}; - std::vector outputMlNotPreselectedD0 = {}; - std::vector outputMlNotPreselectedD0bar = {}; o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorKa selectorKaon; @@ -265,10 +263,13 @@ struct HfCandidateSelectorD0 { int statusCand = 0; int statusPID = 0; + outputMlD0.clear(); + outputMlD0bar.clear(); + if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); + hfMlD0Candidate(outputMlD0, outputMlD0bar); } continue; } @@ -282,7 +283,7 @@ struct HfCandidateSelectorD0 { if (!selectionTopol(candidate)) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); + hfMlD0Candidate(outputMlD0, outputMlD0bar); } continue; } @@ -299,7 +300,7 @@ struct HfCandidateSelectorD0 { if (!topolD0 && !topolD0bar) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); + hfMlD0Candidate(outputMlD0, outputMlD0bar); } continue; } @@ -347,7 +348,7 @@ struct HfCandidateSelectorD0 { if (pidD0 == 0 && pidD0bar == 0) { hfSelD0Candidate(statusD0, statusD0bar, statusHFFlag, statusTopol, statusCand, statusPID); if (applyMl) { - hfMlD0Candidate(outputMlNotPreselectedD0, outputMlNotPreselectedD0bar); + hfMlD0Candidate(outputMlD0, outputMlD0bar); } continue; } @@ -368,8 +369,10 @@ struct HfCandidateSelectorD0 { bool isSelectedMlD0bar = hfMlResponse.isSelectedMl(inputFeaturesD0bar, ptCand, outputMlD0bar); hfMlD0Candidate(outputMlD0, outputMlD0bar); - if (!isSelectedMlD0 && !isSelectedMlD0bar) { + if (!isSelectedMlD0) { statusD0 = 0; + } + if (!isSelectedMlD0bar) { statusD0bar = 0; } if (enableDebugMl) { From 6cb7b29de1b384c1e45dad1767b97dae21674594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Fri, 10 Nov 2023 10:02:14 +0000 Subject: [PATCH 8/9] add Fabio's suggestions --- PWGHF/TableProducer/candidateSelectorD0.cxx | 37 +++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index cf45d327ea6..443ea2fb362 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -363,11 +363,17 @@ struct HfCandidateSelectorD0 { if (applyMl) { // ML selections - std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::analysis::pdg::kD0); - std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::analysis::pdg::kD0Bar); - bool isSelectedMlD0 = hfMlResponse.isSelectedMl(inputFeaturesD0, ptCand, outputMlD0); - bool isSelectedMlD0bar = hfMlResponse.isSelectedMl(inputFeaturesD0bar, ptCand, outputMlD0bar); - hfMlD0Candidate(outputMlD0, outputMlD0bar); + bool isSelectedMlD0 = false; + bool isSelectedMlD0bar = false; + + if (statusD0 > 0) { + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::analysis::pdg::kD0); + isSelectedMlD0 = hfMlResponse.isSelectedMl(inputFeaturesD0, ptCand, outputMlD0); + } + if (statusD0bar > 0) { + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::analysis::pdg::kD0Bar); + isSelectedMlD0bar = hfMlResponse.isSelectedMl(inputFeaturesD0bar, ptCand, outputMlD0bar); + } if (!isSelectedMlD0) { statusD0 = 0; @@ -375,17 +381,22 @@ struct HfCandidateSelectorD0 { if (!isSelectedMlD0bar) { statusD0bar = 0; } + + if (isSelectedMlD0 || isSelectedMlD0bar) { + hfMlD0Candidate(outputMlD0, outputMlD0bar); + } + if (enableDebugMl) { - registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMlD0[0], statusD0); - registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMlD0bar[0], statusD0bar); - registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMlD0[1], statusD0); - registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMlD0bar[1], statusD0bar); - registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMlD0[2], statusD0); - registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMlD0bar[2], statusD0bar); - if (statusD0 > 0) { + if (isSelectedMlD0) { + registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMlD0[0], statusD0); + registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMlD0[1], statusD0); + registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMlD0[2], statusD0); registry.fill(HIST("DebugBdt/hMassDmesonSel"), hfHelper.invMassD0ToPiK(candidate)); } - if (statusD0bar > 0) { + if (isSelectedMlD0bar) { + registry.fill(HIST("DebugBdt/hBdtScore1VsStatus"), outputMlD0bar[0], statusD0bar); + registry.fill(HIST("DebugBdt/hBdtScore2VsStatus"), outputMlD0bar[1], statusD0bar); + registry.fill(HIST("DebugBdt/hBdtScore3VsStatus"), outputMlD0bar[2], statusD0bar); registry.fill(HIST("DebugBdt/hMassDmesonSel"), hfHelper.invMassD0barToKPi(candidate)); } } From 3bd9fc4b84152fe089f77bfe1e09f71b8e8210b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Tavira=20Garc=C3=ADa?= <118979672+atavirag@users.noreply.github.com> Date: Mon, 13 Nov 2023 09:09:55 +0000 Subject: [PATCH 9/9] Always fill hfMlD0Candidate table --- PWGHF/TableProducer/candidateSelectorD0.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 443ea2fb362..aaf1f68b51c 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.cxx @@ -382,9 +382,7 @@ struct HfCandidateSelectorD0 { statusD0bar = 0; } - if (isSelectedMlD0 || isSelectedMlD0bar) { - hfMlD0Candidate(outputMlD0, outputMlD0bar); - } + hfMlD0Candidate(outputMlD0, outputMlD0bar); if (enableDebugMl) { if (isSelectedMlD0) {