diff --git a/PWGUD/TableProducer/muonEfficiencyProducer.cxx b/PWGUD/TableProducer/muonEfficiencyProducer.cxx index 9a7f0987bde..267c9bb55fd 100644 --- a/PWGUD/TableProducer/muonEfficiencyProducer.cxx +++ b/PWGUD/TableProducer/muonEfficiencyProducer.cxx @@ -13,8 +13,13 @@ /// \brief Compact forward-muon skim for offline MCH and MCH-MID efficiency studies /// \author Nazar Burmasov (JINR) +#include "Common/CCDB/EventSelectionParams.h" + #include +#include +#include #include +#include #include #include #include @@ -24,8 +29,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -34,9 +42,13 @@ #include #include #include +#include +#include #include +#include #include +#include #include using namespace o2; @@ -98,6 +110,7 @@ struct MuonEfficiencyProducer { static constexpr float MaxEta = -2.5f; static constexpr float NoAmplitude = -1.f; static constexpr float MaxFITTime = 30.f; + static constexpr int BCsPerOrbit = constants::lhc::LHCMaxBunches; using Tracks = soa::Join; using Matrix55 = ROOT::Math::SMatrix>; @@ -105,9 +118,13 @@ struct MuonEfficiencyProducer { Produces outputBCs; Produces output; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Service ccdb{}; globaltracking::MatchGlobalFwd matcher; - int cachedFieldRun = -1; + bool conditionsInitialized = false; + std::bitset collidingBCs; + float zncBBLower = 0.f; + float zncBBUpper = 0.f; Configurable minPt{"minPt", 0.4f, "Minimum track pT (Gev/c)"}; Configurable minRAbs{"minRAbs", 17.6f, "Minimum absorber-end radius (cm)"}; @@ -118,11 +135,19 @@ struct MuonEfficiencyProducer { void init(InitContext&) { ccdb->setLocalObjectValidityChecking(); + const AxisSpec runAxis{1, 0.5, 1.5, "Run"}; + const AxisSpec bcAxis{BCsPerOrbit, -0.5, BCsPerOrbit - 0.5, "BC in orbit"}; + histos.add("hCounterTVX", "TVX;Run;BC in orbit;Counts", HistType::kTH2D, {runAxis, bcAxis}); + histos.add("hCounterTCE", "TCE;Run;BC in orbit;Counts", HistType::kTH2D, {runAxis, bcAxis}); + histos.add("hCounterZNC", "ZNC;Run;BC in orbit;Counts", HistType::kTH2D, {runAxis, bcAxis}); + histos.get(HIST("hCounterTVX"))->SetCanExtend(TH1::kXaxis); + histos.get(HIST("hCounterTCE"))->SetCanExtend(TH1::kXaxis); + histos.get(HIST("hCounterZNC"))->SetCanExtend(TH1::kXaxis); } - void setField(int run) + void initRunConditions(int run) { - if (cachedFieldRun == run) { + if (conditionsInitialized) { return; } const auto runInfo = parameters::AggregatedRunInfo::buildAggregatedRunInfo(ccdb->instance(), run); @@ -136,7 +161,21 @@ struct MuonEfficiencyProducer { ccdb->get("GLO/Config/GeometryAligned"); } mch::TrackExtrap::setField(); - cachedFieldRun = run; + if (!runInfo.grpLHC) { + LOGF(fatal, "GRPLHCIFData not found for run %d", run); + } + collidingBCs = runInfo.grpLHC->getBunchFilling().getBCPattern(); + auto* params = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", ts); + if (!params) { + LOGF(fatal, "EventSelectionParams not found for run %d", run); + } + zncBBLower = params->fZNCBBlower; + zncBBUpper = params->fZNCBBupper; + const auto label = std::to_string(run); + histos.get(HIST("hCounterTVX"))->GetXaxis()->SetBinLabel(1, label.c_str()); + histos.get(HIST("hCounterTCE"))->GetXaxis()->SetBinLabel(1, label.c_str()); + histos.get(HIST("hCounterZNC"))->GetXaxis()->SetBinLabel(1, label.c_str()); + conditionsInitialized = true; } struct Kinematics { @@ -165,6 +204,7 @@ struct MuonEfficiencyProducer { } void process(aod::BCs const& bcs, aod::FT0s const& ft0s, aod::FV0As const& fv0as, + aod::Zdcs const& zdcs, Tracks const& tracks, aod::Collisions const& collisions, aod::AmbiguousFwdTracks const& ambiguous) { @@ -172,12 +212,15 @@ struct MuonEfficiencyProducer { return; } const int run = bcs.begin().runNumber(); - + initRunConditions(run); + std::vector ft0TriggersByBC(bcs.size(), 0); + std::vector zncIsBBByBC(bcs.size(), 0); std::vector ft0aByBC(bcs.size(), NoAmplitude); std::vector ft0cByBC(bcs.size(), NoAmplitude); std::vector fv0aByBC(bcs.size(), NoAmplitude); std::vector skimBCIds(bcs.size(), -1); for (const auto& ft0 : ft0s) { + ft0TriggersByBC[ft0.bcId()] |= ft0.triggerMask(); if (ft0.timeA() < MaxFITTime) { ft0aByBC[ft0.bcId()] = ft0.sumAmpA(); } @@ -198,6 +241,33 @@ struct MuonEfficiencyProducer { fv0aByBC[fv0.bcId()] = amplitude; } + for (const auto& zdc : zdcs) { + if (zdc.timeZNC() > zncBBLower && zdc.timeZNC() < zncBBUpper) { + zncIsBBByBC[zdc.bcId()] = 1; + } + } + + auto hTVX = histos.get(HIST("hCounterTVX")); + auto hTCE = histos.get(HIST("hCounterTCE")); + auto hZNC = histos.get(HIST("hCounterZNC")); + for (const auto& bc : bcs) { + const auto slot = bc.globalBC() % BCsPerOrbit; + if (!collidingBCs[slot]) { + continue; + } + const auto mask = ft0TriggersByBC[bc.globalIndex()]; + const bool tvx = (mask & (1u << o2::ft0::Triggers::bitVertex)) != 0; + if (tvx) { + hTVX->Fill(1., static_cast(slot)); + if ((mask & (1u << o2::ft0::Triggers::bitCen)) != 0) { + hTCE->Fill(1., static_cast(slot)); + } + } + if (zncIsBBByBC[bc.globalIndex()] != 0u) { + hZNC->Fill(1., static_cast(slot)); + } + } + std::vector ambiguousBCIds(tracks.size(), -1); for (const auto& entry : ambiguous) { const auto& ids = entry.bcIds(); @@ -226,7 +296,6 @@ struct MuonEfficiencyProducer { vtxCov = {col.covXX(), col.covYY()}; referenceBCId = col.bcId(); } - setField(run); if (!propagateMCH(t, vtx, vtxCov, k)) { continue; }