ATLAS Offline Software
SolidStateDetectorElementBase.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /**
6  * @file SolidStateDetectorElementBase.icc
7  **/
8 
9 namespace InDetDD {
10 
11  ///////////////////////////////////////////////////////////////////
12  // Inline methods:
13  ///////////////////////////////////////////////////////////////////
14 
15  inline Trk::DetectorElemType SolidStateDetectorElementBase::detectorType() const{
16  return Trk::DetectorElemType::SolidState;
17  }
18 
19  inline void SolidStateDetectorElementBase::invalidate()
20  {
21  m_cache.reset();
22  }
23 
24  inline void SolidStateDetectorElementBase::setCache()
25  {
26  updateCache();
27  }
28 
29  inline const SiCommonItems* SolidStateDetectorElementBase::getCommonItems() const
30  {
31  return m_commonItems;
32  }
33 
34  inline Identifier SolidStateDetectorElementBase::identify() const
35  {
36  return m_id;
37  }
38 
39  inline IdentifierHash SolidStateDetectorElementBase::identifyHash() const
40  {
41  return m_idHash;
42  }
43 
44  inline const AtlasDetectorID* SolidStateDetectorElementBase::getIdHelper() const
45  {
46  return m_commonItems->getIdHelper();
47  }
48 
49  inline Trk::Surface& SolidStateDetectorElementBase::surface()
50  {
51  return *m_surface;
52  }
53 
54  inline const Trk::Surface& SolidStateDetectorElementBase::surface() const
55  {
56  return *m_surface;
57  }
58 
59  inline const Trk::Surface& SolidStateDetectorElementBase::surface(const Identifier&) const
60  {
61  return surface();
62  }
63 
64  inline const Amg::Transform3D& SolidStateDetectorElementBase::transform() const
65  {
66  if (!m_cache.isValid()) {
67  updateCache();
68  }
69  return m_cache.ptr()->m_transform;
70  }
71 
72  inline const Amg::Transform3D& SolidStateDetectorElementBase::transform(const Identifier&) const
73  {
74  return transform();
75  }
76 
77  inline double SolidStateDetectorElementBase::hitDepthDirection() const
78  {
79  return depthDirection() ? 1 : -1;
80  }
81 
82  inline double SolidStateDetectorElementBase::hitPhiDirection() const
83  {
84  return phiDirection() ? 1 : -1;
85  }
86 
87  inline double SolidStateDetectorElementBase::hitEtaDirection() const
88  {
89  return etaDirection() ? 1 : -1;
90  }
91 
92  inline const Amg::Vector3D& SolidStateDetectorElementBase::normal() const
93  {
94  if (!m_cache.isValid()) {
95  updateCache();
96  }
97  return m_cache.ptr()->m_normal;
98  }
99 
100  inline const Amg::Vector3D& SolidStateDetectorElementBase::center() const
101  {
102  if (!m_cache.isValid()) {
103  updateCache();
104  }
105  return m_cache.ptr()->m_center;
106  }
107 
108  inline const Amg::Vector3D& SolidStateDetectorElementBase::normal(const Identifier&) const
109  {
110  return normal();
111  }
112 
113  inline const Amg::Vector3D& SolidStateDetectorElementBase::center(const Identifier&) const
114  {
115  return center();
116  }
117 
118  inline const GeoTrf::Transform3D& SolidStateDetectorElementBase::transformHit() const
119  {
120  if (!m_cache.isValid()) {
121  updateCache();
122  }
123  return m_cache.ptr()->m_transformHit;
124  }
125 
126  inline HepGeom::Point3D<double> SolidStateDetectorElementBase::globalPositionHit(const HepGeom::Point3D<double>& simulationLocalPos) const
127  {
128  return Amg::EigenTransformToCLHEP(transformHit())*simulationLocalPos;
129  }
130 
131  inline Amg::Vector3D SolidStateDetectorElementBase::globalPositionHit(const Amg::Vector3D& simulationLocalPos) const
132  {
133  return transformHit() * simulationLocalPos;
134  }
135 
136  inline HepGeom::Point3D<double> SolidStateDetectorElementBase::globalPosition(const HepGeom::Point3D<double>& localPos) const
137  {
138  return transformCLHEP() * localPos;
139  }
140 
141  inline Amg::Vector3D SolidStateDetectorElementBase::globalPosition(const Amg::Vector3D& localPos) const
142  {
143  return transform() * localPos;
144  }
145  //NB - these methods use "origin" not "center" - these are equivalent for most cases
146  //For ITk Strip endcaps they differ because of the local sensor frame being defined with respect to the beamline, due to the sensor shape
147  //Therefore, "local" positions for these elements will have large r components
148 
149  inline Amg::Vector3D SolidStateDetectorElementBase::globalPosition(const Amg::Vector2D& localPos) const
150  {
151  if (!m_cache.isValid()) updateCache();
152  const CachedVals& cache = *m_cache.ptr();
153  return cache.m_origin + localPos[Trk::distEta] * cache.m_etaAxis + localPos[Trk::distPhi] * cache.m_phiAxis;
154  }
155 
156  inline Amg::Vector2D SolidStateDetectorElementBase::localPosition(const HepGeom::Point3D<double>& globalPosition) const
157  {
158  if (!m_cache.isValid()) updateCache();
159  const CachedVals& cache = *m_cache.ptr();
160  HepGeom::Vector3D<double> relativePos = globalPosition - cache.m_centerCLHEP;
161  return Amg::Vector2D(relativePos.dot(cache.m_phiAxisCLHEP), relativePos.dot(cache.m_etaAxisCLHEP));
162  }
163 
164  inline Amg::Vector2D SolidStateDetectorElementBase::localPosition(const Amg::Vector3D& globalPosition) const
165  {
166  if (!m_cache.isValid()) updateCache();
167  const CachedVals& cache = *m_cache.ptr();
168  Amg::Vector3D relativePos = globalPosition - cache.m_center;
169  return Amg::Vector2D(relativePos.dot(cache.m_phiAxis), relativePos.dot(cache.m_etaAxis));
170  }
171 
172  inline double SolidStateDetectorElementBase::rMin() const
173  {
174  if (!m_cache.isValid()) updateCache();
175  return m_cache.ptr()->m_minR;
176  }
177 
178  inline double SolidStateDetectorElementBase::rMax() const
179  {
180  if (!m_cache.isValid()) updateCache();
181  return m_cache.ptr()->m_maxR;
182  }
183 
184  inline double SolidStateDetectorElementBase::zMin() const
185  {
186  if (!m_cache.isValid()) updateCache();
187  return m_cache.ptr()->m_minZ;
188  }
189 
190  inline double SolidStateDetectorElementBase::zMax() const
191  {
192  if (!m_cache.isValid()) updateCache();
193  return m_cache.ptr()->m_maxZ;
194  }
195 
196  inline double SolidStateDetectorElementBase::phiMin() const
197  {
198  if (!m_cache.isValid()) updateCache();
199  return m_cache.ptr()->m_minPhi;
200  }
201 
202  inline double SolidStateDetectorElementBase::phiMax() const
203  {
204  if (!m_cache.isValid()) updateCache();
205  return m_cache.ptr()->m_maxPhi;
206  }
207 
208  inline const DetectorDesign& SolidStateDetectorElementBase::design() const
209  {
210  return *m_design;
211  }
212 
213  inline const Trk::SurfaceBounds& SolidStateDetectorElementBase::bounds(const Identifier&) const
214  {
215  return bounds();
216  }
217 
218  inline double SolidStateDetectorElementBase::width() const
219  {
220  return m_design->width();
221  }
222 
223  inline double SolidStateDetectorElementBase::minWidth() const
224  {
225  return m_design->minWidth();
226  }
227 
228  inline double SolidStateDetectorElementBase::maxWidth() const
229  {
230  return m_design->maxWidth();
231  }
232 
233  inline double SolidStateDetectorElementBase::length() const
234  {
235  return m_design->length();
236  }
237 
238  inline double SolidStateDetectorElementBase::thickness() const
239  {
240  return m_design->thickness();
241  }
242 
243  inline double SolidStateDetectorElementBase::etaPitch() const
244  {
245  return m_design->etaPitch();
246  }
247 
248  inline double SolidStateDetectorElementBase::phiPitch() const
249  {
250  return m_design->phiPitch();
251  }
252 
253  inline InDetDD::CarrierType SolidStateDetectorElementBase::carrierType() const
254  {
255  return m_design->carrierType();
256  }
257 
258  inline bool SolidStateDetectorElementBase::swapPhiReadoutDirection() const
259  {
260  bool dir = phiDirection();
261  // equivalent to (m_design->swapHitPhiReadoutDirection() xor !m_phiDirection)
262  return (!m_design->swapHitPhiReadoutDirection() && !dir)
263  || (m_design->swapHitPhiReadoutDirection() && dir);
264  }
265 
266  inline bool SolidStateDetectorElementBase::swapEtaReadoutDirection() const
267  {
268  bool dir = etaDirection();
269  // equivalent to (m_design->swapHitEtaReadoutDirection() xor !m_etaDirection)
270  return ((!m_design->swapHitEtaReadoutDirection() && !dir)
271  || (m_design->swapHitEtaReadoutDirection() && dir));
272  }
273 
274  inline MsgStream& SolidStateDetectorElementBase::msg(MSG::Level lvl) const
275  {
276  return m_commonItems->msg(lvl);
277  }
278 
279  inline bool SolidStateDetectorElementBase::msgLvl(MSG::Level lvl) const
280  {
281  return m_commonItems->msgLvl(lvl);
282  }
283 
284  inline bool SolidStateDetectorElementBase::depthDirection() const
285  {
286  if (!m_axisDir.isValid()) updateCache();
287  return m_axisDir.ptr()->m_depthDirection;
288  }
289 
290  inline bool SolidStateDetectorElementBase::etaDirection() const
291  {
292  if (!m_axisDir.isValid()) updateCache();
293  return m_axisDir.ptr()->m_etaDirection;
294  }
295 
296  inline bool SolidStateDetectorElementBase::phiDirection() const
297  {
298  if (!m_axisDir.isValid()) updateCache();
299  return m_axisDir.ptr()->m_phiDirection;
300  }
301 
302  inline double SolidStateDetectorElementBase::depthAngle() const
303  {
304  if (!m_axisDir.isValid()) updateCache();
305  return m_axisDir.ptr()->m_depthAngle;
306  }
307 
308  inline double SolidStateDetectorElementBase::etaAngle() const
309  {
310  if (!m_axisDir.isValid()) updateCache();
311  return m_axisDir.ptr()->m_etaAngle;
312  }
313 
314  inline double SolidStateDetectorElementBase::phiAngle() const
315  {
316  if (!m_axisDir.isValid()) updateCache();
317  return m_axisDir.ptr()->m_phiAngle;
318  }
319 
320 } // namespace InDetDD