2929#include " PWGUD/Core/SGSelector.h"
3030#include " PWGUD/Core/UPCHelpers.h"
3131
32+ #include " Common/CCDB/ctpRateFetcher.h"
3233#include " Common/Core/RecoDecay.h"
3334#include " Common/DataModel/EventSelection.h"
3435#include " Common/DataModel/Multiplicity.h"
4849#include < Framework/runDataProcessing.h>
4950#include < ReconstructionDataFormats/Vertex.h>
5051
52+ #include < TH1.h>
53+ #include < TH2.h>
54+
5155#include < array>
5256#include < cmath>
5357#include < cstdint>
@@ -70,6 +74,8 @@ namespace full
7074DECLARE_SOA_COLUMN (M, m, float );
7175DECLARE_SOA_COLUMN (Pt, pt, float );
7276DECLARE_SOA_COLUMN (BkgScore, bkgScore, float );
77+ DECLARE_SOA_COLUMN (RunNumber, runNumber, int32_t ); // ! Run number of the collision
78+ DECLARE_SOA_COLUMN (HasLcCandidate, hasLcCandidate, bool ); // ! At least one selected Lc candidate within the task rapidity acceptance
7379DECLARE_SOA_COLUMN (PtProng0, ptProng0, float );
7480DECLARE_SOA_COLUMN (PtProng1, ptProng1, float );
7581DECLARE_SOA_COLUMN (PtProng2, ptProng2, float );
@@ -94,12 +100,15 @@ DECLARE_SOA_TABLE(HfUpcQa, "AOD", "HFUPCQA",
94100 full::AmpFT0A,
95101 full::AmpFT0C,
96102 full::ZdcTimeZNA,
97- full::ZdcTimeZNC);
103+ full::ZdcTimeZNC,
104+ full::HasLcCandidate,
105+ full::RunNumber);
98106
99107DECLARE_SOA_TABLE (HfUpcLcBdtInfos, " AOD" , " HFUPCLCBDTINFOS" ,
100108 full::M,
101109 full::Pt,
102- full::BkgScore);
110+ full::BkgScore,
111+ full::RunNumber);
103112
104113DECLARE_SOA_TABLE (HfUpcLcInfos, " AOD" , " HFUPCLCINFOS" ,
105114 full::M,
@@ -153,13 +162,15 @@ struct HfTaskUpcLc {
153162 Configurable<bool > fillHistQa{" fillHistQa" , false , " Fill histograms for UPC detector QA" };
154163 Configurable<bool > verticesWithUpc{" verticesWithUpc" , false , " Consider vertices with UPC settings" };
155164 Configurable<float > zdcTimeThreshold{" zdcTimeThreshold" , 2 ., " Threshold for ZNA/ZNC time" };
165+ Configurable<std::string> irSource{" irSource" , " ZNC hadronic" , " Estimator of the interaction rate (pp: T0VTX, Pb-Pb: ZNC hadronic)" };
156166 // CCDB configuration
157167 Configurable<std::string> ccdbUrl{" ccdbUrl" , " http://alice-ccdb.cern.ch" , " url of the ccdb repository" };
158168 Configurable<std::string> ccdbPathGrp{" ccdbPathGrp" , " GLO/GRP/GRP" , " Path of the grp file (Run 2)" };
159169 Configurable<std::string> ccdbPathGrpMag{" ccdbPathGrpMag" , " GLO/Config/GRPMagField" , " CCDB path of the GRPMagField object (Run 3)" };
160170
161171 HfEventSelection hfEvSel; // event selection and monitoring
162172 HfUpcGapThresholds upcThresholds; // UPC gap determination thresholds
173+ ctpRateFetcher mRateFetcher ;
163174 SliceCache cache;
164175 Service<o2::ccdb::BasicCCDBManager> ccdb{};
165176
@@ -174,6 +185,8 @@ struct HfTaskUpcLc {
174185 Preslice<aod::HfCand3Prong> candLcPerCollision = aod::hf_cand::collisionId;
175186 PresliceUnsorted<aod::McCollisionLabels> colPerMcCollision = aod::mcparticle::mcCollisionId;
176187
188+ ConfigurableAxis axisInteractionRate{" axisInteractionRate" , {1000 , 0 ., 100 .}, " Interaction rate axis (kHz)" };
189+
177190 HistogramRegistry registry{" registry" , {}};
178191
179192 enum MlClasses : int {
@@ -191,6 +204,11 @@ struct HfTaskUpcLc {
191204 }
192205
193206 auto vbins = std::vector<double >(binsPt);
207+ if (fillHistQa) {
208+ auto hInteractionRateVsRun = registry.add <TH2 >(" Data/hInteractionRateVsRun" , " Selected collisions;Run number;Hadronic interaction rate (kHz)" , HistType::kTH2F , {{1 , 0 ., 1 .}, axisInteractionRate});
209+ hInteractionRateVsRun->SetCanExtend (TH1 ::kXaxis );
210+ hInteractionRateVsRun->GetXaxis ()->LabelsOption (" v" );
211+ }
194212 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 }}});
195213 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 }}});
196214 registry.add (" Data/zdc/timeZNA_vs_timeZNC" , " ZNA vs ZNC time;ZNA Time;ZNC time" , {HistType::kTH2F , {{200 , -10 ., 10 }, {200 , -10 ., 10 }}});
@@ -323,17 +341,25 @@ struct HfTaskUpcLc {
323341 registry.fill (HIST (" Data/hUpcMulti" ), multNTracksPV);
324342 registry.fill (HIST (" Data/hUpcVtz" ), posZ);
325343
326- if (fillTreeUpcQa) {
327- rowUpcQa (numPvContributors, multNTracksPV, posZ, fitInfo.ampFT0A , fitInfo.ampFT0C , zdcTimeZNA, zdcTimeZNC);
344+ if constexpr (!IsMc) {
345+ if (fillHistQa) {
346+ const double rate = mRateFetcher .fetch (ccdb.service , bc.timestamp (), bc.runNumber (), irSource, true );
347+ if (rate >= 0 .) {
348+ const auto runLabel = std::to_string (bc.runNumber ());
349+ registry.get <TH2 >(HIST (" Data/hInteractionRateVsRun" ))->Fill (runLabel.c_str (), rate * 1 .e -3 , 1 .); // Hz to kHz
350+ }
351+ }
328352 }
329353
354+ bool hasLcCandidate = false ;
330355 for (const auto & candidate : groupedLcCandidates) {
331356 if (!(candidate.hfflag () & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) {
332357 continue ;
333358 }
334359 if (yCandRecoMax >= 0 . && std::abs (HfHelper::yLc (candidate)) > yCandRecoMax) {
335360 continue ;
336361 }
362+ hasLcCandidate = true ;
337363 const auto pt = candidate.pt ();
338364 const auto ptProng0 = candidate.ptProng0 ();
339365 const auto ptProng1 = candidate.ptProng1 ();
@@ -371,7 +397,7 @@ struct HfTaskUpcLc {
371397 outputBkg = mlProb[MlClassBackground]; // / bkg score
372398 }
373399 // / Fill the ML outputScores and variables of candidate
374- rowCandUpcBdt (massLc, pt, outputBkg);
400+ rowCandUpcBdt (massLc, pt, outputBkg, bc. runNumber () );
375401
376402 } else {
377403 rowCandUpc (massLc, pt, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa);
@@ -385,6 +411,10 @@ struct HfTaskUpcLc {
385411 fillTHnData (false );
386412 }
387413 }
414+ if (fillTreeUpcQa) {
415+ // One QA row per selected collision, including collisions without Lc candidates.
416+ rowUpcQa (numPvContributors, multNTracksPV, posZ, fitInfo.ampFT0A , fitInfo.ampFT0C , zdcTimeZNA, zdcTimeZNC, hasLcCandidate, bc.runNumber ());
417+ }
388418 }
389419 }
390420
0 commit comments