1515// /
1616// / \author Phil Lennart Stahlhut <[email protected] >, Heidelberg University1717// / \author Carolina Reetz <[email protected] >, Heidelberg University18+ // / \author Jaeyoon Cho <[email protected] >, Inha University19+
20+ #include < vector>
1821
1922#include " CommonConstants/PhysicsConstants.h"
2023#include " Framework/AnalysisTask.h"
@@ -42,7 +45,17 @@ struct HfTaskXicToXiPiPi {
4245 Configurable<std::vector<double >> binsPt{" binsPt" , std::vector<double >{hf_cuts_xic_to_xi_pi_pi::vecBinsPt}, " pT bin limits" };
4346 // MC checks
4447 Configurable<bool > checkDecayTypeMc{" checkDecayTypeMc" , false , " Flag to enable DecayType histogram" };
45-
48+ // THnSparese for ML selection check
49+ Configurable<bool > enableTHn{" enableTHn" , false , " Fill THnSparse for Xic" };
50+ ConfigurableAxis thnConfigAxisPt{" thnConfigAxisPt" , {400 , 0 ., 40 .}, " " };
51+ ConfigurableAxis thnConfigAxisMass{" thnConfigAxisMass" , {300 , 1.8 , 3.0 }, " " };
52+ ConfigurableAxis thnConfigAxisPtProng{" thnConfigAxisPtProng" , {300 , 0 ., 30 .}, " " };
53+ ConfigurableAxis thnConfigAxisChi2PCA{" thnConfigAxisChi2PCA" , {200 , 0 ., 20 }, " " };
54+ ConfigurableAxis thnConfigAxisDecLength{" thnConfigAxisDecLength" , {200 , 0 ., 0.5 }, " " };
55+ ConfigurableAxis thnConfigAxisDecLengthXY{" thnConfigAxisDecLengthXY" , {200 , 0 ., 0.5 }, " " };
56+ ConfigurableAxis thnConfigAxisCPA{" thnConfigAxisCPA" , {110 , -1.1 , 1.1 }, " " };
57+ ConfigurableAxis thnConfigAxisBdtScoreBkg{" thnConfigAxisBdtScoreBkg" , {100 , 0 ., 1 .}, " " };
58+ ConfigurableAxis thnConfigAxisBdtScoreSignal{" thnConfigAxisBdtScoreSignal" , {100 , 0 ., 1 .}, " " };
4659 // Axis
4760 ConfigurableAxis binsDecLength{" binsDecLength" , {200 , 0 ., 0.5 }, " " };
4861 ConfigurableAxis binsErrDecLength{" binsErrDecLength" , {100 , 0 ., 1 .}, " " };
@@ -64,20 +77,15 @@ struct HfTaskXicToXiPiPi {
6477
6578 void init (InitContext const &)
6679 {
67- if (!doprocessWithKFParticle && !doprocessWithDCAFitter && !doprocessMcWithKFParticle && !doprocessMcWithDCAFitter) {
68- LOGF (fatal, " No process function enabled. Please enable one." );
69- }
70- if (doprocessWithKFParticle && doprocessWithDCAFitter) {
71- LOGF (fatal, " Cannot enable doprocessWithKFParticle and doprocessWithDCAFitter at the same time. Please choose one." );
80+ std::array<bool , 8 > doprocess{doprocessWithDCAFitter, doprocessWithKFParticle, doprocessWithDCAFitterAndML, doprocessWithKFParticleAndML, doprocessMcWithDCAFitter, doprocessMcWithKFParticle, doprocessMcWithDCAFitterAndML, doprocessMcWithKFParticleAndML};
81+ if ((std::accumulate (doprocess.begin (), doprocess.end (), 0 )) == 0 ) {
82+ LOGP (fatal, " No process function enabled. Please enable one." );
7283 }
73- if (doprocessMcWithKFParticle && doprocessMcWithDCAFitter ) {
74- LOGF (fatal, " Cannot enable doprocessMcWithKFParticle and doprocessMcWithDCAFitter at the same time. Please choose one." );
84+ if ((doprocessWithDCAFitter || doprocessWithDCAFitterAndML || doprocessMcWithDCAFitter || doprocessMcWithDCAFitterAndML) && (doprocessWithKFParticle || doprocessWithKFParticleAndML || doprocessMcWithKFParticle || doprocessMcWithKFParticleAndML) ) {
85+ LOGP (fatal, " Cannot enable DCAFitter and KFParticle at the same time. Please choose one." );
7586 }
76- if (doprocessWithKFParticle && doprocessMcWithDCAFitter) {
77- LOGF (fatal, " Cannot enable doprocessWithKFParticle and doprocessMcWithDCAFitter at the same time. Please choose one." );
78- }
79- if (doprocessWithDCAFitter && doprocessMcWithKFParticle) {
80- LOGF (fatal, " Cannot enable doprocessWithDCAFitter and doprocessMcWithKFParticle at the same time. Please choose one." );
87+ if ((doprocessWithDCAFitter || doprocessWithKFParticle || doprocessMcWithDCAFitter || doprocessMcWithKFParticle) && (doprocessWithDCAFitterAndML || doprocessWithKFParticleAndML || doprocessMcWithDCAFitterAndML || doprocessMcWithKFParticleAndML)) {
88+ LOGP (fatal, " Cannot enable process function with ML and process function without ML at the same time. Please choose one." );
8189 }
8290
8391 static const AxisSpec axisMassXic = {300 , 1.8 , 3.0 , " inv. mass (GeV/#it{c}^{2})" };
@@ -120,14 +128,14 @@ struct HfTaskXicToXiPiPi {
120128 registry.add (" hMassXiPi1" , " #Xi^{#plus}_{c} candidates;inv. mass #Xi^{#mp} #pi^{#pm} (prong 1) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})" , {HistType::kTH2F , {axisMassXiRes, axisPt}});
121129 registry.add (" hMassXiPi2" , " #Xi^{#plus}_{c} candidates;inv. mass #Xi^{#mp} #pi^{#pm} (prong 2) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})" , {HistType::kTH2F , {axisMassXiRes, axisPt}});
122130
123- if (doprocessWithKFParticle) {
131+ if (doprocessWithKFParticle || doprocessWithKFParticleAndML ) {
124132 registry.add (" hChi2geoXi" , " #Xi^{#plus}_{c} candidates;#Xi^{#mp} #chi^{2}_{geo};entries" , {HistType::kTH2F , {axisChi2, axisPt}});
125133 registry.add (" hChi2geoLam" , " #Xi^{#plus}_{c} candidates;#Lambda #chi^{2}_{geo};entries" , {HistType::kTH2F , {axisChi2, axisPt}});
126134 registry.add (" hChi2topoToPV" , " #Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate #chi^{2}_{topo} to PV;entries" , {HistType::kTH2F , {axisChi2, axisPt}});
127135 registry.add (" hChi2topoXiToXicPlus" , " #Xi^{#plus}_{c} candidates;#Xi^{#mp} candidate #chi^{2}_{topo} to #Xi^{#plus}_{c};entries" , {HistType::kTH2F , {axisChi2, axisPt}});
128136 }
129137
130- if (doprocessMcWithKFParticle || doprocessMcWithDCAFitter) {
138+ if (doprocessMcWithKFParticle || doprocessMcWithDCAFitter || doprocessMcWithKFParticleAndML || doprocessMcWithDCAFitterAndML ) {
131139 // MC reconstructed
132140 registry.add (" hPtGenSig" , " #Xi^{#plus}_{c} candidates (gen+rec);candidate #it{p}_{T}^{gen.} (GeV/#it{c});entries" , {HistType::kTH1F , {{300 , 0 ., 30 .}}});
133141 registry.add (" hPtRecSig" , " #Xi^{#plus}_{c} candidates (matched);candidate #it{p}_{T} (GeV/#it{c});entries" , {HistType::kTH1F , {{300 , 0 ., 30 .}}});
@@ -191,7 +199,7 @@ struct HfTaskXicToXiPiPi {
191199 registry.add (" hMassXiPi2RecSig" , " #Xi^{#plus}_{c} candidates (matched);inv. mass #Xi^{#mp} #pi^{#pm} (prong 2) (GeV/#it{c}^{2});entries" , {HistType::kTH2F , {{300 , 1.0 , 2.0 }, axisPt}});
192200 registry.add (" hMassXiPi2RecBg" , " #Xi^{#plus}_{c} candidates (unmatched);inv. mass #Xi^{#mp} #pi^{#pm} (prong 2) (GeV/#it{c}^{2});entries" , {HistType::kTH2F , {{300 , 1.0 , 2.0 }, axisPt}});
193201
194- if (doprocessMcWithKFParticle) {
202+ if (doprocessMcWithKFParticle || doprocessMcWithDCAFitterAndML ) {
195203 registry.add (" hChi2topoToPVRecSig" , " #Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate #chi^{2}_{topo} to PV;entries" , {HistType::kTH2F , {axisChi2, axisPt}});
196204 registry.add (" hChi2topoToPVRecBg" , " #Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate #chi^{2}_{topo} to PV;entries" , {HistType::kTH2F , {axisChi2, axisPt}});
197205 registry.add (" hChi2geoXiRecSig" , " #Xi^{#plus}_{c} candidates (matched);#Xi^{#mp} #chi^{2}_{geo};entries" , {HistType::kTH2F , {axisChi2, axisPt}});
@@ -235,6 +243,50 @@ struct HfTaskXicToXiPiPi {
235243 registry.get <TH3>(HIST (" hDecayTypeMc" ))->GetXaxis ()->SetBinLabel (iBin + 1 , labels[iBin]);
236244 }
237245 }
246+
247+ if (enableTHn) {
248+ const AxisSpec thnAxisPt{thnConfigAxisPt, " #it{p}_{T} (GeV/#it{c})" };
249+ const AxisSpec thnAxisMass{thnConfigAxisMass, " inv. mass #Xi^{#mp} #pi^{#pm} #pi^{#pm}" };
250+ const AxisSpec thnAxisChi2PCA{thnConfigAxisChi2PCA, " Chi2PCA to sec. vertex (cm)" };
251+ const AxisSpec thnAxisDecLength{thnConfigAxisDecLength, " decay length (cm)" };
252+ const AxisSpec thnAxisDecLengthXY{thnConfigAxisDecLengthXY, " decay length xy (cm)" };
253+ const AxisSpec thnAxisCPA{thnConfigAxisCPA, " #Xi^{#plus}_{c} candidate cosine of pointing angle" };
254+ const AxisSpec thnAxisBdtScoreBkg{thnConfigAxisBdtScoreBkg, " BDT score of background" };
255+ const AxisSpec thnAxisBdtScoreSignal{thnConfigAxisBdtScoreSignal, " BDT score of prompt Xic" };
256+
257+ if (doprocessWithKFParticleAndML || doprocessWithDCAFitterAndML || doprocessMcWithKFParticleAndML || doprocessMcWithDCAFitterAndML) {
258+ // with ML information
259+ registry.add (" hXicToXiPiPiVarsWithML" , " THnSparse for Xic with ML" , HistType::kTHnSparseF , {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisBdtScoreBkg, thnAxisBdtScoreSignal});
260+ } else {
261+ // without ML information
262+ registry.add (" hXicToXiPiPiVars" , " THnSparse for Xic" , HistType::kTHnSparseF , {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA});
263+ }
264+ } // enable THnSpare
265+
266+ } // end init
267+
268+ // / Fill THnSpare depending on whether ML selection is used
269+ // \param candidate is candidate
270+ template <bool useMl, typename T1>
271+ void fillTHnSparse (const T1& candidate)
272+ {
273+ if (!enableTHn) {
274+ return ;
275+ }
276+
277+ if constexpr (useMl) {
278+ // with ML information
279+ double outputBkg = -99 .;
280+ double outputPrompt = -99 .;
281+ if (candidate.mlProbXicToXiPiPi ().size () > 0 ) {
282+ outputBkg = candidate.mlProbXicToXiPiPi ()[0 ];
283+ outputPrompt = candidate.mlProbXicToXiPiPi ()[1 ];
284+ }
285+ registry.get <THnSparse>(HIST (" hXicToXiPiPiVarsWithML" ))->Fill (candidate.pt (), candidate.invMassXic (), candidate.chi2PCA (), candidate.decayLength (), candidate.decayLengthXY (), candidate.cpa (), outputBkg, outputPrompt);
286+ } else {
287+ // without ML information
288+ registry.get <THnSparse>(HIST (" hXicToXiPiPiVars" ))->Fill (candidate.pt (), candidate.invMassXic (), candidate.chi2PCA (), candidate.decayLength (), candidate.decayLengthXY (), candidate.cpa ());
289+ }
238290 }
239291
240292 // / Selection of Xic daughter in geometrical acceptance
@@ -248,7 +300,7 @@ struct HfTaskXicToXiPiPi {
248300 }
249301
250302 // / Function to fill histograms
251- template <bool useKfParticle, typename TCanTable>
303+ template <bool useKfParticle, bool useMl, typename TCanTable>
252304 void fillHistograms (TCanTable const & candidates)
253305 {
254306 for (const auto & candidate : candidates) {
@@ -299,11 +351,20 @@ struct HfTaskXicToXiPiPi {
299351 registry.fill (HIST (" hChi2geoXi" ), candidate.kfCascadeChi2 (), ptCandXic);
300352 registry.fill (HIST (" hChi2geoLam" ), candidate.kfV0Chi2 (), ptCandXic);
301353 }
354+
355+ // fill THnSparse
356+ if (enableTHn) {
357+ if constexpr (useMl) {
358+ fillTHnSparse<true >(candidate);
359+ } else {
360+ fillTHnSparse<false >(candidate);
361+ }
362+ }
302363 } // candidate loop
303364 }
304365
305366 // / Function for MC analysis and histogram filling
306- template <bool useKfParticle, typename TCandTable>
367+ template <bool useKfParticle, bool useMl, typename TCandTable>
307368 void fillHistogramsMc (TCandTable const & candidates,
308369 soa::Join<aod::McParticles, aod::HfCandXicMcGen> const & mcParticles,
309370 aod::TracksWMc const &)
@@ -413,6 +474,15 @@ struct HfTaskXicToXiPiPi {
413474 registry.fill (HIST (" hDecayTypeMc" ), 1 + hf_cand_xic_to_xi_pi_pi::DecayType::NDecayType, candidate.invMassXic (), ptCandXic);
414475 }
415476 }
477+ // fill THnSparse
478+ if (enableTHn) {
479+ if constexpr (useMl) {
480+ fillTHnSparse<true >(candidate);
481+ } else {
482+ fillTHnSparse<false >(candidate);
483+ }
484+ }
485+
416486 } // rec
417487
418488 // MC gen. level
@@ -473,24 +543,38 @@ struct HfTaskXicToXiPiPi {
473543 } // gen
474544 }
475545
546+ // / Data analysis and fill histograms
476547 void processWithDCAFitter (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi>> const & candidates)
477548 {
478- fillHistograms<false >(candidates);
549+ fillHistograms<false , false >(candidates);
479550 }
480551 PROCESS_SWITCH (HfTaskXicToXiPiPi, processWithDCAFitter, " Process data with DCAFitter" , true );
481552
482553 void processWithKFParticle (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfSelXicToXiPiPi>> const & candidates)
483554 {
484- fillHistograms<true >(candidates);
555+ fillHistograms<true , false >(candidates);
485556 }
486557 PROCESS_SWITCH (HfTaskXicToXiPiPi, processWithKFParticle, " Process data with KFParticle" , false );
487558
559+ // / Data analysis and fill histograms with ML
560+ void processWithDCAFitterAndML (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi>> const & candidates)
561+ {
562+ fillHistograms<false , true >(candidates);
563+ }
564+ PROCESS_SWITCH (HfTaskXicToXiPiPi, processWithDCAFitterAndML, " Process data with DCAFitter and ML approach" , false );
565+
566+ void processWithKFParticleAndML (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi>> const & candidates)
567+ {
568+ fillHistograms<true , true >(candidates);
569+ }
570+ PROCESS_SWITCH (HfTaskXicToXiPiPi, processWithKFParticleAndML, " Process data with KFParticle and ML approach" , false );
571+
488572 // / MC analysis and fill histograms
489573 void processMcWithDCAFitter (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi, aod::HfCandXicMcRec>> const & candidates,
490574 soa::Join<aod::McParticles, aod::HfCandXicMcGen> const & mcParticles,
491575 aod::TracksWMc const & tracksWMc)
492576 {
493- fillHistogramsMc<false >(candidates, mcParticles, tracksWMc);
577+ fillHistogramsMc<false , false >(candidates, mcParticles, tracksWMc);
494578 }
495579 PROCESS_SWITCH (HfTaskXicToXiPiPi, processMcWithDCAFitter, " Process MC with DCAFitter" , false );
496580
@@ -499,9 +583,27 @@ struct HfTaskXicToXiPiPi {
499583 soa::Join<aod::McParticles, aod::HfCandXicMcGen> const & mcParticles,
500584 aod::TracksWMc const & tracksWMc)
501585 {
502- fillHistogramsMc<true >(candidates, mcParticles, tracksWMc);
586+ fillHistogramsMc<true , false >(candidates, mcParticles, tracksWMc);
503587 }
504588 PROCESS_SWITCH (HfTaskXicToXiPiPi, processMcWithKFParticle, " Process MC with KFParticle" , false );
589+
590+ // MC analysis and fill histograms with ML
591+ void processMcWithDCAFitterAndML (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi, aod::HfCandXicMcRec>> const & candidates,
592+ soa::Join<aod::McParticles, aod::HfCandXicMcGen> const & mcParticles,
593+ aod::TracksWMc const & tracksWMc)
594+ {
595+ fillHistogramsMc<false , true >(candidates, mcParticles, tracksWMc);
596+ }
597+ PROCESS_SWITCH (HfTaskXicToXiPiPi, processMcWithDCAFitterAndML, " Process MC with DCAFitter and ML approach" , false );
598+
599+ void processMcWithKFParticleAndML (soa::Filtered<soa::Join<aod::HfCandXic, aod::HfCandXicKF, aod::HfSelXicToXiPiPi, aod::HfMlXicToXiPiPi, aod::HfCandXicMcRec>> const & candidates,
600+ soa::Join<aod::McParticles, aod::HfCandXicMcGen> const & mcParticles,
601+ aod::TracksWMc const & tracksWMc)
602+ {
603+ fillHistogramsMc<true , true >(candidates, mcParticles, tracksWMc);
604+ }
605+ PROCESS_SWITCH (HfTaskXicToXiPiPi, processMcWithKFParticleAndML, " Process MC with KFParticle and ML approach" , false );
606+
505607}; // struct
506608
507609WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments