diff --git a/PWGHF/Core/HfHelper.h b/PWGHF/Core/HfHelper.h index b610c194fe9..7714fd68165 100644 --- a/PWGHF/Core/HfHelper.h +++ b/PWGHF/Core/HfHelper.h @@ -947,34 +947,59 @@ class HfHelper } /// Apply selection on ML scores for charm-hadron daughter in b-hadron decays (common for all the beauty channels) - /// \param candB b-hadron candidates /// \param cuts ML score selection per bin of charm-hadron pT /// \param binsPtC pT bin limits of charm hadron + /// \param mlScores vector with ml scores of charm hadron (position 0:bkg 1:prompt 2:nonprompt) /// \return true if b-hadron candidate passes all selections - template - bool selectionDmesMlScoresForB(const T1& candB, const T2& cuts, const T3& binsPtC) + template + bool applySelectionDmesMlScoresForB(const T1& cuts, const T2& binsPtC, float ptC, std::vector mlScores) { - auto ptC = RecoDecay::pt(candB.pxProng0(), candB.pyProng0()); // the first daughter is the charm hadron int pTBin = o2::analysis::findBin(binsPtC, ptC); if (pTBin == -1) { return false; } - if (candB.prong0MlScoreBkg() > cuts->get(pTBin, "ML score charm bkg")) { + if (mlScores[0] > cuts->get(pTBin, "ML score charm bkg")) { return false; } - if (candB.prong0MlScorePrompt() > cuts->get(pTBin, "ML score charm prompt")) { // we want non-prompt for beauty + if (mlScores[1] > cuts->get(pTBin, "ML score charm prompt")) { // we want non-prompt for beauty return false; } - if (candB.prong0MlScoreNonprompt() < cuts->get(pTBin, "ML score charm nonprompt")) { // we want non-prompt for beauty + if (mlScores[2] < cuts->get(pTBin, "ML score charm nonprompt")) { // we want non-prompt for beauty return false; } return true; } + /// Apply selection on ML scores for charm-hadron daughter in b-hadron decays (could be common for all the beauty channels) + /// \param candB b-hadron candidates + /// \param cuts ML score selection per bin of charm-hadron pT + /// \param binsPtC pT bin limits of charm hadron + /// \return true if b-hadron candidate passes all selections + template + bool selectionDmesMlScoresForB(const T1& candD, const T2& cuts, const T3& binsPtC, const std::vector& mlScores) + { + return applySelectionDmesMlScoresForB(cuts, binsPtC, candD.pt(), mlScores); + } + + /// Apply selection on ML scores for charm-hadron daughter in b-hadron decays in reduced format (common for all the beauty channels) + /// \param candB b-hadron candidates + /// \param cuts ML score selection per bin of charm-hadron pT + /// \param binsPtC pT bin limits of charm hadron + /// \return true if b-hadron candidate passes all selections + template + bool selectionDmesMlScoresForBReduced(const T1& candB, const T2& cuts, const T3& binsPtC) + { + std::vector mlScores; + mlScores.push_back(candB.prong0MlScoreBkg()); + mlScores.push_back(candB.prong0MlScorePrompt()); + mlScores.push_back(candB.prong0MlScoreNonprompt()); // we want non-prompt for beauty + return applySelectionDmesMlScoresForB(cuts, binsPtC, RecoDecay::pt(candB.pxProng0(), candB.pyProng0()), mlScores); + } + private: }; diff --git a/PWGHF/Core/HfMlResponseBplusToD0Pi.h b/PWGHF/Core/HfMlResponseBplusToD0Pi.h index 8a3b3875dae..90fb0669675 100644 --- a/PWGHF/Core/HfMlResponseBplusToD0Pi.h +++ b/PWGHF/Core/HfMlResponseBplusToD0Pi.h @@ -26,9 +26,9 @@ // 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_BPLUS(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesBplusToD0Pi::FEATURE) \ +#define FILL_MAP_BPLUS(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesBplusToD0Pi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -59,6 +59,17 @@ break; \ } +// where OBJECT is named candidateD , FEATURE = GETTER and INDEX is the index of the vector +#define CHECK_AND_FILL_VEC_D0_INDEX(FEATURE, GETTER1, GETTER2, INDEX) \ + case static_cast(InputFeaturesBplusToD0Pi::FEATURE): { \ + if (pdgCode == o2::constants::physics::kD0) { \ + inputFeatures.emplace_back((candidateD0.GETTER1())[INDEX]); \ + } else { \ + inputFeatures.emplace_back((candidateD0.GETTER2())[INDEX]); \ + } \ + break; \ + } + namespace o2::analysis { @@ -76,9 +87,9 @@ enum class InputFeaturesBplusToD0Pi : uint8_t { cpa, cpaXY, maxNormalisedDeltaIP, - prong0MlScoreBkg, - prong0MlScorePrompt, - prong0MlScoreNonprompt, + prong0MlProbBkg, + prong0MlProbPrompt, + prong0MlProbNonPrompt, tpcNSigmaPi1, tofNSigmaPi1, tpcTofNSigmaPi1 @@ -97,9 +108,11 @@ class HfMlResponseBplusToD0Pi : public HfMlResponse /// \param candidate is the B+ candidate /// \param prong1 is the candidate's prong1 /// \return inputFeatures vector - template + template std::vector getInputFeatures(T1 const& candidate, - T2 const& prong1) + T2 const& candidateD0, + int const& pdgCode, + T3 const& prong1) { std::vector inputFeatures; @@ -119,9 +132,9 @@ class HfMlResponseBplusToD0Pi : public HfMlResponse CHECK_AND_FILL_VEC_BPLUS(cpa); CHECK_AND_FILL_VEC_BPLUS(cpaXY); CHECK_AND_FILL_VEC_BPLUS(maxNormalisedDeltaIP); - CHECK_AND_FILL_VEC_BPLUS(prong0MlScoreBkg); - CHECK_AND_FILL_VEC_BPLUS(prong0MlScorePrompt); - CHECK_AND_FILL_VEC_BPLUS(prong0MlScoreNonprompt); + CHECK_AND_FILL_VEC_D0_INDEX(prong0MlProbBkg, mlProbD0, mlProbD0bar, 0); + CHECK_AND_FILL_VEC_D0_INDEX(prong0MlProbPrompt, mlProbD0, mlProbD0bar, 1); + CHECK_AND_FILL_VEC_D0_INDEX(prong0MlProbNonPrompt, mlProbD0, mlProbD0bar, 2); // TPC PID variable CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); // TOF PID variable @@ -175,9 +188,9 @@ class HfMlResponseBplusToD0Pi : public HfMlResponse FILL_MAP_BPLUS(cpa), FILL_MAP_BPLUS(cpaXY), FILL_MAP_BPLUS(maxNormalisedDeltaIP), - FILL_MAP_BPLUS(prong0MlScoreBkg), - FILL_MAP_BPLUS(prong0MlScorePrompt), - FILL_MAP_BPLUS(prong0MlScoreNonprompt), + FILL_MAP_BPLUS(prong0MlProbBkg), + FILL_MAP_BPLUS(prong0MlProbPrompt), + FILL_MAP_BPLUS(prong0MlProbNonPrompt), // TPC PID variable FILL_MAP_BPLUS(tpcNSigmaPi1), // TOF PID variable diff --git a/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h b/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h new file mode 100644 index 00000000000..6f56cbce245 --- /dev/null +++ b/PWGHF/Core/HfMlResponseBplusToD0PiReduced.h @@ -0,0 +1,197 @@ +// 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 HfMlResponseBplusToD0PiReduced.h +/// \brief Class to compute the ML response for B± → D0(bar) π± analysis selections in the reduced format +/// \author Antonio Palasciano , INFN Bari + +#ifndef PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PIREDUCED_H_ +#define PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PIREDUCED_H_ + +#include +#include +#include + +#include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.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_BPLUS(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesBplusToD0PiReduced::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_BPLUS_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBplusToD0PiReduced::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// 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 GETTER function taking OBJECT in argument +#define CHECK_AND_FILL_VEC_BPLUS_FUNC(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesBplusToD0PiReduced::FEATURE): { \ + inputFeatures.emplace_back(GETTER(OBJECT)); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_BPLUS_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_BPLUS(GETTER) \ + case static_cast(InputFeaturesBplusToD0PiReduced::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesBplusToD0PiReduced : uint8_t { + ptProng0 = 0, + ptProng1, + impactParameter0, + impactParameter1, + impactParameterProduct, + chi2PCA, + decayLength, + decayLengthXY, + decayLengthNormalised, + decayLengthXYNormalised, + cpa, + cpaXY, + maxNormalisedDeltaIP, + prong0MlScoreBkg, + prong0MlScorePrompt, + prong0MlScoreNonprompt, + tpcNSigmaPi1, + tofNSigmaPi1, + tpcTofNSigmaPi1 +}; + +template +class HfMlResponseBplusToD0PiReduced : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseBplusToD0PiReduced() = default; + /// Default destructor + virtual ~HfMlResponseBplusToD0PiReduced() = default; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the B+ candidate + /// \param prong1 is the candidate's prong1 + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate, + T2 const& prong1) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + if constexpr (withDmesMl) { + switch (idx) { + CHECK_AND_FILL_VEC_BPLUS(ptProng0); + CHECK_AND_FILL_VEC_BPLUS(ptProng1); + CHECK_AND_FILL_VEC_BPLUS(impactParameter0); + CHECK_AND_FILL_VEC_BPLUS(impactParameter1); + CHECK_AND_FILL_VEC_BPLUS(impactParameterProduct); + CHECK_AND_FILL_VEC_BPLUS(chi2PCA); + CHECK_AND_FILL_VEC_BPLUS(decayLength); + CHECK_AND_FILL_VEC_BPLUS(decayLengthXY); + CHECK_AND_FILL_VEC_BPLUS(decayLengthNormalised); + CHECK_AND_FILL_VEC_BPLUS(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_BPLUS(cpa); + CHECK_AND_FILL_VEC_BPLUS(cpaXY); + CHECK_AND_FILL_VEC_BPLUS(maxNormalisedDeltaIP); + CHECK_AND_FILL_VEC_BPLUS(prong0MlScoreBkg); + CHECK_AND_FILL_VEC_BPLUS(prong0MlScorePrompt); + CHECK_AND_FILL_VEC_BPLUS(prong0MlScoreNonprompt); + // TPC PID variable + CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + // TOF PID variable + CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + // Combined PID variables + CHECK_AND_FILL_VEC_BPLUS_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + } + } else { + switch (idx) { + CHECK_AND_FILL_VEC_BPLUS(ptProng0); + CHECK_AND_FILL_VEC_BPLUS(ptProng1); + CHECK_AND_FILL_VEC_BPLUS(impactParameter0); + CHECK_AND_FILL_VEC_BPLUS(impactParameter1); + CHECK_AND_FILL_VEC_BPLUS(impactParameterProduct); + CHECK_AND_FILL_VEC_BPLUS(chi2PCA); + CHECK_AND_FILL_VEC_BPLUS(decayLength); + CHECK_AND_FILL_VEC_BPLUS(decayLengthXY); + CHECK_AND_FILL_VEC_BPLUS(decayLengthNormalised); + CHECK_AND_FILL_VEC_BPLUS(decayLengthXYNormalised); + CHECK_AND_FILL_VEC_BPLUS(cpa); + CHECK_AND_FILL_VEC_BPLUS(cpaXY); + CHECK_AND_FILL_VEC_BPLUS(maxNormalisedDeltaIP); + // TPC PID variable + CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + // TOF PID variable + CHECK_AND_FILL_VEC_BPLUS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + // Combined PID variables + CHECK_AND_FILL_VEC_BPLUS_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + } + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_BPLUS(ptProng0), + FILL_MAP_BPLUS(ptProng1), + FILL_MAP_BPLUS(impactParameter0), + FILL_MAP_BPLUS(impactParameter1), + FILL_MAP_BPLUS(impactParameterProduct), + FILL_MAP_BPLUS(chi2PCA), + FILL_MAP_BPLUS(decayLength), + FILL_MAP_BPLUS(decayLengthXY), + FILL_MAP_BPLUS(decayLengthNormalised), + FILL_MAP_BPLUS(decayLengthXYNormalised), + FILL_MAP_BPLUS(cpa), + FILL_MAP_BPLUS(cpaXY), + FILL_MAP_BPLUS(maxNormalisedDeltaIP), + FILL_MAP_BPLUS(prong0MlScoreBkg), + FILL_MAP_BPLUS(prong0MlScorePrompt), + FILL_MAP_BPLUS(prong0MlScoreNonprompt), + // TPC PID variable + FILL_MAP_BPLUS(tpcNSigmaPi1), + // TOF PID variable + FILL_MAP_BPLUS(tofNSigmaPi1), + // Combined PID variable + FILL_MAP_BPLUS(tpcTofNSigmaPi1)}; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_BPLUS +#undef CHECK_AND_FILL_VEC_BPLUS_FULL +#undef CHECK_AND_FILL_VEC_BPLUS_FUNC +#undef CHECK_AND_FILL_VEC_BPLUS + +#endif // PWGHF_CORE_HFMLRESPONSEBPLUSTOD0PIREDUCED_H_ diff --git a/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx index a47f9137f7c..c5ed599c244 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx @@ -173,7 +173,7 @@ struct HfCandidateSelectorB0ToDPiReduced { } if constexpr (withDmesMl) { // we include it in the topological selections - if (!hfHelper.selectionDmesMlScoresForB(hfCandB0, cutsDmesMl, binsPtDmesMl)) { + if (!hfHelper.selectionDmesMlScoresForBReduced(hfCandB0, cutsDmesMl, binsPtDmesMl)) { hfSelB0ToDPiCandidate(statusB0ToDPi); if (applyB0Ml) { hfMlB0ToDPiCandidate(outputMlNotPreselected); diff --git a/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx index 9960ce06946..60649b57fdd 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx @@ -23,7 +23,7 @@ #include "Common/Core/TrackSelectorPID.h" #include "PWGHF/Core/HfHelper.h" -#include "PWGHF/Core/HfMlResponseBplusToD0Pi.h" +#include "PWGHF/Core/HfMlResponseBplusToD0PiReduced.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" @@ -78,7 +78,7 @@ struct HfCandidateSelectorBplusToD0PiReduced { int mySelectionFlagD0 = -1; int mySelectionFlagD0bar = -1; - o2::analysis::HfMlResponseBplusToD0Pi hfMlResponse; + o2::analysis::HfMlResponseBplusToD0PiReduced hfMlResponse; float outputMlNotPreselected = -1.; std::vector outputMl = {}; o2::ccdb::CcdbApi ccdbApi; @@ -174,7 +174,7 @@ struct HfCandidateSelectorBplusToD0PiReduced { } if constexpr (withDmesMl) { // we include it in the topological selections - if (!hfHelper.selectionDmesMlScoresForB(hfCandBp, cutsDmesMl, binsPtDmesMl)) { + if (!hfHelper.selectionDmesMlScoresForBReduced(hfCandBp, cutsDmesMl, binsPtDmesMl)) { hfSelBplusToD0PiCandidate(statusBplus); if (applyBplusMl) { hfMlBplusToD0PiCandidate(outputMlNotPreselected); diff --git a/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx index b89272f3059..9a6c47fce58 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx @@ -164,7 +164,7 @@ struct HfCandidateSelectorBsToDsPiReduced { } if constexpr (withDmesMl) { // we include it in the topological selections - if (!hfHelper.selectionDmesMlScoresForB(hfCandBs, cutsDmesMl, binsPtDmesMl)) { + if (!hfHelper.selectionDmesMlScoresForBReduced(hfCandBs, cutsDmesMl, binsPtDmesMl)) { hfSelBsToDsPiCandidate(statusBsToDsPi); if (applyBsMl) { hfMlBsToDsPiCandidate(outputMl); diff --git a/PWGHF/DataModel/DerivedTables.h b/PWGHF/DataModel/DerivedTables.h index 55bf8e57cc4..179695e2787 100644 --- a/PWGHF/DataModel/DerivedTables.h +++ b/PWGHF/DataModel/DerivedTables.h @@ -132,6 +132,12 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! momentum [](float pt, float eta) -> float { return RecoDecayPtEtaPhi::p(pt, eta); }); } // namespace hf_cand_base +// Candidate selection flags +namespace hf_cand_sel +{ +DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int8_t); //! bitmap of the selected candidate type +} + // Candidate MC columns namespace hf_cand_mc { @@ -193,6 +199,11 @@ DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant hf_track_index::Prong2Id, \ o2::soa::Marker); +#define DECLARE_CAND_SEL_TABLE(_hf_type_, _hf_description_) \ + DECLARE_SOA_TABLE_STAGED(Hf##_hf_type_##Sels, "HF" _hf_description_ "SEL", \ + hf_cand_sel::CandidateSelFlag, \ + o2::soa::Marker); + #define DECLARE_MCCAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ namespace hf_mc_particle \ { \ @@ -224,6 +235,7 @@ DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant #define DECLARE_CAND_TABLES(_hf_type_, _hf_description_, _hf_namespace_) \ DECLARE_CAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ + DECLARE_CAND_SEL_TABLE(_hf_type_, _hf_description_) \ DECLARE_MCCAND_BASE_TABLE(_hf_type_, _hf_description_, _hf_namespace_) \ DECLARE_MCCAND_ID_TABLE(_hf_type_, _hf_description_) @@ -391,12 +403,6 @@ DECLARE_SOA_COLUMN(NSigTpcTofPr1Charm, nSigTpcTofPr1Charm, float); DECLARE_SOA_COLUMN(NSigTpcTofPr2Charm, nSigTpcTofPr2Charm, float); } // namespace hf_cand_par_charm -// Candidate selection flags -namespace hf_cand_sel -{ -DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int8_t); //! bitmap of the selected candidate type -} - // Candidate MC columns of the charm daughter namespace hf_cand_mc_charm { @@ -467,10 +473,6 @@ DECLARE_SOA_TABLE_STAGED(HfD0ParEs, "HFD0PARE", //! Table with additional candid hf_cand_par::Ct, o2::soa::Marker); -DECLARE_SOA_TABLE_STAGED(HfD0Sels, "HFD0SEL", //! Table with candidate selection flags - hf_cand_sel::CandidateSelFlag, - o2::soa::Marker); - DECLARE_SOA_TABLE_STAGED(HfD0Mls, "HFD0ML", //! Table with candidate selection ML scores hf_cand_mc::MlScores, o2::soa::Marker); @@ -543,8 +545,8 @@ DECLARE_SOA_TABLE_STAGED(HfBplusParEs, "HFBPPARE", //! Table with additional can hf_cand_par::Ct, o2::soa::Marker); -DECLARE_SOA_TABLE_STAGED(HfBplusMls, "HFBPML", //! Table with candidate selection ML scores - hf_cand_mc::MlScoreSig, // why is this the signal ML score instead of the full one? +DECLARE_SOA_TABLE_STAGED(HfBplusMls, "HFBPML", //! Table with candidate selection ML scores + hf_cand_mc::MlScoreSig, o2::soa::Marker); DECLARE_SOA_TABLE_STAGED(HfBplusMlD0s, "HFBPMLD0", //! Table with D0 candidate selection ML scores @@ -620,10 +622,6 @@ DECLARE_SOA_TABLE_STAGED(HfLcParEs, "HFLCPARE", //! Table with additional candid hf_cand_par::Ct, o2::soa::Marker); -DECLARE_SOA_TABLE_STAGED(HfLcSels, "HFLCSEL", //! Table with candidate selection flags - hf_cand_sel::CandidateSelFlag, - o2::soa::Marker); - DECLARE_SOA_TABLE_STAGED(HfLcMls, "HFLCML", //! Table with candidate selection ML scores hf_cand_mc::MlScores, o2::soa::Marker); diff --git a/PWGHF/TableProducer/CMakeLists.txt b/PWGHF/TableProducer/CMakeLists.txt index 58f6d3280e4..f1ac9e9087a 100644 --- a/PWGHF/TableProducer/CMakeLists.txt +++ b/PWGHF/TableProducer/CMakeLists.txt @@ -109,7 +109,7 @@ o2physics_add_dpl_workflow(candidate-selector-b0-to-d-pi o2physics_add_dpl_workflow(candidate-selector-bplus-to-d0-pi SOURCES candidateSelectorBplusToD0Pi.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-selector-bs-to-ds-pi diff --git a/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx b/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx index e8589833f9e..11188cbe117 100644 --- a/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx +++ b/PWGHF/TableProducer/candidateSelectorBplusToD0Pi.cxx @@ -10,10 +10,14 @@ // or submit itself to any jurisdiction. /// \file candidateSelectorBplusToD0Pi.cxx -/// \brief B± → D0bar(D0) π± candidate selector +/// \brief B ± → D0bar (D0) π± candidate selector /// -/// \author Antonio Palasciano , Università degli Studi di Bari & INFN, Sezione di Bari +/// \author Antonio Palasciano , Università degli Studi di Bari /// \author Deepa Thomas , UT Austin +/// \author Nima Zardoshti , CERN + +#include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -22,6 +26,7 @@ #include "Common/Core/TrackSelectorPID.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/HfMlResponseBplusToD0Pi.h" #include "PWGHF/Core/SelectorCuts.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" @@ -32,41 +37,70 @@ using namespace o2::framework; using namespace o2::analysis; struct HfCandidateSelectorBplusToD0Pi { - Produces hfSelBplusToD0PiCandidate; + Produces hfSelBplusToD0PiCandidate; // table defined in CandidateSelectionTables.h + Produces hfMlBplusToD0PiCandidate; // table defined in CandidateSelectionTables.h - // Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; - // Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; + Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; + Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // Enable PID - Configurable usePid{"usePid", true, "Bool to use or not the PID at filtering level"}; + Configurable pionPidMethod{"pionPidMethod", 1, "PID selection method for the bachelor pion (0: none, 1: TPC or TOF, 2: TPC and TOF)"}; Configurable acceptPIDNotApplicable{"acceptPIDNotApplicable", true, "Switch to accept Status::NotApplicable [(NotApplicable for one detector) and (NotApplicable or Conditional for the other)] in PID selection"}; // TPC PID - Configurable ptPidTpcMin{"ptPidTpcMin", 999, "Lower bound of track pT for TPC PID"}; - Configurable ptPidTpcMax{"ptPidTpcMax", 9999, "Upper bound of track pT for TPC PID"}; + Configurable ptPidTpcMin{"ptPidTpcMin", 0.15, "Lower bound of track pT for TPC PID"}; + Configurable ptPidTpcMax{"ptPidTpcMax", 20., "Upper bound of track pT for TPC PID"}; Configurable nSigmaTpcMax{"nSigmaTpcMax", 5., "Nsigma cut on TPC only"}; Configurable nSigmaTpcCombinedMax{"nSigmaTpcCombinedMax", 5., "Nsigma cut on TPC combined with TOF"}; // TOF PID Configurable ptPidTofMin{"ptPidTofMin", 0.15, "Lower bound of track pT for TOF PID"}; - Configurable ptPidTofMax{"ptPidTofMax", 50., "Upper bound of track pT for TOF PID"}; + Configurable ptPidTofMax{"ptPidTofMax", 20., "Upper bound of track pT for TOF PID"}; Configurable nSigmaTofMax{"nSigmaTofMax", 5., "Nsigma cut on TOF only"}; - Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 999., "Nsigma cut on TOF combined with TPC"}; + Configurable nSigmaTofCombinedMax{"nSigmaTofCombinedMax", 5., "Nsigma cut on TOF combined with TPC"}; // topological cuts Configurable> binsPt{"binsPt", std::vector{hf_cuts_bplus_to_d0_pi::vecBinsPt}, "pT bin limits"}; Configurable> cuts{"cuts", {hf_cuts_bplus_to_d0_pi::cuts[0], hf_cuts_bplus_to_d0_pi::nBinsPt, hf_cuts_bplus_to_d0_pi::nCutVars, hf_cuts_bplus_to_d0_pi::labelsPt, hf_cuts_bplus_to_d0_pi::labelsCutVar}, "B+ candidate selection per pT bin"}; + // D0-meson ML cuts + Configurable> binsPtDmesMl{"binsPtDmesMl", std::vector{hf_cuts_ml::vecBinsPt}, "D0-meson pT bin limits for ML cuts"}; + Configurable> cutsDmesMl{"cutsDmesMl", {hf_cuts_ml::cuts[0], hf_cuts_ml::nBinsPt, hf_cuts_ml::nCutScores, hf_cuts_ml::labelsPt, hf_cuts_ml::labelsDmesCutScore}, "D0-meson ML cuts per pT bin"}; // QA switch Configurable activateQA{"activateQA", false, "Flag to enable QA histogram"}; + // B+ ML inference + Configurable applyBplusMl{"applyBplusMl", false, "Flag to apply ML selections"}; + Configurable> binsPtBpMl{"binsPtBpMl", std::vector{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; + Configurable> cutDirBpMl{"cutDirBpMl", std::vector{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; + Configurable> cutsBpMl{"cutsBpMl", {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 nClassesBpMl{"nClassesBpMl", static_cast(hf_cuts_ml::nCutScores), "Number of classes in ML model"}; + 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", std::vector{"path_ccdb/BDT_BPLUS/"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_BPLUSToD0Pi.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; + 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"}; - // check if selectionFlagD (defined in candidateCreatorBplus.cxx) and usePid configurables are in sync - bool selectionFlagDAndUsePidInSync = true; - TrackSelectorPi selectorPion; - HfHelper hfHelper; + o2::analysis::HfMlResponseBplusToD0Pi hfMlResponse; + float outputMlNotPreselected = -1.; + std::vector outputMl = {}; + o2::ccdb::CcdbApi ccdbApi; - using TracksPidWithSel = soa::Join; + HfHelper hfHelper; + TrackSelectorPi selectorPion; HistogramRegistry registry{"registry"}; - void init(InitContext& initContext) + using TracksPion = soa::Join; + + void init(InitContext const&) { - if (usePid) { + std::array doprocess{doprocessSelection, doprocessSelectionWithDmesMl}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { + LOGP(fatal, "Only one process function for data should be enabled at a time."); + } + + if (pionPidMethod < 0 || pionPidMethod > 2) { + LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); + } + + if (pionPidMethod != 0) { selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax); selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax); selectorPion.setRangeNSigmaTpcCondTof(-nSigmaTpcCombinedMax, nSigmaTpcCombinedMax); @@ -82,6 +116,7 @@ struct HfCandidateSelectorBplusToD0Pi { labels[1 + SelectionStep::RecoSkims] = "Skims selection"; labels[1 + SelectionStep::RecoTopol] = "Skims & Topological selections"; labels[1 + SelectionStep::RecoPID] = "Skims & Topological & PID selections"; + labels[1 + aod::SelectionStep::RecoMl] = "ML selection"; static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""}; registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); for (int iBin = 0; iBin < kNBinsSelections; ++iBin) { @@ -89,104 +124,140 @@ struct HfCandidateSelectorBplusToD0Pi { } } - int selectionFlagD0 = -1; - int selectionFlagD0bar = -1; - auto& workflows = initContext.services().get(); - for (const DeviceSpec& device : workflows.devices) { - if (device.name.compare("hf-candidate-creator-bplus") == 0) { - for (const auto& option : device.options) { - if (option.name.compare("selectionFlagD0") == 0) { - selectionFlagD0 = option.defaultValue.get(); - LOGF(info, "selectionFlagD0 = %d", selectionFlagD0); - } - if (option.name.compare("selectionFlagD0bar") == 0) { - selectionFlagD0bar = option.defaultValue.get(); - LOGF(info, "selectionFlagD0bar = %d", selectionFlagD0bar); - } - } + if (applyBplusMl) { + hfMlResponse.configure(binsPtBpMl, cutsBpMl, cutDirBpMl, nClassesBpMl); + if (loadModelsFromCCDB) { + ccdbApi.init(ccdbUrl); + hfMlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); + } else { + hfMlResponse.setModelPathsLocal(onnxFileNames); } + hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures); + hfMlResponse.init(); } - if ((usePid && !selectionFlagD0) || (usePid && !selectionFlagD0bar)) { - selectionFlagDAndUsePidInSync = false; - LOG(warning) << "PID selections required on B+ daughters (usePid=true) but no PID selections on D candidates were required a priori."; - } - if ((!usePid && selectionFlagD0) || (!usePid && selectionFlagD0bar)) { - selectionFlagDAndUsePidInSync = false; - LOG(warning) << "No PID selections required on Bp daughters (usePid=false) but PID selections on D candidates were required a priori."; - } - } - - /// Apply PID selection - /// \param pidTrackPi is the PID status of trackPi (prong1 of B+ candidate) - /// \return true if prong1 of B+ candidate passes all selections - template - bool selectionPID(const T& pidTrackPi) - { - if (!acceptPIDNotApplicable && pidTrackPi != TrackSelectorPID::Accepted) { - return false; - } - if (acceptPIDNotApplicable && pidTrackPi == TrackSelectorPID::Rejected) { - return false; - } - - return true; } - void process(aod::HfCandBplus const& hfCandBs, - soa::Join const&, - TracksPidWithSel const&) + /// Main function to perform B+ candidate creation + /// \param withDmesMl is the flag to use the table with ML scores for the D- daughter (only possible if present in the derived data) + /// \param hfCandsBp B+ candidates + /// \param pionTracks pion tracks + template + void runSelection(Cands const& hfCandsBp, + CandsDmes const& /*hfCandsD0*/, + TracksPion const& /*pionTracks*/) { - for (const auto& hfCandB : hfCandBs) { // looping over Bplus candidates - + for (const auto& hfCandBp : hfCandsBp) { int statusBplus = 0; - auto ptCandB = hfCandB.pt(); + auto ptCandBplus = hfCandBp.pt(); SETBIT(statusBplus, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusBplus = 1 if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandB); + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandBplus); } - // D0 is always index0 and pi is index1 by default - auto trackPi = hfCandB.prong1_as(); - // topological cuts - if (!hfHelper.selectionBplusToD0PiTopol(hfCandB, cuts, binsPt)) { + if (!hfHelper.selectionBplusToD0PiTopol(hfCandBp, cuts, binsPt)) { hfSelBplusToD0PiCandidate(statusBplus); - // LOGF(debug, "B+ candidate selection failed at topology selection"); + if (applyBplusMl) { + hfMlBplusToD0PiCandidate(outputMlNotPreselected); + } + // LOGF(info, "B+ candidate selection failed at topology selection"); continue; } + + auto trackPi = hfCandBp.template prong1_as(); + auto hfCandD = hfCandBp.template prong0_as(); + + if constexpr (withDmesMl) { + std::vector mlScoresD; + if (trackPi.sign() < 0) { + std::copy(hfCandD.mlProbD0().begin(), hfCandD.mlProbD0().end(), std::back_inserter(mlScoresD)); + } else { + std::copy(hfCandD.mlProbD0bar().begin(), hfCandD.mlProbD0bar().end(), std::back_inserter(mlScoresD)); + } + + if (!hfHelper.selectionDmesMlScoresForB(hfCandD, cutsDmesMl, binsPtDmesMl, mlScoresD)) { + hfSelBplusToD0PiCandidate(statusBplus); + if (applyBplusMl) { + hfMlBplusToD0PiCandidate(outputMlNotPreselected); + } + // LOGF(info, "B+ candidate selection failed at D0-meson ML selection"); + continue; + } + } + SETBIT(statusBplus, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusBplus = 3 if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoTopol, ptCandB); + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoTopol, ptCandBplus); } - // checking if selectionFlagD0(D0bar) and usePid are in sync - if (!selectionFlagDAndUsePidInSync) { - hfSelBplusToD0PiCandidate(statusBplus); - continue; - } // track-level PID selection - if (usePid) { - int pidTrackPi = selectorPion.statusTpcAndTof(trackPi); - if (!selectionPID(pidTrackPi)) { // FIXME use helper function + if (pionPidMethod) { + int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; + if (pionPidMethod == 1) { + pidTrackPi = selectorPion.statusTpcOrTof(trackPi); + } else { + pidTrackPi = selectorPion.statusTpcAndTof(trackPi); + } + if (!hfHelper.selectionBplusToD0PiPid(pidTrackPi, acceptPIDNotApplicable.value)) { + // LOGF(info, "B+ candidate selection failed at PID selection"); hfSelBplusToD0PiCandidate(statusBplus); + if (applyBplusMl) { + hfMlBplusToD0PiCandidate(outputMlNotPreselected); + } continue; } SETBIT(statusBplus, SelectionStep::RecoPID); // RecoPID = 2 --> statusBplus = 7 if (activateQA) { - registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoPID, ptCandB); + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoPID, ptCandBplus); + } + } + if (applyBplusMl) { + // B+ ML selections + int pdgCode = o2::constants::physics::kD0; + if (trackPi.sign() > 0) { + pdgCode = -1 * pdgCode; + } + std::vector inputFeatures = hfMlResponse.getInputFeatures(hfCandBp, hfCandD, pdgCode, trackPi); + bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCandBplus, outputMl); + hfMlBplusToD0PiCandidate(outputMl[1]); // storing ML score for signal class + + if (!isSelectedMl) { + hfSelBplusToD0PiCandidate(statusBplus); + continue; + } + SETBIT(statusBplus, SelectionStep::RecoMl); // RecoML = 3 --> statusBplus = 15 if pionPidMethod, 11 otherwise + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoMl, ptCandBplus); } } hfSelBplusToD0PiCandidate(statusBplus); - // LOGF(info, "Successful B+ candidate selection"); + // LOGF(info, "B+ candidate selection passed all selections"); } } + + void processSelection(HfCandBplus const& hfCandsBp, + aod::HfCand2ProngWPid const& hfCandsD0, + TracksPion const& pionTracks) + { + runSelection(hfCandsBp, hfCandsD0, pionTracks); + } // processSelection + + PROCESS_SWITCH(HfCandidateSelectorBplusToD0Pi, processSelection, "Process selection without ML scores of D mesons", true); + + void processSelectionWithDmesMl(HfCandBplus const& hfCandsBp, + soa::Join const& hfCandsD0, + TracksPion const& pionTracks) + { + runSelection(hfCandsBp, hfCandsD0, pionTracks); + } // processSelectionWithDmesMl + + PROCESS_SWITCH(HfCandidateSelectorBplusToD0Pi, processSelectionWithDmesMl, "Process selection with ML scores of D mesons", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx b/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx index c2e424c460c..894acd0a3f9 100644 --- a/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx @@ -49,6 +49,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { Produces rowCandidatePar; Produces rowCandidateParD0; Produces rowCandidateParE; + Produces rowCandidateSel; Produces rowCandidateMl; Produces rowCandidateMlD0; Produces rowCandidateId; @@ -69,6 +70,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; Configurable fillCandidateParD0{"fillCandidateParD0", true, "Fill D0 candidate parameters"}; Configurable fillCandidateParE{"fillCandidateParE", true, "Fill candidate extended parameters"}; + Configurable fillCandidateSel{"fillCandidateSel", true, "Fill candidate selection flags"}; Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; Configurable fillCandidateMlD0{"fillCandidateMlD0", true, "Fill D0 candidate selection ML scores"}; Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; @@ -266,6 +268,10 @@ struct HfDerivedDataCreatorBplusToD0Pi { hfHelper.cosThetaStarBplus(candidate), ct); } + if (fillCandidateSel) { + rowCandidateSel( + BIT(candFlag)); + } if (fillCandidateMl) { rowCandidateMl( mlScore); @@ -348,6 +354,7 @@ struct HfDerivedDataCreatorBplusToD0Pi { reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); reserveTable(rowCandidateParD0, fillCandidateParD0, sizeTableCand); reserveTable(rowCandidateParE, fillCandidateParE, sizeTableCand); + reserveTable(rowCandidateSel, fillCandidateSel, sizeTableCand); reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); reserveTable(rowCandidateMlD0, fillCandidateMlD0, sizeTableCand); reserveTable(rowCandidateId, fillCandidateId, sizeTableCand); diff --git a/PWGJE/Core/JetHFUtilities.h b/PWGJE/Core/JetHFUtilities.h index 00d88d728a0..1334d8ad6f6 100644 --- a/PWGJE/Core/JetHFUtilities.h +++ b/PWGJE/Core/JetHFUtilities.h @@ -494,8 +494,8 @@ void fillHFMcCollisionTable(T const& mcCollision, U& HFMcCollisionTable, int32_t HFMcCollisionTableIndex = HFMcCollisionTable.lastIndex(); } -template -void fillD0CandidateTable(T const& candidate, U& D0ParTable, V& D0ParETable, M& D0SelectionFlagTable, N& D0MlTable, O& D0MCDTable) +template +void fillD0CandidateTable(T const& candidate, U& D0ParTable, V& D0ParETable, M& D0MlTable, N& D0MCDTable) { D0ParTable( candidate.chi2PCA(), @@ -547,8 +547,6 @@ void fillD0CandidateTable(T const& candidate, U& D0ParTable, V& D0ParETable, M& candidate.cosThetaStar(), candidate.ct()); - D0SelectionFlagTable(candidate.candidateSelFlag()); - std::vector mlScoresVector; auto mlScoresSpan = candidate.mlScores(); std::copy(mlScoresSpan.begin(), mlScoresSpan.end(), std::back_inserter(mlScoresVector)); @@ -559,8 +557,8 @@ void fillD0CandidateTable(T const& candidate, U& D0ParTable, V& D0ParETable, M& } } -template -void fillLcCandidateTable(T const& candidate, U& LcParTable, V& LcParETable, M& LcSelectionFlagTable, N& LcMlTable, O& LcMCDTable) +template +void fillLcCandidateTable(T const& candidate, U& LcParTable, V& LcParETable, M& LcMlTable, N& LcMCDTable) { LcParTable( @@ -621,8 +619,6 @@ void fillLcCandidateTable(T const& candidate, U& LcParTable, V& LcParETable, M& candidate.errorImpactParameter2(), candidate.ct()); - LcSelectionFlagTable(candidate.candidateSelFlag()); - std::vector mlScoresVector; auto mlScoresSpan = candidate.mlScores(); std::copy(mlScoresSpan.begin(), mlScoresSpan.end(), std::back_inserter(mlScoresVector)); @@ -714,12 +710,13 @@ void fillHFCandidateTable(T const& candidate, int32_t collisionIndex, U& HFBaseT { HFBaseTable(collisionIndex, candidate.pt(), candidate.eta(), candidate.phi(), candidate.m(), candidate.y()); HFCandidateTableIndex = HFBaseTable.lastIndex(); + HFSelectionFlagTable(candidate.candidateSelFlag()); if constexpr (isD0Candidate()) { - fillD0CandidateTable(candidate, HFParTable, HFParETable, HFSelectionFlagTable, HFMlTable, HFMCDTable); + fillD0CandidateTable(candidate, HFParTable, HFParETable, HFMlTable, HFMCDTable); } if constexpr (isLcCandidate()) { - fillLcCandidateTable(candidate, HFParTable, HFParETable, HFSelectionFlagTable, HFMlTable, HFMCDTable); + fillLcCandidateTable(candidate, HFParTable, HFParETable, HFMlTable, HFMCDTable); } if constexpr (isBplusCandidate()) { fillBplusCandidateTable(candidate, HFParTable, HFParETable, HFParDaughterTable, HFMlTable, HFMlDaughterTable, HFMCDTable); diff --git a/PWGJE/DataModel/Jet.h b/PWGJE/DataModel/Jet.h index 423240fe799..34b8359981f 100644 --- a/PWGJE/DataModel/Jet.h +++ b/PWGJE/DataModel/Jet.h @@ -228,8 +228,8 @@ using McCollisionsLc = o2::soa::Join; using CandidatesLcMCP = o2::soa::Join; using CollisionsBplus = o2::soa::Join; -using CandidatesBplusData = o2::soa::Join; -using CandidatesBplusMCD = o2::soa::Join; +using CandidatesBplusData = o2::soa::Join; +using CandidatesBplusMCD = o2::soa::Join; using JetTracksSubBplus = JTrackBplusSubs; using JetParticlesSubBplus = JMcParticleBplusSubs; using McCollisionsBplus = o2::soa::Join; diff --git a/PWGJE/DataModel/JetReducedDataHF.h b/PWGJE/DataModel/JetReducedDataHF.h index c00a89e029e..855746326a2 100644 --- a/PWGJE/DataModel/JetReducedDataHF.h +++ b/PWGJE/DataModel/JetReducedDataHF.h @@ -129,16 +129,6 @@ DECLARE_SOA_TABLE_STAGED(JBplusPIds, "JBPPID", jbplusindices::JMcCollisionId, jbplusindices::JMcParticleId); -namespace jdummybplus -{ - -DECLARE_SOA_COLUMN(DummyBplus, dummyBplus, bool); - -} // namespace jdummybplus -DECLARE_SOA_TABLE(JDumBplusSels, "AOD", "JDUMBPUSSEL", - jdummybplus::DummyBplus, - o2::soa::Marker<1>); - } // namespace o2::aod #endif // PWGJE_DATAMODEL_JETREDUCEDDATAHF_H_ diff --git a/PWGJE/TableProducer/derivedDataWriter.cxx b/PWGJE/TableProducer/derivedDataWriter.cxx index d82f8d58b45..fb70c198fbf 100644 --- a/PWGJE/TableProducer/derivedDataWriter.cxx +++ b/PWGJE/TableProducer/derivedDataWriter.cxx @@ -141,7 +141,7 @@ struct JetDerivedDataWriter { Produces storedBplusParsTable; Produces storedBplusParExtrasTable; Produces storedBplusParD0sTable; - Produces storedBplusSelsDummyTable; + Produces storedBplusSelsTable; Produces storedBplusMlsTable; Produces storedBplusMlD0sTable; Produces storedBplusMcsTable; @@ -525,7 +525,7 @@ struct JetDerivedDataWriter { } for (const auto& Bplus : Bpluss) { int32_t BplusIndex = -1; - jethfutilities::fillHFCandidateTable(Bplus, collisionBplusIndex, products.storedBplussTable, products.storedBplusParsTable, products.storedBplusParExtrasTable, products.storedBplusParD0sTable, products.storedBplusSelsDummyTable, products.storedBplusMlsTable, products.storedBplusMlD0sTable, products.storedBplusMcsTable, BplusIndex); + jethfutilities::fillHFCandidateTable(Bplus, collisionBplusIndex, products.storedBplussTable, products.storedBplusParsTable, products.storedBplusParExtrasTable, products.storedBplusParD0sTable, products.storedBplusSelsTable, products.storedBplusMlsTable, products.storedBplusMlD0sTable, products.storedBplusMcsTable, BplusIndex); int32_t prong0Id = -1; int32_t prong1Id = -1; @@ -904,7 +904,7 @@ struct JetDerivedDataWriter { const auto lcsPerCollision = Bpluss.sliceBy(BplussPerCollision, collision.globalIndex()); for (const auto& Bplus : lcsPerCollision) { int32_t BplusIndex = -1; - jethfutilities::fillHFCandidateTable(Bplus, collisionBplusIndex, products.storedBplussTable, products.storedBplusParsTable, products.storedBplusParExtrasTable, products.storedBplusParD0sTable, products.storedBplusSelsDummyTable, products.storedBplusMlsTable, products.storedBplusMlD0sTable, products.storedBplusMcsTable, BplusIndex); + jethfutilities::fillHFCandidateTable(Bplus, collisionBplusIndex, products.storedBplussTable, products.storedBplusParsTable, products.storedBplusParExtrasTable, products.storedBplusParD0sTable, products.storedBplusSelsTable, products.storedBplusMlsTable, products.storedBplusMlD0sTable, products.storedBplusMcsTable, BplusIndex); int32_t prong0Id = -1; int32_t prong1Id = -1; diff --git a/PWGJE/Tasks/jetSubstructureBplusOutput.cxx b/PWGJE/Tasks/jetSubstructureBplusOutput.cxx index 89c0b94560f..e81e12566fa 100644 --- a/PWGJE/Tasks/jetSubstructureBplusOutput.cxx +++ b/PWGJE/Tasks/jetSubstructureBplusOutput.cxx @@ -15,7 +15,7 @@ #include "PWGJE/Tasks/jetSubstructureHFOutput.cxx" -using JetSubstructureOutputBplus = JetSubstructureHFOutputTask, aod::CandidatesBplusData, aod::CandidatesBplusMCD, aod::CandidatesBplusMCP, aod::JTrackBplusSubs, soa::Join, soa::Join, aod::BplusCJetCOs, aod::BplusCJetOs, aod::BplusCJetSSOs, aod::BplusCJetMOs, soa::Join, aod::BplusCMCDJetCOs, aod::BplusCMCDJetOs, aod::BplusCMCDJetSSOs, aod::BplusCMCDJetMOs, soa::Join, aod::BplusCMCPJetCOs, aod::BplusCMCPJetOs, aod::BplusCMCPJetSSOs, aod::BplusCMCPJetMOs, soa::Join, aod::BplusCEWSJetCOs, aod::BplusCEWSJetOs, aod::BplusCEWSJetSSOs, aod::BplusCEWSJetMOs, aod::StoredHfBplusCollBase, aod::StoredHfBplusBases, aod::StoredHfBplusPars, aod::StoredHfBplusParEs, aod::StoredHfBplusParD0s, aod::JDumBplusSels, aod::StoredHfBplusMls, aod::StoredHfBplusMlD0s, aod::StoredHfBplusMcs, aod::StoredHfBplusMcCollBases, aod::StoredHfBplusMcRCollIds, aod::StoredHfBplusPBases>; // all the 3P tables have been made into Bplus but they might be made common +using JetSubstructureOutputBplus = JetSubstructureHFOutputTask, aod::CandidatesBplusData, aod::CandidatesBplusMCD, aod::CandidatesBplusMCP, aod::JTrackBplusSubs, soa::Join, soa::Join, aod::BplusCJetCOs, aod::BplusCJetOs, aod::BplusCJetSSOs, aod::BplusCJetMOs, soa::Join, aod::BplusCMCDJetCOs, aod::BplusCMCDJetOs, aod::BplusCMCDJetSSOs, aod::BplusCMCDJetMOs, soa::Join, aod::BplusCMCPJetCOs, aod::BplusCMCPJetOs, aod::BplusCMCPJetSSOs, aod::BplusCMCPJetMOs, soa::Join, aod::BplusCEWSJetCOs, aod::BplusCEWSJetOs, aod::BplusCEWSJetSSOs, aod::BplusCEWSJetMOs, aod::StoredHfBplusCollBase, aod::StoredHfBplusBases, aod::StoredHfBplusPars, aod::StoredHfBplusParEs, aod::StoredHfBplusParD0s, aod::StoredHfBplusSels, aod::StoredHfBplusMls, aod::StoredHfBplusMlD0s, aod::StoredHfBplusMcs, aod::StoredHfBplusMcCollBases, aod::StoredHfBplusMcRCollIds, aod::StoredHfBplusPBases>; // all the 3P tables have been made into Bplus but they might be made common WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) {