2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5#include "CxxUtils/inline_hints.h"
9Surface::operator!=(const Surface& sf) const
11 return !((*this) == sf);
14inline const Amg::Transform3D*
15Surface::cachedTransform() const
17 return ((m_transforms) ? &(m_transforms->transform) : nullptr);
20inline const Amg::Transform3D&
21Surface::transform() const
24 return m_transforms->transform;
26 if (m_associatedDetElement && m_associatedDetElementId.is_valid()) {
27 return m_associatedDetElement->transform(m_associatedDetElementId);
29 if (m_associatedDetElement) {
30 return m_associatedDetElement->transform();
35inline const Amg::Vector3D&
36Surface::center() const
39 return m_transforms->center;
41 if (m_associatedDetElement && m_associatedDetElementId.is_valid()) {
42 return m_associatedDetElement->center(m_associatedDetElementId);
44 if (m_associatedDetElement) {
45 return m_associatedDetElement->center();
50inline const Amg::Vector3D&
51Surface::normal() const
54 return m_transforms->normal;
56 if (m_associatedDetElement && m_associatedDetElementId.is_valid()) {
57 return m_associatedDetElement->normal(m_associatedDetElementId);
59 if (m_associatedDetElement) {
60 return m_associatedDetElement->normal();
65// standard is to set non-defined parameters to 0, but can be changed for
68Surface::localParametersToPosition(const LocalParameters& locpars) const
70 if (locpars.contains(Trk::loc1) && locpars.contains(Trk::loc2)) {
71 return Amg::Vector2D(locpars[Trk::loc1], locpars[loc2]);
73 if (locpars.contains(Trk::loc1)) {
74 return Amg::Vector2D(locpars[Trk::loc1], 0.);
76 if (locpars.contains(Trk::loc2)) {
77 return Amg::Vector2D(0., locpars[loc2]);
79 return Amg::Vector2D(0., 0.);
82// common to planar surfaces
84Surface::pathCorrection(const Amg::Vector3D&, const Amg::Vector3D& mom) const
86 Amg::Vector3D dir(mom.unit());
87 double cosAlpha = dir.dot(normal());
88 return (cosAlpha != 0 ? std::abs(1. / cosAlpha)
89 : 1.); // ST undefined for cosAlpha=0
92//* the templated parameters on Surface method */
95Surface::onSurface(const T& pars, const Trk::BoundaryCheck& bcheck) const
97 // surface pointer comparison as a first fast check (w/o transform)
98 if ((&pars.associatedSurface() == this)) {
99 return (bcheck ? insideBoundsCheck(pars.localPosition(), bcheck) : true);
101 return isOnSurface(pars.position(), bcheck);
104/// Local to Global implementations
105// From Local position
107Surface::localToGlobal(const Amg::Vector2D& locpos) const
109 Amg::Vector3D gPosition;
110 localToGlobal(locpos, Amg::Vector3D(1., 1., 1.), gPosition);
114// From local position and momentum
116Surface::localToGlobal(const Amg::Vector2D& locpos,
117 const Amg::Vector3D& glomom) const
119 Amg::Vector3D gPosition(0., 0., 0.);
120 localToGlobal(locpos, glomom, gPosition);
124// From Local parameters
126Surface::localToGlobal(const LocalParameters& locpars) const
128 Amg::Vector3D gPosition(0., 0., 0.);
130 localParametersToPosition(locpars), Amg::Vector3D(1., 1., 1.), gPosition);
134// From Local parameters and momementum
136Surface::localToGlobal(const LocalParameters& locpars,
137 const Amg::Vector3D& glomom) const
139 Amg::Vector3D gPosition(0., 0., 0.);
140 localToGlobal(localParametersToPosition(locpars), glomom, gPosition);
144inline std::unique_ptr<Surface>
145Surface::uniqueClone() const
147 return std::unique_ptr<Surface>(clone());
150// common to all surfaces, uses memory optized method
151inline std::optional<Amg::Vector2D>
152Surface::globalToLocal(const Amg::Vector3D& glopos, double) const
154 Amg::Vector2D lPosition(0., 0.);
155 if (globalToLocal(glopos, Amg::Vector3D(1., 1., 1.), lPosition)) {
160// common to all surfaces, uses memory optized method
161inline std::optional<Amg::Vector2D>
162Surface::globalToLocal(const Amg::Vector3D& glopos,
163 const Amg::Vector3D& glomom) const
165 Amg::Vector2D lPosition(0., 0.);
166 if (globalToLocal(glopos, glomom, lPosition)) {
172// take local position and return global direction
174Surface::normal(const Amg::Vector2D&) const
176 return Amg::Vector3D(normal());
179inline const Amg::Vector3D&
180Surface::globalReferencePoint() const
185inline const TrkDetElementBase*
186Surface::associatedDetectorElement() const
188 return m_associatedDetElement;
192Surface::associatedDetectorElementIdentifier() const
194 if (!m_associatedDetElement)
195 return Identifier(); // in invalid state
196 if (m_associatedDetElementId.is_valid())
197 return m_associatedDetElementId;
198 return m_associatedDetElement->identify();
201inline const Trk::Layer*
202Surface::associatedLayer() const
204 return (m_associatedLayer);
207inline const Trk::MaterialLayer*
208Surface::materialLayer() const
210 return m_materialLayer.get();
213inline Trk::MaterialLayer*
214Surface::materialLayer()
216 return m_materialLayer.get();
220Surface::baseSurface() const
226Surface::isActive() const
228 return (m_associatedDetElement != nullptr);
232Surface::isFree() const
234 return (m_owner == Trk::noOwn);
238Surface::setTransform(const Amg::Transform3D& trans)
240 m_transforms = std::make_unique<Transforms>(trans);
244Surface::setOwner(SurfaceOwner x)
250Surface::owner() const
256Surface::setMaterialLayer(std::shared_ptr<MaterialLayer> mlay)
258 m_materialLayer = std::move(mlay);
262Surface::associateLayer(const Layer& lay)
264 m_associatedLayer = (&lay);
267// Avoid out-of-line-eigen calls
269inline Amg::Transform3D
270Surface::inverseTransformHelper() const
272 return transform().inverse();
275// Avoid out-of-line-eigen calls
278Surface::inverseTransformMultHelper(const Amg::Vector3D& pos) const
280 return inverseTransformHelper() * pos;
283} // end of namespace Trk