Skip to content

Commit 3e77f58

Browse files
committed
Implement Fabrizio comments
1 parent c370d11 commit 3e77f58

File tree

9 files changed

+412
-225
lines changed

9 files changed

+412
-225
lines changed

PWGHF/Core/HfHelper.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
#include <cmath>
3434
#include <vector>
3535

36+
template <typename T>
37+
concept IsB0ToDstarPiChannel = requires(T candidate) {
38+
candidate.prongD0Id();
39+
};
40+
3641
class HfHelper
3742
{
3843
public:
@@ -634,6 +639,12 @@ class HfHelper
634639
return candidate.m(std::array{o2::constants::physics::MassDMinus, o2::constants::physics::MassPiPlus});
635640
}
636641

642+
template <IsB0ToDstarPiChannel T>
643+
auto invMassB0ToDPi(const T& candidate)
644+
{
645+
return candidate.m(std::array{o2::constants::physics::MassD0, o2::constants::physics::MassPiPlus, o2::constants::physics::MassPiPlus});
646+
}
647+
637648
template <typename T>
638649
auto cosThetaStarB0(const T& candidate)
639650
{

PWGHF/Core/HfMlResponseB0ToDPi.h

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define PWGHF_CORE_HFMLRESPONSEB0TODPI_H_
1919

2020
#include "PWGHF/Core/HfMlResponse.h"
21+
#include "PWGHF/D2H/DataModel/ReducedDataModel.h"
2122
#include "PWGHF/D2H/Utils/utilsRedDataFormat.h"
2223

2324
#include "Tools/ML/MlResponse.h"
@@ -75,9 +76,12 @@ namespace o2::analysis
7576
enum class InputFeaturesB0ToDPi : uint8_t {
7677
ptProng0 = 0,
7778
ptProng1,
79+
ptProng2,
7880
impactParameter0,
7981
impactParameter1,
82+
impactParameter2,
8083
impactParameterProduct,
84+
impactParameterProngSqSum,
8185
chi2PCA,
8286
decayLength,
8387
decayLengthXY,
@@ -91,7 +95,13 @@ enum class InputFeaturesB0ToDPi : uint8_t {
9195
prong0MlScoreNonprompt,
9296
tpcNSigmaPi1,
9397
tofNSigmaPi1,
94-
tpcTofNSigmaPi1
98+
tpcTofNSigmaPi1,
99+
tpcNSigmaPiBachPi,
100+
tofNSigmaPiBachPi,
101+
tpcTofNSigmaPiBachPi,
102+
tpcNSigmaPiSoftPi,
103+
tofNSigmaPiSoftPi,
104+
tpcTofNSigmaPiSoftPi
95105
};
96106

97107
template <typename TypeOutputScore, bool reduced>
@@ -109,7 +119,7 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
109119
/// \return inputFeatures vector
110120
template <bool withDmesMl, typename T1, typename T2>
111121
std::vector<float> getInputFeatures(T1 const& candidate,
112-
T2 const& prong1,
122+
T2 const& prongBachPi,
113123
const std::vector<float>* mlScoresD = nullptr)
114124
{
115125
std::vector<float> inputFeatures;
@@ -130,11 +140,76 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
130140
CHECK_AND_FILL_VEC_B0(cpaXY);
131141
CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP);
132142
// TPC PID variable
133-
CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
143+
CHECK_AND_FILL_VEC_B0_FULL(prongBachPi, tpcNSigmaPi1, tpcNSigmaPi);
134144
// TOF PID variable
135-
CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
145+
CHECK_AND_FILL_VEC_B0_FULL(prongBachPi, tofNSigmaPi1, tofNSigmaPi);
136146
// Combined PID variables
137-
CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
147+
CHECK_AND_FILL_VEC_B0_FUNC(prongBachPi, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
148+
}
149+
if constexpr (withDmesMl) {
150+
if constexpr (reduced) {
151+
switch (idx) {
152+
CHECK_AND_FILL_VEC_B0(prong0MlScoreBkg);
153+
CHECK_AND_FILL_VEC_B0(prong0MlScorePrompt);
154+
CHECK_AND_FILL_VEC_B0(prong0MlScoreNonprompt);
155+
}
156+
} else {
157+
if (mlScoresD) {
158+
switch (idx) {
159+
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreBkg, *mlScoresD, 0);
160+
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScorePrompt, *mlScoresD, 1);
161+
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreNonprompt, *mlScoresD, 2);
162+
}
163+
} else {
164+
LOG(fatal) << "ML scores of D not provided";
165+
}
166+
}
167+
}
168+
}
169+
170+
return inputFeatures;
171+
}
172+
173+
/// Method to get the input features vector needed for ML inference
174+
/// \param candidate is the B0 candidate
175+
/// \param prongBachPi is the candidate's bachelor pion prong
176+
/// \param mlScoresD is the vector of ML scores for the D meson (if available)
177+
/// \note this method is used for B0 → D*∓ π± candidates with D meson ML scores
178+
/// \return inputFeatures vector
179+
template <bool withDmesMl, IsB0ToDstarPiChannel T1, typename T2>
180+
std::vector<float> getInputFeatures(T1 const& candidate,
181+
T2 const& prongBachPi,
182+
const std::vector<float>* mlScoresD = nullptr)
183+
{
184+
std::vector<float> inputFeatures;
185+
auto prongSoftPi = candidate.template prongSoftPi_as<o2::soa::Join<o2::aod::HfRedSoftPiBases, o2::aod::HfRedSoftPiCov, o2::aod::HfRedSoftPiPid>>();
186+
187+
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
188+
switch (idx) {
189+
CHECK_AND_FILL_VEC_B0(ptProng0);
190+
CHECK_AND_FILL_VEC_B0(ptProng1);
191+
CHECK_AND_FILL_VEC_B0(ptProng2);
192+
CHECK_AND_FILL_VEC_B0(impactParameter0);
193+
CHECK_AND_FILL_VEC_B0(impactParameter1);
194+
CHECK_AND_FILL_VEC_B0(impactParameter2);
195+
CHECK_AND_FILL_VEC_B0(impactParameterProngSqSum);
196+
CHECK_AND_FILL_VEC_B0(chi2PCA);
197+
CHECK_AND_FILL_VEC_B0(decayLength);
198+
CHECK_AND_FILL_VEC_B0(decayLengthXY);
199+
CHECK_AND_FILL_VEC_B0(decayLengthNormalised);
200+
CHECK_AND_FILL_VEC_B0(decayLengthXYNormalised);
201+
CHECK_AND_FILL_VEC_B0(cpa);
202+
CHECK_AND_FILL_VEC_B0(cpaXY);
203+
CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP);
204+
// TPC PID variable
205+
CHECK_AND_FILL_VEC_B0_FULL(prongBachPi, tpcNSigmaPiBachPi, tpcNSigmaPi);
206+
CHECK_AND_FILL_VEC_B0_FULL(prongSoftPi, tpcNSigmaPiSoftPi, tpcNSigmaPiSoftPi);
207+
// TOF PID variable
208+
CHECK_AND_FILL_VEC_B0_FULL(prongBachPi, tofNSigmaPiBachPi, tofNSigmaPi);
209+
CHECK_AND_FILL_VEC_B0_FULL(prongSoftPi, tofNSigmaPiSoftPi, tofNSigmaPiSoftPi);
210+
// Combined PID variables
211+
CHECK_AND_FILL_VEC_B0_FUNC(prongBachPi, tpcTofNSigmaPiBachPi, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
212+
CHECK_AND_FILL_VEC_B0_FUNC(prongSoftPi, tpcTofNSigmaPiSoftPi, o2::pid_tpc_tof_utils::getTpcTofNSigmaSoftPi);
138213
}
139214
if constexpr (withDmesMl) {
140215
if constexpr (reduced) {
@@ -167,9 +242,12 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
167242
MlResponse<TypeOutputScore>::mAvailableInputFeatures = {
168243
FILL_MAP_B0(ptProng0),
169244
FILL_MAP_B0(ptProng1),
245+
FILL_MAP_B0(ptProng2),
170246
FILL_MAP_B0(impactParameter0),
171247
FILL_MAP_B0(impactParameter1),
248+
FILL_MAP_B0(impactParameter2),
172249
FILL_MAP_B0(impactParameterProduct),
250+
FILL_MAP_B0(impactParameterProngSqSum),
173251
FILL_MAP_B0(chi2PCA),
174252
FILL_MAP_B0(decayLength),
175253
FILL_MAP_B0(decayLengthXY),
@@ -183,10 +261,16 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
183261
FILL_MAP_B0(prong0MlScoreNonprompt),
184262
// TPC PID variable
185263
FILL_MAP_B0(tpcNSigmaPi1),
264+
FILL_MAP_B0(tpcNSigmaPiSoftPi),
265+
FILL_MAP_B0(tpcNSigmaPiBachPi),
186266
// TOF PID variable
187267
FILL_MAP_B0(tofNSigmaPi1),
268+
FILL_MAP_B0(tofNSigmaPiSoftPi),
269+
FILL_MAP_B0(tofNSigmaPiBachPi),
188270
// Combined PID variable
189-
FILL_MAP_B0(tpcTofNSigmaPi1)};
271+
FILL_MAP_B0(tpcTofNSigmaPi1),
272+
FILL_MAP_B0(tpcTofNSigmaPiSoftPi),
273+
FILL_MAP_B0(tpcTofNSigmaPiBachPi)};
190274
}
191275
};
192276

PWGHF/D2H/DataModel/ReducedDataModel.h

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ DECLARE_SOA_TABLE(HfRedTracksCov, "AOD", "HFREDTRACKCOV", //! Table with track c
293293
HFTRACKPARCOV_COLUMNS,
294294
o2::soa::Marker<1>);
295295

296+
DECLARE_SOA_TABLE(HfRedTracksMom, "AOD", "HFREDTRACKMOM", //! Table with track momentum information for reduced workflow
297+
soa::Index<>,
298+
hf_track_vars_reduced::Px,
299+
hf_track_vars_reduced::Py,
300+
hf_track_vars_reduced::Pz,
301+
hf_track_vars_reduced::Sign);
302+
296303
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
297304
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
298305
DECLARE_SOA_TABLE(HfRedBach0Bases, "AOD", "HFREDBACH0BASE", //! Table with track information for reduced workflow
@@ -551,44 +558,15 @@ DECLARE_SOA_TABLE(HfRedSoftPiPid, "AOD", "HFREDSOFTPIPID",
551558
soa::Index<>,
552559
hf_cand_dstar::TPCNSigmaPiSoftPi,
553560
hf_cand_dstar::TOFNSigmaPiSoftPi,
554-
hf_cand_dstar::TPCNSigmaKaSoftPi,
555-
hf_cand_dstar::TOFNSigmaKaSoftPi,
556561
hf_track_vars_reduced::HasTOF,
557562
hf_track_vars_reduced::HasTPC,
558-
hf_cand_dstar::TPCTOFNSigmaPiSoftPi<hf_cand_dstar::TPCNSigmaPiSoftPi, hf_cand_dstar::TOFNSigmaPiSoftPi>,
559-
hf_cand_dstar::TPCTOFNSigmaKaSoftPi<hf_cand_dstar::TPCNSigmaKaSoftPi, hf_cand_dstar::TOFNSigmaKaSoftPi>)
563+
hf_cand_dstar::TPCTOFNSigmaPiSoftPi<hf_cand_dstar::TPCNSigmaPiSoftPi, hf_cand_dstar::TOFNSigmaPiSoftPi>)
560564

561565
namespace hf_track_index_reduced
562566
{
563567
DECLARE_SOA_INDEX_COLUMN_FULL(SoftPi, softPi, int, HfRedSoftPiBases, ""); //! ReducedCollision index
564568
}; // namespace hf_track_index_reduced
565569

566-
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
567-
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
568-
DECLARE_SOA_TABLE(HfRedDStars, "AOD", "HFREDDSTAR", //! Table with 2prong candidate information for reduced workflow
569-
o2::soa::Index<>,
570-
hf_track_index_reduced::Prong0Id, hf_track_index_reduced::Prong1Id, hf_track_index_reduced::Prong2Id,
571-
hf_track_index_reduced::SoftPiId, hf_track_index_reduced::HfRedCollisionId,
572-
HFTRACKPAR_COLUMNS,
573-
hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex,
574-
hf_charm_cand_reduced::InvMassHypo0, hf_charm_cand_reduced::InvMassHypo1,
575-
hf_track_vars_reduced::PtProngMin, hf_track_vars_reduced::AbsEtaProngMin,
576-
hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax,
577-
aod::track::Px<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
578-
aod::track::Py<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
579-
aod::track::Pz<aod::track::Signed1Pt, track::Tgl>,
580-
aod::track::PVector<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha, aod::track::Tgl>);
581-
582-
DECLARE_SOA_TABLE(HfRedDStarsCov, "AOD", "HFREDDSTARCOV", //! Table with DStar candidate covariance for reduced workflow
583-
o2::soa::Index<>,
584-
HFTRACKPARCOV_COLUMNS,
585-
o2::soa::Marker<1>);
586-
587-
DECLARE_SOA_TABLE(HfRedDStarsMl, "AOD", "HFREDDSTARML", //! Table with DStar candidate ML scores
588-
hf_charm_cand_reduced::MlScoreBkgMassHypo0,
589-
hf_charm_cand_reduced::MlScorePromptMassHypo0,
590-
hf_charm_cand_reduced::MlScoreNonpromptMassHypo0);
591-
592570
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
593571
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
594572
DECLARE_SOA_TABLE(HfRed3Prongs, "AOD", "HFRED3PRONG", //! Table with 3prong candidate information for reduced workflow
@@ -626,6 +604,17 @@ DECLARE_SOA_TABLE_VERSIONED(HfRed3ProngsMl_001, "AOD", "HFRED3PRONGML", 1, //! T
626604

627605
using HfRed3ProngsMl = HfRed3ProngsMl_001;
628606

607+
DECLARE_SOA_TABLE(HfRedMomDDaugs, "AOD", "HFREDMOMDDAUGS", //! Table with 2prong candidate ML scores
608+
hf_cand::PxProng0,
609+
hf_cand::PyProng0,
610+
hf_cand::PzProng0,
611+
hf_cand::PxProng1,
612+
hf_cand::PyProng1,
613+
hf_cand::PzProng1,
614+
hf_cand::PxProng2,
615+
hf_cand::PyProng2,
616+
hf_cand::PzProng2);
617+
629618
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
630619
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
631620
DECLARE_SOA_TABLE(HfRedJpsis, "AOD", "HFREDJPSI", //! Table with J/Psi candidate information for reduced workflow
@@ -755,19 +744,14 @@ using HfRedPidDau0 = HfRedPidDau0s::iterator;
755744
using HfRedPidDau1 = HfRedPidDau1s::iterator;
756745
using HfRedPidDau2 = HfRedPidDau2s::iterator;
757746

758-
DECLARE_SOA_TABLE(HfRedB0SoftPi, "AOD", "HFREDB0SOFTPI", //! Table with track information for reduced workflow
759-
o2::soa::Index<>,
760-
hf_track_index::CollisionId,
761-
hf_cand_dstar::PxSoftPi, hf_cand_dstar::PySoftPi, hf_cand_dstar::PzSoftPi,
762-
hf_cand_dstar::DcaYSoftPi, hf_cand_dstar::SigmaYSoftPi);
763-
764747
// Beauty candidates prongs
765748
namespace hf_cand_b0_reduced
766749
{
767750
DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3Prongs, "_0"); //! Prong0 index
768751
DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index
769-
DECLARE_SOA_INDEX_COLUMN_FULL(ProngDStar, prongDStar, int, HfRedDStars, ""); //! ProngDStar index
770-
DECLARE_SOA_INDEX_COLUMN_FULL(ProngSoftPi, prongSoftPi, int, HfRedB0SoftPi, ""); //! ProngSoftPi index
752+
DECLARE_SOA_INDEX_COLUMN_FULL(ProngD0, prongD0, int, HfRed2Prongs, ""); //! ProngD0 index
753+
DECLARE_SOA_INDEX_COLUMN_FULL(ProngSoftPi, prongSoftPi, int, HfRedTrackBases, ""); //! ProngSoftPi index
754+
DECLARE_SOA_INDEX_COLUMN_FULL(ProngBachPi, prongBachPi, int, HfRedTrackBases, ""); //! ProngBachPi index
771755
DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the D daughter
772756
DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the D daughter
773757
DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the D daughter
@@ -777,7 +761,7 @@ DECLARE_SOA_TABLE(HfRedB0Prongs, "AOD", "HFREDB0PRONG", //! Table with B0 daught
777761
hf_cand_b0_reduced::Prong0Id, hf_cand_b0_reduced::Prong1Id);
778762

779763
DECLARE_SOA_TABLE(HfRedB0ProngDStars, "AOD", "HFREDB0PRONGDST", //! Table with B0 daughter indices
780-
hf_cand_b0_reduced::ProngDStarId, hf_cand_b0_reduced::Prong1Id, hf_cand_b0_reduced::ProngSoftPiId);
764+
hf_cand_b0_reduced::ProngD0Id, hf_cand_b0_reduced::ProngSoftPiId, hf_cand_b0_reduced::ProngBachPiId);
781765

782766
DECLARE_SOA_TABLE(HfRedB0DpMls, "AOD", "HFREDB0DPML", //! Table with ML scores for the D+ daughter
783767
hf_cand_b0_reduced::Prong0MlScoreBkg,
@@ -786,7 +770,7 @@ DECLARE_SOA_TABLE(HfRedB0DpMls, "AOD", "HFREDB0DPML", //! Table with ML scores f
786770
o2::soa::Marker<1>);
787771

788772
using HfRedCandB0 = soa::Join<HfCandB0Ext, HfRedB0Prongs>;
789-
using HfRedCandB0DStar = soa::Join<HfCandB0Ext, HfRedB0ProngDStars>;
773+
using HfRedCandB0DStar = soa::Join<HfCandB0DStExt, HfRedB0ProngDStars>;
790774

791775
namespace hf_cand_bplus_reduced
792776
{
@@ -906,9 +890,8 @@ DECLARE_SOA_TABLE(HfMcCheckDpPis, "AOD", "HFMCCHECKDPPI", //! Table with reconst
906890

907891
// table with results of reconstruction level MC matching
908892
DECLARE_SOA_TABLE(HfMcRecRedDStarPis, "AOD", "HFMCRECREDDSTPI", //! Table with reconstructed MC information on DStarPi pairs for reduced workflow
909-
hf_cand_b0_reduced::ProngDStarId,
910-
hf_cand_b0_reduced::Prong1Id,
911-
hf_cand_b0_reduced::ProngSoftPiId,
893+
hf_cand_b0_reduced::ProngD0Id,
894+
hf_cand_b0_reduced::ProngBachPiId,
912895
hf_cand_b0::FlagMcMatchRec,
913896
hf_cand_b0::FlagWrongCollision,
914897
hf_cand_b0::DebugMcRec,

0 commit comments

Comments
 (0)