diff --git a/PWGMM/Lumi/Tasks/lumiStabilityPP.cxx b/PWGMM/Lumi/Tasks/lumiStabilityPP.cxx index 9143f524ff3..85c66f376c1 100644 --- a/PWGMM/Lumi/Tasks/lumiStabilityPP.cxx +++ b/PWGMM/Lumi/Tasks/lumiStabilityPP.cxx @@ -49,16 +49,20 @@ enum TriggerAliases { AllBCs = 0, FT0CE = 2, FDD = 3, NTriggerAliases }; -enum BCCategories { BCA = 0, // A side BCs (bunch-crossings that had beam only from A side) - BCB = 1, // B type BCs (bunch-crossings that had beam from both sides) - BCC = 2, // C side BCs (bunch-crossings that had beam only from C side) - BCE = 3, // empty BCs (bunch-crossings that did not have beam from either side) - BCL = 4, // leading BCs (bunch-crossings that did not have interacting bunches for a configurable number of preceding BCs) - BCSLFDD = 5, // super-leading BCs for FDD (bunch-crossings that had beam from both sides but did not have FDD activity for a configurable number of preceding BCs) - BCSLFT0 = 6, // super-leading BCs for FT0 (bunch-crossings that had beam from both sides but did not have FT0 activity for a configurable number of preceding BCs) - BCNL = 7, // non-leading BCs of type B (bunch-crossings that come after a BCL and are of type B) - BCNSLFDD = 8, // non-super-leading BCs for FDD of type B (bunch-crossings that had beam from both sides but are not SL for FDD activity for a configurable number of preceding BCs) - BCNSLFT0 = 9, // non-super-leading BCs for FT0 of type B (bunch-crossings that had beam from both sides but are not SL for FT0 activity for a configurable number of preceding BCs) + +// SL types must be after all the others +enum BCCategories { BCA = 0, // A side BCs (bunch-crossings that had beam only from A side) + BCB, // B type BCs (bunch-crossings that had beam from both sides) + BCC, // C side BCs (bunch-crossings that had beam only from C side) + BCE, // empty BCs (bunch-crossings that did not have beam from either side) + BCL, // leading BCs (bunch-crossings that have not-B BCs for a configurable number of preceding BCs) + BCLE, // leading BCs (bunch-crossings that did not have interacting bunches for a configurable number of preceding BCs) + BCNL, // non-leading BCs of type B (bunch-crossings that come after a BCL and are of type B) + BCNLE, // non-leading BCs of type B (bunch-crossings that come after a BCLE and are of type B) + BCSLFDD, // super-leading BCs for FDD (bunch-crossings that had beam from both sides but did not have FDD activity for a configurable number of preceding BCs) + BCSLFT0, // super-leading BCs for FT0 (bunch-crossings that had beam from both sides but did not have FT0 activity for a configurable number of preceding BCs) + BCNSLFDD, // non-super-leading BCs for FDD of type B (bunch-crossings that had beam from both sides but are not SL for FDD activity for a configurable number of preceding BCs) + BCNSLFT0, // non-super-leading BCs for FT0 of type B (bunch-crossings that had beam from both sides but are not SL for FT0 activity for a configurable number of preceding BCs) NBCCategories }; } // namespace lumi } // namespace o2 @@ -72,14 +76,15 @@ using BCsWithTimeStamps = soa::Join; struct LumiStabilityPP { - static constexpr int defaulFlags[1][NBCCategories] = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; - Configurable> doTypeBC{"doTypeBC", {defaulFlags[0], NBCCategories, {"BCA", "BCB", "BCC", "BCE", "BCL", "BCSLFDD", "BCSLFT0", "BCNL", "BCNSLFDD", "BCNSLFT0"}}, "Create and fill histograms for different BC types"}; + static constexpr int defaulFlags[1][NBCCategories] = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; + Configurable> doTypeBC{"doTypeBC", {defaulFlags[0], NBCCategories, {"BCA", "BCB", "BCC", "BCE", "BCL", "BCLE", "BCSLFDD", "BCSLFT0", "BCNL", "BCNLE", "BCNSLFDD", "BCNSLFT0"}}, "Create and fill histograms for different BC types"}; - Configurable numEmptyBCsBeforeLeadingBC{"numEmptyBCsBeforeLeadingBC", 5, "Number of (empty) non-B BCs before a (super)leading BC"}; + static constexpr int defaulNumBCsBeforeLeadingBC[1][3] = {{5, 5, 5}}; + Configurable> numEmptyBCsBeforeLeadingBC{"numEmptyBCsBeforeLeadingBC", {defaulNumBCsBeforeLeadingBC[0], 3, {"BCL", "BCLE", "BCSL"}}, "Create and fill histograms for different BC types"}; Configurable bcShiftFDDForData2023{"bcShiftFDDForData2023", 7, "Number of bc to shift for FDD to be applied for 2023 data only"}; std::bitset beamPatternA, beamPatternC; - std::bitset bcPatternA, bcPatternC, bcPatternB, bcPatternE, bcPatternL; + std::bitset bcPatternA, bcPatternC, bcPatternB, bcPatternE, bcPatternL, bcPatternLE; const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; o2::framework::Service ccdb; @@ -93,8 +98,8 @@ struct LumiStabilityPP { std::array>, NBCCategories>, NTriggerAliases> histBcVsTime; std::array>, NBCCategories>, NTriggerAliases> histBcVsBcId; - std::array>, NBCCategories>, NTriggerAliases> histMu; - std::array>, NBCCategories>, NTriggerAliases> histMuPerBcId; + std::array>, NBCCategories>, NTriggerAliases> histBcInspectVsBcId; + std::array>, BCSLFDD> histBcPattern; // undefined for BC(N)SL std::map> histNBcsVsTime; std::map> histNBcsVsBcId; std::map> histTfPerMin; @@ -103,22 +108,24 @@ struct LumiStabilityPP { std::map> histInteractionRate; static constexpr std::string_view NBCsVsTimeHistNames[NTriggerAliases][NBCCategories] = - {{"AllBCs/BC_A/nBCsVsTime", "AllBCs/BC_B/nBCsVsTime", "AllBCs/BC_C/nBCsVsTime", "AllBCs/BC_E/nBCsVsTime", "AllBCs/BC_L/nBCsVsTime", "AllBCs/BC_SL_FDD/nBCsVsTime", "AllBCs/BC_SL_FT0/nBCsVsTime", "AllBCs/BC_NL/nBCsVsTime", "AllBCs/BC_NSL_FT0/nBCsVsTime", "AllBCs/BC_NSL_FDD/nBCsVsTime"}, - {"FT0VTx/BC_A/nBCsVsTime", "FT0VTx/BC_B/nBCsVsTime", "FT0VTx/BC_C/nBCsVsTime", "FT0VTx/BC_E/nBCsVsTime", "FT0VTx/BC_L/nBCsVsTime", "FT0VTx/BC_SL_FDD/nBCsVsTime", "FT0VTx/BC_SL_FT0/nBCsVsTime", "FT0VTx/BC_NL/nBCsVsTime", "FT0VTx/BC_NSL_FT0/nBCsVsTime", "FT0VTx/BC_NSL_FDD/nBCsVsTime"}, - {"FT0CE/BC_A/nBCsVsTime", "FT0CE/BC_B/nBCsVsTime", "FT0CE/BC_C/nBCsVsTime", "FT0CE/BC_E/nBCsVsTime", "FT0CE/BC_L/nBCsVsTime", "FT0CE/BC_SL_FDD/nBCsVsTime", "FT0CE/BC_SL_FT0/nBCsVsTime", "FT0CE/BC_NL/nBCsVsTime", "FT0CE/BC_NSL_FT0/nBCsVsTime", "FT0CE/BC_NSL_FDD/nBCsVsTime"}, - {"FDD/BC_A/nBCsVsTime", "FDD/BC_B/nBCsVsTime", "FDD/BC_C/nBCsVsTime", "FDD/BC_E/nBCsVsTime", "FDD/BC_L/nBCsVsTime", "FDD/BC_SL_FDD/nBCsVsTime", "FDD/BC_SL_FT0/nBCsVsTime", "FDD/BC_NL/nBCsVsTime", "FDD/BC_NSL_FT0/nBCsVsTime", "FDD/BC_NSL_FDD/nBCsVsTime"}}; + {{"AllBCs/BC_A/nBCsVsTime", "AllBCs/BC_B/nBCsVsTime", "AllBCs/BC_C/nBCsVsTime", "AllBCs/BC_E/nBCsVsTime", "AllBCs/BC_L/nBCsVsTime", "AllBCs/BC_LE/nBCsVsTime", "AllBCs/BC_NL/nBCsVsTime", "AllBCs/BC_NLE/nBCsVsTime", "AllBCs/BC_SL_FDD/nBCsVsTime", "AllBCs/BC_SL_FT0/nBCsVsTime", "AllBCs/BC_NSL_FT0/nBCsVsTime", "AllBCs/BC_NSL_FDD/nBCsVsTime"}, + {"FT0VTx/BC_A/nBCsVsTime", "FT0VTx/BC_B/nBCsVsTime", "FT0VTx/BC_C/nBCsVsTime", "FT0VTx/BC_E/nBCsVsTime", "FT0VTx/BC_L/nBCsVsTime", "FT0VTx/BC_LE/nBCsVsTime", "FT0VTx/BC_NL/nBCsVsTime", "FT0VTx/BC_NLE/nBCsVsTime", "FT0VTx/BC_SL_FDD/nBCsVsTime", "FT0VTx/BC_SL_FT0/nBCsVsTime", "FT0VTx/BC_NSL_FT0/nBCsVsTime", "FT0VTx/BC_NSL_FDD/nBCsVsTime"}, + {"FT0CE/BC_A/nBCsVsTime", "FT0CE/BC_B/nBCsVsTime", "FT0CE/BC_C/nBCsVsTime", "FT0CE/BC_E/nBCsVsTime", "FT0CE/BC_L/nBCsVsTime", "FT0CE/BC_LE/nBCsVsTime", "FT0CE/BC_NL/nBCsVsTime", "FT0CE/BC_NLE/nBCsVsTime", "FT0CE/BC_SL_FDD/nBCsVsTime", "FT0CE/BC_SL_FT0/nBCsVsTime", "FT0CE/BC_NSL_FT0/nBCsVsTime", "FT0CE/BC_NSL_FDD/nBCsVsTime"}, + {"FDD/BC_A/nBCsVsTime", "FDD/BC_B/nBCsVsTime", "FDD/BC_C/nBCsVsTime", "FDD/BC_E/nBCsVsTime", "FDD/BC_L/nBCsVsTime", "FDD/BC_LE/nBCsVsTime", "FDD/BC_NL/nBCsVsTime", "FDD/BC_NLE/nBCsVsTime", "FDD/BC_SL_FDD/nBCsVsTime", "FDD/BC_SL_FT0/nBCsVsTime", "FDD/BC_NSL_FT0/nBCsVsTime", "FDD/BC_NSL_FDD/nBCsVsTime"}}; static constexpr std::string_view NBCsVsBCIDHistNames[NTriggerAliases][NBCCategories] = - {{"AllBCs/BC_A/nBCsVsBCID", "AllBCs/BC_B/nBCsVsBCID", "AllBCs/BC_C/nBCsVsBCID", "AllBCs/BC_E/nBCsVsBCID", "AllBCs/BC_L/nBCsVsBCID", "AllBCs/BC_SL_FDD/nBCsVsBCID", "AllBCs/BC_SL_FT0/nBCsVsBCID", "AllBCs/BC_NL/nBCsVsBCID", "AllBCs/BC_NSL_FT0/nBCsVsBCID", "AllBCs/BC_NSL_FDD/nBCsVsBCID"}, - {"FT0VTx/BC_A/nBCsVsBCID", "FT0VTx/BC_B/nBCsVsBCID", "FT0VTx/BC_C/nBCsVsBCID", "FT0VTx/BC_E/nBCsVsBCID", "FT0VTx/BC_L/nBCsVsBCID", "FT0VTx/BC_SL_FDD/nBCsVsBCID", "FT0VTx/BC_SL_FT0/nBCsVsBCID", "FT0VTx/BC_NL/nBCsVsBCID", "FT0VTx/BC_NSL_FT0/nBCsVsBCID", "FT0VTx/BC_NSL_FDD/nBCsVsBCID"}, - {"FT0CE/BC_A/nBCsVsBCID", "FT0CE/BC_B/nBCsVsBCID", "FT0CE/BC_C/nBCsVsBCID", "FT0CE/BC_E/nBCsVsBCID", "FT0CE/BC_L/nBCsVsBCID", "FT0CE/BC_SL_FDD/nBCsVsBCID", "FT0CE/BC_SL_FT0/nBCsVsBCID", "FT0CE/BC_NL/nBCsVsBCID", "FT0CE/BC_NSL_FT0/nBCsVsBCID", "FT0CE/BC_NSL_FDD/nBCsVsBCID"}, - {"FDD/BC_A/nBCsVsBCID", "FDD/BC_B/nBCsVsBCID", "FDD/BC_C/nBCsVsBCID", "FDD/BC_E/nBCsVsBCID", "FDD/BC_L/nBCsVsBCID", "FDD/BC_SL_FDD/nBCsVsBCID", "FDD/BC_SL_FT0/nBCsVsBCID", "FDD/BC_NL/nBCsVsBCID", "FDD/BC_NSL_FT0/nBCsVsBCID", "FDD/BC_NSL_FDD/nBCsVsBCID"}}; + {{"AllBCs/BC_A/nBCsVsBCID", "AllBCs/BC_B/nBCsVsBCID", "AllBCs/BC_C/nBCsVsBCID", "AllBCs/BC_E/nBCsVsBCID", "AllBCs/BC_L/nBCsVsBCID", "AllBCs/BC_LE/nBCsVsBCID", "AllBCs/BC_NL/nBCsVsBCID", "AllBCs/BC_NLE/nBCsVsBCID", "AllBCs/BC_SL_FDD/nBCsVsBCID", "AllBCs/BC_SL_FT0/nBCsVsBCID", "AllBCs/BC_NSL_FT0/nBCsVsBCID", "AllBCs/BC_NSL_FDD/nBCsVsBCID"}, + {"FT0VTx/BC_A/nBCsVsBCID", "FT0VTx/BC_B/nBCsVsBCID", "FT0VTx/BC_C/nBCsVsBCID", "FT0VTx/BC_E/nBCsVsBCID", "FT0VTx/BC_L/nBCsVsBCID", "FT0VTx/BC_LE/nBCsVsBCID", "FT0VTx/BC_NL/nBCsVsBCID", "FT0VTx/BC_NLE/nBCsVsBCID", "FT0VTx/BC_SL_FDD/nBCsVsBCID", "FT0VTx/BC_SL_FT0/nBCsVsBCID", "FT0VTx/BC_NSL_FT0/nBCsVsBCID", "FT0VTx/BC_NSL_FDD/nBCsVsBCID"}, + {"FT0CE/BC_A/nBCsVsBCID", "FT0CE/BC_B/nBCsVsBCID", "FT0CE/BC_C/nBCsVsBCID", "FT0CE/BC_E/nBCsVsBCID", "FT0CE/BC_L/nBCsVsBCID", "FT0CE/BC_LE/nBCsVsBCID", "FT0CE/BC_NL/nBCsVsBCID", "FT0CE/BC_NLE/nBCsVsBCID", "FT0CE/BC_SL_FDD/nBCsVsBCID", "FT0CE/BC_SL_FT0/nBCsVsBCID", "FT0CE/BC_NSL_FT0/nBCsVsBCID", "FT0CE/BC_NSL_FDD/nBCsVsBCID"}, + {"FDD/BC_A/nBCsVsBCID", "FDD/BC_B/nBCsVsBCID", "FDD/BC_C/nBCsVsBCID", "FDD/BC_E/nBCsVsBCID", "FDD/BC_L/nBCsVsBCID", "FDD/BC_LE/nBCsVsBCID", "FDD/BC_NL/nBCsVsBCID", "FDD/BC_NLE/nBCsVsBCID", "FDD/BC_SL_FDD/nBCsVsBCID", "FDD/BC_SL_FT0/nBCsVsBCID", "FDD/BC_NSL_FT0/nBCsVsBCID", "FDD/BC_NSL_FDD/nBCsVsBCID"}}; + + static constexpr std::string_view NBCsInspectVsBCIDHistNames[NTriggerAliases][NBCCategories] = + {{"AllBCs/BC_A/nBCsInspectedVsBCID", "AllBCs/BC_B/nBCsInspectedVsBCID", "AllBCs/BC_C/nBCsInspectedVsBCID", "AllBCs/BC_E/nBCsInspectedVsBCID", "AllBCs/BC_L/nBCsInspectedVsBCID", "AllBCs/BC_LE/nBCsInspectedVsBCID", "AllBCs/BC_NL/nBCsInspectedVsBCID", "AllBCs/BC_NLE/nBCsInspectedVsBCID", "AllBCs/BC_SL_FDD/nBCsInspectedVsBCID", "AllBCs/BC_SL_FT0/nBCsInspectedVsBCID", "AllBCs/BC_NSL_FT0/nBCsInspectedVsBCID", "AllBCs/BC_NSL_FDD/nBCsInspectedVsBCID"}, + {"FT0VTx/BC_A/nBCsInspectedVsBCID", "FT0VTx/BC_B/nBCsInspectedVsBCID", "FT0VTx/BC_C/nBCsInspectedVsBCID", "FT0VTx/BC_E/nBCsInspectedVsBCID", "FT0VTx/BC_L/nBCsInspectedVsBCID", "FT0VTx/BC_LE/nBCsInspectedVsBCID", "FT0VTx/BC_NL/nBCsInspectedVsBCID", "FT0VTx/BC_NLE/nBCsInspectedVsBCID", "FT0VTx/BC_SL_FDD/nBCsInspectedVsBCID", "FT0VTx/BC_SL_FT0/nBCsInspectedVsBCID", "FT0VTx/BC_NSL_FT0/nBCsInspectedVsBCID", "FT0VTx/BC_NSL_FDD/nBCsInspectedVsBCID"}, + {"FT0CE/BC_A/nBCsInspectedVsBCID", "FT0CE/BC_B/nBCsInspectedVsBCID", "FT0CE/BC_C/nBCsInspectedVsBCID", "FT0CE/BC_E/nBCsInspectedVsBCID", "FT0CE/BC_L/nBCsInspectedVsBCID", "FT0CE/BC_LE/nBCsInspectedVsBCID", "FT0CE/BC_NL/nBCsInspectedVsBCID", "FT0CE/BC_NLE/nBCsInspectedVsBCID", "FT0CE/BC_SL_FDD/nBCsInspectedVsBCID", "FT0CE/BC_SL_FT0/nBCsInspectedVsBCID", "FT0CE/BC_NSL_FT0/nBCsInspectedVsBCID", "FT0CE/BC_NSL_FDD/nBCsInspectedVsBCID"}, + {"FDD/BC_A/nBCsInspectedVsBCID", "FDD/BC_B/nBCsInspectedVsBCID", "FDD/BC_C/nBCsInspectedVsBCID", "FDD/BC_E/nBCsInspectedVsBCID", "FDD/BC_L/nBCsInspectedVsBCID", "FDD/BC_LE/nBCsInspectedVsBCID", "FDD/BC_NL/nBCsInspectedVsBCID", "FDD/BC_NLE/nBCsInspectedVsBCID", "FDD/BC_SL_FDD/nBCsInspectedVsBCID", "FDD/BC_SL_FT0/nBCsInspectedVsBCID", "FDD/BC_NSL_FT0/nBCsInspectedVsBCID", "FDD/BC_NSL_FDD/nBCsInspectedVsBCID"}}; - static constexpr std::string_view MuHistNames[NTriggerAliases][NBCCategories] = - {{"AllBCs/BC_A/Mu", "AllBCs/BC_B/Mu", "AllBCs/BC_C/Mu", "AllBCs/BC_E/Mu", "AllBCs/BC_L/Mu", "AllBCs/BC_SL_FDD/Mu", "AllBCs/BC_SL_FT0/Mu", "AllBCs/BC_NL/Mu", "AllBCs/BC_NSL_FT0/Mu", "AllBCs/BC_NSL_FDD/Mu"}, - {"FT0VTx/BC_A/Mu", "FT0VTx/BC_B/Mu", "FT0VTx/BC_C/Mu", "FT0VTx/BC_E/Mu", "FT0VTx/BC_L/Mu", "FT0VTx/BC_SL_FDD/Mu", "FT0VTx/BC_SL_FT0/Mu", "FT0VTx/BC_NL/Mu", "FT0VTx/BC_NSL_FT0/Mu", "FT0VTx/BC_NSL_FDD/Mu"}, - {"FT0CE/BC_A/Mu", "FT0CE/BC_B/Mu", "FT0CE/BC_C/Mu", "FT0CE/BC_E/Mu", "FT0CE/BC_L/Mu", "FT0CE/BC_SL_FDD/Mu", "FT0CE/BC_SL_FT0/Mu", "FT0CE/BC_NL/Mu", "FT0CE/BC_NSL_FT0/Mu", "FT0CE/BC_NSL_FDD/Mu"}, - {"FDD/BC_A/Mu", "FDD/BC_B/Mu", "FDD/BC_C/Mu", "FDD/BC_E/Mu", "FDD/BC_L/Mu", "FDD/BC_SL_FDD/Mu", "FDD/BC_SL_FT0/Mu", "FDD/BC_NL/Mu", "FDD/BC_NSL_FT0/Mu", "FDD/BC_NSL_FDD/Mu"}}; + static constexpr std::string_view PatternHistNames[BCSLFDD] = {"BC_A/BcPattern", "BC_B/BcPattern", "BC_C/BcPattern", "BC_E/BcPattern", "BC_L/BcPattern", "BC_LE/BcPattern", "BC_NL/BcPattern", "BC_NLE/BcPattern"}; const AxisSpec timeAxis{2880, 0., 2880., "#bf{t-t_{SOF} (min)}"}, bcIDAxis{nBCsPerOrbit, -0.5, static_cast(nBCsPerOrbit) - 0.5, "#bf{BC ID in orbit}"}; @@ -146,11 +153,14 @@ struct LumiStabilityPP { if (doTypeBC->get(0u, iBCCategory)) { histBcVsTime[iTrigger][iBCCategory][runNumber] = registry.add(Form("%d/%s", runNumber, std::string(NBCsVsTimeHistNames[iTrigger][iBCCategory]).c_str()), "Time of triggered BCs since the start of fill;#bf{t-t_{SOF} (min)};#bf{#it{N}_{BC}}", HistType::kTH1D, {timeAxis}); histBcVsBcId[iTrigger][iBCCategory][runNumber] = registry.add(Form("%d/%s", runNumber, std::string(NBCsVsBCIDHistNames[iTrigger][iBCCategory]).c_str()), "BC ID of triggered BCs;#bf{BC ID in orbit};#bf{#it{N}_{BC}}", HistType::kTH1D, {bcIDAxis}); - histMu[iTrigger][iBCCategory][runNumber] = registry.add(Form("%d/%s", runNumber, std::string(MuHistNames[iTrigger][iBCCategory]).c_str()), "pile-up #mu of different triggers;#mu;counts", HistType::kTH1D, {{400, 0., 0.2}}); - histMuPerBcId[iTrigger][iBCCategory][runNumber] = registry.add(Form("%d/%sVsBcId", runNumber, std::string(MuHistNames[iTrigger][iBCCategory]).c_str()), "pile-up #mu of different triggers per BCId;#mu;counts", HistType::kTH2D, {{bcIDAxis}, {400, 0., 0.2}}); + histBcInspectVsBcId[iTrigger][iBCCategory][runNumber] = registry.add(Form("%d/%s", runNumber, std::string(NBCsInspectVsBCIDHistNames[iTrigger][iBCCategory]).c_str()), "BC ID of inspecred BCs;#bf{BC ID in orbit};#bf{#it{N}_{BC}}", HistType::kTH1D, {bcIDAxis}); } } } + + for (int iBCCategory{0}; iBCCategory < BCSLFDD; ++iBCCategory) { + histBcPattern[iBCCategory][runNumber] = registry.add(Form("%d/%s", runNumber, std::string(PatternHistNames[iBCCategory]).c_str()), "BC Pattern;#bf{BC ID in orbit};", HistType::kTH1D, {bcIDAxis}); + } } void setLHCIFData(const auto& bc) @@ -197,14 +207,15 @@ struct LumiStabilityPP { // Create bcPatternL: leading BCs of type B that follow at least "numEmptyBCsBeforeLeadingBC" non-B BCs bcPatternL.reset(); // Initialize all bits to false + bcPatternLE.reset(); LOG(info) << "Starting to create bcPatternL from bcPatternB"; LOG(info) << "Total number of BCs to check: " << o2::constants::lhc::LHCMaxBunches; - int totalLeadingBCs = 0; + std::array totalLeadingBCs = {0, 0}; for (int iBC = 0; iBC < o2::constants::lhc::LHCMaxBunches; iBC++) { if (bcPatternB[iBC]) { // Check if current BC is of type B - int nonBtypeBCsBefore = 0; // Count how many consecutive BCs before this one are non-B - for (int j = 1; j <= numEmptyBCsBeforeLeadingBC; j++) { + int nonBtypeBCsBefore{0}, emptyBCsBefore{0}; // Count how many consecutive BCs before this one are non-B + for (int j = 1; j <= numEmptyBCsBeforeLeadingBC->get(0u, 0u); j++) { int prevBC = (iBC - j + o2::constants::lhc::LHCMaxBunches) % o2::constants::lhc::LHCMaxBunches; // Protection for BCs at small indices to check the end of the orbit if (!bcPatternB[prevBC]) { nonBtypeBCsBefore++; @@ -212,13 +223,50 @@ struct LumiStabilityPP { break; // Stop counting if we hit a BCB } } - if (nonBtypeBCsBefore >= numEmptyBCsBeforeLeadingBC) { // If we found at least numEmptyBCsBeforeLeadingBC non-B BCs before this one, mark it as leading + for (int j = 1; j <= numEmptyBCsBeforeLeadingBC->get(0u, 1u); j++) { + int prevBC = (iBC - j + o2::constants::lhc::LHCMaxBunches) % o2::constants::lhc::LHCMaxBunches; // Protection for BCs at small indices to check the end of the orbit + if (bcPatternE[prevBC]) { + emptyBCsBefore++; + } else { + break; // Stop counting if we hit a non BCE + } + } + if (nonBtypeBCsBefore >= numEmptyBCsBeforeLeadingBC->get(0u, 0u)) { // If we found at least numEmptyBCsBeforeLeadingBC[0] non-B BCs before this one, mark it as leading bcPatternL[iBC] = true; - totalLeadingBCs++; + totalLeadingBCs[0]++; + } + if (emptyBCsBefore >= numEmptyBCsBeforeLeadingBC->get(0u, 1u)) { // If we found at least numEmptyBCsBeforeLeadingBC[1] empty BCs before this one, mark it as leading + bcPatternLE[iBC] = true; + totalLeadingBCs[1]++; + } + } + if (bcPatternA[iBC]) { + histBcPattern[BCA][runNumber]->Fill(iBC); + } + if (bcPatternB[iBC]) { + histBcPattern[BCB][runNumber]->Fill(iBC); + if (!bcPatternL[iBC]) { + histBcPattern[BCNL][runNumber]->Fill(iBC); } + if (!bcPatternLE[iBC]) { + histBcPattern[BCNLE][runNumber]->Fill(iBC); + } + } + if (bcPatternC[iBC]) { + histBcPattern[BCC][runNumber]->Fill(iBC); + } + if (bcPatternE[iBC]) { + histBcPattern[BCE][runNumber]->Fill(iBC); + } + if (bcPatternL[iBC]) { + histBcPattern[BCL][runNumber]->Fill(iBC); + } + if (bcPatternLE[iBC]) { + histBcPattern[BCLE][runNumber]->Fill(iBC); } } - LOG(info) << "bcPatternL creation complete. Total leading BCs found: " << totalLeadingBCs; + LOG(info) << "bcPatternL creation complete. Total leading BCs found: " << totalLeadingBCs[0]; + LOG(info) << "bcPatternLE creation complete. Total leading BCs found: " << totalLeadingBCs[1]; auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), runNumber, metadataInfo.get("LPMProductionTag")); bcSOR = runInfo.orbitSOR * nBCsPerOrbit; // first bc of the first orbit @@ -233,18 +281,9 @@ struct LumiStabilityPP { return (bc.timestamp() - mLHCIFdata->getFillNumberTime()) / 1e3 / 60; // Convert to minutes } - float getMu(double ntriggers, int nbc) - { - if (nbc == 0) { - return 0.; - } - return -std::log(1.f - ntriggers / nbc); - } - template - void fillHistograms(float timeSinceSOF, int64_t localBC, int& nTriggers) + void fillHistograms(float timeSinceSOF, int64_t localBC) { - nTriggers += 1; histBcVsTime[iTrigger][iBCCategory][runNumber]->Fill(timeSinceSOF); histBcVsBcId[iTrigger][iBCCategory][runNumber]->Fill(localBC); } @@ -257,12 +296,6 @@ struct LumiStabilityPP { std::vector> nBCsPerBcId; nBCsPerBcId.resize(nBCsPerOrbit); std::fill(&nBCsPerBcId[0][0], &nBCsPerBcId[0][0] + (static_cast(nBCsPerOrbit) * static_cast(NBCCategories)), 0); // Initialize to 0 - std::vector, NTriggerAliases>> nTriggersPerBcId; - nTriggersPerBcId.resize(nBCsPerOrbit); - std::fill(&nTriggersPerBcId[0][0][0], &nTriggersPerBcId[0][0][0] + (static_cast(nBCsPerOrbit) * static_cast(NTriggerAliases) * static_cast(NBCCategories)), 0); // Initialize to 0 - - int nTriggersPerDf[NTriggerAliases][NBCCategories]; - std::fill(&nTriggersPerDf[0][0], &nTriggersPerDf[0][0] + (static_cast(NTriggerAliases) * static_cast(NBCCategories)), 0); // Initialize to 0 double rate{-1.}; for (const auto& bc : bcs) { @@ -297,10 +330,10 @@ struct LumiStabilityPP { int localBCFDD = globalBCFDD % nBCsPerOrbit; bool isSuperLeadingBcFDD{true}, isSuperLeadingBcFT0{true}; - if (globalBCFDD - globalBCIdOfLastBCWithActivityFDD < numEmptyBCsBeforeLeadingBC) { + if (globalBCFDD - globalBCIdOfLastBCWithActivityFDD < numEmptyBCsBeforeLeadingBC->get(0u, 2u)) { isSuperLeadingBcFDD = false; // not a super-leading BC for FDD } - if (globalBC - globalBCIdOfLastBCWithActivityFT0 < numEmptyBCsBeforeLeadingBC) { + if (globalBC - globalBCIdOfLastBCWithActivityFT0 < numEmptyBCsBeforeLeadingBC->get(0u, 2u)) { isSuperLeadingBcFT0 = false; // not a super-leading BC for FT0 } @@ -330,12 +363,12 @@ struct LumiStabilityPP { } if (bcPatternB[iLocalBC]) { nBCsPerBcId[iLocalBC][BCB]++; - if (iGlobalBC - globalBCIdOfLastBCWithActivityFDD > numEmptyBCsBeforeLeadingBC) { + if (iGlobalBC - globalBCIdOfLastBCWithActivityFDD > numEmptyBCsBeforeLeadingBC->get(0u, 2u)) { nBCsPerBcId[iLocalBC][BCSLFDD]++; } else { nBCsPerBcId[iLocalBC][BCNSLFDD]++; } - if (iGlobalBC - globalBCIdOfLastBCWithActivityFT0 > numEmptyBCsBeforeLeadingBC) { + if (iGlobalBC - globalBCIdOfLastBCWithActivityFT0 > numEmptyBCsBeforeLeadingBC->get(0u, 2u)) { nBCsPerBcId[iLocalBC][BCSLFT0]++; } else { nBCsPerBcId[iLocalBC][BCNSLFT0]++; @@ -343,6 +376,9 @@ struct LumiStabilityPP { if (!bcPatternL[iLocalBC]) { nBCsPerBcId[iLocalBC][BCNL]++; } + if (!bcPatternLE[iLocalBC]) { + nBCsPerBcId[iLocalBC][BCNLE]++; + } } if (bcPatternC[iLocalBC]) { nBCsPerBcId[iLocalBC][BCC]++; @@ -353,6 +389,9 @@ struct LumiStabilityPP { if (bcPatternL[iLocalBC]) { nBCsPerBcId[iLocalBC][BCL]++; } + if (bcPatternLE[iLocalBC]) { + nBCsPerBcId[iLocalBC][BCLE]++; + } } int64_t thisTFid = (globalBC - bcSOR) / nBCsPerTF; @@ -367,91 +406,107 @@ struct LumiStabilityPP { if (doTypeBC->get(0u, iBCCategory)) { if (iTrigger == AllBCs) { if (iBCCategory == BCA && bcPatternA[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCB && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCC && bcPatternC[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCE && bcPatternE[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCL && bcPatternL[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); + if (iBCCategory == BCLE && bcPatternLE[localBC]) + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCSLFDD && isSuperLeadingBcFDD) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCSLFT0 && isSuperLeadingBcFT0) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNL && !bcPatternL[localBC] && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); + if (iBCCategory == BCNLE && !bcPatternLE[localBC] && bcPatternB[localBC]) + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNSLFDD && !isSuperLeadingBcFDD && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNSLFT0 && !isSuperLeadingBcFT0 && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); } if (iTrigger == FT0Vtx && ctpInputMask.test(2)) { if (iBCCategory == BCA && bcPatternA[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCB && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCC && bcPatternC[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCE && bcPatternE[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCL && bcPatternL[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); + if (iBCCategory == BCLE && bcPatternLE[localBC]) + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCSLFDD && isSuperLeadingBcFDD) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCSLFT0 && isSuperLeadingBcFT0) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNL && !bcPatternL[localBC] && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); + if (iBCCategory == BCNLE && !bcPatternLE[localBC] && bcPatternB[localBC]) + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNSLFDD && !isSuperLeadingBcFDD && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNSLFT0 && !isSuperLeadingBcFT0 && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); } if (iTrigger == FT0CE && ctpInputMask.test(4)) { if (iBCCategory == BCA && bcPatternA[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCB && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCC && bcPatternC[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCE && bcPatternE[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCL && bcPatternL[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); + if (iBCCategory == BCLE && bcPatternLE[localBC]) + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCSLFDD && isSuperLeadingBcFDD) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCSLFT0 && isSuperLeadingBcFT0) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNL && !bcPatternL[localBC] && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); + if (iBCCategory == BCNLE && !bcPatternLE[localBC] && bcPatternB[localBC]) + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNSLFDD && !isSuperLeadingBcFDD && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); if (iBCCategory == BCNSLFT0 && !isSuperLeadingBcFT0 && bcPatternB[localBC]) - fillHistograms(timeSinceSOF, localBC, nTriggersPerBcId[localBC][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBC); } if (iTrigger == FDD && ctpInputMask.test(15)) { if (iBCCategory == BCA && bcPatternA[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCB && bcPatternB[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCC && bcPatternC[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCE && bcPatternE[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCL && bcPatternL[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); + if (iBCCategory == BCLE && bcPatternLE[localBCFDD]) + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCSLFDD && isSuperLeadingBcFDD) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCSLFT0 && isSuperLeadingBcFT0) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCNL && !bcPatternL[localBCFDD] && bcPatternB[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); + if (iBCCategory == BCNLE && !bcPatternLE[localBCFDD] && bcPatternB[localBCFDD]) + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCNSLFDD && !isSuperLeadingBcFDD && bcPatternB[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); if (iBCCategory == BCNSLFT0 && !isSuperLeadingBcFT0 && bcPatternB[localBCFDD]) - fillHistograms(timeSinceSOF, localBCFDD, nTriggersPerBcId[localBCFDD][iTrigger][iBCCategory]); + fillHistograms(timeSinceSOF, localBCFDD); } } } @@ -467,16 +522,9 @@ struct LumiStabilityPP { for (int iTrigger{0}; iTrigger < NTriggerAliases; ++iTrigger) { for (int iBCCategory{0}; iBCCategory < NBCCategories; ++iBCCategory) { if (doTypeBC->get(0u, iBCCategory)) { - int nTotBCs{0}; - int nTotTriggers{0}; for (int iBcId{0}; iBcId < nBCsPerOrbit; ++iBcId) { - float muPerBcId = getMu(nTriggersPerBcId[iBcId][iTrigger][iBCCategory], nBCsPerBcId[iBcId][iBCCategory]); - histMuPerBcId[iTrigger][iBCCategory][runNumber]->Fill(iBcId, muPerBcId); - nTotBCs += nBCsPerBcId[iBcId][iBCCategory]; - nTotTriggers += nTriggersPerBcId[iBcId][iTrigger][iBCCategory]; + histBcInspectVsBcId[iTrigger][iBCCategory][runNumber]->Fill(iBcId, nBCsPerBcId[iBcId][iBCCategory]); } - float mu = getMu(nTotTriggers, nTotBCs); - histMu[iTrigger][iBCCategory][runNumber]->Fill(mu); } } }