Skip to content

Commit ef27e99

Browse files
author
Mattia Faggin
committed
Fix ML for D*, and add PID for soft pion.
1 parent c07eea9 commit ef27e99

File tree

5 files changed

+52
-38
lines changed

5 files changed

+52
-38
lines changed

PWGHF/Core/HfMlResponseDstarToD0Pi.h

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
break; \
5050
}
5151

52+
// Specific case of CHECK_AND_FILL_VEC_DSTAR_FULL(OBJECT, FEATURE, GETTER)
53+
// where OBJECT is named candidate and FEATURE != GETTER
54+
#define CHECK_AND_FILL_VEC_DSTAR_GETTER(FEATURE, GETTER) \
55+
case static_cast<uint8_t>(InputFeaturesDstarToD0Pi::FEATURE): { \
56+
inputFeatures.emplace_back(candidate.GETTER()); \
57+
break; \
58+
}
59+
5260
// Very specific case of CHECK_AND_FILL_VEC_DSTAR_FULL(OBJECT, FEATURE, GETTER)
5361
// Use for push back different value for D*+ or D*- candidate
5462
#define CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(POSGETTER, NEGGETTER, FEATURENAME) \
@@ -151,9 +159,8 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse<TypeOutputScore>
151159
/// \param prong1 is the candidate's prong1
152160
/// \param prongSoftPi is the candidate's prongSoftPi
153161
/// \return inputFeatures vector
154-
template <typename T1, typename T2>
155-
std::vector<float> getInputFeatures(T1 const& candidate,
156-
T2 const& prong0, T2 const& prong1, T2 const& prongSoftPi)
162+
template <typename T1>
163+
std::vector<float> getInputFeatures(T1 const& candidate)
157164
{
158165
std::vector<float> inputFeatures;
159166

@@ -186,24 +193,24 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse<TypeOutputScore>
186193
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(cosThetaStarD0, cosThetaStarD0Bar, cosThetaStarD0);
187194
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(invMassD0, invMassD0Bar, massD0);
188195
CHECK_AND_FILL_VEC_DSTAR_DELTA_MASS_D0(deltaMassD0);
189-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCPiPr0, tpcNSigmaPi);
190-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCKaPr0, tpcNSigmaKa);
191-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTOFPiPr0, tofNSigmaPi);
192-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTOFKaPr0, tofNSigmaKa);
193-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCTOFPiPr0, tpcTofNSigmaPi);
194-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong0, prong1, nSigmaTPCTOFKaPr0, tpcTofNSigmaKa);
195-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCPiPr1, tpcNSigmaPi);
196-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCKaPr1, tpcNSigmaKa);
197-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTOFPiPr1, tofNSigmaPi);
198-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTOFKaPr1, tofNSigmaKa);
199-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCTOFPiPr1, tpcTofNSigmaPi);
200-
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(prong1, prong0, nSigmaTPCTOFKaPr1, tpcTofNSigmaKa);
201-
CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCPiPrSoftPi, tpcNSigmaPi);
202-
CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCKaPrSoftPi, tpcNSigmaKa);
203-
CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTOFPiPrSoftPi, tofNSigmaPi);
204-
CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTOFKaPrSoftPi, tofNSigmaKa);
205-
CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCTOFPiPrSoftPi, tpcTofNSigmaPi);
206-
CHECK_AND_FILL_VEC_DSTAR_FULL(prongSoftPi, nSigmaTPCTOFKaPrSoftPi, tpcTofNSigmaKa);
196+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcPi0, nSigTpcPi1, nSigmaTPCPiPr0);
197+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcKa0, nSigTpcKa1, nSigmaTPCKaPr0);
198+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofPi0, nSigTofPi1, nSigmaTOFPiPr0);
199+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofKa0, nSigTofKa1, nSigmaTOFKaPr0);
200+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaPi0, tpcTofNSigmaPi1, nSigmaTPCTOFPiPr0);
201+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaKa0, tpcTofNSigmaKa1, nSigmaTPCTOFKaPr0);
202+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcPi1, nSigTpcPi0, nSigmaTPCPiPr1);
203+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTpcKa1, nSigTpcKa0, nSigmaTPCKaPr1);
204+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofPi1, nSigTofPi0, nSigmaTOFPiPr1);
205+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(nSigTofKa1, nSigTofKa0, nSigmaTOFKaPr1);
206+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaPi1, tpcTofNSigmaPi0, nSigmaTPCTOFPiPr1);
207+
CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(tpcTofNSigmaKa1, tpcTofNSigmaKa0, nSigmaTPCTOFKaPr1);
208+
CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCPiPrSoftPi, nSigTpcPi2);
209+
CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCKaPrSoftPi, nSigTpcKa2);
210+
CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTOFPiPrSoftPi, nSigTofPi2);
211+
CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTOFKaPrSoftPi, nSigTofPi2);
212+
CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCTOFPiPrSoftPi, tpcTofNSigmaPi2);
213+
CHECK_AND_FILL_VEC_DSTAR_GETTER(nSigmaTPCTOFKaPrSoftPi, tpcTofNSigmaKa2);
207214
}
208215
}
209216

@@ -270,5 +277,6 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse<TypeOutputScore>
270277
#undef CHECK_AND_FILL_VEC_DSTAR
271278
#undef CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE
272279
#undef CHECK_AND_FILL_VEC_DSTAR_DELTA_MASS_D0
280+
#undef CHECK_AND_FILL_VEC_DSTAR_GETTER
273281

274282
#endif // PWGHF_CORE_HFMLRESPONSEDSTARTOD0PI_H_

PWGHF/DataModel/CandidateReconstructionTables.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,7 @@ DECLARE_SOA_EXTENDED_TABLE_USER(HfCandDstarExt, HfCandDstarBase, "HFCANDDSTREXT"
24272427

24282428
using HfCandDstars = HfCandDstarExt;
24292429
using HfCandDstar = HfCandDstars::iterator;
2430+
using HfCandDstarsWPid = soa::Join<HfCandDstars, HfProng0PidPi, HfProng0PidKa, HfProng1PidPi, HfProng1PidKa, /*soft pion*/ HfProng2PidPi, /*soft pion*/ HfProng2PidKa>;
24302431

24312432
// table with results of reconstruction level MC matching
24322433
DECLARE_SOA_TABLE(HfCandDstarMcRec, "AOD", "HFCANDDSTRMCREC",

PWGHF/TableProducer/candidateCreatorDstar.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct HfCandidateCreatorDstar {
5959
Produces<aod::HfProng0PidKa> rowProng0PidKa;
6060
Produces<aod::HfProng1PidPi> rowProng1PidPi;
6161
Produces<aod::HfProng1PidKa> rowProng1PidKa;
62+
Produces<aod::HfProng2PidPi> rowProngSoftPiPidPi;
63+
Produces<aod::HfProng2PidKa> rowProngSoftPiPidKa;
6264

6365
Configurable<bool> fillHistograms{"fillHistograms", true, "fill histograms"};
6466

@@ -201,7 +203,7 @@ struct HfCandidateCreatorDstar {
201203
continue;
202204
}
203205

204-
auto trackPi = rowTrackIndexDstar.template prong0_as<aod::TracksWCov>();
206+
auto trackPi = rowTrackIndexDstar.template prong0_as<TracksWCovExtraPidPiKa>();
205207
auto prongD0 = rowTrackIndexDstar.template prongD0_as<aod::Hf2Prongs>();
206208
auto trackD0Prong0 = prongD0.template prong0_as<TracksWCovExtraPidPiKa>();
207209
auto trackD0Prong1 = prongD0.template prong1_as<TracksWCovExtraPidPiKa>();
@@ -359,6 +361,9 @@ struct HfCandidateCreatorDstar {
359361
fillProngPid<HfProngSpecies::Kaon>(trackD0Prong0, rowProng0PidKa);
360362
fillProngPid<HfProngSpecies::Pion>(trackD0Prong1, rowProng1PidPi);
361363
fillProngPid<HfProngSpecies::Kaon>(trackD0Prong1, rowProng1PidKa);
364+
// fill soft-pion PID rows
365+
fillProngPid<HfProngSpecies::Pion>(trackPi, rowProngSoftPiPidPi);
366+
fillProngPid<HfProngSpecies::Kaon>(trackPi, rowProngSoftPiPidKa);
362367

363368
if (fillHistograms) {
364369
registry.fill(HIST("QA/hPtD0"), ptD0);

PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct HfCandidateSelectorDstarToD0Pi {
108108

109109
using TracksSel = soa::Join<aod::TracksWDcaExtra, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa>;
110110
// using TracksSel = soa::Join<aod::Tracks, aod::TracksPidPi, aod::TracksPidKa>;
111-
using HfFullDstarCandidate = soa::Join<aod::HfD0FromDstarWPid, aod::HfCandDstars>;
111+
using HfFullDstarCandidate = soa::Join<aod::HfD0FromDstar, aod::HfCandDstarsWPid>;
112112

113113
AxisSpec axisBdtScore{100, 0.f, 1.f};
114114
AxisSpec axisSelStatus{2, -0.5f, 1.5f};
@@ -465,7 +465,7 @@ struct HfCandidateSelectorDstarToD0Pi {
465465
// ML selections
466466
bool isSelectedMlDstar = false;
467467

468-
std::vector<float> inputFeatures = hfMlResponse.getInputFeatures(candDstar, prong0, prong1, prongPi);
468+
std::vector<float> inputFeatures = hfMlResponse.getInputFeatures(candDstar);
469469
isSelectedMlDstar = hfMlResponse.isSelectedMl(inputFeatures, ptCand, outputMlDstarToD0Pi);
470470

471471
hfMlDstarCandidate(outputMlDstarToD0Pi);

PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ struct HfTreeCreatorDstarToD0Pi {
255255
Configurable<float> downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of background candidates to keep for ML trainings"};
256256
Configurable<float> ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"};
257257

258-
using CandDstarWSelFlag = soa::Filtered<soa::Join<aod::HfD0FromDstarWPid, aod::HfCandDstars, aod::HfSelDstarToD0Pi>>;
259-
using CandDstarWSelFlagMcRec = soa::Filtered<soa::Join<aod::HfD0FromDstarWPid, aod::HfCandDstars, aod::HfSelDstarToD0Pi, aod::HfCandDstarMcRec>>;
258+
using CandDstarWSelFlag = soa::Filtered<soa::Join<aod::HfD0FromDstar, aod::HfCandDstarsWPid, aod::HfSelDstarToD0Pi>>;
259+
using CandDstarWSelFlagMcRec = soa::Filtered<soa::Join<aod::HfD0FromDstar, aod::HfCandDstarsWPid, aod::HfSelDstarToD0Pi, aod::HfCandDstarMcRec>>;
260260
using TracksWPid = soa::Join<aod::Tracks, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa>;
261261
using CandDstarMcGen = soa::Filtered<soa::Join<aod::McParticles, aod::HfCandDstarMcGen>>;
262262

@@ -372,12 +372,12 @@ struct HfTreeCreatorDstarToD0Pi {
372372
candidate.nSigTofKa1(),
373373
candidate.tpcTofNSigmaPi1(),
374374
candidate.tpcTofNSigmaKa1(),
375-
prongSoftPi.tpcNSigmaPi(),
376-
prongSoftPi.tpcNSigmaKa(),
377-
prongSoftPi.tofNSigmaPi(),
378-
prongSoftPi.tofNSigmaKa(),
379-
prongSoftPi.tpcTofNSigmaPi(),
380-
prongSoftPi.tpcTofNSigmaKa(),
375+
candidate.nSigTpcPi2(),
376+
candidate.nSigTpcKa2(),
377+
candidate.nSigTofPi2(),
378+
candidate.nSigTofKa2(),
379+
candidate.tpcTofNSigmaPi2(),
380+
candidate.tpcTofNSigmaKa2(),
381381
massD0,
382382
candidate.ptD0(),
383383
candidate.etaD0(),
@@ -441,12 +441,12 @@ struct HfTreeCreatorDstarToD0Pi {
441441
candidate.nSigTofKa1(),
442442
candidate.tpcTofNSigmaPi1(),
443443
candidate.tpcTofNSigmaKa1(),
444-
prongSoftPi.tpcNSigmaPi(),
445-
prongSoftPi.tpcNSigmaKa(),
446-
prongSoftPi.tofNSigmaPi(),
447-
prongSoftPi.tofNSigmaKa(),
448-
prongSoftPi.tpcTofNSigmaPi(),
449-
prongSoftPi.tpcTofNSigmaKa(),
444+
candidate.nSigTpcPi2(),
445+
candidate.nSigTpcKa2(),
446+
candidate.nSigTofPi2(),
447+
candidate.nSigTofKa2(),
448+
candidate.tpcTofNSigmaPi2(),
449+
candidate.tpcTofNSigmaKa2(),
450450
massD0,
451451
candidate.ptD0(),
452452
candidate.pD0(),

0 commit comments

Comments
 (0)