Skip to content

Commit 2ab1d97

Browse files
[PWGHF] Remove redundant D0 ML selection in D* selector (#12746)
1 parent c806cad commit 2ab1d97

File tree

3 files changed

+6
-69
lines changed

3 files changed

+6
-69
lines changed

PWGHF/Core/HfMlResponseDstarToD0Pi.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -221,28 +221,6 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse<TypeOutputScore>
221221
return inputFeatures;
222222
}
223223

224-
/// Method to get the input features used for D0 in HF triggers
225-
/// \param candidate is the D* candidate
226-
/// \return inputFeatures vector
227-
template <typename T1>
228-
std::vector<float> getInputFeaturesTrigger(T1 const& candidate)
229-
{
230-
std::vector<float> inputFeatures;
231-
232-
for (const auto& idx : MlResponse<TypeOutputScore>::mCachedIndices) {
233-
switch (idx) {
234-
CHECK_AND_FILL_VEC_DSTAR(ptProng0);
235-
CHECK_AND_FILL_VEC_DSTAR_GETTER(impactParameterXY0, impactParameter0);
236-
CHECK_AND_FILL_VEC_DSTAR(impactParameterZ0);
237-
CHECK_AND_FILL_VEC_DSTAR(ptProng1);
238-
CHECK_AND_FILL_VEC_DSTAR_GETTER(impactParameterXY1, impactParameter1);
239-
CHECK_AND_FILL_VEC_DSTAR(impactParameterZ1);
240-
}
241-
}
242-
243-
return inputFeatures;
244-
}
245-
246224
protected:
247225
/// Method to fill the map of available input features
248226
void setAvailableInputFeatures()

PWGHF/DataModel/CandidateReconstructionTables.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,6 @@ enum DecayType { DplusToPiKPi = 0,
982982
XicToPKPi,
983983
N3ProngDecays }; // always keep N3ProngDecays at the end
984984

985-
static constexpr int DstarToPiKPiBkg = DecayType::N3ProngDecays;
986-
987985
// Ds± → K± K∓ π± or D± → K± K∓ π±
988986

989987
enum DecayChannelDToKKPi {

PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -97,38 +97,23 @@ struct HfCandidateSelectorDstarToD0Pi {
9797
Configurable<LabeledArray<double>> 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"};
9898
Configurable<int> nClassesMl{"nClassesMl", static_cast<int>(hf_cuts_ml::NCutScores), "Number of classes in ML model"};
9999
Configurable<std::vector<std::string>> namesInputFeatures{"namesInputFeatures", std::vector<std::string>{"feature1", "feature2"}, "Names of ML model input features"};
100-
// ML inference D0
101-
Configurable<bool> applyMlD0Daug{"applyMlD0Daug", false, "Flag to apply ML selections on D0 daughter"};
102-
Configurable<std::vector<double>> binsPtMlD0Daug{"binsPtMlD0Daug", std::vector<double>{hf_cuts_ml::vecBinsPt}, "pT bin limits for ML application on D0 daughter"};
103-
Configurable<std::vector<int>> cutDirMlD0Daug{"cutDirMlD0Daug", std::vector<int>{hf_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold on D0 daughter"};
104-
Configurable<LabeledArray<double>> cutsMlD0Daug{"cutsMlD0Daug", {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 on D0 daughter"};
105-
Configurable<int> nClassesMlD0Daug{"nClassesMlD0Daug", static_cast<int>(hf_cuts_ml::NCutScores), "Number of classes in ML model on D0 daughter"};
106-
Configurable<std::vector<std::string>> namesInputFeaturesD0Daug{"namesInputFeaturesD0Daug", std::vector<std::string>{"feature1", "feature2"}, "Names of ML model input features on D0 daughter"};
107100

108101
// CCDB configuration
109102
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
110103
Configurable<std::vector<std::string>> modelPathsCCDB{"modelPathsCCDB", std::vector<std::string>{""}, "Paths of models on CCDB"};
111-
Configurable<std::vector<std::string>> modelPathsCCDBD0Daug{"modelPathsCCDBD0Daug", std::vector<std::string>{""}, "Paths of models on CCDB for D0 daughter"};
112104
Configurable<std::vector<std::string>> onnxFileNames{"onnxFileNames", std::vector<std::string>{"Model.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"};
113-
Configurable<std::vector<std::string>> onnxFileNamesD0Daug{"onnxFileNamesD0Daug", std::vector<std::string>{"Model.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path) for D0 daughter"};
114105
Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"};
115106
Configurable<bool> loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"};
116107

117-
// PDG mass for kaon, pion and D0
118-
double massD0, massPi, massK;
119-
120108
HfHelper hfHelper;
121109
o2::analysis::HfMlResponseDstarToD0Pi<float> hfMlResponse;
122-
o2::analysis::HfMlResponseDstarToD0Pi<float> hfMlResponseD0Daughter;
123110
std::vector<float> outputMlDstarToD0Pi = {};
124-
std::vector<float> outputMlD0ToKPi = {};
125111
o2::ccdb::CcdbApi ccdbApi;
126112

127113
TrackSelectorPi selectorPion;
128114
TrackSelectorKa selectorKaon;
129115

130116
using TracksSel = soa::Join<aod::TracksWDcaExtra, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa>;
131-
// using TracksSel = soa::Join<aod::Tracks, aod::TracksPidPi, aod::TracksPidKa>;
132117
using HfFullDstarCandidate = soa::Join<aod::HfD0FromDstar, aod::HfCandDstarsWPid>;
133118

134119
AxisSpec axisBdtScore{100, 0.f, 1.f};
@@ -139,9 +124,6 @@ struct HfCandidateSelectorDstarToD0Pi {
139124

140125
void init(InitContext&)
141126
{
142-
massPi = MassPiPlus;
143-
massK = MassKPlus;
144-
massD0 = MassD0;
145127

146128
selectorPion.setRangePtTpc(ptPidTpcMin, ptPidTpcMax);
147129
selectorPion.setRangeNSigmaTpc(-nSigmaTpcMax, nSigmaTpcMax);
@@ -183,18 +165,6 @@ struct HfCandidateSelectorDstarToD0Pi {
183165
hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
184166
hfMlResponse.init();
185167
}
186-
187-
if (applyMlD0Daug) {
188-
hfMlResponseD0Daughter.configure(binsPtMlD0Daug, cutsMlD0Daug, cutDirMlD0Daug, nClassesMlD0Daug);
189-
if (loadModelsFromCCDB) {
190-
ccdbApi.init(ccdbUrl);
191-
hfMlResponseD0Daughter.setModelPathsCCDB(onnxFileNamesD0Daug, ccdbApi, modelPathsCCDBD0Daug, timestampCCDB);
192-
} else {
193-
hfMlResponseD0Daughter.setModelPathsLocal(onnxFileNamesD0Daug);
194-
}
195-
hfMlResponseD0Daughter.cacheInputFeaturesIndices(namesInputFeaturesD0Daug);
196-
hfMlResponseD0Daughter.init();
197-
}
198168
}
199169

200170
/// Conjugate-independent topological cuts on D0
@@ -258,14 +228,6 @@ struct HfCandidateSelectorDstarToD0Pi {
258228
return false;
259229
}
260230

261-
if (applyMlD0Daug) {
262-
outputMlD0ToKPi.clear();
263-
std::vector<float> inputFeaturesD0 = hfMlResponseD0Daughter.getInputFeaturesTrigger(candidate);
264-
bool isSelectedMlD0 = hfMlResponseD0Daughter.isSelectedMl(inputFeaturesD0, candpT, outputMlD0ToKPi);
265-
if (!isSelectedMlD0) {
266-
return false;
267-
}
268-
}
269231
return true;
270232
}
271233

@@ -323,10 +285,10 @@ struct HfCandidateSelectorDstarToD0Pi {
323285
if (prongSoftPi.sign() > 0.) { // Selection of D*+
324286
mInvDstar = candidate.invMassDstar();
325287
mInvD0 = candidate.invMassD0();
326-
if (std::abs(mInvD0 - massD0) > cutsD0->get(binPt, "m")) {
288+
if (std::abs(mInvD0 - MassD0) > cutsD0->get(binPt, "m")) {
327289
return false;
328290
}
329-
if (useTriggerMassCut && !isCandidateInMassRange(mInvD0, massD0, candidate.ptD0(), hfTriggerCuts)) {
291+
if (useTriggerMassCut && !isCandidateInMassRange(mInvD0, MassD0, candidate.ptD0(), hfTriggerCuts)) {
330292
return false;
331293
}
332294
// cut on daughter pT
@@ -351,10 +313,10 @@ struct HfCandidateSelectorDstarToD0Pi {
351313
} else if (prongSoftPi.sign() < 0.) { // Selection of D*-
352314
mInvAntiDstar = candidate.invMassAntiDstar();
353315
mInvD0Bar = candidate.invMassD0Bar();
354-
if (std::abs(mInvD0Bar - massD0) > cutsD0->get(binPt, "m")) {
316+
if (std::abs(mInvD0Bar - MassD0) > cutsD0->get(binPt, "m")) {
355317
return false;
356318
}
357-
if (useTriggerMassCut && !isCandidateInMassRange(mInvD0Bar, massD0, candidate.ptD0(), hfTriggerCuts)) {
319+
if (useTriggerMassCut && !isCandidateInMassRange(mInvD0Bar, MassD0, candidate.ptD0(), hfTriggerCuts)) {
358320
return false;
359321
}
360322
// cut on daughter pT
@@ -379,11 +341,11 @@ struct HfCandidateSelectorDstarToD0Pi {
379341

380342
// in case only sideband candidates have to be stored, additional invariant-mass cut
381343
if (keepOnlySidebandCandidates && prongSoftPi.sign() > 0.) {
382-
if (std::abs((mInvDstar - mInvD0) - massPi) < distanceFromDeltaMassForSidebands) {
344+
if (std::abs((mInvDstar - mInvD0) - MassPiPlus) < distanceFromDeltaMassForSidebands) {
383345
return false;
384346
}
385347
} else if (keepOnlySidebandCandidates && prongSoftPi.sign() < 0.) {
386-
if (std::abs((mInvAntiDstar - mInvD0Bar) - massPi) < distanceFromDeltaMassForSidebands) {
348+
if (std::abs((mInvAntiDstar - mInvD0Bar) - MassPiPlus) < distanceFromDeltaMassForSidebands) {
387349
return false;
388350
}
389351
}
@@ -499,7 +461,6 @@ struct HfCandidateSelectorDstarToD0Pi {
499461
if (applyMl) {
500462
// ML selections
501463
bool isSelectedMlDstar = false;
502-
503464
std::vector<float> inputFeatures = hfMlResponse.getInputFeatures(candDstar);
504465
isSelectedMlDstar = hfMlResponse.isSelectedMl(inputFeatures, ptCand, outputMlDstarToD0Pi);
505466

0 commit comments

Comments
 (0)