Skip to content

Commit 1aab6a9

Browse files
authored
[PWGHF] Fix ML variable addition to tree creator (AliceO2Group#9885)
1 parent dfbf7e7 commit 1aab6a9

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

PWGHF/TableProducer/treeCreatorD0ToKPi.cxx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/// \author Nicolo' Jacazio <[email protected]>, CERN
1818
/// \author Andrea Tavira García <[email protected]>, IJCLab
1919

20+
#include <vector>
21+
2022
#include "CommonConstants/PhysicsConstants.h"
2123
#include "Framework/AnalysisTask.h"
2224
#include "Framework/runDataProcessing.h"
@@ -275,7 +277,7 @@ struct HfTreeCreatorD0ToKPi {
275277

276278
template <bool applyMl, typename T>
277279
auto fillTable(const T& candidate, int candFlag, double invMass, double cosThetaStar, double topoChi2,
278-
double ct, double y, double e, int8_t flagMc, int8_t origin)
280+
double ct, double y, double e, int8_t flagMc, int8_t origin, std::vector<float> const& mlProbD0)
279281
{
280282
if (fillCandidateLiteTable) {
281283
rowCandidateLite(
@@ -379,18 +381,10 @@ struct HfTreeCreatorD0ToKPi {
379381
candidate.globalIndex());
380382
}
381383
if constexpr (applyMl) {
382-
if (candidate.isSelD0()) {
383-
rowCandidateMl(
384-
candidate.mlProbD0()[0],
385-
candidate.mlProbD0()[1],
386-
candidate.mlProbD0()[2]);
387-
}
388-
if (candidate.isSelD0bar()) {
389-
rowCandidateMl(
390-
candidate.mlProbD0bar()[0],
391-
candidate.mlProbD0bar()[1],
392-
candidate.mlProbD0bar()[2]);
393-
}
384+
rowCandidateMl(
385+
mlProbD0[0],
386+
mlProbD0[1],
387+
mlProbD0[2]);
394388
}
395389
}
396390

@@ -425,6 +419,7 @@ struct HfTreeCreatorD0ToKPi {
425419
double eD = hfHelper.eD0(candidate);
426420
double ctD = hfHelper.ctD0(candidate);
427421
float massD0, massD0bar;
422+
std::vector<float> mlProbD0, mlProbD0bar;
428423
float topolChi2PerNdf = -999.;
429424
if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) {
430425
massD0 = candidate.kfGeoMassD0();
@@ -435,10 +430,16 @@ struct HfTreeCreatorD0ToKPi {
435430
massD0bar = hfHelper.invMassD0barToKPi(candidate);
436431
}
437432
if (candidate.isSelD0()) {
438-
fillTable<applyMl>(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0);
433+
if constexpr (applyMl) {
434+
mlProbD0 = std::vector<float>(candidate.mlProbD0().begin(), candidate.mlProbD0().end());
435+
}
436+
fillTable<applyMl>(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0, mlProbD0);
439437
}
440438
if (candidate.isSelD0bar()) {
441-
fillTable<applyMl>(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0);
439+
if constexpr (applyMl) {
440+
mlProbD0bar = std::vector<float>(candidate.mlProbD0bar().begin(), candidate.mlProbD0bar().end());
441+
}
442+
fillTable<applyMl>(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0, mlProbD0bar);
442443
}
443444
}
444445
}
@@ -524,6 +525,7 @@ struct HfTreeCreatorD0ToKPi {
524525
double ctD = hfHelper.ctD0(candidate);
525526
float massD0, massD0bar;
526527
float topolChi2PerNdf = -999.;
528+
std::vector<float> mlProbD0, mlProbD0bar;
527529
if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) {
528530
massD0 = candidate.kfGeoMassD0();
529531
massD0bar = candidate.kfGeoMassD0bar();
@@ -533,10 +535,16 @@ struct HfTreeCreatorD0ToKPi {
533535
massD0bar = hfHelper.invMassD0barToKPi(candidate);
534536
}
535537
if (candidate.isSelD0()) {
536-
fillTable<applyMl>(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec());
538+
if constexpr (applyMl) {
539+
mlProbD0 = std::vector<float>(candidate.mlProbD0().begin(), candidate.mlProbD0().end());
540+
}
541+
fillTable<applyMl>(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec(), mlProbD0);
537542
}
538543
if (candidate.isSelD0bar()) {
539-
fillTable<applyMl>(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec());
544+
if constexpr (applyMl) {
545+
mlProbD0bar = std::vector<float>(candidate.mlProbD0bar().begin(), candidate.mlProbD0bar().end());
546+
}
547+
fillTable<applyMl>(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec(), mlProbD0bar);
540548
}
541549
}
542550

0 commit comments

Comments
 (0)