ATLAS Offline Software
SiDetectorElementStatus.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
5 #include <stdexcept>
6 #include <sstream>
7 
8 #ifdef DO_VALIDATE_STATUS_ARRAY
9 #include "GaudiKernel/ThreadLocalContext.h"
10 #include <iostream>
11 namespace dbg {
12  void break_point( bool input1, bool input2, const char *label) {
13  const EventContext& ctx = Gaudi::Hive::currentContext();
14  std::cout << "DEBUG " << ctx.evt() << " " << "inconsistent information:" << input1 << " != " << input2 << " = " << label << std::endl;
15  }
16  void break_point( double input1, double input2, const char *label) {
17  const EventContext& ctx = Gaudi::Hive::currentContext();
18  std::cout << "DEBUG " << ctx.evt() << " " << "inconsistent information:" << input1 << " != " << input2 << " = " << label << std::endl;
19  }
20  void break_point( uint64_t input1, uint64_t input2, const char *label) {
21  const EventContext& ctx = Gaudi::Hive::currentContext();
22  std::cout << "DEBUG " << ctx.evt() << " " << "inconsistent information:" << input1 << " != " << input2 << " = " << label << std::endl;
23  }
24 }
25 #endif
26 
27 namespace InDet {
29  if ( (!getElementStatus().empty() && !b.getElementStatus().empty() && getElementStatus().size() != b.getElementStatus().size())
30  || (!getElementChipStatus().empty() && !b.getElementChipStatus().empty() && getElementChipStatus().size() != b.getElementChipStatus().size())) {
31  std::stringstream msg;
32  msg << "Status array sizes do not match:"
33  << getElementStatus().size() << " != " << b.getElementStatus().size() << " || "
34  << getElementChipStatus().size() << " != " << b.getElementChipStatus().size();
35  throw std::runtime_error(msg.str());
36  }
37 
38  if (!getElementStatus().empty() && !b.getElementStatus().empty()) {
39  for (std::size_t elm_i=0; elm_i < m_elementStatus.size(); ++elm_i) {
40  m_elementStatus[elm_i] = m_elementStatus[elm_i] && b.m_elementStatus[elm_i];
41  }
42  }
43  else if (!b.getElementStatus().empty()) {
44  m_elementStatus = b.m_elementStatus;
45  }
46 
47  if (!getElementChipStatus().empty() && !b.getElementChipStatus().empty()) {
48  for (std::size_t elm_i=0; elm_i < m_elementChipStatus.size(); ++elm_i) {
49  m_elementChipStatus[elm_i] &= b.m_elementChipStatus[elm_i];
50  }
51  }
52  else if (!b.getElementChipStatus().empty()) {
53  m_elementChipStatus = b.m_elementChipStatus;
54  }
55  if (&getBadCells() != &b.getBadCells()) {
56  if (!m_owner) notOwningBadCells();
57  if (!getBadCells().empty() && !b.getBadCells().empty()) {
58  unsigned int element_i=0;
59  for (const std::vector<unsigned short> &bad_module_strips : b.getBadCells()) {
60  std::vector<unsigned short> &dest = (*m_badCells)[element_i];
61  if (dest.empty()) {
62  dest=bad_module_strips;
63  }
64  else {
65  for (unsigned int bad_strip : bad_module_strips) {
66  std::vector<unsigned short>::const_iterator iter = std::lower_bound(dest.begin(),dest.end(),bad_strip);
67  if (iter == dest.end() || *iter != bad_strip) {
68  dest.insert( iter, bad_strip);
69  }
70  }
71  }
72  ++element_i;
73  }
74  }
75  else if (!b.getBadCells().empty()){
76  *m_badCells = b.getBadCells();
77  }
78  }
79  return *this;
80  }
81 
82  void SiDetectorElementStatus::notOwningBadCells() { throw std::logic_error("Bad cells not owned by this instance, cannot return non const bad cell pointer."); }
83 } // namespace InDetDD
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
InDet::SiDetectorElementStatus::m_elementChipStatus
std::vector< ChipFlags_t > m_elementChipStatus
Definition: SiDetectorElementStatus.h:138
SiDetectorElementStatus.h
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::SiDetectorElementStatus::m_elementStatus
std::vector< bool > m_elementStatus
Definition: SiDetectorElementStatus.h:137
InDet::SiDetectorElementStatus::m_badCells
std::vector< std::vector< unsigned short > > * m_badCells
Definition: SiDetectorElementStatus.h:139
InDet::SiDetectorElementStatus::getBadCells
const std::vector< std::vector< unsigned short > > & getBadCells() const
Definition: SiDetectorElementStatus.h:120
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
skel.input1
tuple input1
Definition: skel.GENtoEVGEN.py:750
InDet::SiDetectorElementStatus::merge
SiDetectorElementStatus & merge(const SiDetectorElementStatus &a)
bitwise AND of module and chip status bits.
Definition: SiDetectorElementStatus.cxx:28
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
InDet::SiDetectorElementStatus::notOwningBadCells
static void notOwningBadCells()
Definition: SiDetectorElementStatus.cxx:82
dbg
Definition: SGImplSvc.cxx:69
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
InDet::SiDetectorElementStatus::m_owner
bool m_owner
Definition: SiDetectorElementStatus.h:140
InDet::SiDetectorElementStatus::getElementChipStatus
const std::vector< ChipFlags_t > & getElementChipStatus() const
Definition: SiDetectorElementStatus.h:118
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7