ATLAS Offline Software
Loading...
Searching...
No Matches
ConeSurface.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 ConeSurface::operator==(const ConeSurface& csf) const
8{
9 //comparison with self
10 if (this == &csf){
11 return true;
12 }
13 bool transfEqual(transform().isApprox(csf.transform(), 10e-8));
14 bool centerEqual = (transfEqual) ? (center() == csf.center()) : false;
15 bool boundsEqual = (centerEqual) ? (bounds() == csf.bounds()) : false;
16 return boundsEqual;
17}
18
19/** Return the surface type */
20inline constexpr SurfaceType
21ConeSurface::type() const
22{
23 return ConeSurface::staticType;
24}
25
26template<int DIM, class T>
27std::unique_ptr<ParametersT<DIM, T, ConeSurface>>
28ConeSurface::createUniqueParameters(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, ConeSurface>>(
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, ConeSurface>>
42ConeSurface::createUniqueParameters(const Amg::Vector3D& position,
43 const Amg::Vector3D& momentum,
44 double charge,
45 std::optional<AmgSymMatrix(DIM)> cov) const
46{
47 return std::make_unique<ParametersT<DIM, T, ConeSurface>>(
48 position, momentum, charge, *this, std::move(cov));
49}
50
51inline ConeSurface*
52ConeSurface::clone() const
53{
54 return new ConeSurface(*this);
55}
56
57inline Amg::Vector3D
58ConeSurface::normal(const Amg::Vector2D& lp) const
59{
60 // (cos phi cos alpha, sin phi cos alpha, sgn z sin alpha)
61 double phi = lp[Trk::locRPhi] / (bounds().r(lp[Trk::locZ]));
62 double sgn = lp[Trk::locZ] > 0 ? -1. : +1.;
63 Amg::Vector3D localNormal(cos(phi) * bounds().cosAlpha(),
64 sin(phi) * bounds().cosAlpha(),
65 sgn * bounds().sinAlpha());
66 return Amg::Vector3D(transform().rotation() * localNormal);
67}
68
69inline const ConeBounds&
70ConeSurface::bounds() const
71{
72 return *(m_bounds.get());
73}
74
75inline bool
76ConeSurface::insideBounds(const Amg::Vector2D& locpos,
77 double tol1,
78 double tol2) const
79{
80 return bounds().inside(locpos, tol1, tol2);
81}
82
83inline bool
84ConeSurface::insideBoundsCheck(const Amg::Vector2D& locpos,
85 const BoundaryCheck& bchk) const
86{
87 return bounds().inside(locpos, bchk.toleranceLoc1, bchk.toleranceLoc2);
88}
89
90inline Amg::Vector2D
91ConeSurface::localParametersToPosition(const LocalParameters& locpars) const
92{
93 if (locpars.contains(Trk::locRPhi) && locpars.contains(Trk::locZ))
94 return Amg::Vector2D(locpars[Trk::locRPhi], locpars[Trk::locZ]);
95 if (locpars.contains(Trk::locRPhi)) {
96 // not obvious what one should do here with the "r" bit, so by definintion
97 // take that r=1 if no z is given to fix down the r component
98 double phi = locpars[Trk::locRPhi];
99 return Amg::Vector2D(phi, locpars[Trk::locZ]);
100 } else if (locpars.contains(Trk::locZ)) {
101 double r = locpars[Trk::locZ] * bounds().tanAlpha();
102 // by definition set it to M_PI/2
103 return Amg::Vector2D(r * M_PI * 0.5, locpars[Trk::locZ]);
104 }
105 return Amg::Vector2D(0., 0.);
106}
107
108/** Return properly formatted class name for screen output */
109inline std::string
110ConeSurface::name() const
111{
112 return "Trk::ConeSurface";
113}
114
115}