Skip to content

Commit 7275a53

Browse files
committed
update taskUpcLc file
1 parent 99313de commit 7275a53

1 file changed

Lines changed: 93 additions & 11 deletions

File tree

PWGHF/D2H/Tasks/taskUpcLc.cxx

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ DECLARE_SOA_COLUMN(AmpFT0A, ampFT0A, float);
7979
DECLARE_SOA_COLUMN(AmpFT0C, ampFT0C, float);
8080
DECLARE_SOA_COLUMN(ZdcTimeZNA, zdcTimeZNA, float);
8181
DECLARE_SOA_COLUMN(ZdcTimeZNC, zdcTimeZNC, float);
82+
DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t);
83+
DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t);
84+
DECLARE_SOA_COLUMN(PtBhadMotherPart, ptBhadMotherPart, float);
8285
} // namespace full
8386
DECLARE_SOA_TABLE(HfUpcQa, "AOD", "HFUPCQA",
8487
full::PvContributors,
@@ -103,12 +106,33 @@ DECLARE_SOA_TABLE(HfUpcLcInfos, "AOD", "HFUPCLCINFOS",
103106
full::Chi2PCA,
104107
full::DecayLength,
105108
full::Cpa);
109+
DECLARE_SOA_TABLE(HfUpcLcMcBdtInfos, "AOD", "HFUPCLCMCBDT",
110+
full::M,
111+
full::Pt,
112+
full::BkgScore,
113+
full::FlagMcMatchRec,
114+
full::OriginMcRec,
115+
full::PtBhadMotherPart);
116+
DECLARE_SOA_TABLE(HfUpcLcMcInfos, "AOD", "HFUPCLCMCINFO",
117+
full::M,
118+
full::Pt,
119+
full::PtProng0,
120+
full::PtProng1,
121+
full::PtProng2,
122+
full::Chi2PCA,
123+
full::DecayLength,
124+
full::Cpa,
125+
full::FlagMcMatchRec,
126+
full::OriginMcRec,
127+
full::PtBhadMotherPart);
106128
} // namespace o2::aod
107129

108130
/// Λc± → p± K∓ π± analysis task
109131
struct HfTaskUpcLc {
110132
Produces<o2::aod::HfUpcLcBdtInfos> rowCandUpcBdt;
111133
Produces<o2::aod::HfUpcLcInfos> rowCandUpc;
134+
Produces<o2::aod::HfUpcLcMcBdtInfos> rowCandUpcMcBdt;
135+
Produces<o2::aod::HfUpcLcMcInfos> rowCandUpcMc;
112136
Produces<o2::aod::HfUpcQa> rowUpcQa;
113137

114138
Configurable<int> selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"};
@@ -133,6 +157,8 @@ struct HfTaskUpcLc {
133157

134158
using LcCandidates = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc>>;
135159
using LcCandidatesMl = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfMlLcToPKPi>>;
160+
using LcCandidatesMc = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfCand3ProngMcRec>>;
161+
using LcCandidatesMlMc = soa::Filtered<soa::Join<aod::HfCand3Prong, aod::HfSelLc, aod::HfMlLcToPKPi, aod::HfCand3ProngMcRec>>;
136162

137163
Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc;
138164
Preslice<aod::HfCand3Prong> candLcPerCollision = aod::hf_cand::collisionId;
@@ -149,7 +175,7 @@ struct HfTaskUpcLc {
149175

150176
void init(InitContext&)
151177
{
152-
const std::array<bool, 2> doprocess{doprocessDataWithMlWithUpc, doprocessDataStdWithUpc};
178+
const std::array<bool, 4> doprocess{doprocessDataWithMlWithUpc, doprocessDataStdWithUpc, doprocessMcWithMlWithUpc, doprocessMcStdWithUpc};
153179
if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) {
154180
LOGP(fatal, "no or more than one process function enabled! Please check your configuration!");
155181
}
@@ -178,13 +204,13 @@ struct HfTaskUpcLc {
178204
return o2::hf_centrality::getCentralityColl<Coll>(collision);
179205
}
180206

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
207+
template <bool FillMl, bool IsMc, typename CollType, typename CandType, typename BCsType>
208+
void runAnalysisPerCollisionWithUpc(CollType const& collisions,
209+
CandType const& candidates,
210+
BCsType const& bcs,
211+
aod::FT0s const& ft0s,
212+
aod::FV0As const& fv0as,
213+
aod::FDDs const& fdds
188214

189215
)
190216
{
@@ -244,7 +270,23 @@ struct HfTaskUpcLc {
244270
}
245271
registry.fill(HIST("Data/hUpcGapAfterSelection"), static_cast<int>(gap));
246272
}
247-
const bool ignoreZdcTime = (zdcTimeThreshold < 0.f);
273+
if constexpr (!IsMc) {
274+
if (!hasZdc) {
275+
continue;
276+
}
277+
}
278+
if constexpr (IsMc) {
279+
if (!hasZdc && fillHistQa) {
280+
registry.fill(HIST("Data/fitInfo/ampFT0A_vs_ampFT0C"), fitInfo.ampFT0A, fitInfo.ampFT0C);
281+
}
282+
if (!hasZdc) {
283+
registry.fill(HIST("Data/hUpcGapAfterSelection"), static_cast<int>(gap));
284+
}
285+
}
286+
bool ignoreZdcTime = (zdcTimeThreshold < 0.f);
287+
if constexpr (IsMc) {
288+
ignoreZdcTime = ignoreZdcTime || !hasZdc;
289+
}
248290
const auto multNTracksPV = collision.multNTracksPV();
249291
const auto posZ = collision.posZ();
250292
if (gap == o2::aod::sgselector::TrueGap::SingleGapA && (ignoreZdcTime || (std::abs(zdcTimeZNA) > zdcTimeThreshold && std::abs(zdcTimeZNC) < zdcTimeThreshold))) {
@@ -289,6 +331,18 @@ struct HfTaskUpcLc {
289331

290332
auto fillTHnData = [&](bool isPKPi) {
291333
const auto massLc = isPKPi ? HfHelper::invMassLcToPKPi(candidate) : HfHelper::invMassLcToPiKP(candidate);
334+
if constexpr (IsMc) {
335+
if constexpr (FillMl) {
336+
const auto& mlProb = isPKPi ? candidate.mlProbLcToPKPi() : candidate.mlProbLcToPiKP();
337+
if (mlProb.size() == NumberOfMlClasses) {
338+
outputBkg = mlProb[MlClassBackground]; /// bkg score
339+
}
340+
rowCandUpcMcBdt(massLc, pt, outputBkg, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.ptBhadMotherPart());
341+
} else {
342+
rowCandUpcMc(massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, candidate.flagMcMatchRec(), candidate.originMcRec(), candidate.ptBhadMotherPart());
343+
}
344+
return;
345+
}
292346
if constexpr (FillMl) {
293347
const auto& mlProb = isPKPi ? candidate.mlProbLcToPKPi() : candidate.mlProbLcToPiKP();
294348
if (mlProb.size() == NumberOfMlClasses) {
@@ -321,7 +375,7 @@ struct HfTaskUpcLc {
321375
aod::FDDs const& fdds,
322376
aod::Zdcs const& /*zdcs*/)
323377
{
324-
runAnalysisPerCollisionDataWithUpc<true>(collisions, selectedLcCandidatesMl, bcs, ft0s, fv0as, fdds);
378+
runAnalysisPerCollisionWithUpc<true, false>(collisions, selectedLcCandidatesMl, bcs, ft0s, fv0as, fdds);
325379
}
326380
PROCESS_SWITCH(HfTaskUpcLc, processDataWithMlWithUpc, "Process real data with the ML method with UPC", false);
327381

@@ -334,9 +388,37 @@ struct HfTaskUpcLc {
334388
aod::FDDs const& fdds,
335389
aod::Zdcs const& /*zdcs*/)
336390
{
337-
runAnalysisPerCollisionDataWithUpc<false>(collisions, selectedLcCandidates, bcs, ft0s, fv0as, fdds);
391+
runAnalysisPerCollisionWithUpc<false, false>(collisions, selectedLcCandidates, bcs, ft0s, fv0as, fdds);
338392
}
339393
PROCESS_SWITCH(HfTaskUpcLc, processDataStdWithUpc, "Process real data with the standard method with UPC", false);
394+
395+
void processMcWithMlWithUpc(soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::Mults> const& collisions,
396+
aod::BcFullInfos const& bcs,
397+
LcCandidatesMlMc const& selectedLcCandidatesMlMc,
398+
aod::McCollisions const&,
399+
aod::TracksWMc const&,
400+
aod::FT0s const& ft0s,
401+
aod::FV0As const& fv0as,
402+
aod::FDDs const& fdds,
403+
aod::Zdcs const& /*zdcs*/)
404+
{
405+
runAnalysisPerCollisionWithUpc<true, true>(collisions, selectedLcCandidatesMlMc, bcs, ft0s, fv0as, fdds);
406+
}
407+
PROCESS_SWITCH(HfTaskUpcLc, processMcWithMlWithUpc, "Process MC with the ML method with UPC", false);
408+
409+
void processMcStdWithUpc(soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::Mults> const& collisions,
410+
aod::BcFullInfos const& bcs,
411+
LcCandidatesMc const& selectedLcCandidatesMc,
412+
aod::McCollisions const&,
413+
aod::TracksWMc const&,
414+
aod::FT0s const& ft0s,
415+
aod::FV0As const& fv0as,
416+
aod::FDDs const& fdds,
417+
aod::Zdcs const& /*zdcs*/)
418+
{
419+
runAnalysisPerCollisionWithUpc<false, true>(collisions, selectedLcCandidatesMc, bcs, ft0s, fv0as, fdds);
420+
}
421+
PROCESS_SWITCH(HfTaskUpcLc, processMcStdWithUpc, "Process MC with the standard method with UPC", false);
340422
};
341423

342424
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)