ATLAS Offline Software
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 
5 namespace Trk {
6 
7 inline 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 */
20 inline constexpr SurfaceType
21 ConeSurface::type() const
22 {
23  return ConeSurface::staticType;
24 }
25 
26 template<int DIM, class T>
27 std::unique_ptr<ParametersT<DIM, T, ConeSurface>>
28 ConeSurface::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 */
40 template<int DIM, class T>
41 std::unique_ptr<ParametersT<DIM, T, ConeSurface>>
42 ConeSurface::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 
51 inline ConeSurface*
52 ConeSurface::clone() const
53 {
54  return new ConeSurface(*this);
55 }
56 
57 inline Amg::Vector3D
58 ConeSurface::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 
69 inline const ConeBounds&
70 ConeSurface::bounds() const
71 {
72  return *(m_bounds.get());
73 }
74 
75 inline bool
76 ConeSurface::insideBounds(const Amg::Vector2D& locpos,
77  double tol1,
78  double tol2) const
79 {
80  return bounds().inside(locpos, tol1, tol2);
81 }
82 
83 inline bool
84 ConeSurface::insideBoundsCheck(const Amg::Vector2D& locpos,
85  const BoundaryCheck& bchk) const
86 {
87  return bounds().inside(locpos, bchk.toleranceLoc1, bchk.toleranceLoc2);
88 }
89 
90 inline Amg::Vector2D
91 ConeSurface::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 */
109 inline std::string
110 ConeSurface::name() const
111 {
112  return "Trk::ConeSurface";
113 }
114 
115 }