Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 81 additions & 45 deletions PWGHF/D2H/Tasks/taskLc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,77 @@ using namespace o2::hf_occupancy;
using namespace o2::hf_evsel;
using namespace o2::analysis::hf_upc;

namespace o2::aod
{
namespace full
{
DECLARE_SOA_COLUMN(M, m, float);
DECLARE_SOA_COLUMN(Pt, pt, float);
DECLARE_SOA_COLUMN(BkgScore, bkgScore, float);
DECLARE_SOA_COLUMN(PromptScore, promptScore, float);
DECLARE_SOA_COLUMN(FdScore, fdScore, float);
DECLARE_SOA_COLUMN(PtProng0, ptProng0, float);
DECLARE_SOA_COLUMN(PtProng1, ptProng1, float);
DECLARE_SOA_COLUMN(PtProng2, ptProng2, float);
DECLARE_SOA_COLUMN(Chi2PCA, chi2PCA, float);
DECLARE_SOA_COLUMN(DecayLength, decayLength, float);
DECLARE_SOA_COLUMN(Cpa, cpa, float);
DECLARE_SOA_COLUMN(PvContributors, pvContributors, float);
DECLARE_SOA_COLUMN(AmpFV0A, ampFV0A, float);
DECLARE_SOA_COLUMN(AmpFT0A, ampFT0A, float);
DECLARE_SOA_COLUMN(AmpFT0C, ampFT0C, float);
DECLARE_SOA_COLUMN(ZdcEnergyZNA, zdcEnergyZNA, float);
DECLARE_SOA_COLUMN(ZdcEnergyZNC, zdcEnergyZNC, float);
DECLARE_SOA_COLUMN(ZdcTimeZNA, zdcTimeZNA, float);
DECLARE_SOA_COLUMN(ZdcTimeZNC, zdcTimeZNC, float);
} // namespace full

DECLARE_SOA_TABLE(HfUpcLcBdtInfos, "AOD", "HFUPCLCBDTINFOS",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you call this table BDT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the tree includes BDT scores for the candidates.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it also includes other BDT-unrelated columns. See my comment above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Here the detector variables and the BDT output are both required together for offline selections. Given this use case, I would prefer to keep the current structure.

full::M,
full::Pt,
full::BkgScore,
full::PromptScore,
full::FdScore,
full::PvContributors,
full::AmpFV0A,
full::AmpFT0A,
full::AmpFT0C,
full::ZdcEnergyZNA,
full::ZdcEnergyZNC,
full::ZdcTimeZNA,
full::ZdcTimeZNC);

DECLARE_SOA_TABLE(HfUpcLcInfos, "AOD", "HFUPCLCINFOS",
full::M,
full::Pt,
full::PtProng0,
Comment on lines +114 to +117
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you duplicate columns in both tables?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One table corresponds to the BDT-applied version, while the other does not. However, both require the mass and pt information.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You never fill both tables. It would be better to have one table with the common columns that you fill in any case and a second table with the extra columns for the BDT case.

full::PtProng1,
full::PtProng2,
full::Chi2PCA,
full::DecayLength,
full::Cpa,
full::PvContributors,
full::AmpFV0A,
full::AmpFT0A,
full::AmpFT0C,
full::ZdcEnergyZNA,
full::ZdcEnergyZNC,
full::ZdcTimeZNA,
full::ZdcTimeZNC);
} // namespace o2::aod

/// Λc± → p± K∓ π± analysis task
struct HfTaskLc {
Produces<o2::aod::HfUpcLcBdtInfos> rowCandUpcBdt;
Produces<o2::aod::HfUpcLcInfos> rowCandUpc;

Configurable<int> selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"};
Configurable<double> yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"};
Configurable<double> yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"};
Configurable<std::vector<double>> binsPt{"binsPt", std::vector<double>{hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits"};
// ThnSparse for ML outputScores and Vars
Configurable<bool> fillTHn{"fillTHn", false, "fill THn"};
Configurable<bool> fillUPCTHnLite{"fillUPCTHnLite", false, "fill THn"};
Configurable<bool> fillTreeOnlySingleGap{"fillTreeOnlySingleGap", false, "fill THn"};
Configurable<bool> storeOccupancy{"storeOccupancy", true, "Flag to store occupancy information"};
Configurable<int> occEstimator{"occEstimator", 2, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"};
Configurable<bool> storeProperLifetime{"storeProperLifetime", false, "Flag to store proper lifetime"};
Expand Down Expand Up @@ -128,10 +190,6 @@ struct HfTaskLc {
ConfigurableAxis thnConfigAxisOccupancy{"thnConfigAxisOccupancy", {14, 0, 14000}, "axis for centrality"};
ConfigurableAxis thnConfigAxisProperLifetime{"thnConfigAxisProperLifetime", {200, 0, 2}, "Proper lifetime, ps"};
ConfigurableAxis thnConfigAxisGapType{"thnConfigAxisGapType", {7, -1.5, 5.5}, "axis for UPC gap type (see TrueGap enum in o2::aod::sgselector)"};
ConfigurableAxis thnConfigAxisFV0A{"thnConfigAxisFV0A", {1001, -1.5, 999.5}, "axis for FV0-A amplitude (a.u.)"};
ConfigurableAxis thnConfigAxisFT0{"thnConfigAxisFT0", {1001, -1.5, 999.5}, "axis for FT0 amplitude (a.u.)"};
ConfigurableAxis thnConfigAxisZN{"thnConfigAxisZN", {510, -1.5, 49.5}, "axis for ZN energy (a.u.)"};
ConfigurableAxis thnConfigAxisZNTime{"thnConfigAxisZNTime", {200, -10, 10}, "axis for ZN energy (a.u.)"};
HistogramRegistry registry{"registry", {}};
HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject};

Expand Down Expand Up @@ -293,27 +351,17 @@ struct HfTaskLc {
const AxisSpec thnAxisTracklets{thnConfigAxisNumPvContr, "Number of PV contributors"};
const AxisSpec thnAxisOccupancy{thnConfigAxisOccupancy, "Occupancy"};
const AxisSpec thnAxisProperLifetime{thnConfigAxisProperLifetime, "T_{proper} (ps)"};
const AxisSpec thnAxisFV0A{thnConfigAxisFV0A, "FV0-A amplitude"};
const AxisSpec thnAxisFT0A{thnConfigAxisFT0, "FT0-A amplitude"};
const AxisSpec thnAxisFT0C{thnConfigAxisFT0, "FT0-C amplitude"};
const AxisSpec thnAxisZNA{thnConfigAxisZN, "ZNA energy"};
const AxisSpec thnAxisZNC{thnConfigAxisZN, "ZNC energy"};
const AxisSpec thnAxisZNATime{thnConfigAxisZNTime, "ZNA time"};
const AxisSpec thnAxisZNCTime{thnConfigAxisZNTime, "ZNC time"};

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

std::vector<AxisSpec> axesStd, axesWithBdt, axesGen, axesUpc, axesUpcWithBdt;
std::vector<AxisSpec> axesStd, axesWithBdt, axesGen;

if (isDataStd && !isUpc) {
axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets};
}
if (isDataStd && isUpc) {
axesUpc = {thnAxisMass, thnAxisPt, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisFV0A, thnAxisFT0A, thnAxisFT0C, thnAxisZNA, thnAxisZNC, thnAxisZNATime, thnAxisZNCTime};
}
if (isMcStd) {
axesStd = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
}
Expand All @@ -323,9 +371,6 @@ struct HfTaskLc {
if (isDataWithMl && !isUpc) {
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets};
}
if (isDataWithMl && isUpc) {
axesUpcWithBdt = {thnAxisMass, thnAxisPt, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisFV0A, thnAxisFT0A, thnAxisFT0C, thnAxisZNA, thnAxisZNC, thnAxisZNATime, thnAxisZNCTime};
}
if (isMcWithMl) {
axesWithBdt = {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisTracklets, thnAxisPtB, thnAxisCanType};
}
Expand All @@ -344,25 +389,20 @@ struct HfTaskLc {
}
}
}
if (isUpc) {
if (isDataStd) {
registry.add("hnLcUpcVars", "THn for Lambdac candidates for Data in UPC", HistType::kTHnSparseF, axesUpc);
} else if (isDataWithMl) {
registry.add("hnLcUpcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data in UPC", HistType::kTHnSparseF, axesUpcWithBdt);
if (!isUpc) {
if (isDataWithMl) {
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, axesWithBdt);
} else if (isMcWithMl) {
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, axesWithBdt);
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
} else if (isDataStd) {
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, axesStd);
} else {
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, axesStd);
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
}
} else if (isDataWithMl) {
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for data with ML", HistType::kTHnSparseF, axesWithBdt);
} else if (isMcWithMl) {
registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores for mc with ML", HistType::kTHnSparseF, axesWithBdt);
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
} else if (isDataStd) {
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for data without ML", HistType::kTHnSparseF, axesStd);
} else {
registry.add("hnLcVars", "THn for Reconstructed Lambdac candidates for mc without ML", HistType::kTHnSparseF, axesStd);
registry.add("hnLcVarsGen", "THn for Generated Lambdac", HistType::kTHnSparseF, axesGen);
}
}

if (isUpc) {
hfEvSel.addHistograms(qaRegistry); // collision monitoring
}
Expand Down Expand Up @@ -819,25 +859,21 @@ struct HfTaskLc {
outputFD = mlProb[MlClassNonPrompt]; /// non-prompt score
}
/// Fill the ML outputScores and variables of candidate
if (fillUPCTHnLite) {
if (fillTreeOnlySingleGap) {
if (gap == o2::aod::sgselector::TrueGap::SingleGapA || gap == o2::aod::sgselector::TrueGap::SingleGapC) {
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)};
registry.get<THnSparse>(HIST("hnLcUpcVarsWithBdt"))->Fill(valuesToFill.data());
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));
}
} else {
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)};
registry.get<THnSparse>(HIST("hnLcUpcVarsWithBdt"))->Fill(valuesToFill.data());
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));
}

} else {
if (fillUPCTHnLite) {
if (fillTreeOnlySingleGap) {
if (gap == o2::aod::sgselector::TrueGap::SingleGapA || gap == o2::aod::sgselector::TrueGap::SingleGapC) {
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)};
registry.get<THnSparse>(HIST("hnLcUpcVars"))->Fill(valuesToFill.data());
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));
}
} else {
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)};
registry.get<THnSparse>(HIST("hnLcUpcVars"))->Fill(valuesToFill.data());
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));
}
}
};
Expand Down
Loading