diff --git a/PWGHF/D2H/Tasks/CMakeLists.txt b/PWGHF/D2H/Tasks/CMakeLists.txt index a3726135da8..b3007ed4d03 100644 --- a/PWGHF/D2H/Tasks/CMakeLists.txt +++ b/PWGHF/D2H/Tasks/CMakeLists.txt @@ -141,7 +141,7 @@ o2physics_add_dpl_workflow(task-lc o2physics_add_dpl_workflow(task-upc-lc SOURCES taskUpcLc.cxx REUSE_FROM HfCandidatesPCH - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::SGCutParHolder O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::SGCutParHolder O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(task-lc-to-k0s-p diff --git a/PWGHF/D2H/Tasks/taskUpcLc.cxx b/PWGHF/D2H/Tasks/taskUpcLc.cxx index 9d8d28b9d8a..915e7a19e6a 100644 --- a/PWGHF/D2H/Tasks/taskUpcLc.cxx +++ b/PWGHF/D2H/Tasks/taskUpcLc.cxx @@ -29,6 +29,7 @@ #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/UPCHelpers.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -48,6 +49,9 @@ #include #include +#include +#include + #include #include #include @@ -70,6 +74,8 @@ namespace full DECLARE_SOA_COLUMN(M, m, float); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(BkgScore, bkgScore, float); +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); //! Run number of the collision +DECLARE_SOA_COLUMN(HasLcCandidate, hasLcCandidate, bool); //! At least one selected Lc candidate within the task rapidity acceptance DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); DECLARE_SOA_COLUMN(PtProng2, ptProng2, float); @@ -94,12 +100,15 @@ DECLARE_SOA_TABLE(HfUpcQa, "AOD", "HFUPCQA", full::AmpFT0A, full::AmpFT0C, full::ZdcTimeZNA, - full::ZdcTimeZNC); + full::ZdcTimeZNC, + full::HasLcCandidate, + full::RunNumber); DECLARE_SOA_TABLE(HfUpcLcBdtInfos, "AOD", "HFUPCLCBDTINFOS", full::M, full::Pt, - full::BkgScore); + full::BkgScore, + full::RunNumber); DECLARE_SOA_TABLE(HfUpcLcInfos, "AOD", "HFUPCLCINFOS", full::M, @@ -153,6 +162,7 @@ struct HfTaskUpcLc { Configurable fillHistQa{"fillHistQa", false, "Fill histograms for UPC detector QA"}; Configurable verticesWithUpc{"verticesWithUpc", false, "Consider vertices with UPC settings"}; Configurable zdcTimeThreshold{"zdcTimeThreshold", 2., "Threshold for ZNA/ZNC time"}; + Configurable irSource{"irSource", "ZNC hadronic", "Estimator of the interaction rate (pp: T0VTX, Pb-Pb: ZNC hadronic)"}; // CCDB configuration Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable ccdbPathGrp{"ccdbPathGrp", "GLO/GRP/GRP", "Path of the grp file (Run 2)"}; @@ -160,6 +170,7 @@ struct HfTaskUpcLc { HfEventSelection hfEvSel; // event selection and monitoring HfUpcGapThresholds upcThresholds; // UPC gap determination thresholds + ctpRateFetcher mRateFetcher; SliceCache cache; Service ccdb{}; @@ -174,6 +185,8 @@ struct HfTaskUpcLc { Preslice candLcPerCollision = aod::hf_cand::collisionId; PresliceUnsorted colPerMcCollision = aod::mcparticle::mcCollisionId; + ConfigurableAxis axisInteractionRate{"axisInteractionRate", {1000, 0., 100.}, "Interaction rate axis (kHz)"}; + HistogramRegistry registry{"registry", {}}; enum MlClasses : int { @@ -191,6 +204,11 @@ struct HfTaskUpcLc { } auto vbins = std::vector(binsPt); + if (fillHistQa) { + auto hInteractionRateVsRun = registry.add("Data/hInteractionRateVsRun", "Selected collisions;Run number;Hadronic interaction rate (kHz)", HistType::kTH2F, {{1, 0., 1.}, axisInteractionRate}); + hInteractionRateVsRun->SetCanExtend(TH1::kXaxis); + hInteractionRateVsRun->GetXaxis()->LabelsOption("v"); + } registry.add("Data/fitInfo/ampFT0A_vs_ampFT0C", "FT0-A vs FT0-C amplitude;FT0-A amplitude (a.u.);FT0-C amplitude (a.u.)", {HistType::kTH2F, {{200, 0., 200}, {200, 0., 200}}}); registry.add("Data/zdc/energyZNA_vs_energyZNC", "ZNA vs ZNC common energy;E_{ZNA}^{common} (a.u.);E_{ZNC}^{common} (a.u.)", {HistType::kTH2F, {{100, 0., 10}, {100, 0., 10}}}); registry.add("Data/zdc/timeZNA_vs_timeZNC", "ZNA vs ZNC time;ZNA Time;ZNC time", {HistType::kTH2F, {{200, -10., 10}, {200, -10., 10}}}); @@ -323,10 +341,17 @@ struct HfTaskUpcLc { registry.fill(HIST("Data/hUpcMulti"), multNTracksPV); registry.fill(HIST("Data/hUpcVtz"), posZ); - if (fillTreeUpcQa) { - rowUpcQa(numPvContributors, multNTracksPV, posZ, fitInfo.ampFT0A, fitInfo.ampFT0C, zdcTimeZNA, zdcTimeZNC); + if constexpr (!IsMc) { + if (fillHistQa) { + const double rate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource, true); + if (rate >= 0.) { + const auto runLabel = std::to_string(bc.runNumber()); + registry.get(HIST("Data/hInteractionRateVsRun"))->Fill(runLabel.c_str(), rate * 1.e-3, 1.); // Hz to kHz + } + } } + bool hasLcCandidate = false; for (const auto& candidate : groupedLcCandidates) { if (!(candidate.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { continue; @@ -334,6 +359,7 @@ struct HfTaskUpcLc { if (yCandRecoMax >= 0. && std::abs(HfHelper::yLc(candidate)) > yCandRecoMax) { continue; } + hasLcCandidate = true; const auto pt = candidate.pt(); const auto ptProng0 = candidate.ptProng0(); const auto ptProng1 = candidate.ptProng1(); @@ -371,7 +397,7 @@ struct HfTaskUpcLc { outputBkg = mlProb[MlClassBackground]; /// bkg score } /// Fill the ML outputScores and variables of candidate - rowCandUpcBdt(massLc, pt, outputBkg); + rowCandUpcBdt(massLc, pt, outputBkg, bc.runNumber()); } else { rowCandUpc(massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa); @@ -385,6 +411,10 @@ struct HfTaskUpcLc { fillTHnData(false); } } + if (fillTreeUpcQa) { + // One QA row per selected collision, including collisions without Lc candidates. + rowUpcQa(numPvContributors, multNTracksPV, posZ, fitInfo.ampFT0A, fitInfo.ampFT0C, zdcTimeZNA, zdcTimeZNC, hasLcCandidate, bc.runNumber()); + } } }