2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
6 * @file SolidStateDetectorElementBase.icc
11 ///////////////////////////////////////////////////////////////////
13 ///////////////////////////////////////////////////////////////////
15 inline Trk::DetectorElemType SolidStateDetectorElementBase::detectorType() const{
16 return Trk::DetectorElemType::SolidState;
19 inline void SolidStateDetectorElementBase::invalidate()
24 inline void SolidStateDetectorElementBase::setCache()
29 inline const SiCommonItems* SolidStateDetectorElementBase::getCommonItems() const
34 inline Identifier SolidStateDetectorElementBase::identify() const
39 inline IdentifierHash SolidStateDetectorElementBase::identifyHash() const
44 inline const AtlasDetectorID* SolidStateDetectorElementBase::getIdHelper() const
46 return m_commonItems->getIdHelper();
49 inline Trk::Surface& SolidStateDetectorElementBase::surface()
54 inline const Trk::Surface& SolidStateDetectorElementBase::surface() const
59 inline const Trk::Surface& SolidStateDetectorElementBase::surface(const Identifier&) const
64 inline const Amg::Transform3D& SolidStateDetectorElementBase::transform() const
66 if (!m_cache.isValid()) {
69 return m_cache.ptr()->m_transform;
72 inline const Amg::Transform3D& SolidStateDetectorElementBase::transform(const Identifier&) const
77 inline double SolidStateDetectorElementBase::hitDepthDirection() const
79 return depthDirection() ? 1 : -1;
82 inline double SolidStateDetectorElementBase::hitPhiDirection() const
84 return phiDirection() ? 1 : -1;
87 inline double SolidStateDetectorElementBase::hitEtaDirection() const
89 return etaDirection() ? 1 : -1;
92 inline const Amg::Vector3D& SolidStateDetectorElementBase::normal() const
94 if (!m_cache.isValid()) {
97 return m_cache.ptr()->m_normal;
100 inline const Amg::Vector3D& SolidStateDetectorElementBase::center() const
102 if (!m_cache.isValid()) {
105 return m_cache.ptr()->m_center;
108 inline const Amg::Vector3D& SolidStateDetectorElementBase::normal(const Identifier&) const
113 inline const Amg::Vector3D& SolidStateDetectorElementBase::center(const Identifier&) const
118 inline const GeoTrf::Transform3D& SolidStateDetectorElementBase::transformHit() const
120 if (!m_cache.isValid()) {
123 return m_cache.ptr()->m_transformHit;
126 inline HepGeom::Point3D<double> SolidStateDetectorElementBase::globalPositionHit(const HepGeom::Point3D<double>& simulationLocalPos) const
128 return Amg::EigenTransformToCLHEP(transformHit())*simulationLocalPos;
131 inline Amg::Vector3D SolidStateDetectorElementBase::globalPositionHit(const Amg::Vector3D& simulationLocalPos) const
133 return transformHit() * simulationLocalPos;
136 inline HepGeom::Point3D<double> SolidStateDetectorElementBase::globalPosition(const HepGeom::Point3D<double>& localPos) const
138 return transformCLHEP() * localPos;
141 inline Amg::Vector3D SolidStateDetectorElementBase::globalPosition(const Amg::Vector3D& localPos) const
143 return transform() * localPos;
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
149 inline Amg::Vector3D SolidStateDetectorElementBase::globalPosition(const Amg::Vector2D& localPos) const
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;
156 inline Amg::Vector2D SolidStateDetectorElementBase::localPosition(const HepGeom::Point3D<double>& globalPosition) const
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));
164 inline Amg::Vector2D SolidStateDetectorElementBase::localPosition(const Amg::Vector3D& globalPosition) const
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));
172 inline double SolidStateDetectorElementBase::rMin() const
174 if (!m_cache.isValid()) updateCache();
175 return m_cache.ptr()->m_minR;
178 inline double SolidStateDetectorElementBase::rMax() const
180 if (!m_cache.isValid()) updateCache();
181 return m_cache.ptr()->m_maxR;
184 inline double SolidStateDetectorElementBase::zMin() const
186 if (!m_cache.isValid()) updateCache();
187 return m_cache.ptr()->m_minZ;
190 inline double SolidStateDetectorElementBase::zMax() const
192 if (!m_cache.isValid()) updateCache();
193 return m_cache.ptr()->m_maxZ;
196 inline double SolidStateDetectorElementBase::phiMin() const
198 if (!m_cache.isValid()) updateCache();
199 return m_cache.ptr()->m_minPhi;
202 inline double SolidStateDetectorElementBase::phiMax() const
204 if (!m_cache.isValid()) updateCache();
205 return m_cache.ptr()->m_maxPhi;
208 inline const DetectorDesign& SolidStateDetectorElementBase::design() const
213 inline const Trk::SurfaceBounds& SolidStateDetectorElementBase::bounds(const Identifier&) const
218 inline double SolidStateDetectorElementBase::width() const
220 return m_design->width();
223 inline double SolidStateDetectorElementBase::minWidth() const
225 return m_design->minWidth();
228 inline double SolidStateDetectorElementBase::maxWidth() const
230 return m_design->maxWidth();
233 inline double SolidStateDetectorElementBase::length() const
235 return m_design->length();
238 inline double SolidStateDetectorElementBase::thickness() const
240 return m_design->thickness();
243 inline double SolidStateDetectorElementBase::etaPitch() const
245 return m_design->etaPitch();
248 inline double SolidStateDetectorElementBase::phiPitch() const
250 return m_design->phiPitch();
253 inline InDetDD::CarrierType SolidStateDetectorElementBase::carrierType() const
255 return m_design->carrierType();
258 inline bool SolidStateDetectorElementBase::swapPhiReadoutDirection() const
260 bool dir = phiDirection();
261 // equivalent to (m_design->swapHitPhiReadoutDirection() xor !m_phiDirection)
262 return (!m_design->swapHitPhiReadoutDirection() && !dir)
263 || (m_design->swapHitPhiReadoutDirection() && dir);
266 inline bool SolidStateDetectorElementBase::swapEtaReadoutDirection() const
268 bool dir = etaDirection();
269 // equivalent to (m_design->swapHitEtaReadoutDirection() xor !m_etaDirection)
270 return ((!m_design->swapHitEtaReadoutDirection() && !dir)
271 || (m_design->swapHitEtaReadoutDirection() && dir));
274 inline MsgStream& SolidStateDetectorElementBase::msg(MSG::Level lvl) const
276 return m_commonItems->msg(lvl);
279 inline bool SolidStateDetectorElementBase::msgLvl(MSG::Level lvl) const
281 return m_commonItems->msgLvl(lvl);
284 inline bool SolidStateDetectorElementBase::depthDirection() const
286 if (!m_axisDir.isValid()) updateCache();
287 return m_axisDir.ptr()->m_depthDirection;
290 inline bool SolidStateDetectorElementBase::etaDirection() const
292 if (!m_axisDir.isValid()) updateCache();
293 return m_axisDir.ptr()->m_etaDirection;
296 inline bool SolidStateDetectorElementBase::phiDirection() const
298 if (!m_axisDir.isValid()) updateCache();
299 return m_axisDir.ptr()->m_phiDirection;
302 inline double SolidStateDetectorElementBase::depthAngle() const
304 if (!m_axisDir.isValid()) updateCache();
305 return m_axisDir.ptr()->m_depthAngle;
308 inline double SolidStateDetectorElementBase::etaAngle() const
310 if (!m_axisDir.isValid()) updateCache();
311 return m_axisDir.ptr()->m_etaAngle;
314 inline double SolidStateDetectorElementBase::phiAngle() const
316 if (!m_axisDir.isValid()) updateCache();
317 return m_axisDir.ptr()->m_phiAngle;
320 } // namespace InDetDD