ATLAS Offline Software
Loading...
Searching...
No Matches
EllipseBounds.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// EllipseBounds.h, c) ATLAS Detector software
7// M. Wolter, June 2006
9
10#ifndef TRKSURFACES_ELLIPSEBOUNDS_H
11#define TRKSURFACES_ELLIPSEBOUNDS_H
12
13// Trk
17//
18#include <cmath>
19#include <cstdlib>
20
21class MsgStream;
22
23
24namespace Trk {
25
36
37class EllipseBounds final: public SurfaceBounds
38{
39public:
51
53
55 EllipseBounds(const EllipseBounds& discbo) = default;
56
58 EllipseBounds& operator=(const EllipseBounds& discbo) = default;
59
61 EllipseBounds(EllipseBounds&& discbo) noexcept = default;
62
64 EllipseBounds& operator=(EllipseBounds&& discbo) noexcept = default;
65
67 virtual ~EllipseBounds() = default;
68
70 EllipseBounds(double minrad1, double minrad2, double maxrad1, double maxrad2, double hphisec = M_PI);
71
73 EllipseBounds(double minrad1, double minrad2, double maxrad1, double maxrad2, double avephi, double hphisec);
74
75
77 virtual bool operator==(const SurfaceBounds& sbo) const override;
78
80 virtual EllipseBounds* clone() const override final;
81
83 virtual BoundsType type() const override final { return SurfaceBounds::Ellipse; }
84
87 virtual bool inside(const Amg::Vector2D& locpo, double tol1 = 0., double tol2 = 0.) const override final;
88 virtual bool inside(const Amg::Vector2D& locpo, const BoundaryCheck& bchk) const override final;
89
91 virtual bool insideLoc1(const Amg::Vector2D& locpo, double tol1 = 0.) const override final;
92
94 virtual bool insideLoc2(const Amg::Vector2D& locpo, double tol2 = 0.) const override final;
95
97 virtual double minDistance(const Amg::Vector2D& pos) const override final;
98
100 double rMinX() const;
101
103 double rMinY() const;
104
106 double rMaxX() const;
107
109 double rMaxY() const;
110
112 virtual double r() const override final;
113
115 double averagePhi() const;
116
118 double halfPhiSector() const;
119
121 virtual MsgStream& dump(MsgStream& sl) const override;
123 virtual std::ostream& dump(std::ostream& sl) const override;
124
125private:
128
130 inline double square(double x) const { return x * x; };
131};
132
133inline EllipseBounds*
135{
136 return new EllipseBounds(*this);
137}
138
139inline bool
140EllipseBounds::inside(const Amg::Vector2D& locpo, double tol1, double tol2) const
141{
142 double alpha = acos(cos(locpo[locPhi] - m_boundValues[EllipseBounds::bv_averagePhi]));
143 bool insidePhi = (m_boundValues[EllipseBounds::bv_halfPhiSector] + tol2 < M_PI)
145 : 1;
146 bool insideInner = (m_boundValues[EllipseBounds::bv_rMinX] <= tol1) ||
148 (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMinX] - tol1)) +
150 1);
151 bool insideOuter = (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMaxX] + tol1)) +
153 1);
154 return (insideInner && insideOuter && insidePhi);
155}
156
157inline bool
158EllipseBounds::inside(const Amg::Vector2D& locpo, const BoundaryCheck& bchk) const
159{
160 return EllipseBounds::inside(locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
161}
162
163inline bool
164EllipseBounds::insideLoc1(const Amg::Vector2D& locpo, double tol1) const
165{
166 bool insideInner = (m_boundValues[EllipseBounds::bv_rMinX] <= tol1) ||
168 (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMinX] - tol1)) +
170 1);
171 bool insideOuter = (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMaxX] + tol1)) +
173 1);
174 return (insideInner && insideOuter);
175}
176
177inline bool
178EllipseBounds::insideLoc2(const Amg::Vector2D& locpo, double tol2) const
179{
180 double alpha = acos(cos(locpo[locPhi] - m_boundValues[EllipseBounds::bv_averagePhi]));
181 bool insidePhi = (m_boundValues[EllipseBounds::bv_halfPhiSector] + tol2 < M_PI)
183 : 1;
184 return insidePhi;
185}
186
187inline double
192inline double
197inline double
202inline double
207inline double
212inline double
217inline double
222
223} // end of namespace
224
225#endif // TRKSURFACES_ELLIPSEBOUNDS_H
#define M_PI
double TDD_real_t
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
double toleranceLoc2
absolute tolerance in local 2 coordinate
double toleranceLoc1
absolute tolerance in local 1 coordinate
EllipseBounds(const EllipseBounds &discbo)=default
Copy constructor.
double rMinX() const
This method returns first inner radius.
double rMinY() const
This method returns second inner radius.
virtual bool insideLoc1(const Amg::Vector2D &locpo, double tol1=0.) const override final
Check for inside first local coordinate.
virtual double minDistance(const Amg::Vector2D &pos) const override final
Minimal distance to boundary ( > 0 if outside and <=0 if inside)
virtual bool insideLoc2(const Amg::Vector2D &locpo, double tol2=0.) const override final
Check for inside second local coordinate.
EllipseBounds & operator=(const EllipseBounds &discbo)=default
Assignment operator.
virtual ~EllipseBounds()=default
Destructor.
EllipseBounds()
Default Constructor.
virtual BoundsType type() const override final
Return the type of the bounds for persistency.
double averagePhi() const
This method returns the average phi.
std::vector< TDD_real_t > m_boundValues
The internal storage of the bounds can be float/double.
double rMaxY() const
This method returns second outer radius.
virtual bool operator==(const SurfaceBounds &sbo) const override
Equality operator.
EllipseBounds(EllipseBounds &&discbo) noexcept=default
Move constructor.
double halfPhiSector() const
This method returns the halfPhiSector which is covered by the disc.
double rMaxX() const
This method returns first outer radius.
virtual EllipseBounds * clone() const override final
Virtual constructor.
virtual double r() const override final
This method returns the maximum expansion on the plane (=max(rMaxX,rMaxY))
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
This method checks if the point given in the local coordinates is between two ellipsoids if only tol1...
double square(double x) const
helper function for squaring
EllipseBounds & operator=(EllipseBounds &&discbo) noexcept=default
Move assignment operator.
SurfaceBounds()=default
Default Constructor.
BoundsType
This enumerator simplifies the persistency, by saving a dynamic_cast to happen.
STL class.
int r
Definition globals.cxx:22
Definition of ATLAS Math & Geometry primitives (Amg)
Eigen::Matrix< double, 2, 1 > Vector2D
Ensure that the ATLAS eigen extensions are properly loaded.
@ locY
local cartesian
Definition ParamDefs.h:38
@ x
Definition ParamDefs.h:55
@ locX
Definition ParamDefs.h:37
@ locPhi
local polar
Definition ParamDefs.h:45
-event-from-file
STL namespace.
#define private