diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringSCT.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringSCT.py index 152892dd0226e784fc429a1becdae1bd3462a69a..c990379888124b30eb207fa3a2509e3db75765da 100755 --- a/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringSCT.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetMonitoringSCT.py @@ -27,27 +27,27 @@ InDetSCTHitsTool = SCTHitsNoiseMonTool ( name = "InDetSCTHitsNoiseMonTool", if (InDetFlags.doPrintConfigurables()): printfunc (InDetSCTHitsTool) -from SCT_Monitoring.SCT_MonitoringConf import SCTErrMonTool -InDetSCTErrMonTool = SCTErrMonTool ( name = "InDetSCTErrMonTool", - OutputLevel = 4, - histoPathBase = "/stat", - UseDCS = InDetFlags.useDCS() ) -if InDetFlags.useDCS(): - from SCT_ConditionsTools.SCT_DCSConditionsToolSetup import SCT_DCSConditionsToolSetup - sct_DCSConditionsToolSetup = SCT_DCSConditionsToolSetup() - sct_DCSConditionsToolSetup.setup() - InDetSCTErrMonTool.SCT_DCSConditionsTool = sct_DCSConditionsToolSetup.getTool() -else: - InDetSCTErrMonTool.SCT_DCSConditionsTool = None +if not useNewAlgs: + from SCT_Monitoring.SCT_MonitoringConf import SCTErrMonTool + InDetSCTErrMonTool = SCTErrMonTool ( name = "InDetSCTErrMonTool", + OutputLevel = 4, + histoPathBase = "/stat", + UseDCS = InDetFlags.useDCS() ) + if InDetFlags.useDCS(): + from SCT_ConditionsTools.SCT_DCSConditionsToolSetup import SCT_DCSConditionsToolSetup + sct_DCSConditionsToolSetup = SCT_DCSConditionsToolSetup() + sct_DCSConditionsToolSetup.setup() + InDetSCTErrMonTool.SCT_DCSConditionsTool = sct_DCSConditionsToolSetup.getTool() + else: + InDetSCTErrMonTool.SCT_DCSConditionsTool = None -if jobproperties.Beam.beamType()=='collisions': - from AthenaMonitoring.FilledBunchFilterTool import GetFilledBunchFilterTool - InDetSCTErrMonTool.FilterTools += [GetFilledBunchFilterTool()] + if jobproperties.Beam.beamType()=='collisions': + from AthenaMonitoring.FilledBunchFilterTool import GetFilledBunchFilterTool + InDetSCTErrMonTool.FilterTools += [GetFilledBunchFilterTool()] -if (InDetFlags.doPrintConfigurables()): - printfunc (InDetSCTErrMonTool) + if (InDetFlags.doPrintConfigurables()): + printfunc (InDetSCTErrMonTool) -if not useNewAlgs: from SCT_Monitoring.SCT_MonitoringConf import SCTTracksMonTool InDetSCTTracksMonTool = SCTTracksMonTool ( name = "InDetSCTTracksMonTool", OutputLevel = 4, @@ -116,16 +116,16 @@ InDetSCTMonMan = AthenaMonManager("InDetSCTMonManager", Run = DQMonFlags.monManRun(), LumiBlock = DQMonFlags.monManLumiBlock(), AthenaMonTools = [ InDetSCTHitsTool, - InDetSCTErrMonTool ] ) if useNewAlgs: - # include("SCT_Monitoring/SCTErrMonAlg_jobOptions.py") + include("SCT_Monitoring/SCTErrMonAlg_jobOptions.py") include("SCT_Monitoring/SCTHitEffMonAlg_jobOptions.py") include("SCT_Monitoring/SCTLorentzMonAlg_jobOptions.py") include("SCT_Monitoring/SCTTracksMonAlg_jobOptions.py") else: + InDetSCTMonMan.AthenaMonTools += [ InDetSCTErrMonTool ] InDetSCTMonMan.AthenaMonTools += [ InDetSCTHitEffMonTool ] InDetSCTMonMan.AthenaMonTools += [ InDetSCTLorentzMonTool ] InDetSCTMonMan.AthenaMonTools += [ InDetSCTTracksMonTool ] diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h b/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h index 11ac1182f3f45888fcafe2c511c40a5fedb7acaa..c1ce3e6aa6d7a5d8eb884ed296522d17fabbdb00 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/SCT_Monitoring/SCT_MonitoringNumbers.h @@ -18,7 +18,7 @@ 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, 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, GENERAL=3, INVALID_SYSTEM=4}; + 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 @@ -27,7 +27,7 @@ namespace SCT_Monitoring{ } ///Conversion index->bec inline Bec index2Bec(const unsigned int i) { - return (i < 4) ? (index2BecArray[i]) : INVALID_SYSTEM; + return i < N_REGIONS_INC_GENERAL ? (index2BecArray[i]) : INVALID_SYSTEM; } ///Numbers to use in histograms diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py b/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py index e58ca7db2efaeda6e8b495304dd91fa12fd0e94b..a94c1047ce69b4578029a5a2d08b5f4d13c81143 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/share/SCTErrMonAlg_jobOptions.py @@ -105,6 +105,22 @@ for i in range(sctMon.N_ERRCATEGORY): xmin = 0.5, xmax = sctMon.NBINS_LBs+0.5) +# Filled in fillByteStreamErrors +for errCate in range(sctMon.N_ERRCATEGORY): + for region in range(sctMon.N_REGIONS): + for layer in range(sctMon.N_ENDCAPSx2): + myMonGroup.defineHistogram(varname = "eta, phi, hasError_"+sctMon.CategoryErrorsNames[errCate]+"_"+sctMon.subDetNameShort[region].Data()+"_"+str(layer/2)+"_"+str(layer%2)+";SCT_NumberOf"+sctMon.CategoryErrorsNames[errCate]+sctMon.subDetNameShort[region].Data()+"_"+str(layer/2)+"_"+str(layer%2), + type = "TProfile2D", + title = "Num of "+sctMon.CategoryErrorsNames[errCate]+" per "+sctMon.layerName[region].Data()+str(layer/2)+"_"+str(layer%2), + path = "SCT"+sctMon.subDetNameShort[region].Data()+"/errors/"+sctMon.CategoryErrorsNames[errCate], + xbins = sctMon.N_ETA_BINS if region==sctMon.BARREL_INDEX else sctMon.N_ETA_BINS_EC, + xmin = (sctMon.FIRST_ETA_BIN if region==sctMon.BARREL_INDEX else sctMon.FIRST_ETA_BIN_EC)-0.5, + xmax = (sctMon.LAST_ETA_BIN if region==sctMon.BARREL_INDEX else sctMon.LAST_ETA_BIN_EC)+0.5, + ybins = sctMon.N_PHI_BINS if region==sctMon.BARREL_INDEX else sctMon.N_PHI_BINS_EC, + ymin = (sctMon.FIRST_PHI_BIN if region==sctMon.BARREL_INDEX else sctMon.FIRST_PHI_BIN_EC)-0.5, + ymax = (sctMon.LAST_PHI_BIN if region==sctMon.BARREL_INDEX else sctMon.LAST_PHI_BIN_EC)+0.5, + duration = "lb") + # 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 66777500eca0a2b6a2bf38aa08f754afd05b312b..289386b064b5be4b6f13d73f3d1077daaec573ad 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.cxx +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.cxx @@ -42,6 +42,26 @@ StatusCode SCTErrMonAlg::initialize() { m_geo[i] = moduleGeo; } + // Fill existing wafers + m_indicesVector.reserve(maxHash); + SCT_ID::const_id_iterator waferIterator{m_pSCTHelper->wafer_begin()}; + SCT_ID::const_id_iterator waferEnd{m_pSCTHelper->wafer_end()}; + for (; waferIterator not_eq waferEnd; ++waferIterator) { + const Identifier waferId{*waferIterator}; + int layer{m_pSCTHelper->layer_disk(waferId)}; + int side{m_pSCTHelper->side(waferId)}; + int barrel_ec{m_pSCTHelper->barrel_ec(waferId)}; + int ieta{m_pSCTHelper->eta_module(waferId)}; + int iphi{m_pSCTHelper->phi_module(waferId)}; + layer = layer * 2 + side; + int regionIndex{GENERAL_INDEX}; + if ((barrel_ec == BARREL) and (layer >= 0) and (layer < N_BARRELSx2)) regionIndex = BARREL_INDEX; + else if (barrel_ec == ENDCAP_A) regionIndex = ENDCAP_A_INDEX; + else if (barrel_ec == ENDCAP_C) regionIndex = ENDCAP_C_INDEX; + else continue; + m_indicesVector.push_back(indices_t{regionIndex, layer, ieta, iphi}); + } + return AthMonitorAlgorithm::initialize(); } @@ -147,7 +167,7 @@ SCTErrMonAlg::fillConfigurationDetails(const EventContext& ctx) const { auto detailedConfBinAcc{Monitored::Scalar<int>("detailedConfBin")}; auto nBadAcc{Monitored::Scalar<double>("nBad")}; for (unsigned int i{0}; i<ConfbinsDetailed; i++) { - detailedConfBinAcc = 0; + detailedConfBinAcc = i; if (i==0) nBadAcc = nBadMods; else if (i==1) nBadAcc = nBadLink0; else if (i==2) nBadAcc = nBadLink1; @@ -192,18 +212,29 @@ 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); + categoryErrorMap_t categoryErrorMap; int total_errors{0}; for (int errType{0}; errType < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++errType) { - total_errors += fillByteStreamErrorsHelper(m_byteStreamErrTool->getErrorSet(errType), errType, tot_mod_bytestreamCate_errs); + total_errors += fillByteStreamErrorsHelper(m_byteStreamErrTool->getErrorSet(errType), errType, categoryErrorMap); } /// 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])}; + categoryErrorMap.count(errCate))}; fill("SCTErrMonitor", lumiBlockAcc, nCategoryErrorsAcc); + + for (const indices_t& indices : m_indicesVector) { + const int region{indices[REGIONINDEX]}; + const int layer{indices[LAYERINDEX]}; + const int eta{indices[ETAINDEX]}; + const int phi{indices[PHIINDEX]}; + auto etaAcc{Monitored::Scalar<int>("eta", eta)}; + auto phiAcc{Monitored::Scalar<int>("phi", phi)}; + auto hasErrorAcc{Monitored::Scalar<bool>("hasError_"+CategoryErrorsNames[errCate]+"_"+subDetNameShort[region].Data()+"_"+to_string(layer/2)+"_"+to_string(layer%2), + categoryErrorMap[errCate][region][layer][eta][phi])}; + fill("SCTErrMonitor", etaAcc, phiAcc, hasErrorAcc); + } } if (m_coverageCheck) { @@ -270,10 +301,10 @@ SCTErrMonAlg::fillByteStreamErrors(const EventContext& ctx) const { int SCTErrMonAlg::fillByteStreamErrorsHelper(const set<IdentifierHash>& errors, int err_type, - std::array<int, CategoryErrors::N_ERRCATEGORY>& tot_mod_bytestreamCate_errs) const { - + categoryErrorMap_t& categoryErrorMap) const { //--- Check categories of the BS error - bool b_category[CategoryErrors::N_ERRCATEGORY]; + std::array<bool, CategoryErrors::N_ERRCATEGORY> b_category; + b_category.fill(false); b_category[CategoryErrors::MASKEDLINKALL] = (err_type == SCT_ByteStreamErrors::MaskedLink) or (err_type == SCT_ByteStreamErrors::MaskedROD); @@ -325,10 +356,12 @@ SCTErrMonAlg::fillByteStreamErrorsHelper(const set<IdentifierHash>& errors, if (not hash.is_valid()) continue; //--- FIll module information with BS error - Identifier fitId{m_pSCTHelper->wafer_id(hash)}; + const Identifier fitId{m_pSCTHelper->wafer_id(hash)}; int layer{m_pSCTHelper->layer_disk(fitId)}; int side{m_pSCTHelper->side(fitId)}; int barrel_ec{m_pSCTHelper->barrel_ec(fitId)}; + int ieta{m_pSCTHelper->eta_module(fitId)}; + int iphi{m_pSCTHelper->phi_module(fitId)}; layer = layer * 2 + side; // barrel_ec = {ENDCAP_C=-2, BARREL=0, ENDCAP_A=2} // -> regionIndex = {ENDCAP_C_INDEX=0, BARREL_INDEX=1, ENDCAP_A_INDEX=2, GENERAL_INDEX=3} @@ -345,6 +378,12 @@ SCTErrMonAlg::fillByteStreamErrorsHelper(const set<IdentifierHash>& errors, } if (m_doPerLumiErrors) numErrorsPerLumi[regionIndex][layer]++; + + for (int errCate{0}; errCate < CategoryErrors::N_ERRCATEGORY; ++errCate) { + if (b_category[errCate] and regionIndex!=GENERAL_INDEX) { + categoryErrorMap[errCate][regionIndex][layer][ieta][iphi] = true; + } + } } /// Fill /SCT/GENERAL/errors/Masked Links /// @@ -372,10 +411,6 @@ 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 5677754e3991886374b716e6c5d062327efb47d0..0050bd2f25e9e5444fa81838196929218eb4a30b 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.h +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonAlg.h @@ -16,6 +16,7 @@ #include "SCT_ConditionsTools/ISCT_ConfigurationConditionsTool.h" #include "SCT_ConditionsTools/ISCT_DCSConditionsTool.h" +#include <array> #include <atomic> #include <mutex> #include <utility> @@ -34,12 +35,46 @@ class SCTErrMonAlg : public AthMonitorAlgorithm { // First pair is eta and second pair is phi. // First element of pair is minimum second is maximum. typedef std::pair<std::pair<double, double>, std::pair<double, double>> moduleGeo_t; + class categoryErrorMap_t : public std::array<std::array<std::array<std::array<std::array<bool, + SCT_Monitoring::N_PHI_BINS>, SCT_Monitoring::N_ETA_BINS>, SCT_Monitoring::N_ENDCAPSx2>, + SCT_Monitoring::N_REGIONS>, SCT_Monitoring::N_ERRCATEGORY> { + // N_PHI_BINS=56 > N_PHI_BINS_EC=52, N_ETA_BINS=13 > N_ETA_BINS_EC=3, N_ENDCAPSx2=18 > N_BARRELSx2=8 defined in SCT_MonitoringNumbers.h + public: + categoryErrorMap_t() { + for (int iCat{0}; iCat<SCT_Monitoring::N_ERRCATEGORY; iCat++) { + for (int iReg{0}; iReg<SCT_Monitoring::N_REGIONS; iReg++) { + for (int iLay{0}; iLay<SCT_Monitoring::N_ENDCAPSx2; iLay++) { + for (int iEta{0}; iEta<SCT_Monitoring::N_ETA_BINS; iEta++) { + (*this)[iCat][iReg][iLay][iEta].fill(false); + } + } + } + } + }; + int count(int errCate) { + int cnt{0}; + for (int iReg{0}; iReg<SCT_Monitoring::N_REGIONS; iReg++) { + for (int iLay{0}; iLay<SCT_Monitoring::N_ENDCAPSx2; iLay++) { + for (int iEta{0}; iEta<SCT_Monitoring::N_ETA_BINS; iEta++) { + for (int iPhi{0}; iPhi<SCT_Monitoring::N_PHI_BINS; iPhi++) { + if ((*this)[errCate][iReg][iLay][iEta][iPhi]) cnt++; + } + } + } + } + return cnt; + } + }; + enum {REGIONINDEX, LAYERINDEX, ETAINDEX, PHIINDEX, NINDICES}; + typedef std::array<int, NINDICES> indices_t; + typedef std::vector<indices_t> indicesVector_t; static const unsigned int s_nBinsEta; static const double s_rangeEta; static const unsigned int s_nBinsPhi; static const double s_wafersThreshold; + indicesVector_t m_indicesVector{}; std::vector<moduleGeo_t> m_geo{}; mutable std::atomic_bool m_isFirstConfigurationDetails{true}; @@ -63,7 +98,7 @@ class SCTErrMonAlg : public AthMonitorAlgorithm { /// Used in fillByteStreamErrors() int fillByteStreamErrorsHelper(const std::set<IdentifierHash>& errors, int err_type, - std::array<int, SCT_Monitoring::CategoryErrors::N_ERRCATEGORY>& tot_mod_bytestreamCate_errs) const; + categoryErrorMap_t& categoryErrorMap) 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.h b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.h index 926a7565aa07951d425e270548eff8961a53be46..a172bc54517ce331a77a374b87a40df33af3addb 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.h +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/src/SCTErrMonTool.h @@ -146,7 +146,7 @@ class SCTErrMonTool : public ManagedMonitorToolBase { // Unnecessary but necessary to fill necessary m_ConfNew /// Under LB directories // total number of errors - TH2F_LW* m_pallErrsCate[SCT_ByteStreamErrors::NUM_ERROR_TYPES][SCT_Monitoring::N_REGIONS][SCT_Monitoring::N_ENDCAPSx2]{}; // Filled in fillByteStreamErrorsHelper. Used to fill m_allErrsCate and m_summaryErrsRecent + TH2F_LW* m_pallErrsCate[SCT_Monitoring::CategoryErrors::N_ERRCATEGORY][SCT_Monitoring::N_REGIONS][SCT_Monitoring::N_ENDCAPSx2]{}; // Filled in fillByteStreamErrorsHelper. Used to fill m_allErrsCate and m_summaryErrsRecent // Default histos to print per lumi block TH2F_LW* m_numErrorsPerLumi[SCT_Monitoring::N_REGIONS_INC_GENERAL]{}; // Filled in fillByteStreamErrorsHelper. Used to fill m_rateErrorsPerLumi /// Detector coverage @@ -158,7 +158,7 @@ class SCTErrMonTool : public ManagedMonitorToolBase { TProfile_LW* m_ConfNew{}; // Filled in fillCondDBMaps using m_MaskedAllLinks and m_allErrsCate. Noise plots are also used. TProfile_LW* m_LinksWithCategorisedErrorsVsLB[SCT_Monitoring::CategoryErrors::N_ERRCATEGORY]{}; // Fillded in fillByteStreamErrors using m_pallErrsCate /// Under LB directories - TProfile2D_LW* m_allErrsCate[SCT_ByteStreamErrors::NUM_ERROR_TYPES][SCT_Monitoring::N_REGIONS][SCT_Monitoring::N_ENDCAPSx2]{}; // Rate of errors. Filled in fillByteStreamErrors. Used to fill necessary m_ConfNew + TProfile2D_LW* m_allErrsCate[SCT_Monitoring::CategoryErrors::N_ERRCATEGORY][SCT_Monitoring::N_REGIONS][SCT_Monitoring::N_ENDCAPSx2]{}; // Rate of errors. Filled in fillByteStreamErrors. Used to fill necessary m_ConfNew TProfile2D_LW* m_rateErrorsPerLumi[SCT_Monitoring::N_REGIONS]{}; // Filled in checkRateHists using m_numErrorsPerLumi /// Only online TProfile_LW* m_ConfOnline[SCT_Monitoring::N_REGIONS_INC_GENERAL]{}; // Filled in fillCondDBMaps using m_MaskedAllLinks and m_allErrsCate