4747
4848#include < array>
4949#include < cmath>
50+ #include < cstdint>
5051#include < numeric>
5152#include < string>
5253#include < vector> // std::vector
@@ -79,6 +80,9 @@ DECLARE_SOA_COLUMN(AmpFT0A, ampFT0A, float);
7980DECLARE_SOA_COLUMN (AmpFT0C, ampFT0C, float );
8081DECLARE_SOA_COLUMN (ZdcTimeZNA, zdcTimeZNA, float );
8182DECLARE_SOA_COLUMN (ZdcTimeZNC, zdcTimeZNC, float );
83+ DECLARE_SOA_COLUMN (FlagMcMatchRec, flagMcMatchRec, int8_t );
84+ DECLARE_SOA_COLUMN (OriginMcRec, originMcRec, int8_t );
85+ DECLARE_SOA_COLUMN (PtBhadMotherPart, ptBhadMotherPart, float );
8286} // namespace full
8387DECLARE_SOA_TABLE (HfUpcQa, " AOD" , " HFUPCQA" ,
8488 full::PvContributors,
@@ -103,12 +107,33 @@ DECLARE_SOA_TABLE(HfUpcLcInfos, "AOD", "HFUPCLCINFOS",
103107 full::Chi2PCA,
104108 full::DecayLength,
105109 full::Cpa);
110+ DECLARE_SOA_TABLE (HfUpcLcMcBdtInfos, " AOD" , " HFUPCLCMCBDT" ,
111+ full::M,
112+ full::Pt,
113+ full::BkgScore,
114+ full::FlagMcMatchRec,
115+ full::OriginMcRec,
116+ full::PtBhadMotherPart);
117+ DECLARE_SOA_TABLE (HfUpcLcMcInfos, " AOD" , " HFUPCLCMCINFO" ,
118+ full::M,
119+ full::Pt,
120+ full::PtProng0,
121+ full::PtProng1,
122+ full::PtProng2,
123+ full::Chi2PCA,
124+ full::DecayLength,
125+ full::Cpa,
126+ full::FlagMcMatchRec,
127+ full::OriginMcRec,
128+ full::PtBhadMotherPart);
106129} // namespace o2::aod
107130
108131// / Λc± → p± K∓ π± analysis task
109132struct HfTaskUpcLc {
110133 Produces<o2::aod::HfUpcLcBdtInfos> rowCandUpcBdt;
111134 Produces<o2::aod::HfUpcLcInfos> rowCandUpc;
135+ Produces<o2::aod::HfUpcLcMcBdtInfos> rowCandUpcMcBdt;
136+ Produces<o2::aod::HfUpcLcMcInfos> rowCandUpcMc;
112137 Produces<o2::aod::HfUpcQa> rowUpcQa;
113138
114139 Configurable<int > selectionFlagLc{" selectionFlagLc" , 1 , " Selection Flag for Lc" };
@@ -133,6 +158,8 @@ struct HfTaskUpcLc {
133158
134159 using LcCandidates = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc>>;
135160 using LcCandidatesMl = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfMlLcToPKPi>>;
161+ using LcCandidatesMc = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfCand3ProngMcRec>>;
162+ using LcCandidatesMlMc = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfMlLcToPKPi, aod::HfCand3ProngMcRec>>;
136163
137164 Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc;
138165 Preslice<aod::HfCand3Prong> candLcPerCollision = aod::hf_cand::collisionId;
@@ -149,7 +176,7 @@ struct HfTaskUpcLc {
149176
150177 void init (InitContext&)
151178 {
152- const std::array<bool , 2 > doprocess{doprocessDataWithMlWithUpc, doprocessDataStdWithUpc};
179+ const std::array<bool , 4 > doprocess{doprocessDataWithMlWithUpc, doprocessDataStdWithUpc, doprocessMcWithMlWithUpc, doprocessMcStdWithUpc };
153180 if ((std::accumulate (doprocess.begin (), doprocess.end (), 0 )) != 1 ) {
154181 LOGP (fatal, " no or more than one process function enabled! Please check your configuration!" );
155182 }
@@ -178,13 +205,13 @@ struct HfTaskUpcLc {
178205 return o2::hf_centrality::getCentralityColl<Coll>(collision);
179206 }
180207
181- template <bool FillMl, typename CollType, typename CandType, typename BCsType>
182- void runAnalysisPerCollisionDataWithUpc (CollType const & collisions,
183- CandType const & candidates,
184- BCsType const & bcs,
185- aod::FT0s const & ft0s,
186- aod::FV0As const & fv0as,
187- aod::FDDs const & fdds
208+ template <bool FillMl, bool IsMc, typename CollType, typename CandType, typename BCsType>
209+ void runAnalysisPerCollisionWithUpc (CollType const & collisions,
210+ CandType const & candidates,
211+ BCsType const & bcs,
212+ aod::FT0s const & ft0s,
213+ aod::FV0As const & fv0as,
214+ aod::FDDs const & fdds
188215
189216 )
190217 {
@@ -244,7 +271,23 @@ struct HfTaskUpcLc {
244271 }
245272 registry.fill (HIST (" Data/hUpcGapAfterSelection" ), static_cast <int >(gap));
246273 }
247- const bool ignoreZdcTime = (zdcTimeThreshold < 0 .f );
274+ if constexpr (!IsMc) {
275+ if (!hasZdc) {
276+ continue ;
277+ }
278+ }
279+ if constexpr (IsMc) {
280+ if (!hasZdc && fillHistQa) {
281+ registry.fill (HIST (" Data/fitInfo/ampFT0A_vs_ampFT0C" ), fitInfo.ampFT0A , fitInfo.ampFT0C );
282+ }
283+ if (!hasZdc) {
284+ registry.fill (HIST (" Data/hUpcGapAfterSelection" ), static_cast <int >(gap));
285+ }
286+ }
287+ bool ignoreZdcTime = (zdcTimeThreshold < 0 .f );
288+ if constexpr (IsMc) {
289+ ignoreZdcTime = ignoreZdcTime || !hasZdc;
290+ }
248291 const auto multNTracksPV = collision.multNTracksPV ();
249292 const auto posZ = collision.posZ ();
250293 if (gap == o2::aod::sgselector::TrueGap::SingleGapA && (ignoreZdcTime || (std::abs (zdcTimeZNA) > zdcTimeThreshold && std::abs (zdcTimeZNC) < zdcTimeThreshold))) {
@@ -289,6 +332,18 @@ struct HfTaskUpcLc {
289332
290333 auto fillTHnData = [&](bool isPKPi) {
291334 const auto massLc = isPKPi ? HfHelper::invMassLcToPKPi (candidate) : HfHelper::invMassLcToPiKP (candidate);
335+ if constexpr (IsMc) {
336+ if constexpr (FillMl) {
337+ const auto & mlProb = isPKPi ? candidate.mlProbLcToPKPi () : candidate.mlProbLcToPiKP ();
338+ if (mlProb.size () == NumberOfMlClasses) {
339+ outputBkg = mlProb[MlClassBackground]; // / bkg score
340+ }
341+ rowCandUpcMcBdt (massLc, pt, outputBkg, candidate.flagMcMatchRec (), candidate.originMcRec (), candidate.ptBhadMotherPart ());
342+ } else {
343+ rowCandUpcMc (massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, candidate.flagMcMatchRec (), candidate.originMcRec (), candidate.ptBhadMotherPart ());
344+ }
345+ return ;
346+ }
292347 if constexpr (FillMl) {
293348 const auto & mlProb = isPKPi ? candidate.mlProbLcToPKPi () : candidate.mlProbLcToPiKP ();
294349 if (mlProb.size () == NumberOfMlClasses) {
@@ -321,7 +376,7 @@ struct HfTaskUpcLc {
321376 aod::FDDs const & fdds,
322377 aod::Zdcs const & /* zdcs*/ )
323378 {
324- runAnalysisPerCollisionDataWithUpc <true >(collisions, selectedLcCandidatesMl, bcs, ft0s, fv0as, fdds);
379+ runAnalysisPerCollisionWithUpc <true , false >(collisions, selectedLcCandidatesMl, bcs, ft0s, fv0as, fdds);
325380 }
326381 PROCESS_SWITCH (HfTaskUpcLc, processDataWithMlWithUpc, " Process real data with the ML method with UPC" , false );
327382
@@ -334,9 +389,37 @@ struct HfTaskUpcLc {
334389 aod::FDDs const & fdds,
335390 aod::Zdcs const & /* zdcs*/ )
336391 {
337- runAnalysisPerCollisionDataWithUpc< false >(collisions, selectedLcCandidates, bcs, ft0s, fv0as, fdds);
392+ runAnalysisPerCollisionWithUpc< false , false >(collisions, selectedLcCandidates, bcs, ft0s, fv0as, fdds);
338393 }
339394 PROCESS_SWITCH (HfTaskUpcLc, processDataStdWithUpc, " Process real data with the standard method with UPC" , false );
395+
396+ void processMcWithMlWithUpc (soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::Mults> const & collisions,
397+ aod::BcFullInfos const & bcs,
398+ LcCandidatesMlMc const & selectedLcCandidatesMlMc,
399+ aod::McCollisions const &,
400+ aod::TracksWMc const &,
401+ aod::FT0s const & ft0s,
402+ aod::FV0As const & fv0as,
403+ aod::FDDs const & fdds,
404+ aod::Zdcs const & /* zdcs*/ )
405+ {
406+ runAnalysisPerCollisionWithUpc<true , true >(collisions, selectedLcCandidatesMlMc, bcs, ft0s, fv0as, fdds);
407+ }
408+ PROCESS_SWITCH (HfTaskUpcLc, processMcWithMlWithUpc, " Process MC with the ML method with UPC" , false );
409+
410+ void processMcStdWithUpc (soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::Mults> const & collisions,
411+ aod::BcFullInfos const & bcs,
412+ LcCandidatesMc const & selectedLcCandidatesMc,
413+ aod::McCollisions const &,
414+ aod::TracksWMc const &,
415+ aod::FT0s const & ft0s,
416+ aod::FV0As const & fv0as,
417+ aod::FDDs const & fdds,
418+ aod::Zdcs const & /* zdcs*/ )
419+ {
420+ runAnalysisPerCollisionWithUpc<false , true >(collisions, selectedLcCandidatesMc, bcs, ft0s, fv0as, fdds);
421+ }
422+ PROCESS_SWITCH (HfTaskUpcLc, processMcStdWithUpc, " Process MC with the standard method with UPC" , false );
340423};
341424
342425WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments