Skip to content

Commit dbf77fb

Browse files
committed
replace THnSparse with TTree
1 parent a5f65eb commit dbf77fb

2 files changed

Lines changed: 80 additions & 42 deletions

File tree

PWGHF/D2H/Tasks/taskLc.cxx

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ struct HfTaskLc {
111111
Preslice<aod::HfCand3Prong> candLcPerCollision = aod::hf_cand::collisionId;
112112
PresliceUnsorted<aod::McCollisionLabels> colPerMcCollision = aod::mcparticle::mcCollisionId;
113113

114+
Produces<o2::aod::HfUpcLcBdtInfos> rowCandUpcBdt;
115+
Produces<o2::aod::HfUpcLcInfos> rowCandUpc;
116+
114117
ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {72, 0, 36}, ""};
115118
ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {300, 1.98, 2.58}, ""};
116119
ConfigurableAxis thnConfigAxisPtProng{"thnConfigAxisPtProng", {100, 0, 20}, ""};
@@ -128,10 +131,6 @@ struct HfTaskLc {
128131
ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {14, 0, 14000}, "axis for centrality"};
129132
ConfigurableAxis thnConfigAxisProperLifetime{"thnConfigAxisProperLifetime", {200, 0, 2}, "Proper lifetime, ps"};
130133
ConfigurableAxis thnConfigAxisGapType{"thnConfigAxisGapType", {7, -1.5, 5.5}, "axis for UPC gap type (see TrueGap enum in o2::aod::sgselector)"};
131-
ConfigurableAxis thnConfigAxisFV0A{"thnConfigAxisFV0A", {1001, -1.5, 999.5}, "axis for FV0-A amplitude (a.u.)"};
132-
ConfigurableAxis thnConfigAxisFT0{"thnConfigAxisFT0", {1001, -1.5, 999.5}, "axis for FT0 amplitude (a.u.)"};
133-
ConfigurableAxis thnConfigAxisZN{"thnConfigAxisZN", {510, -1.5, 49.5}, "axis for ZN energy (a.u.)"};
134-
ConfigurableAxis thnConfigAxisZNTime{"thnConfigAxisZNTime", {200, -10, 10}, "axis for ZN energy (a.u.)"};
135134
HistogramRegistry registry{"registry", {}};
136135
HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject};
137136

@@ -293,27 +292,17 @@ struct HfTaskLc {
293292
const AxisSpec thnAxisTracklets{thnConfigAxisNumPvContr, "Number of PV contributors"};
294293
const AxisSpec thnAxisOccupancy{thnConfigAxisOccupancy, "Occupancy"};
295294
const AxisSpec thnAxisProperLifetime{thnConfigAxisProperLifetime, "T_{proper} (ps)"};
296-
const AxisSpec thnAxisFV0A{thnConfigAxisFV0A, "FV0-A amplitude"};
297-
const AxisSpec thnAxisFT0A{thnConfigAxisFT0, "FT0-A amplitude"};
298-
const AxisSpec thnAxisFT0C{thnConfigAxisFT0, "FT0-C amplitude"};
299-
const AxisSpec thnAxisZNA{thnConfigAxisZN, "ZNA energy"};
300-
const AxisSpec thnAxisZNC{thnConfigAxisZN, "ZNC energy"};
301-
const AxisSpec thnAxisZNATime{thnConfigAxisZNTime, "ZNA time"};
302-
const AxisSpec thnAxisZNCTime{thnConfigAxisZNTime, "ZNC time"};
303295

304296
bool const isDataWithMl = doprocessDataWithMl || doprocessDataWithMlWithFT0C || doprocessDataWithMlWithFT0M || doprocessDataWithMlWithUpc;
305297
bool const isMcWithMl = doprocessMcWithMl || doprocessMcWithMlWithFT0C || doprocessMcWithMlWithFT0M;
306298
bool const isDataStd = doprocessDataStd || doprocessDataStdWithFT0C || doprocessDataStdWithFT0M || doprocessDataStdWithUpc;
307299
bool const isMcStd = doprocessMcStd || doprocessMcStdWithFT0C || doprocessMcStdWithFT0M;
308300

309-
std::vector<AxisSpec> axesStd, axesWithBdt, axesGen, axesUpc, axesUpcWithBdt;
301+
std::vector<AxisSpec> axesStd, axesWithBdt, axesGen;
310302

311303
if (isDataStd && !isUpc) {
312304
axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets};
313305
}
314-
if (isDataStd && isUpc) {
315-
axesUpc = {thnAxisMass, thnAxisPt, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisFV0A, thnAxisFT0A, thnAxisFT0C, thnAxisZNA, thnAxisZNC, thnAxisZNATime, thnAxisZNCTime};
316-
}
317306
if (isMcStd) {
318307
axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
319308
}
@@ -323,9 +312,6 @@ struct HfTaskLc {
323312
if (isDataWithMl && !isUpc) {
324313
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets};
325314
}
326-
if (isDataWithMl && isUpc) {
327-
axesUpcWithBdt = {thnAxisMass, thnAxisPt, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisFV0A, thnAxisFT0A, thnAxisFT0C, thnAxisZNA, thnAxisZNC, thnAxisZNATime, thnAxisZNCTime};
328-
}
329315
if (isMcWithMl) {
330316
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
331317
}
@@ -344,25 +330,20 @@ struct HfTaskLc {
344330
}
345331
}
346332
}
347-
if (isUpc) {
348-
if (isDataStd) {
349-
registry.add("hnLcUpcVars", "THn for Lambdac candidates for Data in UPC", HistType::kTHnSparseF, axesUpc);
350-
} else if (isDataWithMl) {
351-
registry.add("hnLcUpcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data in UPC", HistType::kTHnSparseF, axesUpcWithBdt);
333+
if (!isUpc) {
334+
if (isDataWithMl) {
335+
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, axesWithBdt);
336+
} else if (isMcWithMl) {
337+
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, axesWithBdt);
338+
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
339+
} else if (isDataStd) {
340+
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, axesStd);
341+
} else {
342+
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, axesStd);
343+
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
352344
}
353-
} else if (isDataWithMl) {
354-
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, axesWithBdt);
355-
} else if (isMcWithMl) {
356-
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, axesWithBdt);
357-
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
358-
} else if (isDataStd) {
359-
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, axesStd);
360-
} else {
361-
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, axesStd);
362-
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
363345
}
364346
}
365-
366347
if (isUpc) {
367348
hfEvSel.addHistograms(qaRegistry); // collision monitoring
368349
}
@@ -821,23 +802,19 @@ struct HfTaskLc {
821802
/// Fill the ML outputScores and variables of candidate
822803
if (fillUPCTHnLite) {
823804
if (gap == o2::aod::sgselector::TrueGap::SingleGapA || gap == o2::aod::sgselector::TrueGap::SingleGapC) {
824-
std::vector<double> valuesToFill{massLc, pt, outputBkg, outputPrompt, outputFD, static_cast<double>(numPvContributors), static_cast<double>(fitInfo.ampFV0A), static_cast<double>(fitInfo.ampFT0A), static_cast<double>(fitInfo.ampFT0C), static_cast<double>(zdcEnergyZNA), static_cast<double>(zdcEnergyZNC), static_cast<double>(zdcTimeZNA), static_cast<double>(zdcTimeZNC)};
825-
registry.get<THnSparse>(HIST("hnLcUpcVarsWithBdt"))->Fill(valuesToFill.data());
805+
rowCandUpcBdt(massLc, pt, outputBkg, outputPrompt, outputFD, static_cast<float>(numPvContributors), static_cast<float>(fitInfo.ampFV0A), static_cast<float>(fitInfo.ampFT0A), static_cast<float>(fitInfo.ampFT0C), static_cast<float>(zdcEnergyZNA), static_cast<float>(zdcEnergyZNC), static_cast<float>(zdcTimeZNA), static_cast<float>(zdcTimeZNC));
826806
}
827807
} else {
828-
std::vector<double> valuesToFill{massLc, pt, outputBkg, outputPrompt, outputFD, static_cast<double>(numPvContributors), static_cast<double>(fitInfo.ampFV0A), static_cast<double>(fitInfo.ampFT0A), static_cast<double>(fitInfo.ampFT0C), static_cast<double>(zdcEnergyZNA), static_cast<double>(zdcEnergyZNC), static_cast<double>(zdcTimeZNA), static_cast<double>(zdcTimeZNC)};
829-
registry.get<THnSparse>(HIST("hnLcUpcVarsWithBdt"))->Fill(valuesToFill.data());
808+
rowCandUpcBdt(massLc, pt, outputBkg, outputPrompt, outputFD, static_cast<float>(numPvContributors), static_cast<float>(fitInfo.ampFV0A), static_cast<float>(fitInfo.ampFT0A), static_cast<float>(fitInfo.ampFT0C), static_cast<float>(zdcEnergyZNA), static_cast<float>(zdcEnergyZNC), static_cast<float>(zdcTimeZNA), static_cast<float>(zdcTimeZNC));
830809
}
831810

832811
} else {
833812
if (fillUPCTHnLite) {
834813
if (gap == o2::aod::sgselector::TrueGap::SingleGapA || gap == o2::aod::sgselector::TrueGap::SingleGapC) {
835-
std::vector<double> valuesToFill{massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<double>(numPvContributors), static_cast<double>(fitInfo.ampFV0A), static_cast<double>(fitInfo.ampFT0A), static_cast<double>(fitInfo.ampFT0C), static_cast<double>(zdcEnergyZNA), static_cast<double>(zdcEnergyZNC), static_cast<double>(zdcTimeZNA), static_cast<double>(zdcTimeZNC)};
836-
registry.get<THnSparse>(HIST("hnLcUpcVars"))->Fill(valuesToFill.data());
814+
rowCandUpc(massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<float>(numPvContributors), static_cast<float>(fitInfo.ampFV0A), static_cast<float>(fitInfo.ampFT0A), static_cast<float>(fitInfo.ampFT0C), static_cast<float>(zdcEnergyZNA), static_cast<float>(zdcEnergyZNC), static_cast<float>(zdcTimeZNA), static_cast<float>(zdcTimeZNC));
837815
}
838816
} else {
839-
std::vector<double> valuesToFill{massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<double>(numPvContributors), static_cast<double>(fitInfo.ampFV0A), static_cast<double>(fitInfo.ampFT0A), static_cast<double>(fitInfo.ampFT0C), static_cast<double>(zdcEnergyZNA), static_cast<double>(zdcEnergyZNC), static_cast<double>(zdcTimeZNA), static_cast<double>(zdcTimeZNC)};
840-
registry.get<THnSparse>(HIST("hnLcUpcVars"))->Fill(valuesToFill.data());
817+
rowCandUpc(massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, static_cast<float>(numPvContributors), static_cast<float>(fitInfo.ampFV0A), static_cast<float>(fitInfo.ampFT0A), static_cast<float>(fitInfo.ampFT0C), static_cast<float>(zdcEnergyZNA), static_cast<float>(zdcEnergyZNC), static_cast<float>(zdcTimeZNA), static_cast<float>(zdcTimeZNC));
841818
}
842819
}
843820
};

PWGHF/Utils/utilsUpcHf.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,67 @@
2727
#include <string>
2828
#include <type_traits>
2929

30+
using namespace o2::framework;
31+
using namespace o2::aod;
32+
namespace o2::aod
33+
{
34+
namespace full
35+
{
36+
DECLARE_SOA_COLUMN(M, m, float);
37+
DECLARE_SOA_COLUMN(Pt, pt, float);
38+
DECLARE_SOA_COLUMN(BkgScore, bkgScore, float);
39+
DECLARE_SOA_COLUMN(PromptScore, promptScore, float);
40+
DECLARE_SOA_COLUMN(FDScore, fDScore, float);
41+
DECLARE_SOA_COLUMN(PtProng0, ptProng0, float);
42+
DECLARE_SOA_COLUMN(PtProng1, ptProng1, float);
43+
DECLARE_SOA_COLUMN(PtProng2, ptProng2, float);
44+
DECLARE_SOA_COLUMN(Chi2PCA, chi2PCA, float);
45+
DECLARE_SOA_COLUMN(DecayLength, decayLength, float);
46+
DECLARE_SOA_COLUMN(CPA, cpa, float);
47+
DECLARE_SOA_COLUMN(PvContributors, pvContributors, float);
48+
DECLARE_SOA_COLUMN(AmpFV0A, ampFV0A, float);
49+
DECLARE_SOA_COLUMN(AmpFT0A, ampFT0A, float);
50+
DECLARE_SOA_COLUMN(AmpFT0C, ampFT0C, float);
51+
DECLARE_SOA_COLUMN(ZdcEnergyZNA, zdcEnergyZNA, float);
52+
DECLARE_SOA_COLUMN(ZdcEnergyZNC, zdcEnergyZNC, float);
53+
DECLARE_SOA_COLUMN(ZdcTimeZNA, zdcTimeZNA, float);
54+
DECLARE_SOA_COLUMN(ZdcTimeZNC, zdcTimeZNC, float);
55+
} // namespace full
56+
57+
DECLARE_SOA_TABLE(HfUpcLcBdtInfos, "AOD", "HFUPCLCBDTINFOS",
58+
full::M,
59+
full::Pt,
60+
full::BkgScore,
61+
full::PromptScore,
62+
full::FDScore,
63+
full::PvContributors,
64+
full::AmpFV0A,
65+
full::AmpFT0A,
66+
full::AmpFT0C,
67+
full::ZdcEnergyZNA,
68+
full::ZdcEnergyZNC,
69+
full::ZdcTimeZNA,
70+
full::ZdcTimeZNC);
71+
72+
DECLARE_SOA_TABLE(HfUpcLcInfos, "AOD", "HFUPCLCINFOS",
73+
full::M,
74+
full::Pt,
75+
full::PtProng0,
76+
full::PtProng1,
77+
full::PtProng2,
78+
full::Chi2PCA,
79+
full::DecayLength,
80+
full::CPA,
81+
full::PvContributors,
82+
full::AmpFV0A,
83+
full::AmpFT0A,
84+
full::AmpFT0C,
85+
full::ZdcEnergyZNA,
86+
full::ZdcEnergyZNC,
87+
full::ZdcTimeZNA,
88+
full::ZdcTimeZNC);
89+
} // namespace o2::aod
90+
3091
namespace o2::analysis::hf_upc
3192
{
3293

0 commit comments

Comments
 (0)