ATLAS Offline Software
Loading...
Searching...
No Matches
CylinderBounds.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5namespace Trk {
6inline bool CylinderBounds::operator==(const CylinderBounds& bo) const
7{
8 return *this == static_cast<const SurfaceBounds &>(bo);
9}
10
11inline CylinderBounds*
12CylinderBounds::clone() const
13{
14 return new CylinderBounds(*this);
15}
16
17inline bool
18CylinderBounds::inside(const Amg::Vector2D& locpo,
19 double tol1,
20 double tol2) const
21{
22 double z = locpo[locZ];
23 bool insideZ = insideLocZ(z, tol2);
24 if (!insideZ)
25 return false;
26 // no check on Phi neccesary
27 if (!m_checkPhi)
28 return true;
29 // now check insidePhi
30 double localPhi =
31 (locpo[locRPhi] / m_boundValues[CylinderBounds::bv_radius]) -
32 m_boundValues[CylinderBounds::bv_averagePhi];
33 localPhi -= (localPhi > M_PI) ? 2. * M_PI : 0.;
34 return (localPhi * localPhi <
35 (m_boundValues[CylinderBounds::bv_halfPhiSector] + tol1) *
36 (m_boundValues[CylinderBounds::bv_halfPhiSector] + tol1));
37}
38
39inline bool
40CylinderBounds::inside(const Amg::Vector2D& locpo,
41 const BoundaryCheck& bchk) const
42{
43 if (bchk.bcType == 0 || bchk.nSigmas == 0 ||
44 m_boundValues[CylinderBounds::bv_halfPhiSector] != M_PI)
45 return CylinderBounds::inside(
46 locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
47
48 float theta =
49 (bchk.lCovariance(1, 0) != 0 &&
50 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)) != 0)
51 ? .5 * bchk.FastArcTan(2 * bchk.lCovariance(1, 0) /
52 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)))
53 : 0.;
54 sincosCache scResult = bchk.FastSinCos(theta);
55 double dphi = scResult.sinC * scResult.sinC * bchk.lCovariance(0, 0);
56 double dz = scResult.cosC * scResult.cosC * bchk.lCovariance(0, 1);
57 double max_ell = dphi > dz ? dphi : dz;
58 double limit = bchk.nSigmas * sqrt(max_ell);
59 return insideLocZ(locpo[locZ], limit);
60}
61
62inline bool
63CylinderBounds::inside3D(const Amg::Vector3D& glopo,
64 double tol1,
65 double tol2) const
66{
67 return inside(glopo.perp(), glopo.phi(), glopo.z(), tol1, tol2);
68}
69
70inline bool
71CylinderBounds::inside(double r, double phi, double z, double tol1, double tol2)
72 const
73{
74
75 bool insideZ = insideLocZ(z, tol2);
76 if (!insideZ)
77 return false;
78 double diffR = (m_boundValues[CylinderBounds::bv_radius] - r);
79 bool insideR = diffR * diffR < tol1 * tol1;
80 if (!insideR)
81 return false;
82 // now check insidePhi if needed
83 if (!m_checkPhi)
84 return true;
85 // phi needs to be checked
86 double localPhi = phi - m_boundValues[CylinderBounds::bv_averagePhi];
87 localPhi -= (localPhi > M_PI) ? 2. * M_PI : 0.;
88 return (localPhi * localPhi <
89 m_boundValues[CylinderBounds::bv_halfPhiSector] *
90 m_boundValues[CylinderBounds::bv_halfPhiSector]);
91}
92
93inline bool
94CylinderBounds::insideLocZ(double z, double tol2) const
95{
96 return (m_boundValues[CylinderBounds::bv_halfZ] + tol2) - fabs(z) > 0.;
97}
98
99inline bool
100CylinderBounds::insideLoc1(const Amg::Vector2D& locpo, double tol1) const
101{
102 bool insideRphi = false;
103 if (fabs(m_boundValues[CylinderBounds::bv_averagePhi]) < 10e-7)
104 insideRphi =
105 (fabs(locpo[locRPhi] / m_boundValues[CylinderBounds::bv_radius]) <
106 (m_boundValues[CylinderBounds::bv_halfPhiSector] + tol1));
107 else {
108 double localPhi =
109 (locpo[locRPhi] / m_boundValues[CylinderBounds::bv_radius]) -
110 m_boundValues[CylinderBounds::bv_averagePhi];
111 localPhi -= (localPhi > M_PI) ? 2. * M_PI : 0.;
112 insideRphi =
113 (localPhi < (m_boundValues[CylinderBounds::bv_halfPhiSector] + tol1));
114 }
115 return (insideRphi);
116}
117
118inline bool
119CylinderBounds::insideLoc2(const Amg::Vector2D& locpo, double tol2) const
120{
121 return insideLocZ(locpo[locZ], tol2);
122}
123
124inline bool
125CylinderBounds::insideRadius(const Amg::Vector2D& locpo, double tol) const
126{
127 return (this->inside(locpo, tol, 0) &&
128 fabs(locpo[locR]) < m_boundValues[CylinderBounds::bv_radius] + tol);
129}
130
131inline double
132CylinderBounds::r() const
133{
134 return m_boundValues[CylinderBounds::bv_radius];
135}
136
137inline double
138CylinderBounds::averagePhi() const
139{
140 return m_boundValues[CylinderBounds::bv_averagePhi];
141}
142
143inline double
144CylinderBounds::halfPhiSector() const
145{
146 return m_boundValues[CylinderBounds::bv_halfPhiSector];
147}
148
149inline double
150CylinderBounds::halflengthZ() const
151{
152 return m_boundValues[CylinderBounds::bv_halfZ];
153}
154
155}
156