diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h b/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h index d56250f8a31c2815ad86681273e1d2b2e9465e8b..11ac1182f3f45888fcafe2c511c40a5fedb7acaa 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h @@ -16,9 +16,9 @@ namespace SCT_Monitoring{ ///what array indices mean when looping over subsystems - enum BecIndex {INVALID_INDEX=-1, ENDCAP_C_INDEX=0, BARREL_INDEX=1, ENDCAP_A_INDEX=2, GENERAL_INDEX=3}; + enum BecIndex {INVALID_INDEX=-1, ENDCAP_C_INDEX=0, BARREL_INDEX=1, ENDCAP_A_INDEX=2, GENERAL_INDEX=3, N_REGIONS=3, N_REGIONS_INC_GENERAL=N_REGIONS+1}; ///Possible values of the 'BEC' (Barrel or EndCap) value - enum Bec{ ENDCAP_C=-2, BARREL=0, ENDCAP_A=2, N_REGIONS=3, GENERAL=3, INVALID_SYSTEM=4, N_REGIONS_INC_GENERAL=N_REGIONS+1}; + enum Bec{ ENDCAP_C=-2, BARREL=0, ENDCAP_A=2, GENERAL=3, INVALID_SYSTEM=4}; ///Array for conversion of an array index to a Bec static const std::vector<Bec> index2BecArray={ENDCAP_C, BARREL, ENDCAP_A, GENERAL}; ///Conversion bec->index @@ -50,6 +50,12 @@ namespace SCT_Monitoring{ }; enum CategoryErrors {MASKEDLINKALL=0, SUMMARY, BADERR, LINKLEVEL, RODLEVEL, MASKEDCHIP, N_ERRCATEGORY}; + static const std::vector<std::string> CategoryErrorsNames = {"MaskedLinkALL", // MASKEDLINKALL + "Errors", // SUMMARY + "BadErrors", // BADERR + "LinkLevelErrors", // LINKLEVEL + "RODLevelErrors", // RODLEVEL + "MaskedChipALL"}; // MASKEDCHIP enum ProblemForCoverage { allRegion, //All SCT module for counting good module diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py b/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py index 310b32376736d12d45d005fd76a7c1e44e9e63f8..e58ca7db2efaeda6e8b495304dd91fa12fd0e94b 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py @@ -35,6 +35,45 @@ myMonGroup = helper.addGroup(myMonAlg, "SCTErrMonitor", "SCT/") from ROOT import SCT_Monitoring as sctMon +# Filled in fillHistograms +myMonGroup.defineHistogram(varname = "lumiBlock;NumberOfEventsVsLB", + cutmask = "is1D", + type = "TH1F", + title = "Num of events per LB ;LumiBlock", + path = "GENERAL/Conf", + xbins = sctMon.NBINS_LBs, + xmin = 0.5, + xmax = sctMon.NBINS_LBs+0.5) + +# Filled in fillHistograms +myMonGroup.defineHistogram(varname = "lumiBlock;NumberOfSCTFlagErrorsVsLB", + cutmask = "sctFlag", + type = "TH1F", + title = "Num of SCT Flag errors per LB ;LumiBlock", + path = "GENERAL/Conf", + xbins = sctMon.NBINS_LBs, + xmin = 0.5, + xmax = sctMon.NBINS_LBs+0.5) + +# Filled in fillHistograms +myMonGroup.defineHistogram(varname = "lumiBlock, sctFlag;FractionOfSCTFlagErrorsPerLB", + type = "TProfile", + title = "Frac of SCT Flag errors per LB ;LumiBlock", + path = "GENERAL/Conf", + xbins = sctMon.NBINS_LBs, + xmin = 0.5, + xmax = sctMon.NBINS_LBs+0.5) + +# Filled in fillConfigurationDetails +myMonGroup.defineHistogram(varname = "detailedConfBin, nBad;SCTConfDetails", + type = "TProfile", + title = "Exclusion from the Configuration", + path = "GENERAL/Conf", + xbins = sctMon.ConfbinsDetailed, + xmin = -0.5, + xmax = sctMon.ConfbinsDetailed-0.5, + xlabels = ["Modules", "Link 0", "Link 1", "Chips", "Strips (10^{2})"]) + # Filled in fillHistograms myMonGroup.defineHistogram(varname = "moduleOutBin, moduleOut;SCTConfOutM", type = "TProfile", @@ -56,6 +95,16 @@ for i in range(SCT_ByteStreamErrors.NUM_ERROR_TYPES): xmin = 0.5, xmax = sctMon.NBINS_LBs+0.5) +# Fiiled in fillByteStreamErrors +for i in range(sctMon.N_ERRCATEGORY): + myMonGroup.defineHistogram(varname = "lumiBlock, n_"+sctMon.CategoryErrorsNames[i]+";SCT_LinksWith"+sctMon.CategoryErrorsNames[i]+"VsLbs", + type = "TProfile", + title = "Ave. Num of Links with "+sctMon.CategoryErrorsNames[i]+" per LB in All Region;LumiBlock;Num of Links with "+sctMon.CategoryErrorsNames[i], + path = "GENERAL/Conf", + xbins = sctMon.NBINS_LBs, + xmin = 0.5, + xmax = sctMon.NBINS_LBs+0.5) + # Filled in fillByteStreamErrorsHelper myMonGroup.defineHistogram(varname = "maskedLinksBin;Masked Links", weight = "maskedLinks", diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.cxx b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.cxx index cb8e5de10069e0cfa531ef83d7c00085ae5a85fc..66777500eca0a2b6a2bf38aa08f754afd05b312b 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.cxx +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.cxx @@ -46,6 +46,36 @@ StatusCode SCTErrMonAlg::initialize() { } StatusCode SCTErrMonAlg::fillHistograms(const EventContext& ctx) const { + SG::ReadHandle<xAOD::EventInfo> pEvent{m_EventInfoKey, ctx}; + if (not pEvent.isValid()) { + ATH_MSG_WARNING("Could not retrieve event info!"); + return StatusCode::SUCCESS; + } + + bool sctFlag{false}; + if (pEvent->errorState(xAOD::EventInfo::SCT) == xAOD::EventInfo::Error) { + sctFlag = true; + } + /// Fill NumberOfSCTFlagErrorsVsLB, NumberOfEventsVsLB and FractionOfSCTFlagErrorsPerLB + /// under /SCT/GENERAL/Conf/ /// + auto lumiBlockAcc{Monitored::Scalar<int>("lumiBlock", pEvent->lumiBlock())}; + auto is1DAcc{Monitored::Scalar<bool>("is1D", true)}; + auto sctFlagAcc{Monitored::Scalar<bool>("sctFlag", sctFlag)}; + fill("SCTErrMonitor", lumiBlockAcc, is1DAcc, sctFlagAcc); + + if (sctFlag) { + return StatusCode::SUCCESS; + } + + // The numbers of disabled modules, links, strips do not change during a run. + if (m_isFirstConfigurationDetails) { + std::lock_guard{m_mutex}; + if (m_isFirstConfigurationDetails) { + ATH_CHECK(fillConfigurationDetails(ctx)); + m_isFirstConfigurationDetails = false; + } + } + ATH_CHECK(fillByteStreamErrors(ctx)); /// Fill /SCT/GENERAL/Conf/SCTConfOutM /// @@ -70,16 +100,84 @@ StatusCode SCTErrMonAlg::fillHistograms(const EventContext& ctx) const { return StatusCode::SUCCESS; } +StatusCode +SCTErrMonAlg::fillConfigurationDetails(const EventContext& ctx) const { + ATH_MSG_DEBUG("Inside fillConfigurationDetails()"); + unsigned int nBadMods{static_cast<unsigned int>(m_configurationTool->badModules()->size())}; // bad modules + const map<IdentifierHash, pair<bool, bool>>* badLinks{m_configurationTool->badLinks(ctx)}; // bad links + unsigned int nBadLink0{0}, nBadLink1{0}, nBadLinkBoth{0}; + for (const pair<IdentifierHash, pair<bool, bool>>& link: *badLinks) { + pair<bool, bool> status{link.second}; + if ((status.first == false) and (status.second == true)) { + ++nBadLink0; + } + if ((status.first == true) and (status.second == false)) { + ++nBadLink1; + } + if ((status.first == false) and (status.second == false)) { + ++nBadLinkBoth; + } + } + + const map<Identifier, unsigned int>* badChips{m_configurationTool->badChips(ctx)}; // bad chips + unsigned int nBadChips{0}; + for (const pair<Identifier, unsigned int>& chip : *badChips) { + unsigned int status{chip.second}; + for (unsigned int i{0}; i < CHIPS_PER_MODULE; i++) { + nBadChips += ((status & (1 << i)) == 0 ? 0 : 1); + } + } + + set<Identifier> badStripsAll; // bad strips + m_configurationTool->badStrips(badStripsAll, ctx); + unsigned int nBadStrips{static_cast<unsigned int>(badStripsAll.size())}; + + set<Identifier> badStripsExclusive; // bad strips w/o bad modules and chips + m_configurationTool->badStrips(badStripsExclusive, ctx, true, true); + int nBadStripsExclusive{static_cast<int>(badStripsExclusive.size())}; + int nBadStripsExclusiveBEC[N_REGIONS] = { + 0, 0, 0 + }; + for (const Identifier& strip: badStripsExclusive) { + int bec{m_pSCTHelper->barrel_ec(strip)}; + nBadStripsExclusiveBEC[bec2Index(bec)] += 1; + } + + /// Fill /SCT/GENERAL/Conf/SCTConfDetails /// + auto detailedConfBinAcc{Monitored::Scalar<int>("detailedConfBin")}; + auto nBadAcc{Monitored::Scalar<double>("nBad")}; + for (unsigned int i{0}; i<ConfbinsDetailed; i++) { + detailedConfBinAcc = 0; + if (i==0) nBadAcc = nBadMods; + else if (i==1) nBadAcc = nBadLink0; + else if (i==2) nBadAcc = nBadLink1; + else if (i==3) nBadAcc = nBadChips; + else if (i==4) nBadAcc = static_cast<double>(nBadStripsExclusive) / 100.; + fill("SCTErrMonitor", detailedConfBinAcc, nBadAcc); + } + + ATH_MSG_DEBUG("-----------------------------------------------------------------------"); + ATH_MSG_DEBUG("Number of bad modules = " << nBadMods); + ATH_MSG_DEBUG("Number of bad link 0 = " << nBadLink0); + ATH_MSG_DEBUG("Number of bad link 1 = " << nBadLink1); + ATH_MSG_DEBUG("Number of bad link both = " << nBadLinkBoth); + ATH_MSG_DEBUG("Number of bad chips = " << nBadChips); + ATH_MSG_DEBUG("Number of bad strips = " << nBadStrips); + ATH_MSG_DEBUG("Number of bad strips exclusive = " << nBadStripsExclusive); + ATH_MSG_DEBUG("Number of bad strips exclusive (ECC, B, ECA) = " + << nBadStripsExclusiveBEC[ENDCAP_C_INDEX] << ", " + << nBadStripsExclusiveBEC[BARREL_INDEX] << ", " + << nBadStripsExclusiveBEC[ENDCAP_A_INDEX] << ", "); + ATH_MSG_DEBUG("-----------------------------------------------------------------------"); + + return StatusCode::SUCCESS; +} + StatusCode SCTErrMonAlg::fillByteStreamErrors(const EventContext& ctx) const { - //--- Get event information SG::ReadHandle<xAOD::EventInfo> pEvent{m_EventInfoKey, ctx}; if (not pEvent.isValid()) { - ATH_MSG_ERROR("Could not retrieve event info!"); - return StatusCode::RECOVERABLE; - } - - if (pEvent->errorState(xAOD::EventInfo::SCT) == xAOD::EventInfo::Error) { + ATH_MSG_WARNING("Could not retrieve event info!"); return StatusCode::SUCCESS; } @@ -94,11 +192,20 @@ SCTErrMonAlg::fillByteStreamErrors(const EventContext& ctx) const { fill("SCTErrMonitor", lumiBlockAcc, nBSErrorsAcc); } + std::array<int, CategoryErrors::N_ERRCATEGORY> tot_mod_bytestreamCate_errs; + tot_mod_bytestreamCate_errs.fill(0); int total_errors{0}; for (int errType{0}; errType < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++errType) { - total_errors += fillByteStreamErrorsHelper(m_byteStreamErrTool->getErrorSet(errType), errType); + total_errors += fillByteStreamErrorsHelper(m_byteStreamErrTool->getErrorSet(errType), errType, tot_mod_bytestreamCate_errs); } - + /// Fill /SCT/GENERAL/errors/SCT_LinksWith*VsLbs /// + for (int errCate{0}; errCate < CategoryErrors::N_ERRCATEGORY; ++errCate) { + auto lumiBlockAcc{Monitored::Scalar<int>("lumiBlock", pEvent->lumiBlock())}; + auto nCategoryErrorsAcc{Monitored::Scalar<int>("n_"+CategoryErrorsNames[errCate], + tot_mod_bytestreamCate_errs[errCate])}; + fill("SCTErrMonitor", lumiBlockAcc, nCategoryErrorsAcc); + } + if (m_coverageCheck) { ATH_MSG_INFO("Detector Coverage calculation starts" ); @@ -162,7 +269,8 @@ SCTErrMonAlg::fillByteStreamErrors(const EventContext& ctx) const { int SCTErrMonAlg::fillByteStreamErrorsHelper(const set<IdentifierHash>& errors, - int err_type) const { + int err_type, + std::array<int, CategoryErrors::N_ERRCATEGORY>& tot_mod_bytestreamCate_errs) const { //--- Check categories of the BS error bool b_category[CategoryErrors::N_ERRCATEGORY]; @@ -264,6 +372,10 @@ SCTErrMonAlg::fillByteStreamErrorsHelper(const set<IdentifierHash>& errors, } } + for (int errCate{0}; errCate < CategoryErrors::N_ERRCATEGORY; ++errCate) { + if (b_category[errCate]) tot_mod_bytestreamCate_errs[errCate]++; + } + if (b_category[CategoryErrors::SUMMARY]) return nerrors; return 0; } diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.h b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.h index c0356b1287e52a61f0ef16678dd06ebe359853ca..5677754e3991886374b716e6c5d062327efb47d0 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.h +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.h @@ -16,6 +16,8 @@ #include "SCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h" #include "SCT_ConditionsTools/ISCT_DCSConditionsTool.h" +#include <atomic> +#include <mutex> #include <utility> #include <vector> @@ -40,6 +42,9 @@ class SCTErrMonAlg : public AthMonitorAlgorithm { std::vector<moduleGeo_t> m_geo{}; + mutable std::atomic_bool m_isFirstConfigurationDetails{true}; + mutable std::mutex m_mutex{}; + BooleanProperty m_makeConfHisto{this, "MakeConfHisto", true}; BooleanProperty m_coverageCheck{this, "CoverageCheck", true}; BooleanProperty m_useDCS{this, "UseDCS", true}; @@ -53,10 +58,12 @@ class SCTErrMonAlg : public AthMonitorAlgorithm { const SCT_ID* m_pSCTHelper{nullptr}; /// Used in fillHistograms() + StatusCode fillConfigurationDetails(const EventContext& ctx) const; StatusCode fillByteStreamErrors(const EventContext& ctx) const; /// Used in fillByteStreamErrors() int fillByteStreamErrorsHelper(const std::set<IdentifierHash>& errors, - int err_type) const; + int err_type, + std::array<int, SCT_Monitoring::CategoryErrors::N_ERRCATEGORY>& tot_mod_bytestreamCate_errs) const; void numByteStreamErrors(const std::set<IdentifierHash>& errors, int& ntot) const; bool disabledSCT(std::set<IdentifierHash>& sctHashDisabled) const; bool errorSCT(std::set<IdentifierHash>& sctHashBadLinkError, diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.cxx b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.cxx index 3d2950fb3709004dd10e073f1c9fb3e7ca6b4d06..7f5dc970447bd36ba2060325820bf6914043d778 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.cxx +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.cxx @@ -1186,9 +1186,9 @@ SCTErrMonTool::fillConfigurationDetails() { ATH_MSG_DEBUG("Number of bad strips = " << nBadStrips); ATH_MSG_DEBUG("Number of bad strips exclusive = " << nBadStripsExclusive); ATH_MSG_DEBUG("Number of bad strips exclusive (ECC, B, ECA) = " - << nBadStripsExclusiveBEC[0] << ", " - << nBadStripsExclusiveBEC[1] << ", " - << nBadStripsExclusiveBEC[2] << ", "); + << nBadStripsExclusiveBEC[ENDCAP_C_INDEX] << ", " + << nBadStripsExclusiveBEC[BARREL_INDEX] << ", " + << nBadStripsExclusiveBEC[ENDCAP_A_INDEX] << ", "); ATH_MSG_DEBUG("-----------------------------------------------------------------------"); return StatusCode::SUCCESS;