ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
InDet::SiDetectorElementStatus Class Referenceabstract

#include <SiDetectorElementStatus.h>

Inheritance diagram for InDet::SiDetectorElementStatus:
Collaboration diagram for InDet::SiDetectorElementStatus:

Public Member Functions

 SiDetectorElementStatus (const InDetDD::SiDetectorElementCollection &detector_elements)
 
 SiDetectorElementStatus (const SiDetectorElementStatus &si_detector_element_status)
 
 SiDetectorElementStatus (const InDetDD::SiDetectorElementCollection &detector_elements, const std::vector< std::vector< unsigned short > > &bad_cells)
 
virtual ~SiDetectorElementStatus ()
 
SiDetectorElementStatusoperator= (const SiDetectorElementStatus &)=delete
 
unsigned int numberOfChips (const IdentifierHash &hash) const
 
const InDetDD::SiDetectorElementgetDetectorElement (const IdentifierHash &hash) const
 
const std::vector< InDetDD::SiDetectorElement * > & getDetectorElements () const
 
bool isGood (IdentifierHash hash) const
 
bool isChipGood (IdentifierHash hash, unsigned int chip) const
 
bool isCellGood (IdentifierHash hash, unsigned short cell_i) const
 
SiDetectorElementStatusmerge (const SiDetectorElementStatus &a)
 bitwise AND of module and chip status bits. More...
 
const std::vector< bool > & getElementStatus () const
 
std::vector< bool > & getElementStatus ()
 
const std::vector< ChipFlags_t > & getElementChipStatus () const
 
std::vector< ChipFlags_t > & getElementChipStatus ()
 
const std::vector< std::vector< unsigned short > > & getBadCells () const
 
std::vector< std::vector< unsigned short > > & getBadCells ()
 Get a non-const bad cells container owned by this instance. More...
 

Protected Member Functions

virtual unsigned int numberOfChips (const InDetDD::SiDetectorDesign &design) const =0
 

Private Member Functions

void copyBadCells ()
 

Static Private Member Functions

static void notOwningBadCells ()
 

Private Attributes

const InDetDD::SiDetectorElementCollectionm_detectorElements = nullptr
 
std::vector< bool > m_elementStatus
 
std::vector< ChipFlags_tm_elementChipStatus
 
std::vector< std::vector< unsigned short > > * m_badCells = nullptr
 
bool m_owner = false
 

Detailed Description

Definition at line 62 of file SiDetectorElementStatus.h.

Constructor & Destructor Documentation

◆ SiDetectorElementStatus() [1/3]

InDet::SiDetectorElementStatus::SiDetectorElementStatus ( const InDetDD::SiDetectorElementCollection detector_elements)
inline

Definition at line 64 of file SiDetectorElementStatus.h.

65  : m_detectorElements(&detector_elements), m_badCells(new std::vector<std::vector<unsigned short> >()), m_owner(true) {}

◆ SiDetectorElementStatus() [2/3]

InDet::SiDetectorElementStatus::SiDetectorElementStatus ( const SiDetectorElementStatus si_detector_element_status)
inline

Definition at line 67 of file SiDetectorElementStatus.h.

68  : m_detectorElements(si_detector_element_status.m_detectorElements),
69  m_elementStatus( si_detector_element_status.m_elementStatus ),
70  m_elementChipStatus( si_detector_element_status.m_elementChipStatus ),
71  // cppcheck-suppress copyCtorPointerCopying
72  m_badCells( si_detector_element_status.m_badCells ),
73  m_owner( false )
74  {
75  }

◆ SiDetectorElementStatus() [3/3]

InDet::SiDetectorElementStatus::SiDetectorElementStatus ( const InDetDD::SiDetectorElementCollection detector_elements,
const std::vector< std::vector< unsigned short > > &  bad_cells 
)
inline

Definition at line 77 of file SiDetectorElementStatus.h.

79  : m_detectorElements(&detector_elements),
80  m_badCells(const_cast<std::vector<std::vector<unsigned short> > *>(&bad_cells)), // const_cast but not owned object treated as const.
81  m_owner(false)
82  {}

◆ ~SiDetectorElementStatus()

virtual InDet::SiDetectorElementStatus::~SiDetectorElementStatus ( )
inlinevirtual

Definition at line 84 of file SiDetectorElementStatus.h.

84 { if (m_owner) delete m_badCells; }

Member Function Documentation

◆ copyBadCells()

void InDet::SiDetectorElementStatus::copyBadCells ( )
inlineprivate

Definition at line 131 of file SiDetectorElementStatus.h.

131  {
132  m_badCells = new std::vector<std::vector<unsigned short> > (*m_badCells);
133  m_owner=true;
134  }

◆ getBadCells() [1/2]

std::vector<std::vector<unsigned short> >& InDet::SiDetectorElementStatus::getBadCells ( )
inline

Get a non-const bad cells container owned by this instance.

Will create a copy of the bad cells container if it is not owned by this instance.

Definition at line 125 of file SiDetectorElementStatus.h.

125 { if (!m_owner) { copyBadCells(); } return *m_badCells; }

◆ getBadCells() [2/2]

const std::vector<std::vector<unsigned short> >& InDet::SiDetectorElementStatus::getBadCells ( ) const
inline

Definition at line 120 of file SiDetectorElementStatus.h.

120 { return *m_badCells; }

◆ getDetectorElement()

const InDetDD::SiDetectorElement* InDet::SiDetectorElementStatus::getDetectorElement ( const IdentifierHash hash) const
inline

Definition at line 91 of file SiDetectorElementStatus.h.

91  {
92  return m_detectorElements->at(hash.value());
93  }

◆ getDetectorElements()

const std::vector<InDetDD::SiDetectorElement*>& InDet::SiDetectorElementStatus::getDetectorElements ( ) const
inline

Definition at line 94 of file SiDetectorElementStatus.h.

94  {
95  return *m_detectorElements;
96  }

◆ getElementChipStatus() [1/2]

std::vector<ChipFlags_t>& InDet::SiDetectorElementStatus::getElementChipStatus ( )
inline

Definition at line 119 of file SiDetectorElementStatus.h.

119 { return m_elementChipStatus; }

◆ getElementChipStatus() [2/2]

const std::vector<ChipFlags_t>& InDet::SiDetectorElementStatus::getElementChipStatus ( ) const
inline

Definition at line 118 of file SiDetectorElementStatus.h.

118 { return m_elementChipStatus; }

◆ getElementStatus() [1/2]

std::vector<bool>& InDet::SiDetectorElementStatus::getElementStatus ( )
inline

Definition at line 117 of file SiDetectorElementStatus.h.

117 { return m_elementStatus; }

◆ getElementStatus() [2/2]

const std::vector<bool>& InDet::SiDetectorElementStatus::getElementStatus ( ) const
inline

Definition at line 116 of file SiDetectorElementStatus.h.

116 { return m_elementStatus; }

◆ isCellGood()

bool InDet::SiDetectorElementStatus::isCellGood ( IdentifierHash  hash,
unsigned short  cell_i 
) const
inline

Definition at line 107 of file SiDetectorElementStatus.h.

107  {
108  const std::vector<unsigned short> &bad_cells= std::as_const(m_badCells)->at(hash);
109  return !std::binary_search(bad_cells.begin(),bad_cells.end(),cell_i);
110  }

◆ isChipGood()

bool InDet::SiDetectorElementStatus::isChipGood ( IdentifierHash  hash,
unsigned int  chip 
) const
inline

Definition at line 100 of file SiDetectorElementStatus.h.

100  {
101 #ifndef NDEBUG
102  assert( m_elementStatus.empty() || (chip < numberOfChips(hash) && ((1<<(numberOfChips(hash)-1) ) <= std::numeric_limits<ChipFlags_t>::max())));
103 #endif
104  return m_elementChipStatus.empty() || m_elementChipStatus.at(hash.value()) & (1<<chip);
105  }

◆ isGood()

bool InDet::SiDetectorElementStatus::isGood ( IdentifierHash  hash) const
inline

Definition at line 97 of file SiDetectorElementStatus.h.

97  {
98  return m_elementStatus.at(hash.value());
99  }

◆ merge()

SiDetectorElementStatus & InDet::SiDetectorElementStatus::merge ( const SiDetectorElementStatus a)

bitwise AND of module and chip status bits.

Definition at line 28 of file SiDetectorElementStatus.cxx.

28  {
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  }

◆ notOwningBadCells()

void InDet::SiDetectorElementStatus::notOwningBadCells ( )
staticprivate

Definition at line 82 of file SiDetectorElementStatus.cxx.

82 { throw std::logic_error("Bad cells not owned by this instance, cannot return non const bad cell pointer."); }

◆ numberOfChips() [1/2]

unsigned int InDet::SiDetectorElementStatus::numberOfChips ( const IdentifierHash hash) const
inline

Definition at line 88 of file SiDetectorElementStatus.h.

88  {
89  return numberOfChips(getDetectorElement(hash)->design());
90  }

◆ numberOfChips() [2/2]

virtual unsigned int InDet::SiDetectorElementStatus::numberOfChips ( const InDetDD::SiDetectorDesign design) const
protectedpure virtual

◆ operator=()

SiDetectorElementStatus& InDet::SiDetectorElementStatus::operator= ( const SiDetectorElementStatus )
delete

Member Data Documentation

◆ m_badCells

std::vector<std::vector<unsigned short> >* InDet::SiDetectorElementStatus::m_badCells = nullptr
private

Definition at line 139 of file SiDetectorElementStatus.h.

◆ m_detectorElements

const InDetDD::SiDetectorElementCollection* InDet::SiDetectorElementStatus::m_detectorElements = nullptr
private

Definition at line 136 of file SiDetectorElementStatus.h.

◆ m_elementChipStatus

std::vector<ChipFlags_t> InDet::SiDetectorElementStatus::m_elementChipStatus
private

Definition at line 138 of file SiDetectorElementStatus.h.

◆ m_elementStatus

std::vector<bool> InDet::SiDetectorElementStatus::m_elementStatus
private

Definition at line 137 of file SiDetectorElementStatus.h.

◆ m_owner

bool InDet::SiDetectorElementStatus::m_owner = false
private

Definition at line 140 of file SiDetectorElementStatus.h.


The documentation for this class was generated from the following files:
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
max
#define max(a, b)
Definition: cfImp.cxx:41
InDet::SiDetectorElementStatus::m_elementChipStatus
std::vector< ChipFlags_t > m_elementChipStatus
Definition: SiDetectorElementStatus.h:138
InDet::SiDetectorElementStatus::m_elementStatus
std::vector< bool > m_elementStatus
Definition: SiDetectorElementStatus.h:137
InDet::SiDetectorElementStatus::getDetectorElement
const InDetDD::SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementStatus.h:91
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:294
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
InDet::SiDetectorElementStatus::m_detectorElements
const InDetDD::SiDetectorElementCollection * m_detectorElements
Definition: SiDetectorElementStatus.h:136
InDet::SiDetectorElementStatus::notOwningBadCells
static void notOwningBadCells()
Definition: SiDetectorElementStatus.cxx:82
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
InDet::SiDetectorElementStatus::m_owner
bool m_owner
Definition: SiDetectorElementStatus.h:140
InDet::SiDetectorElementStatus::numberOfChips
unsigned int numberOfChips(const IdentifierHash &hash) const
Definition: SiDetectorElementStatus.h:88
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
InDet::SiDetectorElementStatus::getElementChipStatus
const std::vector< ChipFlags_t > & getElementChipStatus() const
Definition: SiDetectorElementStatus.h:118
InDet::SiDetectorElementStatus::copyBadCells
void copyBadCells()
Definition: SiDetectorElementStatus.h:131
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7