ATLAS Offline Software
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 
21 class MsgStream;
22 
23 
24 namespace Trk {
25 
37 class EllipseBounds final: public SurfaceBounds
38 {
39 public:
42  {
43  bv_rMinX = 0,
44  bv_rMinY = 1,
45  bv_rMaxX = 2,
46  bv_rMaxY = 3,
49  bv_length = 6
50  };
52  EllipseBounds();
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 
125 private:
128 
130  inline double square(double x) const { return x * x; };
131 };
132 
133 inline EllipseBounds*
135 {
136  return new EllipseBounds(*this);
137 }
138 
139 inline bool
140 EllipseBounds::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)
144  ? (alpha <= (m_boundValues[EllipseBounds::bv_halfPhiSector] + tol2))
145  : 1;
146  bool insideInner = (m_boundValues[EllipseBounds::bv_rMinX] <= tol1) ||
148  (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMinX] - tol1)) +
149  square(locpo[locY] / (m_boundValues[EllipseBounds::bv_rMinY] - tol1)) >
150  1);
151  bool insideOuter = (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMaxX] + tol1)) +
152  square(locpo[locY] / (m_boundValues[EllipseBounds::bv_rMaxY] + tol1)) <
153  1);
154  return (insideInner && insideOuter && insidePhi);
155 }
156 
157 inline bool
158 EllipseBounds::inside(const Amg::Vector2D& locpo, const BoundaryCheck& bchk) const
159 {
160  return EllipseBounds::inside(locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
161 }
162 
163 inline bool
164 EllipseBounds::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)) +
169  square(locpo[locY] / (m_boundValues[EllipseBounds::bv_rMinY] - tol1)) >
170  1);
171  bool insideOuter = (square(locpo[locX] / (m_boundValues[EllipseBounds::bv_rMaxX] + tol1)) +
172  square(locpo[locY] / (m_boundValues[EllipseBounds::bv_rMaxY] + tol1)) <
173  1);
174  return (insideInner && insideOuter);
175 }
176 
177 inline bool
178 EllipseBounds::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)
182  ? (alpha <= (m_boundValues[EllipseBounds::bv_halfPhiSector] + tol2))
183  : 1;
184  return insidePhi;
185 }
186 
187 inline double
189 {
191 }
192 inline double
194 {
196 }
197 inline double
199 {
201 }
202 inline double
204 {
206 }
207 inline double
209 {
211 }
212 inline double
214 {
216 }
217 inline double
219 {
221 }
222 
223 } // end of namespace
224 
225 #endif // TRKSURFACES_ELLIPSEBOUNDS_H
Trk::EllipseBounds::insideLoc2
virtual bool insideLoc2(const Amg::Vector2D &locpo, double tol2=0.) const override final
Check for inside second local coordinate.
Definition: EllipseBounds.h:178
Trk::EllipseBounds::bv_rMaxY
@ bv_rMaxY
Definition: EllipseBounds.h:46
Trk::SurfaceBounds::BoundsType
BoundsType
Definition: SurfaceBounds.h:59
Trk::EllipseBounds::operator=
EllipseBounds & operator=(EllipseBounds &&discbo) noexcept=default
Move assignment operator.
Trk::EllipseBounds::rMaxY
double rMaxY() const
This method returns second outer radius.
Definition: EllipseBounds.h:203
Trk::EllipseBounds::rMaxX
double rMaxX() const
This method returns first outer radius.
Definition: EllipseBounds.h:198
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Trk::EllipseBounds::halfPhiSector
double halfPhiSector() const
This method returns the halfPhiSector which is covered by the disc.
Definition: EllipseBounds.h:218
Trk::EllipseBounds::averagePhi
double averagePhi() const
This method returns the average phi.
Definition: EllipseBounds.h:213
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::EllipseBounds::operator=
EllipseBounds & operator=(const EllipseBounds &discbo)=default
Assignment operator.
Trk::EllipseBounds
Definition: EllipseBounds.h:38
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
Trk::SurfaceBounds
Definition: SurfaceBounds.h:47
Trk::EllipseBounds::dump
virtual MsgStream & dump(MsgStream &sl) const override
Output Method for MsgStream.
Definition: EllipseBounds.cxx:172
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::EllipseBounds::EllipseBounds
EllipseBounds(const EllipseBounds &discbo)=default
Copy constructor.
Trk::EllipseBounds::inside
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...
Definition: EllipseBounds.h:140
Trk::EllipseBounds::clone
virtual EllipseBounds * clone() const override final
Virtual constructor.
Definition: EllipseBounds.h:134
Trk::EllipseBounds::square
double square(double x) const
helper function for squaring
Definition: EllipseBounds.h:130
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
Trk::EllipseBounds::EllipseBounds
EllipseBounds()
Default Constructor.
Definition: EllipseBounds.cxx:20
ParamDefs.h
Trk::EllipseBounds::~EllipseBounds
virtual ~EllipseBounds()=default
Destructor.
Trk::EllipseBounds::bv_length
@ bv_length
Definition: EllipseBounds.h:49
Trk::BoundaryCheck::toleranceLoc1
double toleranceLoc1
absolute tolerance in local 1 coordinate
Definition: BoundaryCheck.h:68
GeoPrimitives.h
SurfaceBounds.h
Trk::EllipseBounds::rMinX
double rMinX() const
This method returns first inner radius.
Definition: EllipseBounds.h:188
vector
Definition: MultiHisto.h:13
Trk::EllipseBounds::rMinY
double rMinY() const
This method returns second inner radius.
Definition: EllipseBounds.h:193
Trk::EllipseBounds::bv_averagePhi
@ bv_averagePhi
Definition: EllipseBounds.h:47
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::EllipseBounds::operator==
virtual bool operator==(const SurfaceBounds &sbo) const override
Equality operator.
Definition: EllipseBounds.cxx:84
Trk::EllipseBounds::m_boundValues
std::vector< TDD_real_t > m_boundValues
The internal storage of the bounds can be float/double.
Definition: EllipseBounds.h:127
Trk::EllipseBounds::bv_rMinY
@ bv_rMinY
Definition: EllipseBounds.h:44
Trk::EllipseBounds::minDistance
virtual double minDistance(const Amg::Vector2D &pos) const override final
Minimal distance to boundary ( > 0 if outside and <=0 if inside)
Definition: EllipseBounds.cxx:98
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
Trk::locPhi
@ locPhi
local polar
Definition: ParamDefs.h:45
Trk::EllipseBounds::type
virtual BoundsType type() const override final
Return the type of the bounds for persistency.
Definition: EllipseBounds.h:83
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::EllipseBounds::BoundValues
BoundValues
Definition: EllipseBounds.h:42
Trk::EllipseBounds::r
virtual double r() const override final
This method returns the maximum expansion on the plane (=max(rMaxX,rMaxY))
Definition: EllipseBounds.h:208
Trk::EllipseBounds::bv_rMaxX
@ bv_rMaxX
Definition: EllipseBounds.h:45
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
Trk::EllipseBounds::bv_rMinX
@ bv_rMinX
Definition: EllipseBounds.h:43
Trk::BoundaryCheck::toleranceLoc2
double toleranceLoc2
absolute tolerance in local 2 coordinate
Definition: BoundaryCheck.h:69
Trk::x
@ x
Definition: ParamDefs.h:55
Trk::EllipseBounds::EllipseBounds
EllipseBounds(EllipseBounds &&discbo) noexcept=default
Move constructor.
Trk::EllipseBounds::bv_halfPhiSector
@ bv_halfPhiSector
Definition: EllipseBounds.h:48
Trk::SurfaceBounds::Ellipse
@ Ellipse
Definition: SurfaceBounds.h:64
Trk::EllipseBounds::insideLoc1
virtual bool insideLoc1(const Amg::Vector2D &locpo, double tol1=0.) const override final
Check for inside first local coordinate.
Definition: EllipseBounds.h:164
TDD_real_t
double TDD_real_t
Definition: AnnulusBounds.h:20