2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
7 inline bool CylinderSurface::operator==(const CylinderSurface& csf) const
12 bool transfEqual(transform().isApprox(csf.transform(), 10e-8));
13 bool centerEqual = (transfEqual) ? (center() == csf.center()) : false;
14 bool boundsEqual = (centerEqual) ? (bounds() == csf.bounds()) : false;
18 /** Return the surface type */
19 inline constexpr SurfaceType
20 CylinderSurface::type() const
22 return CylinderSurface::staticType;
25 template<int DIM, class T>
26 std::unique_ptr<ParametersT<DIM, T, CylinderSurface>>
27 CylinderSurface::createUniqueParameters(
33 std::optional<AmgSymMatrix(DIM)> cov) const
35 return std::make_unique<ParametersT<DIM, T, CylinderSurface>>(
36 l1, l2, phi, theta, qop, *this, std::move(cov));
39 /** Use the Surface as a ParametersBase constructor, from global parameters */
40 template<int DIM, class T>
41 std::unique_ptr<ParametersT<DIM, T, CylinderSurface>>
42 CylinderSurface::createUniqueParameters(
43 const Amg::Vector3D& position,
44 const Amg::Vector3D& momentum,
46 std::optional<AmgSymMatrix(DIM)> cov) const
48 return std::make_unique<ParametersT<DIM, T, CylinderSurface>>(
49 position, momentum, charge, *this, std::move(cov));
52 inline CylinderSurface*
53 CylinderSurface::clone() const
55 return new CylinderSurface(*this);
59 CylinderSurface::normal(const Amg::Vector2D& lp) const
61 double phi = lp[Trk::locRPhi] / (bounds().r());
62 Amg::Vector3D localNormal(cos(phi), sin(phi), 0.);
63 return Amg::Vector3D(transform().linear() * localNormal);
67 CylinderSurface::pathCorrection(const Amg::Vector3D& pos,
68 const Amg::Vector3D& mom) const
70 // the global normal vector is pos-center.unit() - at the z of the position
71 // @TODO make safe for tilt
72 Amg::Vector3D pcT(pos.x() - center().x(), pos.y() - center().y(), 0.);
73 Amg::Vector3D normalT(pcT.unit()); // transverse normal
74 double cosAlpha = normalT.dot(mom.unit());
75 return (cosAlpha != 0 ? std::abs(1. / cosAlpha)
76 : 1.); // ST undefined for cosAlpha=0
79 inline const CylinderBounds&
80 CylinderSurface::bounds() const
82 return *(m_bounds.get());
86 CylinderSurface::hasBounds() const
88 return m_bounds.get() != nullptr;
92 CylinderSurface::insideBounds(const Amg::Vector2D& locpos,
96 return bounds().inside(locpos, tol1, tol2);
100 CylinderSurface::insideBoundsCheck(const Amg::Vector2D& locpos,
101 const BoundaryCheck& bchk) const
103 return bounds().inside(locpos, bchk);
107 CylinderSurface::localParametersToPosition(const LocalParameters& locpars) const
109 if (locpars.contains(Trk::locRPhi) && locpars.contains(Trk::locZ))
110 return Amg::Vector2D(locpars[Trk::locRPhi], locpars[Trk::locZ]);
111 if (locpars.contains(Trk::locRPhi))
112 return Amg::Vector2D(locpars[Trk::locRPhi], 0.);
113 if (locpars.contains(Trk::locZ))
114 return Amg::Vector2D(bounds().r(), locpars[Trk::locZ]);
115 return Amg::Vector2D(bounds().r(), 0.);
119 CylinderSurface::name() const
121 return "Trk::CylinderSurface";