@@ -78,6 +78,9 @@ DECLARE_SOA_COLUMN(PtPi1, ptPi1, float);
7878DECLARE_SOA_COLUMN (ImpactParameterPi1, impactParameterPi1, float ); // ! Normalised impact parameter of Pi1 (prong2)
7979DECLARE_SOA_COLUMN (ImpactParameterNormalisedPi1, impactParameterNormalisedPi1, float ); // ! Normalised impact parameter of Pi1 (prong2)
8080DECLARE_SOA_COLUMN (MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float ); // ! Maximum normalized difference between measured and expected impact parameter of candidate prongs
81+ DECLARE_SOA_COLUMN (MlScoreBkg, mlScoreBkg, float ); // ! ML score for background class
82+ DECLARE_SOA_COLUMN (MlScorePrompt, mlScorePrompt, float ); // ! ML score for prompt signal class
83+ DECLARE_SOA_COLUMN (MlScoreNonPrompt, mlScoreNonPrompt, float ); // ! ML score for non-prompt signal class (3-class model only, -1 otherwise)
8184} // namespace full
8285
8386DECLARE_SOA_TABLE (HfCandXicToXiPiPiLites, " AOD" , " HFXICXI2PILITE" ,
@@ -117,7 +120,7 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLites, "AOD", "HFXICXI2PILITE",
117120 full::ImpactParameterNormalisedPi1,
118121 full::MaxNormalisedDeltaIP);
119122
120- DECLARE_SOA_TABLE (HfCandXicToXiPiPiLiteKfs, " AOD" , " HFXICXI2PILITEKF " ,
123+ DECLARE_SOA_TABLE (HfCandXicToXiPiPiLiteKfs, " AOD" , " HFXICXI2PILITKF " ,
121124 full::ParticleFlag,
122125 hf_cand_mc_flag::OriginMcRec,
123126 full::CandidateSelFlag,
@@ -186,7 +189,7 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLiteKfs, "AOD", "HFXICXI2PILITEKF",
186189 hf_cand_xic_to_xi_pi_pi::DcaXYPi0Xi,
187190 hf_cand_xic_to_xi_pi_pi::DcaXYPi1Xi);
188191
189- DECLARE_SOA_TABLE (HfCandXicToXiPiPiLiteMLs, " AOD" , " HFXICXI2PILITEML " ,
192+ DECLARE_SOA_TABLE (HfCandXicToXiPiPiLiteMLs, " AOD" , " HFXICXI2PIMLITE " ,
190193 full::ParticleFlag,
191194 hf_cand_mc_flag::OriginMcRec,
192195 full::CandidateSelFlag,
@@ -212,7 +215,10 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiLiteMLs, "AOD", "HFXICXI2PILITEML",
212215 full::ImpactParameterNormalisedPi0,
213216 full::ImpactParameterPi1,
214217 full::ImpactParameterNormalisedPi1,
215- full::MaxNormalisedDeltaIP);
218+ full::MaxNormalisedDeltaIP,
219+ full::MlScoreBkg,
220+ full::MlScorePrompt,
221+ full::MlScoreNonPrompt);
216222
217223DECLARE_SOA_TABLE (HfCandXicToXiPiPiFulls, " AOD" , " HFXICXI2PIFULL" ,
218224 full::ParticleFlag,
@@ -378,7 +384,6 @@ struct HfTreeCreatorXicToXiPiPi {
378384
379385 Configurable<int > selectionFlagXic{" selectionFlagXic" , 1 , " Selection Flag for Xic" };
380386 Configurable<bool > fillCandidateLiteTable{" fillCandidateLiteTable" , false , " Switch to fill lite table with candidate properties" };
381- Configurable<bool > fillCandidateMlLiteTable{" fillCandidateMlLiteTable" , false , " Switch to fill lite table with ML related variables" };
382387 Configurable<bool > fillGenParticleTable{" fillGenParticleTable" , false , " Switch to fill table with MC truth for generated particles" };
383388 // parameters for production of training samples
384389 Configurable<bool > fillOnlySignal{" fillOnlySignal" , false , " Flag to fill derived tables with signal for ML trainings" };
@@ -388,9 +393,10 @@ struct HfTreeCreatorXicToXiPiPi {
388393
389394 using SelectedCandidates = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi>>;
390395 using SelectedCandidatesKf = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfSelXicToXiPiPi>>;
391- using SelectedCandidatesML = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi>>;
396+ using SelectedCandidatesML = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfMlXicToXiPiPi, aod:: HfSelXicToXiPiPi>>;
392397 using SelectedCandidatesMc = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicMcRec, aod::HfSelXicToXiPiPi>>;
393398 using SelectedCandidatesKfMc = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfCandXicMcRec, aod::HfSelXicToXiPiPi>>;
399+ using SelectedCandidatesMcML = soa::Filtered<soa::Join<aod::HfCandXic, aod::HfMlXicToXiPiPi, aod::HfCandXicMcRec, aod::HfSelXicToXiPiPi>>;
394400 using MatchedGenXicToXiPiPi = soa::Filtered<soa::Join<aod::McParticles, aod::HfCandXicMcGen>>;
395401
396402 Filter filterSelectCandidates = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic;
@@ -403,10 +409,7 @@ struct HfTreeCreatorXicToXiPiPi {
403409
404410 void init (InitContext const &)
405411 {
406- std::array<bool , 5 > doprocess{doprocessData, doprocessDataKf, doprocessDataWithML, doprocessMc, doprocessMcKf};
407- if (std::accumulate (doprocess.begin (), doprocess.end (),0 ) == 0 ) {
408- LOGP (fatal, " No process fuction enabled?" );
409- }
412+ std::array<bool , 6 > doprocess{doprocessData, doprocessDataKf, doprocessDataWithML, doprocessMc, doprocessMcKf, doprocessMcWithML};
410413 if (std::accumulate (doprocess.begin (), doprocess.end (),0 ) != 1 ) {
411414 LOGP (fatal, " Only one process function can be enabled at a time." );
412415 }
@@ -421,7 +424,7 @@ struct HfTreeCreatorXicToXiPiPi {
421424 particleFlag = candidate.flagMcMatchRec ();
422425 originMc = candidate.originMcRec ();
423426 }
424- if constexpr (!DoKf) {
427+ if constexpr (!DoKf && !DoMl ) {
425428 if (fillCandidateLiteTable) {
426429 rowCandidateLite (
427430 particleFlag,
@@ -522,7 +525,7 @@ struct HfTreeCreatorXicToXiPiPi {
522525 candidate.nSigTofPiFromLambda (),
523526 candidate.nSigTofPrFromLambda ());
524527 }
525- } else {
528+ } else if constexpr (DoKf) {
526529 if (fillCandidateLiteTable) {
527530 rowCandidateLiteKf (
528531 particleFlag,
@@ -674,7 +677,16 @@ struct HfTreeCreatorXicToXiPiPi {
674677 candidate.dcaXYPi1Xi ());
675678 }
676679 }
677- if constexpr (DoMl){
680+ if constexpr (DoMl) {
681+ float mlScoreBkg = -1 .f , mlScorePrompt = -1 .f , mlScoreNonPrompt = -1 .f ;
682+ const int scoreSize = static_cast <int >(candidate.mlProbXicToXiPiPi ().size ());
683+ if (scoreSize > 0 ) {
684+ mlScoreBkg = candidate.mlProbXicToXiPiPi ()[0 ];
685+ mlScorePrompt = candidate.mlProbXicToXiPiPi ()[1 ];
686+ if (scoreSize > 2 ) {
687+ mlScoreNonPrompt = candidate.mlProbXicToXiPiPi ()[2 ];
688+ }
689+ }
678690 rowCandidateLiteMl (
679691 particleFlag,
680692 originMc,
@@ -701,7 +713,10 @@ struct HfTreeCreatorXicToXiPiPi {
701713 candidate.impactParameterNormalised1 (),
702714 candidate.impactParameter2 (),
703715 candidate.impactParameterNormalised2 (),
704- candidate.maxNormalisedDeltaIP ());
716+ candidate.maxNormalisedDeltaIP (),
717+ mlScoreBkg,
718+ mlScorePrompt,
719+ mlScoreNonPrompt);
705720 }
706721 }
707722
@@ -751,16 +766,10 @@ struct HfTreeCreatorXicToXiPiPi {
751766 rowCandidateLiteMl.reserve (candidates.size ());
752767
753768 for (const auto & candidate : candidates) {
754- if (fillOnlyBackground && downSampleBkgFactor < 1 .) {
755- float const pseudoRndm = candidate.ptProng1 () * 1000 . - static_cast <int64_t >(candidate.ptProng1 () * 1000 );
756- if (pseudoRndm >= downSampleBkgFactor && candidate.pt () < ptMaxForDownSample) {
757- continue ;
758- }
759- }
760769 fillCandidateTable<false , false , true >(candidate);
761770 }
762771 }
763- PROCESS_SWITCH (HfTreeCreatorXicToXiPiPi, processDataWithML, " Process data with DCAFitter reconstruction and ML" , true );
772+ PROCESS_SWITCH (HfTreeCreatorXicToXiPiPi, processDataWithML, " Process data with DCAFitter reconstruction and ML" , false );
764773
765774 void processMc (SelectedCandidatesMc const & candidates,
766775 MatchedGenXicToXiPiPi const & particles)
@@ -869,6 +878,52 @@ struct HfTreeCreatorXicToXiPiPi {
869878 }
870879 }
871880 PROCESS_SWITCH (HfTreeCreatorXicToXiPiPi, processMcKf, " Process MC with KF Particle reconstruction" , false );
881+
882+ void processMcWithML (SelectedCandidatesMcML const & candidates,
883+ MatchedGenXicToXiPiPi const & particles)
884+ {
885+ // Filling candidate properties
886+ rowCandidateLiteMl.reserve (candidates.size ());
887+ if (fillOnlySignal) {
888+ for (const auto & candidate : candidates) {
889+ if (candidate.flagMcMatchRec () == int8_t (0 )) {
890+ continue ;
891+ }
892+ fillCandidateTable<true , false , true >(candidate);
893+ }
894+ } else if (fillOnlyBackground) {
895+ for (const auto & candidate : candidates) {
896+ if (candidate.flagMcMatchRec () != int8_t (0 )) {
897+ continue ;
898+ }
899+ float const pseudoRndm = candidate.ptProng1 () * 1000 . - static_cast <int64_t >(candidate.ptProng1 () * 1000 );
900+ if (candidate.pt () < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) {
901+ continue ;
902+ }
903+ fillCandidateTable<true , false , true >(candidate);
904+ }
905+ } else {
906+ for (const auto & candidate : candidates) {
907+ fillCandidateTable<true , false , true >(candidate);
908+ }
909+ }
910+
911+ if (fillGenParticleTable) {
912+ rowCandidateFullParticles.reserve (particles.size ());
913+ for (const auto & particle : particles) {
914+ rowCandidateFullParticles (
915+ particle.flagMcMatchGen (),
916+ particle.originMcGen (),
917+ particle.pdgBhadMotherPart (),
918+ particle.pt (),
919+ particle.eta (),
920+ particle.phi (),
921+ RecoDecay::y (particle.pVector (), o2::constants::physics::MassXiCPlus),
922+ particle.decayLengthMcGen ());
923+ }
924+ }
925+ }
926+ PROCESS_SWITCH (HfTreeCreatorXicToXiPiPi, processMcWithML, " Process MC with DCAFitter reconstruction and ML" , false );
872927};
873928
874929WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments