ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_DetElementContainer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9namespace InDetDD{
10
12 : AthMessaging("TRT_DetElementContainer")
13 , m_trtcoll()
14 , m_trtnum(nullptr)
15 {
16 clear();
17 }
18
23
25 {
26 m_trtnum=mynum;
27 }
28
33
38
43
45 , unsigned int moduleIndex
46 , unsigned int phiIndex
47 , unsigned int strawLayerIndex) const
48 {
49 if ( positive >= 2 || moduleIndex >= NMODMAX
50 || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXBR) return nullptr;
51
52 return m_baArray[positive][moduleIndex][phiIndex][strawLayerIndex];
53 }
54
56 , unsigned int moduleIndex
57 , unsigned int phiIndex
58 , unsigned int strawLayerIndex)
59 {
60 if ( positive >= 2 || moduleIndex >= NMODMAX
61 || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXBR) return nullptr;
62
63 return m_baArray[positive][moduleIndex][phiIndex][strawLayerIndex];
64 }
65
66
68 , unsigned int wheelIndex
69 , unsigned int strawLayerIndex
70 , unsigned int phiIndex) const
71 {
72 if ( positive >= 2 || wheelIndex >= NWHEELMAX
73 || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXEC) return nullptr;
74
75 return m_ecArray[positive][wheelIndex][strawLayerIndex][phiIndex];
76 }
77
79 , unsigned int wheelIndex
80 , unsigned int strawLayerIndex
81 , unsigned int phiIndex)
82 {
83 if ( positive >= 2 || wheelIndex >= NWHEELMAX
84 || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXEC) return nullptr;
85
86 return m_ecArray[positive][wheelIndex][strawLayerIndex][phiIndex];
87 }
88
90 {
91 // check if the element has already been added
92 if (std::find(m_trtcoll.begin(), m_trtcoll.end(), barrel) != m_trtcoll.end()) return;
93 // check if something was stored at the given indices
94 TRT_BarrelElement* arrayElement = m_baArray
95 [barrel->getCode().isPosZ()]
96 [barrel->getCode().getModuleIndex()]
97 [barrel->getCode().getPhiIndex()]
98 [barrel->getCode().getStrawLayerIndex()];
99 if (arrayElement != nullptr) {
100 m_trtcoll.erase(std::remove(m_trtcoll.begin(), m_trtcoll.end(), arrayElement));
101 delete arrayElement;
102 }
103 m_baArray[barrel->getCode().isPosZ()]
104 [barrel->getCode().getModuleIndex()]
105 [barrel->getCode().getPhiIndex()]
106 [barrel->getCode().getStrawLayerIndex()] = barrel;
107 m_trtcoll.push_back(barrel);
108 }
109
111 {
112 // check if the element has already been added
113 if (std::find(m_trtcoll.begin(), m_trtcoll.end(), endcap) != m_trtcoll.end()) return;
114 // check if something was stored at the given indices
115 TRT_EndcapElement* arrayElement = m_ecArray
116 [endcap->getCode().isPosZ()]
117 [endcap->getCode().getWheelIndex()]
118 [endcap->getCode().getStrawLayerIndex()]
119 [endcap->getCode().getPhiIndex()];
120 if (arrayElement != nullptr) {
121 m_trtcoll.erase(std::remove(m_trtcoll.begin(), m_trtcoll.end(), arrayElement));
122 delete arrayElement;
123 }
124 m_ecArray[endcap->getCode().isPosZ()]
125 [endcap->getCode().getWheelIndex()]
126 [endcap->getCode().getStrawLayerIndex()]
127 [endcap->getCode().getPhiIndex()] = endcap;
128 m_trtcoll.push_back(endcap);
129 }
130
132 {
133 if (m_baArray
134 [barrel->getCode().isPosZ()]
135 [barrel->getCode().getModuleIndex()]
136 [barrel->getCode().getPhiIndex()]
137 [barrel->getCode().getStrawLayerIndex()] ) {
138
139 //Element already added - complain!
140 ATH_MSG_DEBUG("manageBarrelElement: Overriding existing element");
141 }
142
144 [barrel->getCode().isPosZ()]
145 [barrel->getCode().getModuleIndex()]
146 [barrel->getCode().getPhiIndex()]
147 [barrel->getCode().getStrawLayerIndex()]
148 =barrel;
149
150 // Add the barrel element to the hash vector:
151 if (idHelper) {
152 Identifier id = idHelper->layer_id(barrel->getCode().isPosZ() ? +1 : -1,
153 barrel->getCode().getPhiIndex(),
154 barrel->getCode().getModuleIndex(),
155 barrel->getCode().getStrawLayerIndex());
156 IdentifierHash hashId = idHelper->straw_layer_hash(id);
157 if (hashId.is_valid()) {
158 if (m_trtcoll.size() <= hashId) {
159 m_trtcoll.resize(static_cast<unsigned int>(hashId) + 1);
160 }
161 if (m_trtcoll[hashId]) {
162 //Element already added - complain!
163 ATH_MSG_DEBUG("manageBarrelElement: Overriding existing element for hashID");
164 }
165 m_trtcoll[hashId]=barrel;
166 }
167 else {
168 ATH_MSG_WARNING("manageBarrelElement: Invalid identifier");
169 }
170 }
171 }
172
174 {
175 if (m_ecArray
176 [endcap->getCode().isPosZ()]
177 [endcap->getCode().getWheelIndex()]
178 [endcap->getCode().getStrawLayerIndex()]
179 [endcap->getCode().getPhiIndex()] ) {
180 //Element already added - complain!
181 ATH_MSG_WARNING("manageEndcapElement: Overriding existing element");
182 }
183
185 [endcap->getCode().isPosZ()]
186 [endcap->getCode().getWheelIndex()]
187 [endcap->getCode().getStrawLayerIndex()]
188 [endcap->getCode().getPhiIndex()]
189 =endcap;
190
191 if (idHelper) {
192 Identifier id = idHelper->layer_id(endcap->getCode().isPosZ() ? +2 : -2,
193 endcap->getCode().getPhiIndex(),
194 endcap->getCode().getWheelIndex(),
195 endcap->getCode().getStrawLayerIndex());
196
197 IdentifierHash hashId = idHelper->straw_layer_hash(id);
198 if (hashId.is_valid()) {
199 if (m_trtcoll.size() <= hashId) {
200 m_trtcoll.resize(static_cast<unsigned int>(hashId) + 1);
201 }
202 if (m_trtcoll[hashId]) {
203 //Element already added - complain!
204 ATH_MSG_DEBUG("manageEndcapElement: Overriding existing element for hashID");
205 }
206 m_trtcoll[hashId]=endcap;
207 } else {
208 ATH_MSG_WARNING("manageEndcapElement: Invalid identifier");
209 }
210 }
211 }
212
214 {
215 m_trtcoll.clear();
216 for (auto & ec : m_baArray) {
217 for (auto & mod : ec) {
218 for (auto & phi : mod) {
219 for (auto & sLay : phi) {
220 sLay = nullptr;
221 }
222 }
223 }
224 }
225 for (auto & ec : m_ecArray) {
226 for (auto & whe : ec) {
227 for (auto & sLay : whe) {
228 for(auto & phi : sLay) {
229 phi = nullptr;
230 }
231 }
232 }
233 }
234 }
235
236}
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
Extended TRT_BaseElement to describe a TRT readout element, this is a planar layer with n ( order of ...
Class to hold collection of TRT detector elements.
TRT_EndcapElement * m_ecArray[2][NWHEELMAX][NSTRAWLAYMAXEC][NPHIMAX]
void manageEndcapElement(TRT_EndcapElement *endcap, const TRT_ID *idHelper)
void manageBarrelElement(TRT_BarrelElement *barrel, const TRT_ID *idHelper)
const TRT_DetElementCollection * getElements() const
void addEndcapElement(TRT_EndcapElement *element)
void setNumerology(const TRT_Numerology *mynum)
const TRT_EndcapElement * getEndcapDetElement(unsigned int positive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex) const
TRT_BarrelElement * m_baArray[2][NMODMAX][NPHIMAX][NSTRAWLAYMAXBR]
const TRT_BarrelElement * getBarrelDetElement(unsigned int positive, unsigned int moduleIndex, unsigned int phiIndex, unsigned int strawLayerIndex) const
const TRT_Numerology * getTRTNumerology() const
void addBarrelElement(TRT_BarrelElement *element)
unsigned int isPosZ() const
unsigned int getPhiIndex() const
unsigned int getStrawLayerIndex() const
unsigned int getWheelIndex() const
Extended class of a TRT_BaseElement to describe a readout elment in the endcap.
const TRT_EndcapCode & getCode() const
Doomed (?
Helper class to organize the straw elements on TRT readout elements.
This is an Identifier helper class for the TRT subdetector.
Definition TRT_ID.h:82
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition TRT_ID.h:494
IdentifierHash straw_layer_hash(Identifier straw_layer_id) const
straw_layer hash from id - optimized
Definition TRT_ID.h:687
Message Stream Member.
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.