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