ATLAS Offline Software
Loading...
Searching...
No Matches
CylinderSurface.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5namespace Trk {
6
7inline bool CylinderSurface::operator==(const CylinderSurface& csf) const
8{
9 if (this == &csf){
10 return true;
11 }
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;
15 return boundsEqual;
16}
17
18/** Return the surface type */
19inline constexpr SurfaceType
20CylinderSurface::type() const
21{
22 return CylinderSurface::staticType;
23}
24
25template<int DIM, class T>
26std::unique_ptr<ParametersT<DIM, T, CylinderSurface>>
27CylinderSurface::createUniqueParameters(
28 double l1,
29 double l2,
30 double phi,
31 double theta,
32 double qop,
33 std::optional<AmgSymMatrix(DIM)> cov) const
34{
35 return std::make_unique<ParametersT<DIM, T, CylinderSurface>>(
36 l1, l2, phi, theta, qop, *this, std::move(cov));
37}
38
39/** Use the Surface as a ParametersBase constructor, from global parameters */
40template<int DIM, class T>
41std::unique_ptr<ParametersT<DIM, T, CylinderSurface>>
42CylinderSurface::createUniqueParameters(
43 const Amg::Vector3D& position,
44 const Amg::Vector3D& momentum,
45 double charge,
46 std::optional<AmgSymMatrix(DIM)> cov) const
47{
48 return std::make_unique<ParametersT<DIM, T, CylinderSurface>>(
49 position, momentum, charge, *this, std::move(cov));
50}
51
52inline CylinderSurface*
53CylinderSurface::clone() const
54{
55 return new CylinderSurface(*this);
56}
57
58inline Amg::Vector3D
59CylinderSurface::normal(const Amg::Vector2D& lp) const
60{
61 double phi = lp[Trk::locRPhi] / (bounds().r());
62 Amg::Vector3D localNormal(cos(phi), sin(phi), 0.);
63 return Amg::Vector3D(transform().linear() * localNormal);
64}
65
66inline double
67CylinderSurface::pathCorrection(const Amg::Vector3D& pos,
68 const Amg::Vector3D& mom) const
69{
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
77}
78
79inline const CylinderBounds&
80CylinderSurface::bounds() const
81{
82 return *(m_bounds.get());
83}
84
85inline bool
86CylinderSurface::hasBounds() const
87{
88 return m_bounds.get() != nullptr;
89}
90
91inline bool
92CylinderSurface::insideBounds(const Amg::Vector2D& locpos,
93 double tol1,
94 double tol2) const
95{
96 return bounds().inside(locpos, tol1, tol2);
97}
98
99inline bool
100CylinderSurface::insideBoundsCheck(const Amg::Vector2D& locpos,
101 const BoundaryCheck& bchk) const
102{
103 return bounds().inside(locpos, bchk);
104}
105
106inline Amg::Vector2D
107CylinderSurface::localParametersToPosition(const LocalParameters& locpars) const
108{
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.);
116}
117
118inline std::string
119CylinderSurface::name() const
120{
121 return "Trk::CylinderSurface";
122}
123
124}