@@ -84,13 +84,12 @@ DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! Run number
8484DECLARE_SOA_COLUMN (Centrality, centrality, float ); // ! Collision centrality (for reco MC)
8585// ML scores
8686DECLARE_SOA_COLUMN (BkgScore, bkgScore, float ); // ! Bkg score (for reco MC candidates)
87- DECLARE_SOA_COLUMN (PromptScore, promptScore, float ); // ! Prompt score (for reco MC candidates)
8887DECLARE_SOA_COLUMN (FdScore, fdScore, float ); // ! FD score (for reco MC candidates)
8988} // namespace full
90-
91- DECLARE_SOA_TABLE (HfCandDpMlScores, " AOD " , " HFCANDDPMLSCORES " ,
89+ DECLARE_SOA_TABLE (HfCandDpMls, " AOD " , " HFCANDDPML " ,
90+ full::Centrality ,
9291 full::BkgScore,
93- full::FdScore)
92+ full::FdScore, )
9493
9594DECLARE_SOA_TABLE (HfCandDpLites, " AOD" , " HFCANDDPLITE" ,
9695 hf_cand::Chi2PCA,
@@ -244,13 +243,13 @@ struct HfTreeCreatorDplusToPiKPi {
244243 Produces<o2::aod::HfCandDpFullEvs> rowCandidateFullEvents;
245244 Produces<o2::aod::HfCandDpFullPs> rowCandidateFullParticles;
246245 Produces<o2::aod::HfCandDpLites> rowCandidateLite;
247- Produces<o2::aod::HfCandDpMlScores > rowCandidateMl;
246+ Produces<o2::aod::HfCandDpMls > rowCandidateMl;
248247
249248 Configurable<int > selectionFlagDplus{" selectionFlagDplus" , 1 , " Selection Flag for Dplus" };
250249 Configurable<bool > fillCandidateLiteTable{" fillCandidateLiteTable" , false , " Switch to fill lite table with candidate properties" };
251250 // parameters for production of training samples
252251 Configurable<bool > fillOnlySignal{" fillOnlySignal" , false , " Flag to fill derived tables with signal for ML trainings" };
253- Configurable<bool > fillMlScores{ " fillMlScores " , false , " Flag to fill derived tables with ML info" };
252+ Configurable<bool > fillOnlySignalMl{ " fillOnlySignalMl " , false , " Flag to fill derived tables with MC and ML info" };
254253 Configurable<bool > fillOnlyBackground{" fillOnlyBackground" , false , " Flag to fill derived tables with background for ML trainings" };
255254 Configurable<float > downSampleBkgFactor{" downSampleBkgFactor" , 1 ., " Fraction of background candidates to keep for ML trainings" };
256255 Configurable<float > ptMaxForDownSample{" ptMaxForDownSample" , 10 ., " Maximum pt for the application of the downsampling factor" };
@@ -270,6 +269,7 @@ struct HfTreeCreatorDplusToPiKPi {
270269 Partition<SelectedCandidatesMc> reconstructedCandSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast <int8_t >(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) || nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast <int8_t >(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)); // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
271270 Partition<SelectedCandidatesMc> reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast <int8_t >(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi));
272271 Partition<SelectedCandidatesMcWithMl> reconstructedCandSigMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast <int8_t >(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) || nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast <int8_t >(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) || nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast <int8_t >(BIT(aod::hf_cand_3prong::DstarToPiKPiBkg)); // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
272+ // Partition<SelectedCandidatesMcWithMl> reconstructedCandSigMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast<int8_t>(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) || nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast<int8_t>(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) || nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast<int8_t>(BIT(aod::hf_cand_3prong::DecayType::DstarToD0Pi)); // DecayType::DsToKKPi is used to flag both Ds± → K± K∓ π± and D± → K± K∓ π±
273273
274274 void init (InitContext const &)
275275 {
@@ -301,15 +301,18 @@ struct HfTreeCreatorDplusToPiKPi {
301301 channelMc = candidate.flagMcDecayChanRec ();
302302 }
303303
304+ std::vector<float > outputMl = {-999 ., -999 .};
304305 if constexpr (doMl) {
305- LOG (info) << " fillMl" ;
306- std::vector<float > outputMl = {-999 ., -999 .};
306+ LOG (info) << " in filler fillOnlySignalMl: " << fillOnlySignalMl;
307307 for (unsigned int iclass = 0 ; iclass < classMl->size (); iclass++) {
308308 outputMl[iclass] = candidate.mlProbDplusToPiKPi ()[classMl->at (iclass)];
309309 }
310+ auto collision = candidate.template collision_as <McRecoCollisionsCent>();
311+ double cent = getCentralityColl (collision, CentralityEstimator::FT0C);
310312 rowCandidateMl (
313+ cent,
311314 outputMl[0 ],
312- outputMl[1 ]
315+ outputMl[1 ],
313316 );
314317 }
315318
@@ -318,7 +321,7 @@ struct HfTreeCreatorDplusToPiKPi {
318321 auto prong2 = candidate.template prong2_as <TracksWPid>();
319322
320323 if (fillCandidateLiteTable) {
321- LOG (info) << " fillLite " ;
324+ LOG (info) << " fillCandidateLiteTable: " << fillCandidateLiteTable ;
322325 rowCandidateLite (
323326 candidate.chi2PCA (),
324327 candidate.decayLength (),
@@ -486,66 +489,69 @@ struct HfTreeCreatorDplusToPiKPi {
486489 McRecoCollisionsCent const &,
487490 TracksWPid const &)
488491 {
489- // Filling event properties
490- rowCandidateFullEvents.reserve (collisions.size ());
491- for (const auto & collision : collisions) {
492- fillEvent (collision, 0 , 1 );
493- }
494-
495- // Filling candidate properties
496- if (fillOnlySignal) {
497- if (fillMlScores) {
498- rowCandidateMl.reserve (reconstructedCandSigMl.size ());
499- if (fillCandidateLiteTable) {
500- rowCandidateLite.reserve (reconstructedCandSigMl.size ());
501- } else {
502- rowCandidateFull.reserve (reconstructedCandSigMl.size ());
503- }
504- LOG (info) << " Fill candidate with ml" ;
505- for (const auto & candidate : candidateswithml) {
506- if (downSampleBkgFactor < 1 .) {
507- float pseudoRndm = candidate.ptProng0 () * 1000 . - (int64_t )(candidate.ptProng0 () * 1000 );
508- if (candidate.pt () < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
509- continue ;
492+ LOG (info) << " Process MC" ;
493+ // Filling event properties
494+ rowCandidateFullEvents.reserve (collisions.size ());
495+ for (const auto & collision : collisions) {
496+ fillEvent (collision, 0 , 1 );
497+ }
498+
499+ LOG (info) << " fillOnlySignal: " << fillOnlySignal;
500+ LOG (info) << " fillCandidateLiteTable: " << fillCandidateLiteTable;
501+ // Filling candidate properties
502+ if (fillOnlySignal) {
503+ if (fillCandidateLiteTable) {
504+ rowCandidateLite.reserve (reconstructedCandSig.size ());
505+ } else {
506+ rowCandidateFull.reserve (reconstructedCandSig.size ());
507+ }
508+ LOG (info) << " reconstructedCandSig.size(): " << reconstructedCandSig.size ();
509+ for (const auto & candidate : reconstructedCandSig) {
510+ LOG (info) << " fillCandidateTable<true>(candidate)" ;
511+ fillCandidateTable<true >(candidate);
512+ }
513+ } else if (fillOnlySignalMl) {
514+ LOG (info) << " fillOnlySignalMl: " << fillOnlySignalMl;
515+ rowCandidateMl.reserve (reconstructedCandSigMl.size ());
516+ if (fillCandidateLiteTable) {
517+ rowCandidateLite.reserve (reconstructedCandSigMl.size ());
518+ } else {
519+ rowCandidateFull.reserve (reconstructedCandSigMl.size ());
520+ }
521+ for (const auto & candidate : reconstructedCandSigMl) {
522+ if (downSampleBkgFactor < 1 .) {
523+ float pseudoRndm = candidate.ptProng0 () * 1000 . - (int64_t )(candidate.ptProng0 () * 1000 );
524+ if (candidate.pt () < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
525+ continue ;
526+ }
510527 }
528+ fillCandidateTable<true , true >(candidate);
529+ }
530+ } else if (fillOnlyBackground) {
531+ if (fillCandidateLiteTable) {
532+ rowCandidateLite.reserve (reconstructedCandBkg.size ());
533+ } else {
534+ rowCandidateFull.reserve (reconstructedCandBkg.size ());
535+ }
536+ for (const auto & candidate : reconstructedCandBkg) {
537+ if (downSampleBkgFactor < 1 .) {
538+ float pseudoRndm = candidate.ptProng0 () * 1000 . - static_cast <int64_t >(candidate.ptProng0 () * 1000 );
539+ if (candidate.pt () < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
540+ continue ;
541+ }
542+ }
543+ fillCandidateTable<true >(candidate);
511544 }
512- fillCandidateTable<true , true >(candidate);
513- }
514- } else {
515- if (fillCandidateLiteTable) {
516- rowCandidateLite.reserve (reconstructedCandSig.size ());
517545 } else {
518- rowCandidateFull.reserve (reconstructedCandSig.size ());
519- }
520- for (const auto & candidate : reconstructedCandSig) {
521- fillCandidateTable<true >(candidate);
522- }
523- }
524- } else if (fillOnlyBackground) {
525- if (fillCandidateLiteTable) {
526- rowCandidateLite.reserve (reconstructedCandBkg.size ());
527- } else {
528- rowCandidateFull.reserve (reconstructedCandBkg.size ());
529- }
530- for (const auto & candidate : reconstructedCandBkg) {
531- if (downSampleBkgFactor < 1 .) {
532- float pseudoRndm = candidate.ptProng0 () * 1000 . - static_cast <int64_t >(candidate.ptProng0 () * 1000 );
533- if (candidate.pt () < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
534- continue ;
546+ if (fillCandidateLiteTable) {
547+ rowCandidateLite.reserve (candidates.size ());
548+ } else {
549+ rowCandidateFull.reserve (candidates.size ());
550+ }
551+ for (const auto & candidate : candidates) {
552+ fillCandidateTable<true >(candidate);
535553 }
536554 }
537- fillCandidateTable<true >(candidate);
538- }
539- } else {
540- if (fillCandidateLiteTable) {
541- rowCandidateLite.reserve (candidates.size ());
542- } else {
543- rowCandidateFull.reserve (candidates.size ());
544- }
545- for (const auto & candidate : candidates) {
546- fillCandidateTable<true >(candidate);
547- }
548- }
549555
550556 // Filling particle properties
551557 rowCandidateFullParticles.reserve (particles.size ());
0 commit comments