ATLAS Offline Software
Loading...
Searching...
No Matches
SiDetectorElementStatus.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6// SiDetectorElementStatus.h
8// (c) ATLAS Detector software
10
11
12#ifndef INDETREADOUTGEOMETRY_SIDETECTORELEMENTINFO_H
13#define INDETREADOUTGEOMETRY_SIDETECTORELEMENTINFO_H
14
15#include <vector>
16#include <utility>
20
21
22// @TODO remove in the future once new Pixel and SCT conditions summary information is fully validated
23//#ifndef DO_VALIDATE_STATUS_ARRAY
24//# define DO_VALIDATE_STATUS_ARRAY
25//#endif
26
27#ifdef DO_VALIDATE_STATUS_ARRAY
28#define VALIDATE_STATUS_ARRAY_ACTIVATED true
29#include <stdexcept>
30namespace dbg {
31 void break_point( bool input1, bool input2, const char *label);
32 void break_point( double input1, double input2, const char *label);
33 void break_point( uint64_t input1, uint64_t input2, const char *label);
34
35
36}
37
38#define VALIDATE_STATUS_ARRAY( use_info, info_val, summary_val) \
39 { \
40 auto is_good = summary_val; \
41 auto is_good_precomp = (use_info) ? info_val : is_good; \
42 if (is_good != is_good_precomp) { \
43 dbg::break_point(is_good, is_good_precomp,#info_val); \
44 [[maybe_unused]] auto is_good_precomp2 = info_val; \
45 [[maybe_unused]] auto is_good2 = summary_val; \
46 throw std::logic_error("Inconsistent conditions summary information." ); \
47 } } \
48 do { } while (0)
49#else
50#define VALIDATE_STATUS_ARRAY_ACTIVATED false
51#define VALIDATE_STATUS_ARRAY( use_info, info_val, summary_val) do { } while (0)
52#endif
53
54
55// @TODO move to namespace InDetDD ?
56namespace InDet {
57 class SiDetectorDesign;
58
59 // @TODO or use bitset ?
60 using ChipFlags_t = unsigned short;
61
63 public:
65 : m_detectorElements(&detector_elements), m_badCells(new std::vector<std::vector<unsigned short> >()), m_owner(true) {}
66
67 SiDetectorElementStatus(const SiDetectorElementStatus &si_detector_element_status)
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 }
76
78 const std::vector<std::vector<unsigned short> > &bad_cells)
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 {}
83
84 virtual ~SiDetectorElementStatus() { if (m_owner) delete m_badCells; }
85
87
88 unsigned int numberOfChips(const IdentifierHash& hash) const {
89 return numberOfChips(getDetectorElement(hash)->design());
90 }
92 return m_detectorElements->at(hash.value());
93 }
97 bool isGood(IdentifierHash hash) const {
98 return m_elementStatus.at(hash.value());
99 }
100 bool isChipGood(IdentifierHash hash, unsigned int chip) const {
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 }
106
107 bool isCellGood(IdentifierHash hash, unsigned short cell_i) const {
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 }
111
115
116 const std::vector<bool> &getElementStatus() const { return m_elementStatus; }
117 std::vector<bool> &getElementStatus() { return m_elementStatus; }
118 const std::vector<ChipFlags_t> &getElementChipStatus() const { return m_elementChipStatus; }
119 std::vector<ChipFlags_t> &getElementChipStatus() { return m_elementChipStatus; }
120 const std::vector<std::vector<unsigned short> > &getBadCells() const { return *m_badCells; }
121
125 std::vector<std::vector<unsigned short> > &getBadCells() { if (!m_owner) { copyBadCells(); } return *m_badCells; }
126
127 protected:
128 virtual unsigned int numberOfChips(const InDetDD::SiDetectorDesign& design) const = 0;
129 private:
130 static void notOwningBadCells() ;
132 m_badCells = new std::vector<std::vector<unsigned short> > (*m_badCells);
133 m_owner=true;
134 }
135
137 std::vector<bool> m_elementStatus;
138 std::vector<ChipFlags_t> m_elementChipStatus;
139 std::vector<std::vector<unsigned short> > *m_badCells = nullptr;
140 bool m_owner = false;
141 };
142
143} // namespace InDetDD
144
147
148CONDCONT_MIXED_DEF( InDet::SiDetectorElementStatus, 207353830 );
149
150#endif // INDETREADOUTGEOMETRY_SIDETECTORELEMENTINFO_H
#define CONDCONT_MIXED_DEF(...)
Definition CondCont.h:1446
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
static Double_t a
This is a "hash" representation of an Identifier.
Base class for the detector design classes for Pixel and SCT.
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
SiDetectorElementStatus(const InDetDD::SiDetectorElementCollection &detector_elements, const std::vector< std::vector< unsigned short > > &bad_cells)
virtual unsigned int numberOfChips(const InDetDD::SiDetectorDesign &design) const =0
const InDetDD::SiDetectorElementCollection * m_detectorElements
const std::vector< bool > & getElementStatus() const
bool isChipGood(IdentifierHash hash, unsigned int chip) const
std::vector< std::vector< unsigned short > > * m_badCells
const InDetDD::SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
std::vector< std::vector< unsigned short > > & getBadCells()
Get a non-const bad cells container owned by this instance.
const InDetDD::SiDetectorElementCollection & getDetectorElements() const
const std::vector< ChipFlags_t > & getElementChipStatus() const
SiDetectorElementStatus(const InDetDD::SiDetectorElementCollection &detector_elements)
bool isCellGood(IdentifierHash hash, unsigned short cell_i) const
std::vector< ChipFlags_t > & getElementChipStatus()
unsigned int numberOfChips(const IdentifierHash &hash) const
bool isGood(IdentifierHash hash) const
SiDetectorElementStatus(const SiDetectorElementStatus &si_detector_element_status)
SiDetectorElementStatus & operator=(const SiDetectorElementStatus &)=delete
std::vector< ChipFlags_t > m_elementChipStatus
const std::vector< std::vector< unsigned short > > & getBadCells() const
unsigned short ChipFlags_t
std::string label(const std::string &format, int i)
Definition label.h:19
Primary Vertex Finder.
Definition merge.py:1
STL namespace.