ATLAS Offline Software
InDetGlobalErrorMonTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //Local
7 
10 
12 
15 
16 #include "TH2F.h"
17 
19  const std::string & name,
20  const IInterface* parent):
22  m_pixID( nullptr ),
23  m_sctID( nullptr ),
24  m_errorGeoPixel(),
25  m_disabledGeoPixel(),
26  m_errorGeoSCT(),
27  m_disabledGeoSCT(),
28  m_disabledModulesMapPixel( nullptr ),
29  m_disabledModulesMapSCT( nullptr ),
30  m_badModulesMapPixel(nullptr),
31  m_errorModulesMapPixel(nullptr),
32  m_errorModulesMapSCT(nullptr),
33  m_totalModulesMapPixel(nullptr),
34  m_totalModulesMapSCT(nullptr),
35  m_totalModulesMapSi(nullptr),
36  m_c_nBinsEta( 200 ),
37  m_c_rangeEta( 2.5 ),
38  m_c_nBinsPhi( 200 )
39 {
40 }
41 
43 
44  if (detStore()->retrieve(m_pixID, "PixelID").isFailure()){
45  msg(MSG::ERROR) << "Could not retrieve Pixel ID helper" << endmsg;
46  return StatusCode::FAILURE;
47  }
48  if (detStore()->retrieve(m_sctID, "SCT_ID").isFailure()){
49  msg(MSG::ERROR) << "Could not retrieve SCT ID helper" << endmsg;
50  return StatusCode::FAILURE;
51  }
52 
54 
55  ATH_CHECK(m_ConfigurationTool.retrieve());
56  ATH_CHECK(m_byteStreamErrTool.retrieve());
57 
60 
62 }
63 
64 
65 /*---------------------------------------------------------*/
67 {
68  MonGroup monGr_shift( this, "InDetGlobal/Track/DeadModules", run, ATTRIB_UNMANAGED );
69 
70  bool status = true;
71  if ( newRunFlag() )
72  {
73  m_disabledModulesMapPixel = new TH2F( "disabledModulesMapPixel", "Map of disabled modules for Pixel",
75  m_c_nBinsPhi, -M_PI, M_PI );
76 
77  m_disabledModulesMapSCT = new TH2F( "disabledModulesMapSCT", "Map of disabled modules for SCT",
79  m_c_nBinsPhi, -M_PI, M_PI );
80 
81  m_badModulesMapPixel = new TH2F( "badModulesMapPixel", "Map of bad modules for Pixel",
83  m_c_nBinsPhi, -M_PI, M_PI );
84 
85  m_errorModulesMapPixel = new TH2F( "errorModulesMapPixel", "Map of modules in error for Pixel",
87  m_c_nBinsPhi, -M_PI, M_PI );
88 
89  m_errorModulesMapSCT = new TH2F( "errorModulesMapSCT", "Map of bad modules for SCT",
91  m_c_nBinsPhi, -M_PI, M_PI );
92 
93  m_totalModulesMapPixel = new TH2F( "totalModulesMapPixel", "Map of all bad and disabled modules for Pixel",
95  m_c_nBinsPhi, -M_PI, M_PI );
96 
97  m_totalModulesMapSCT = new TH2F( "totalModulesMapSCT", "Map of all bad and disabled modules for SCT",
99  m_c_nBinsPhi, -M_PI, M_PI );
100 
101  m_totalModulesMapSi = new TH2F( "totalModulesMapSi", "Map of all bad and disabled modules for Pixel and SCT",
103  m_c_nBinsPhi, -M_PI, M_PI );
104 
105  status &= monGr_shift.regHist( m_disabledModulesMapPixel ).isSuccess();
106  status &= monGr_shift.regHist( m_errorModulesMapPixel ).isSuccess();
107  status &= monGr_shift.regHist( m_disabledModulesMapSCT ).isSuccess();
108  status &= monGr_shift.regHist( m_errorModulesMapSCT ).isSuccess();
109  status &= monGr_shift.regHist( m_totalModulesMapPixel ).isSuccess();
110  status &= monGr_shift.regHist( m_totalModulesMapSCT ).isSuccess();
111  status &= monGr_shift.regHist( m_totalModulesMapSi ).isSuccess();
112  }
113 
114  return ( status ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
115 }
116 
117 /*---------------------------------------------------------*/
119 {
120  return StatusCode::SUCCESS;
121 }
122 
124 {
126  {
127  m_disabledModulesMapPixel->Reset("ICE");
128  m_errorModulesMapPixel->Reset("ICE");
129  m_badModulesMapPixel->Reset("ICE");
130  m_totalModulesMapPixel->Reset("ICE");
131  m_disabledModulesMapSCT->Reset("ICE");
132  m_errorModulesMapSCT->Reset("ICE");
133  m_totalModulesMapSCT->Reset("ICE");
134  m_totalModulesMapSi->Reset("ICE");
135 
136  SyncPixel();
137  SyncErrorSCT();
138  SyncDisabledSCT();
139 
140  {
143  while (currIt != currEnd) {
144  FillModule( (*currIt).second, m_disabledModulesMapPixel );
145  ++currIt;
146  }
147  }
148 
149  {
150  geoContainer_t::iterator currIt = m_errorGeoPixel.begin();
152  while (currIt != currEnd) {
153  FillModule( (*currIt).second, m_badModulesMapPixel );
154  ++currIt;
155  }
156  }
157 
160 
161  {
164  while (currIt != currEnd) {
165  FillModule( (*currIt).second, m_disabledModulesMapSCT );
166  ++currIt;
167  }
168  }
169 
170  {
171  geoContainer_t::iterator currIt = m_errorGeoSCT.begin();
172  geoContainer_t::iterator currEnd = m_errorGeoSCT.end();
173  while (currIt != currEnd) {
174  FillModule( (*currIt).second, m_errorModulesMapSCT );
175  ++currIt;
176  }
177  }
178 
181 
184  }
185  return StatusCode::SUCCESS;
186 }
187 
189 {
190  unsigned int lowX = 0;
191  unsigned int highX = 0;
192  unsigned int lowY = 0;
193  unsigned int highY = 0;
194  double area = 0.;
195 
196  double widthEta = 2. * m_c_rangeEta / m_c_nBinsEta;
197  double widthPhi = 2. * M_PI / m_c_nBinsPhi;
198  double edgesEta[200], centerEta[200],
199  edgesPhi[200], centerPhi[200];
200 
201  histo->GetXaxis()->GetLowEdge(edgesEta);
202  histo->GetXaxis()->GetCenter(centerEta);
203  histo->GetYaxis()->GetLowEdge(edgesPhi);
204  histo->GetYaxis()->GetCenter(centerPhi);
205 
206  for ( unsigned int i = 0; i < m_c_nBinsEta; i++ )
207  if ( edgesEta[i] + widthEta > module.first.first )
208  {
209  lowX = i;
210  break;
211  }
212  for ( unsigned int i = lowX; i < m_c_nBinsEta; i++ )
213  if ( edgesEta[i] > module.first.second )
214  {
215  highX = i;
216  break;
217  }
218  for ( unsigned int i = 0; i < m_c_nBinsPhi; i++ )
219  if ( edgesPhi[i] + widthPhi > module.second.first )
220  {
221  lowY = i;
222  break;
223  }
224  for ( unsigned int i = lowY; i < m_c_nBinsPhi; i++ )
225  if ( edgesPhi[i] > module.second.second )
226  {
227  highY = i;
228  break;
229  }
230  for ( unsigned int i = lowX; i < highX; i++ )
231  for ( unsigned int j = lowY; j < highY; j++ )
232  {
233  area = (
234  ((( module.first.second < edgesEta[i] + widthEta ) ? module.first.second : (edgesEta[i] + widthEta) ) -
235  ( ( module.first.first > edgesEta[i] ) ? module.first.first : edgesEta[i] ) ) *
236  ((( module.second.second < edgesPhi[j] + widthPhi ) ? module.second.second : (edgesPhi[j] + widthPhi) ) -
237  ( ( module.second.first > edgesPhi[j] ) ? module.second.first : edgesPhi[j] ) )
238  ) / ( widthEta * widthPhi );
239  histo->Fill( centerEta[i], centerPhi[j], area );
240  }
241  }
242 
244 {
245  double rz = 0;
246  double deltaZ = 0;
247 
248  m_errorGeoSCT.clear();
249  const EventContext& ctx{Gaudi::Hive::currentContext()};
251  const InDetDD::SiDetectorElementCollection* elements(sctDetEle.retrieve());
252  if (elements==nullptr) {
253  ATH_MSG_ERROR(m_SCTDetEleCollKey.fullKey() << " could not be retrieved in SyncErrorSCT()");
254  return false;
255  }
256 
257  for ( unsigned int i = 0; i < SCT_ByteStreamErrors::NUM_ERROR_TYPES; i++ )
258  {
259  const std::set<IdentifierHash> sctErrors = m_byteStreamErrTool->getErrorSet( i, ctx );
260  // Check that all modules are registered
261  for(const auto& idHash : sctErrors) {
262  // The module is already registered, no need to do something
263  if ( m_errorGeoSCT.count( idHash ) )
264  continue;
265  else
266  {
267  moduleGeo_t moduleGeo;
268 
269  const InDetDD::SiDetectorElement * newElement = elements->getDetectorElement( idHash );
270  newElement->getEtaPhiRegion( deltaZ,
271  moduleGeo.first.first, moduleGeo.first.second,
272  moduleGeo.second.first, moduleGeo.second.second,
273  rz );
274  m_errorGeoSCT.insert( std::make_pair( idHash, moduleGeo ) );
275  }
276  }
277  }
278 
279  return true;
280 }
281 
283 {
284  double rz = 0;
285  double deltaZ = 0;
286 
287  m_errorGeoPixel.clear();
288  m_disabledGeoPixel.clear();
289  const EventContext& ctx{Gaudi::Hive::currentContext()};
291  const InDetDD::SiDetectorElementCollection* elements(pixelDetEle.retrieve());
292  if (elements==nullptr) {
293  ATH_MSG_ERROR(m_pixelDetEleCollKey.fullKey() << " could not be retrieved in SyncDisabledPixel()");
294  return false;
295  }
296 
299 
300  // Check that all modules are registered
301  for (; fit != fitEnd; ++fit)
302  {
303  IdentifierHash waferHash = m_pixID->wafer_hash((*fit));
304 
305  // Inactive module, flagging time!
306  if ( !m_pixelCondSummaryTool->isActive( waferHash, ctx ) )
307  {
308  moduleGeo_t moduleGeo;
309 
310  const InDetDD::SiDetectorElement * newElement = elements->getDetectorElement( waferHash );
311  newElement->getEtaPhiRegion( deltaZ,
312  moduleGeo.first.first, moduleGeo.first.second,
313  moduleGeo.second.first, moduleGeo.second.second,
314  rz );
315 
316  m_disabledGeoPixel.insert( std::pair<IdentifierHash, moduleGeo_t>( waferHash, moduleGeo ) );
317 
318  }
319  // Bad module, flagging time!
320  if ( m_pixelCondSummaryTool->isActive( waferHash, ctx ) && !m_pixelCondSummaryTool->isGood( waferHash, ctx ) )
321  {
322  moduleGeo_t moduleGeo;
323 
324  const InDetDD::SiDetectorElement * newElement = elements->getDetectorElement( waferHash );
325  newElement->getEtaPhiRegion( deltaZ,
326  moduleGeo.first.first, moduleGeo.first.second,
327  moduleGeo.second.first, moduleGeo.second.second,
328  rz );
329 
330  m_errorGeoPixel.insert( std::pair<IdentifierHash, moduleGeo_t>( waferHash, moduleGeo ) );
331  }
332  }
333 
334  return true;
335 }
336 
338 {
339  bool altered = false;
340  double rz = 0;
341  double deltaZ = 0;
342 
343  m_disabledGeoSCT.clear();
344 
346  const InDetDD::SiDetectorElementCollection* elements(sctDetEle.retrieve());
347  if (elements==nullptr) {
348  ATH_MSG_ERROR(m_SCTDetEleCollKey.fullKey() << " could not be retrieved in SyncDisabledSCT()");
349  return false;
350  }
351 
352  const std::set<Identifier>* badModules = m_ConfigurationTool->badModules();
353  std::set<Identifier>::const_iterator fit = badModules->begin();
354  std::set<Identifier>::const_iterator fitEnd = badModules->end();
355 
356  // Check that all modules are registered
357  for (; fit != fitEnd; ++fit)
358  {
359  // The module is already registered, no need to do something
360  if ( m_disabledGeoSCT.count( (*fit) ) )
361  continue;
362  else
363  {
364  altered = true;
365  moduleGeo_t moduleGeo;
366 
367  const IdentifierHash waferHash = m_sctID->wafer_hash( (*fit) );
368 
369  const InDetDD::SiDetectorElement * newElement = elements->getDetectorElement( waferHash );
370  newElement->getEtaPhiRegion( deltaZ,
371  moduleGeo.first.first, moduleGeo.first.second,
372  moduleGeo.second.first, moduleGeo.second.second,
373  rz );
374 
375  m_disabledGeoSCT.insert( std::pair<Identifier, moduleGeo_t>( (*fit), moduleGeo ) );
376  }
377  }
378 
379  return altered;
380 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
InDetGlobalErrorMonTool::m_disabledGeoPixel
geoContainer_t m_disabledGeoPixel
Definition: InDetGlobalErrorMonTool.h:65
InDetGlobalErrorMonTool::m_disabledModulesMapPixel
TH2F * m_disabledModulesMapPixel
Definition: InDetGlobalErrorMonTool.h:69
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
PixelID::const_id_iterator
std::vector< Identifier >::const_iterator const_id_iterator
Definition: PixelID.h:72
PixelID::wafer_end
const_id_iterator wafer_end(void) const
Definition: PixelID.cxx:925
InDetGlobalErrorMonTool::initialize
virtual StatusCode initialize()
Definition: InDetGlobalErrorMonTool.cxx:42
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
InDetGlobalErrorMonTool::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: InDetGlobalErrorMonTool.h:62
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
TH2F
Definition: rootspy.cxx:420
InDetGlobalErrorMonTool::m_ConfigurationTool
ToolHandle< ISCT_ConfigurationConditionsTool > m_ConfigurationTool
Definition: InDetGlobalErrorMonTool.h:57
ManagedMonitorToolBase::endOfLumiBlockFlag
bool endOfLumiBlockFlag() const
Definition: ManagedMonitorToolBase.h:858
InDetGlobalErrorMonTool::bookHistogramsRecurrent
virtual StatusCode bookHistogramsRecurrent()
An inheriting class should either override this function, bookHists() or bookHistograms().
Definition: InDetGlobalErrorMonTool.cxx:66
InDetGlobalErrorMonTool::m_disabledGeoSCT
geoContainerPure_t m_disabledGeoSCT
Definition: InDetGlobalErrorMonTool.h:67
InDetGlobalErrorMonTool::m_pixID
const PixelID * m_pixID
Definition: InDetGlobalErrorMonTool.h:53
PixelID::wafer_begin
const_id_iterator wafer_begin(void) const
Iterators over full set of ids. Wafer iterator is sorted.
Definition: PixelID.cxx:921
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDetGlobalErrorMonTool::SyncPixel
bool SyncPixel()
Definition: InDetGlobalErrorMonTool.cxx:282
InDetGlobalErrorMonTool::InDetGlobalErrorMonTool
InDetGlobalErrorMonTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: InDetGlobalErrorMonTool.cxx:18
InDetGlobalErrorMonTool::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: InDetGlobalErrorMonTool.h:61
InDetGlobalErrorMonTool::m_totalModulesMapSi
TH2F * m_totalModulesMapSi
Definition: InDetGlobalErrorMonTool.h:76
InDetDD::SolidStateDetectorElementBase::getEtaPhiRegion
void getEtaPhiRegion(double deltaZ, double &etaMin, double &etaMax, double &phiMin, double &phiMax, double &rz) const
Method for building up region of interest table.
Definition: SolidStateDetectorElementBase.cxx:140
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
ReadCondHandle.h
InDetGlobalErrorMonTool::m_c_nBinsPhi
const unsigned int m_c_nBinsPhi
Definition: InDetGlobalErrorMonTool.h:80
InDetGlobalErrorMonTool::m_disabledModulesMapSCT
TH2F * m_disabledModulesMapSCT
Definition: InDetGlobalErrorMonTool.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
python.PyAthena.module
module
Definition: PyAthena.py:134
InDetGlobalErrorMonTool::m_errorGeoPixel
geoContainer_t m_errorGeoPixel
Definition: InDetGlobalErrorMonTool.h:64
InDetGlobalErrorMonTool::m_totalModulesMapPixel
TH2F * m_totalModulesMapPixel
Definition: InDetGlobalErrorMonTool.h:74
ManagedMonitorToolBase::MonGroup
A container of information describing a monitoring object.
Definition: ManagedMonitorToolBase.h:138
PixelID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: PixelID.h:387
PixelDetectorManager.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadCondHandle::retrieve
const_pointer_type retrieve()
Definition: ReadCondHandle.h:161
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:669
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDetGlobalErrorMonTool::m_sctID
const SCT_ID * m_sctID
Definition: InDetGlobalErrorMonTool.h:54
InDetGlobalErrorMonTool.h
ManagedMonitorToolBase::ATTRIB_UNMANAGED
@ ATTRIB_UNMANAGED
Definition: ManagedMonitorToolBase.h:131
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDetGlobalErrorMonTool::procHistograms
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
Definition: InDetGlobalErrorMonTool.cxx:123
run
Definition: run.py:1
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
InDetGlobalErrorMonTool::m_errorGeoSCT
geoContainer_t m_errorGeoSCT
Definition: InDetGlobalErrorMonTool.h:66
InDetGlobalErrorMonTool::SyncErrorSCT
bool SyncErrorSCT()
Definition: InDetGlobalErrorMonTool.cxx:243
InDetGlobalErrorMonTool::m_errorModulesMapPixel
TH2F * m_errorModulesMapPixel
Definition: InDetGlobalErrorMonTool.h:72
InDetGlobalErrorMonTool::m_byteStreamErrTool
ToolHandle< ISCT_ByteStreamErrorsTool > m_byteStreamErrTool
Definition: InDetGlobalErrorMonTool.h:59
ManagedMonitorToolBase::MonGroup::regHist
StatusCode regHist(TH1 *h)
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
Definition: ManagedMonitorToolBase.cxx:195
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
InDetGlobalErrorMonTool::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: InDetGlobalErrorMonTool.cxx:118
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetGlobalErrorMonTool::m_totalModulesMapSCT
TH2F * m_totalModulesMapSCT
Definition: InDetGlobalErrorMonTool.h:75
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDetGlobalErrorMonTool::m_errorModulesMapSCT
TH2F * m_errorModulesMapSCT
Definition: InDetGlobalErrorMonTool.h:73
SiDetectorElement.h
InDetGlobalErrorMonTool::moduleGeo_t
std::pair< std::pair< double, double >, std::pair< double, double > > moduleGeo_t
Definition: InDetGlobalErrorMonTool.h:28
SCT_FlaggedCondEnum::NUM_ERROR_TYPES
@ NUM_ERROR_TYPES
Definition: SCT_FlaggedCondEnum.h:28
ManagedMonitorToolBase::endOfRunFlag
bool endOfRunFlag() const
Definition: ManagedMonitorToolBase.h:859
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDetGlobalErrorMonTool::FillModule
void FillModule(moduleGeo_t module, TH2F *histo) const
Definition: InDetGlobalErrorMonTool.cxx:188
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
InDetGlobalErrorMonTool::m_pixelCondSummaryTool
ToolHandle< IInDetConditionsTool > m_pixelCondSummaryTool
Definition: InDetGlobalErrorMonTool.h:56
InDetGlobalErrorMonTool::m_c_nBinsEta
const unsigned int m_c_nBinsEta
Definition: InDetGlobalErrorMonTool.h:78
InDetGlobalErrorMonTool::m_badModulesMapPixel
TH2F * m_badModulesMapPixel
Definition: InDetGlobalErrorMonTool.h:71
merge.status
status
Definition: merge.py:17
AthenaMonManager::lumiBlockNumber
static unsigned int lumiBlockNumber()
Definition: AthenaMonManager.cxx:352
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
IdentifierHash
Definition: IdentifierHash.h:38
makeComparison.deltaZ
int deltaZ
Definition: makeComparison.py:46
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
InDetGlobalErrorMonTool::m_c_rangeEta
const float m_c_rangeEta
Definition: InDetGlobalErrorMonTool.h:79
InDetGlobalErrorMonTool::SyncDisabledSCT
bool SyncDisabledSCT()
Definition: InDetGlobalErrorMonTool.cxx:337
ManagedMonitorToolBase::newRunFlag
bool newRunFlag() const
Definition: ManagedMonitorToolBase.h:854