Skip to content

Commit 878fb4b

Browse files
[PWGHF] Add D*pi channel in B0 reduced workflow (#12451)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent b246336 commit 878fb4b

File tree

10 files changed

+1086
-219
lines changed

10 files changed

+1086
-219
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
@@ -75,9 +75,12 @@ namespace o2::analysis
7575
enum class InputFeaturesB0ToDPi : uint8_t {
7676
ptProng0 = 0,
7777
ptProng1,
78+
ptProng2,
7879
impactParameter0,
7980
impactParameter1,
81+
impactParameter2,
8082
impactParameterProduct,
83+
impactParameterProngSqSum,
8184
chi2PCA,
8285
decayLength,
8386
decayLengthXY,
@@ -91,7 +94,13 @@ enum class InputFeaturesB0ToDPi : uint8_t {
9194
prong0MlScoreNonprompt,
9295
tpcNSigmaPi1,
9396
tofNSigmaPi1,
94-
tpcTofNSigmaPi1
97+
tpcTofNSigmaPi1,
98+
tpcNSigmaPiBachPi,
99+
tofNSigmaPiBachPi,
100+
tpcTofNSigmaPiBachPi,
101+
tpcNSigmaPiSoftPi,
102+
tofNSigmaPiSoftPi,
103+
tpcTofNSigmaPiSoftPi
95104
};
96105

97106
template <typename TypeOutputScore, bool reduced>
@@ -109,7 +118,7 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
109118
/// \return inputFeatures vector
110119
template <bool withDmesMl, typename T1, typename T2>
111120
std::vector<float> getInputFeatures(T1 const& candidate,
112-
T2 const& prong1,
121+
T2 const& prongBachPi,
113122
const std::vector<float>* mlScoresD = nullptr)
114123
{
115124
std::vector<float> inputFeatures;
@@ -130,11 +139,77 @@ class HfMlResponseB0ToDPi : public HfMlResponse<TypeOutputScore>
130139
CHECK_AND_FILL_VEC_B0(cpaXY);
131140
CHECK_AND_FILL_VEC_B0(maxNormalisedDeltaIP);
132141
// TPC PID variable
133-
CHECK_AND_FILL_VEC_B0_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi);
142+
CHECK_AND_FILL_VEC_B0_FULL(prongBachPi, tpcNSigmaPi1, tpcNSigmaPi);
134143
// TOF PID variable
135-
CHECK_AND_FILL_VEC_B0_FULL(prong1, tofNSigmaPi1, tofNSigmaPi);
144+
CHECK_AND_FILL_VEC_B0_FULL(prongBachPi, tofNSigmaPi1, tofNSigmaPi);
136145
// Combined PID variables
137-
CHECK_AND_FILL_VEC_B0_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
146+
CHECK_AND_FILL_VEC_B0_FUNC(prongBachPi, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1);
147+
}
148+
if constexpr (withDmesMl) {
149+
if constexpr (reduced) {
150+
switch (idx) {
151+
CHECK_AND_FILL_VEC_B0(prong0MlScoreBkg);
152+
CHECK_AND_FILL_VEC_B0(prong0MlScorePrompt);
153+
CHECK_AND_FILL_VEC_B0(prong0MlScoreNonprompt);
154+
}
155+
} else {
156+
if (mlScoresD) {
157+
switch (idx) {
158+
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreBkg, *mlScoresD, 0);
159+
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScorePrompt, *mlScoresD, 1);
160+
CHECK_AND_FILL_VEC_B0_INDEX(prong0MlScoreNonprompt, *mlScoresD, 2);
161+
}
162+
} else {
163+
LOG(fatal) << "ML scores of D not provided";
164+
}
165+
}
166+
}
167+
}
168+
169+
return inputFeatures;
170+
}
171+
172+
/// Method to get the input features vector needed for ML inference
173+
/// \param candidate is the B0 candidate
174+
/// \param prongBachPi is the candidate's bachelor pion prong
175+
/// \param prongSoftPi is the candidate's soft 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, typename T1, typename T2, typename T3>
180+
std::vector<float> getInputFeaturesDStarPi(T1 const& candidate,
181+
T2 const& prongBachPi,
182+
T3 const& prongSoftPi,
183+
const std::vector<float>* mlScoresD = nullptr)
184+
{
185+
std::vector<float> inputFeatures;
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: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,12 @@ DECLARE_SOA_TABLE(HfRedTracksCov, "AOD", "HFREDTRACKCOV", //! Table with track c
293293
HFTRACKPARCOV_COLUMNS,
294294
o2::soa::Marker<1>);
295295

296-
DECLARE_SOA_TABLE(HfRedSoftPiBases, "AOD", "HFREDSOFTPIBASE", //! Table with track information for reduced workflow
297-
soa::Index<>,
298-
hf_track_index_reduced::TrackId,
299-
hf_track_index_reduced::HfRedCollisionId,
300-
HFTRACKPAR_COLUMNS,
301-
hf_track_vars_reduced::ItsNCls,
302-
hf_track_vars_reduced::TpcNClsCrossedRows,
303-
hf_track_vars_reduced::TpcChi2NCl,
304-
aod::track::Px<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
305-
aod::track::Py<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
306-
aod::track::Pz<aod::track::Signed1Pt, track::Tgl>,
307-
aod::track::PVector<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha, aod::track::Tgl>,
308-
o2::soa::Marker<2>);
309-
310-
DECLARE_SOA_TABLE(HfRedSoftPiCov, "AOD", "HFREDSOFTPICOV", //! Table with track covariance information for reduced workflow
296+
DECLARE_SOA_TABLE(HfRedTracksMom, "AOD", "HFREDTRACKMOM", //! Table with track momentum information for reduced workflow
311297
soa::Index<>,
312-
HFTRACKPARCOV_COLUMNS,
313-
o2::soa::Marker<2>);
298+
hf_track_vars_reduced::Px,
299+
hf_track_vars_reduced::Py,
300+
hf_track_vars_reduced::Pz,
301+
hf_track_vars_reduced::Sign);
314302

315303
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
316304
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
@@ -546,6 +534,39 @@ DECLARE_SOA_TABLE(HfRed2ProngsMl, "AOD", "HFRED2PRONGML", //! Table with 2prong
546534
hf_charm_cand_reduced::MlScorePromptMassHypo1,
547535
hf_charm_cand_reduced::MlScoreNonpromptMassHypo1);
548536

537+
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
538+
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
539+
DECLARE_SOA_TABLE(HfRedSoftPiBases, "AOD", "HFREDSOFTPIBASE", //! Table with track information for reduced workflow
540+
soa::Index<>,
541+
hf_track_index_reduced::TrackId,
542+
hf_track_index_reduced::HfRedCollisionId,
543+
HFTRACKPAR_COLUMNS,
544+
hf_track_vars_reduced::ItsNCls,
545+
hf_track_vars_reduced::TpcNClsCrossedRows,
546+
hf_track_vars_reduced::TpcChi2NCl,
547+
aod::track::Px<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
548+
aod::track::Py<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha>,
549+
aod::track::Pz<aod::track::Signed1Pt, track::Tgl>,
550+
aod::track::PVector<aod::track::Signed1Pt, aod::track::Snp, aod::track::Alpha, aod::track::Tgl>);
551+
552+
DECLARE_SOA_TABLE(HfRedSoftPiCov, "AOD", "HFREDSOFTPICOV", //! Table with track covariance information for reduced workflow
553+
soa::Index<>,
554+
HFTRACKPARCOV_COLUMNS,
555+
o2::soa::Marker<2>);
556+
557+
DECLARE_SOA_TABLE(HfRedSoftPiPid, "AOD", "HFREDSOFTPIPID",
558+
soa::Index<>,
559+
hf_cand_dstar::TPCNSigmaPiSoftPi,
560+
hf_cand_dstar::TOFNSigmaPiSoftPi,
561+
hf_track_vars_reduced::HasTOF,
562+
hf_track_vars_reduced::HasTPC,
563+
hf_cand_dstar::TPCTOFNSigmaPiSoftPi<hf_cand_dstar::TPCNSigmaPiSoftPi, hf_cand_dstar::TOFNSigmaPiSoftPi>)
564+
565+
namespace hf_track_index_reduced
566+
{
567+
DECLARE_SOA_INDEX_COLUMN_FULL(SoftPi, softPi, int, HfRedSoftPiBases, ""); //! ReducedCollision index
568+
}; // namespace hf_track_index_reduced
569+
549570
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
550571
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
551572
DECLARE_SOA_TABLE(HfRed3Prongs, "AOD", "HFRED3PRONG", //! Table with 3prong candidate information for reduced workflow
@@ -583,6 +604,17 @@ DECLARE_SOA_TABLE_VERSIONED(HfRed3ProngsMl_001, "AOD", "HFRED3PRONGML", 1, //! T
583604

584605
using HfRed3ProngsMl = HfRed3ProngsMl_001;
585606

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+
586618
// CAREFUL: need to follow convention [Name = Description + 's'] in DECLARE_SOA_TABLE(Name, "AOD", Description)
587619
// to call DECLARE_SOA_INDEX_COLUMN_FULL later on
588620
DECLARE_SOA_TABLE(HfRedJpsis, "AOD", "HFREDJPSI", //! Table with J/Psi candidate information for reduced workflow
@@ -711,11 +743,15 @@ using HfRedPidDau2s = HfRedPidDau2s_001;
711743
using HfRedPidDau0 = HfRedPidDau0s::iterator;
712744
using HfRedPidDau1 = HfRedPidDau1s::iterator;
713745
using HfRedPidDau2 = HfRedPidDau2s::iterator;
746+
714747
// Beauty candidates prongs
715748
namespace hf_cand_b0_reduced
716749
{
717750
DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3Prongs, "_0"); //! Prong0 index
718751
DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index
752+
DECLARE_SOA_INDEX_COLUMN_FULL(ProngD0, prongD0, int, HfRed2Prongs, "_0"); //! ProngD0 index
753+
DECLARE_SOA_INDEX_COLUMN_FULL(ProngBachPi, prongBachPi, int, HfRedTrackBases, "_1"); //! ProngBachPi index
754+
DECLARE_SOA_INDEX_COLUMN_FULL(ProngSoftPi, prongSoftPi, int, HfRedSoftPiBases, "_2"); //! ProngSoftPi index
719755
DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the D daughter
720756
DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the D daughter
721757
DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the D daughter
@@ -724,13 +760,17 @@ DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! N
724760
DECLARE_SOA_TABLE(HfRedB0Prongs, "AOD", "HFREDB0PRONG", //! Table with B0 daughter indices
725761
hf_cand_b0_reduced::Prong0Id, hf_cand_b0_reduced::Prong1Id);
726762

763+
DECLARE_SOA_TABLE(HfRedB0ProngDStars, "AOD", "HFREDB0PRONGDST", //! Table with B0 daughter indices
764+
hf_cand_b0_reduced::ProngD0Id, hf_cand_b0_reduced::ProngBachPiId, hf_cand_b0_reduced::ProngSoftPiId);
765+
727766
DECLARE_SOA_TABLE(HfRedB0DpMls, "AOD", "HFREDB0DPML", //! Table with ML scores for the D+ daughter
728767
hf_cand_b0_reduced::Prong0MlScoreBkg,
729768
hf_cand_b0_reduced::Prong0MlScorePrompt,
730769
hf_cand_b0_reduced::Prong0MlScoreNonprompt,
731770
o2::soa::Marker<1>);
732771

733772
using HfRedCandB0 = soa::Join<HfCandB0Ext, HfRedB0Prongs>;
773+
using HfRedCandB0DStar = soa::Join<HfCandB0DStExt, HfRedB0ProngDStars>;
734774

735775
namespace hf_cand_bplus_reduced
736776
{
@@ -848,6 +888,15 @@ DECLARE_SOA_TABLE(HfMcCheckDpPis, "AOD", "HFMCCHECKDPPI", //! Table with reconst
848888
hf_b0_mc::PdgCodeProng3,
849889
o2::soa::Marker<1>);
850890

891+
// table with results of reconstruction level MC matching
892+
DECLARE_SOA_TABLE(HfMcRecRedDStarPis, "AOD", "HFMCRECREDDSTPI", //! Table with reconstructed MC information on DStarPi pairs for reduced workflow
893+
hf_cand_b0_reduced::ProngD0Id,
894+
hf_cand_b0_reduced::ProngBachPiId,
895+
hf_cand_b0::FlagMcMatchRec,
896+
hf_cand_b0::FlagWrongCollision,
897+
hf_cand_b0::DebugMcRec,
898+
hf_b0_mc::PtMother);
899+
851900
// Table with same size as HFCANDB0
852901
DECLARE_SOA_TABLE(HfMcRecRedB0s, "AOD", "HFMCRECREDB0", //! Reconstruction-level MC information on B0 candidates for reduced workflow
853902
hf_cand_b0::FlagMcMatchRec,

0 commit comments

Comments
 (0)