ATLAS Offline Software
SCTErrMonAlg.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef SCTERRMONALG_H
8 #define SCTERRMONALG_H
9 
11 
13 
20 
21 #include "TH2F.h"
22 
23 #include <array>
24 #include <atomic>
25 #include <mutex>
26 #include <utility>
27 #include <vector>
28 
29 class SCT_ID;
30 
32  public:
33  SCTErrMonAlg(const std::string& name, ISvcLocator* pSvcLocator);
34  virtual ~SCTErrMonAlg() = default;
35  virtual StatusCode initialize() override final;
36  virtual StatusCode fillHistograms(const EventContext& ctx) const override final;
37  virtual StatusCode stop() override final;
38 
39  private:
40  // First pair is eta and second pair is phi.
41  // First element of pair is minimum second is maximum.
42  typedef std::pair<std::pair<double, double>, std::pair<double, double>> moduleGeo_t;
43  class categoryErrorMap_t : public std::array<std::array<std::array<std::array<std::array<bool,
46  // 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
47  public:
49  for (int iCat{0}; iCat<SCT_Monitoring::N_ERRCATEGORY; iCat++) {
50  for (int iReg{0}; iReg<SCT_Monitoring::N_REGIONS; iReg++) {
51  for (int iLay{0}; iLay<SCT_Monitoring::N_ENDCAPSx2; iLay++) {
52  for (int iEta{0}; iEta<SCT_Monitoring::N_ETA_BINS; iEta++) {
53  (*this)[iCat][iReg][iLay][iEta].fill(false);
54  }
55  }
56  }
57  }
58  };
59  int count(int errCate) {
60  int cnt{0};
61  for (int iReg{0}; iReg<SCT_Monitoring::N_REGIONS; iReg++) {
62  for (int iLay{0}; iLay<SCT_Monitoring::N_ENDCAPSx2; iLay++) {
63  for (int iEta{0}; iEta<SCT_Monitoring::N_ETA_BINS; iEta++) {
64  for (int iPhi{0}; iPhi<SCT_Monitoring::N_PHI_BINS; iPhi++) {
65  if ((*this)[errCate][iReg][iLay][iEta][iPhi]) cnt++;
66  }
67  }
68  }
69  }
70  return cnt;
71  }
72  };
73 
74  struct CacheEntry {
75  EventContext::ContextEvt_t m_evt{EventContext::INVALID_CONTEXT_EVT};
76  std::vector<TH2F> m_mapSCT;
77  };
78 
79  static const unsigned int s_nBinsEta;
80  static const double s_rangeEta;
81  static const unsigned int s_nBinsPhi;
82  static const double s_wafersThreshold;
83 
84  std::vector<moduleGeo_t> m_geo{};
85 
86  mutable std::atomic_bool m_isFirstConfigurationDetails{true};
87  mutable std::mutex m_mutex{};
88  mutable SG::SlotSpecificObj<CacheEntry> m_cache ATLAS_THREAD_SAFE; // Guarded by m_mutex
89  mutable std::array<std::atomic_int, SCT_Monitoring::N_REGIONS_INC_GENERAL> m_nMaskedLinks ATLAS_THREAD_SAFE {};
90  // For coverage check because it is time consuming and run at the first event of each lumi block.
91  mutable std::set<uint32_t> m_procLB ATLAS_THREAD_SAFE;//Used to find new LB, and fill only once per LB
92 
93  BooleanProperty m_makeConfHisto{this, "MakeConfHisto", true};
94  BooleanProperty m_coverageCheck{this, "CoverageCheck", true};
95  BooleanProperty m_coverageCheckOnlyFirtsEventOfLB{this, "CoverageCheckOnlyFirtsEventOfLB", true};
96  BooleanProperty m_useDCS{this, "UseDCS", true};
97  BooleanProperty m_doPerLumiErrors{this, "DoPerLumiErrors", true, "Do lumi block 2D error histos"};
98  BooleanProperty m_doOnline{this, "doOnlineMon", false};
99 
100  ToolHandle<ISCT_ByteStreamErrorsTool> m_byteStreamErrTool{this, "SCT_ByteStreamErrorsTool", "SCT_ByteStreamErrorsTool/SCT_ByteStreamErrorsTool", "Tool to retrieve SCT ByteStream Errors"};
101  ToolHandle<ISCT_ConfigurationConditionsTool> m_configurationTool{this, "conditionsTool", "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration Tool"};
102  ToolHandle<ISCT_DCSConditionsTool> m_dcsTool{this, "SCT_DCSConditionsTool", "SCT_DCSConditionsTool/InDetSCT_DCSConditionsTool", "Tool to retrieve SCT DCS information"};
103  ToolHandle<IInDetConditionsTool> m_pSummaryTool{this, "SCT_ConditionsSummaryTool", "SCT_ConditionsSummaryTool/InDetSCT_ConditionsSummaryTool", "Tool to retrieve SCT Conditions summary"};
104  ToolHandle<ISCT_FlaggedConditionTool> m_flaggedTool{this, "SCT_FlaggedConditionTool", "SCT_FlaggedConditionTool/InDetSCT_FlaggedConditionTool", "Tool to retrieve bad wafers with many fired strips"};
105 
106  const SCT_ID* m_pSCTHelper{nullptr};
107 
109  StatusCode fillConfigurationDetails(const EventContext& ctx) const;
110  StatusCode fillByteStreamErrors(const EventContext& ctx) const;
112  int fillByteStreamErrorsHelper(const std::set<IdentifierHash>& errors,
113  int err_type,
114  categoryErrorMap_t& categoryErrorMap,
115  std::array<int, SCT_Monitoring::N_REGIONS_INC_GENERAL>& nMaskedLinks) const;
116  void numByteStreamErrors(const std::set<IdentifierHash>& errors, int& ntot) const;
117  bool disabledSCT(std::set<IdentifierHash>& sctHashDisabled) const;
118  bool errorSCT(std::set<IdentifierHash>& sctHashBadLinkError,
119  std::set<IdentifierHash>& sctHashBadRODError,
120  std::set<IdentifierHash>& sctHashBadError) const;
121  bool summarySCT(std::set<IdentifierHash>& sctHashAll, std::set<IdentifierHash>& sctHashSummary) const;
122  bool psTripDCSSCT(std::set<IdentifierHash>& sctHashPSTripDCS, float& PSTripModules) const;
123  void fillWafer(moduleGeo_t module, TH2F& histo) const;
124  double calculateDetectorCoverage(const TH2F& histo, const TH2F& histoAll) const;
125 };
126 
127 #endif // SCTERRMONALG_H
SCTErrMonAlg::categoryErrorMap_t
Definition: SCTErrMonAlg.h:45
ISCT_ByteStreamErrorsTool.h
SCTErrMonAlg::moduleGeo_t
std::pair< std::pair< double, double >, std::pair< double, double > > moduleGeo_t
Definition: SCTErrMonAlg.h:42
SCTErrMonAlg::m_isFirstConfigurationDetails
std::atomic_bool m_isFirstConfigurationDetails
Definition: SCTErrMonAlg.h:86
SCT_Monitoring::N_REGIONS
@ N_REGIONS
Definition: SCT_MonitoringNumbers.h:19
SCTErrMonAlg::categoryErrorMap_t::count
int count(int errCate)
Definition: SCTErrMonAlg.h:59
IInDetConditionsTool.h
SCT_Monitoring::N_ENDCAPSx2
@ N_ENDCAPSx2
Definition: SCT_MonitoringNumbers.h:46
SCTErrMonAlg::m_dcsTool
ToolHandle< ISCT_DCSConditionsTool > m_dcsTool
Definition: SCTErrMonAlg.h:102
SCTErrMonAlg::m_pSummaryTool
ToolHandle< IInDetConditionsTool > m_pSummaryTool
Definition: SCTErrMonAlg.h:103
SCT_ConditionsData::N_REGIONS
@ N_REGIONS
Definition: SCT_ConditionsParameters.h:28
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ISCT_FlaggedConditionTool.h
SCT_Monitoring::N_ERRCATEGORY
@ N_ERRCATEGORY
Definition: SCT_MonitoringNumbers.h:54
SCTErrMonAlg::fillByteStreamErrorsHelper
int fillByteStreamErrorsHelper(const std::set< IdentifierHash > &errors, int err_type, categoryErrorMap_t &categoryErrorMap, std::array< int, SCT_Monitoring::N_REGIONS_INC_GENERAL > &nMaskedLinks) const
Used in fillByteStreamErrors()
Definition: SCTErrMonAlg.cxx:386
SCTErrMonAlg::fillWafer
void fillWafer(moduleGeo_t module, TH2F &histo) const
Definition: SCTErrMonAlg.cxx:652
SCTErrMonAlg::errorSCT
bool errorSCT(std::set< IdentifierHash > &sctHashBadLinkError, std::set< IdentifierHash > &sctHashBadRODError, std::set< IdentifierHash > &sctHashBadError) const
Definition: SCTErrMonAlg.cxx:581
SCTErrMonAlg::m_pSCTHelper
const SCT_ID * m_pSCTHelper
Definition: SCTErrMonAlg.h:106
SCTErrMonAlg::CacheEntry
Definition: SCTErrMonAlg.h:74
SCTErrMonAlg::psTripDCSSCT
bool psTripDCSSCT(std::set< IdentifierHash > &sctHashPSTripDCS, float &PSTripModules) const
Definition: SCTErrMonAlg.cxx:634
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
SCTErrMonAlg::~SCTErrMonAlg
virtual ~SCTErrMonAlg()=default
SCTErrMonAlg::CacheEntry::m_mapSCT
std::vector< TH2F > m_mapSCT
Definition: SCTErrMonAlg.h:76
SCT_Monitoring
Definition: SCT_MonitoringNumbers.h:17
SCTErrMonAlg::disabledSCT
bool disabledSCT(std::set< IdentifierHash > &sctHashDisabled) const
Definition: SCTErrMonAlg.cxx:565
SCT_Monitoring::N_PHI_BINS
@ N_PHI_BINS
Definition: SCT_MonitoringNumbers.h:42
SCTErrMonAlg::categoryErrorMap_t::categoryErrorMap_t
categoryErrorMap_t()
Definition: SCTErrMonAlg.h:48
SCTErrMonAlg::m_mutex
std::mutex m_mutex
Definition: SCTErrMonAlg.h:87
SCTErrMonAlg::s_wafersThreshold
static const double s_wafersThreshold
Definition: SCTErrMonAlg.h:82
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
SCTErrMonAlg::m_geo
std::vector< moduleGeo_t > m_geo
Definition: SCTErrMonAlg.h:84
python.PyAthena.module
module
Definition: PyAthena.py:131
SCTErrMonAlg::m_doPerLumiErrors
BooleanProperty m_doPerLumiErrors
Definition: SCTErrMonAlg.h:97
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
SCTErrMonAlg::stop
virtual StatusCode stop() override final
Definition: SCTErrMonAlg.cxx:140
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthMonitorAlgorithm.h
SCTErrMonAlg::fillByteStreamErrors
StatusCode fillByteStreamErrors(const EventContext &ctx) const
Definition: SCTErrMonAlg.cxx:226
SCTErrMonAlg::ATLAS_THREAD_SAFE
SG::SlotSpecificObj< CacheEntry > m_cache ATLAS_THREAD_SAFE
Definition: SCTErrMonAlg.h:88
SCTErrMonAlg
Definition: SCTErrMonAlg.py:1
SCTErrMonAlg::numByteStreamErrors
void numByteStreamErrors(const std::set< IdentifierHash > &errors, int &ntot) const
Definition: SCTErrMonAlg.cxx:557
SCTErrMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override final
adds event to the monitoring histograms
Definition: SCTErrMonAlg.cxx:50
SCTErrMonAlg::m_doOnline
BooleanProperty m_doOnline
Definition: SCTErrMonAlg.h:98
SCTErrMonAlg::summarySCT
bool summarySCT(std::set< IdentifierHash > &sctHashAll, std::set< IdentifierHash > &sctHashSummary) const
Definition: SCTErrMonAlg.cxx:615
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
lumiFormat.array
array
Definition: lumiFormat.py:91
SCTErrMonAlg::m_coverageCheck
BooleanProperty m_coverageCheck
Definition: SCTErrMonAlg.h:94
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SCTErrMonAlg::s_nBinsEta
static const unsigned int s_nBinsEta
Definition: SCTErrMonAlg.h:79
SCT_MonitoringNumbers.h
SCT_Monitoring::N_ETA_BINS
@ N_ETA_BINS
Definition: SCT_MonitoringNumbers.h:41
ISCT_ConfigurationConditionsTool.h
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
SCTErrMonAlg::m_flaggedTool
ToolHandle< ISCT_FlaggedConditionTool > m_flaggedTool
Definition: SCTErrMonAlg.h:104
SCT_ID
Definition: SCT_ID.h:68
SCTErrMonAlg::s_rangeEta
static const double s_rangeEta
Definition: SCTErrMonAlg.h:80
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
SCTErrMonAlg::calculateDetectorCoverage
double calculateDetectorCoverage(const TH2F &histo, const TH2F &histoAll) const
Definition: SCTErrMonAlg.cxx:698
SCTErrMonAlg::fillConfigurationDetails
StatusCode fillConfigurationDetails(const EventContext &ctx) const
Used in fillHistograms()
Definition: SCTErrMonAlg.cxx:151
SCTErrMonAlg::m_coverageCheckOnlyFirtsEventOfLB
BooleanProperty m_coverageCheckOnlyFirtsEventOfLB
Definition: SCTErrMonAlg.h:95
SCTErrMonAlg::m_byteStreamErrTool
ToolHandle< ISCT_ByteStreamErrorsTool > m_byteStreamErrTool
Definition: SCTErrMonAlg.h:100
SlotSpecificObj.h
Maintain a set of objects, one per slot.
SCTErrMonAlg::SCTErrMonAlg
SCTErrMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCTErrMonAlg.cxx:14
SCTErrMonAlg::m_useDCS
BooleanProperty m_useDCS
Definition: SCTErrMonAlg.h:96
SCTErrMonAlg::m_configurationTool
ToolHandle< ISCT_ConfigurationConditionsTool > m_configurationTool
Definition: SCTErrMonAlg.h:101
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:74
SCTErrMonAlg::ATLAS_THREAD_SAFE
std::set< uint32_t > m_procLB ATLAS_THREAD_SAFE
Definition: SCTErrMonAlg.h:91
SCTErrMonAlg::m_makeConfHisto
BooleanProperty m_makeConfHisto
Definition: SCTErrMonAlg.h:93
ISCT_DCSConditionsTool.h
SCTErrMonAlg::initialize
virtual StatusCode initialize() override final
initialize
Definition: SCTErrMonAlg.cxx:21
SCTErrMonAlg::CacheEntry::m_evt
EventContext::ContextEvt_t m_evt
Definition: SCTErrMonAlg.h:75
SCTErrMonAlg::s_nBinsPhi
static const unsigned int s_nBinsPhi
Definition: SCTErrMonAlg.h:81