ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::EllipseBounds Class Referencefinal

#include <EllipseBounds.h>

Inheritance diagram for Trk::EllipseBounds:
Collaboration diagram for Trk::EllipseBounds:

Public Types

enum  BoundValues {
  bv_rMinX = 0, bv_rMinY = 1, bv_rMaxX = 2, bv_rMaxY = 3,
  bv_averagePhi = 4, bv_halfPhiSector = 5, bv_length = 6
}
 
enum  BoundsType {
  Cone = 0, Cylinder = 1, Diamond = 2, Disc = 3,
  Ellipse = 5, Rectangle = 6, RotatedTrapezoid = 7, Trapezoid = 8,
  Triangle = 9, DiscTrapezoidal = 10, Annulus = 11, Other = 12
}
 

Public Member Functions

 EllipseBounds ()
 Default Constructor. More...
 
 EllipseBounds (const EllipseBounds &discbo)=default
 Copy constructor. More...
 
EllipseBoundsoperator= (const EllipseBounds &discbo)=default
 Assignment operator. More...
 
 EllipseBounds (EllipseBounds &&discbo) noexcept=default
 Move constructor. More...
 
EllipseBoundsoperator= (EllipseBounds &&discbo) noexcept=default
 Move assignment operator. More...
 
virtual ~EllipseBounds ()=default
 Destructor. More...
 
 EllipseBounds (double minrad1, double minrad2, double maxrad1, double maxrad2, double hphisec=M_PI)
 Constructor for full of an ellipsoid disc around phi=0. More...
 
 EllipseBounds (double minrad1, double minrad2, double maxrad1, double maxrad2, double avephi, double hphisec)
 Constructor for an ellipsoid disc around phi != 0. More...
 
virtual bool operator== (const SurfaceBounds &sbo) const override
 Equality operator. More...
 
virtual EllipseBoundsclone () const override final
 Virtual constructor. More...
 
virtual BoundsType type () const override final
 Return the type of the bounds for persistency. More...
 
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 is given and additional in the phi sector is tol2 is given. More...
 
virtual bool inside (const Amg::Vector2D &locpo, const BoundaryCheck &bchk) const override final
 
virtual bool insideLoc1 (const Amg::Vector2D &locpo, double tol1=0.) const override final
 Check for inside first local coordinate. More...
 
virtual bool insideLoc2 (const Amg::Vector2D &locpo, double tol2=0.) const override final
 Check for inside second local coordinate. More...
 
virtual double minDistance (const Amg::Vector2D &pos) const override final
 Minimal distance to boundary ( > 0 if outside and <=0 if inside) More...
 
double rMinX () const
 This method returns first inner radius. More...
 
double rMinY () const
 This method returns second inner radius. More...
 
double rMaxX () const
 This method returns first outer radius. More...
 
double rMaxY () const
 This method returns second outer radius. More...
 
virtual double r () const override final
 This method returns the maximum expansion on the plane (=max(rMaxX,rMaxY)) More...
 
double averagePhi () const
 This method returns the average phi. More...
 
double halfPhiSector () const
 This method returns the halfPhiSector which is covered by the disc. More...
 
virtual MsgStream & dump (MsgStream &sl) const override
 Output Method for MsgStream. More...
 
virtual std::ostream & dump (std::ostream &sl) const override
 Output Method for std::ostream. More...
 
virtual bool operator!= (const SurfaceBounds &sb) const
 Non-Equality operator. More...
 

Protected Member Functions

void swap (double &b1, double &b2)
 Swap method to be called from DiscBounds or TrapezoidalBounds. More...
 
virtual void initCache ()
 virtual initCache method for object persistency More...
 

Private Member Functions

double square (double x) const
 helper function for squaring More...
 

Private Attributes

std::vector< TDD_real_tm_boundValues
 The internal storage of the bounds can be float/double. More...
 

Detailed Description

Class to describe the bounds for a planar EllipseSurface, i.e. the surface between two ellipses. By providing an argument for hphisec, the bounds can be restricted to a phirange around the center position.

Author
Marci.nosp@m.n.Wo.nosp@m.lter@.nosp@m.cern.nosp@m..ch

Definition at line 37 of file EllipseBounds.h.

Member Enumeration Documentation

◆ BoundsType

This enumerator simplifies the persistency, by saving a dynamic_cast to happen.

Other is reserved for the GeometrySurfaces implementation.

Enumerator
Cone 
Cylinder 
Diamond 
Disc 
Ellipse 
Rectangle 
RotatedTrapezoid 
Trapezoid 
Triangle 
DiscTrapezoidal 
Annulus 
Other 

Definition at line 58 of file SurfaceBounds.h.

59  {
60  Cone = 0,
61  Cylinder = 1,
62  Diamond = 2,
63  Disc = 3,
64  Ellipse = 5,
65  Rectangle = 6,
66  RotatedTrapezoid = 7,
67  Trapezoid = 8,
68  Triangle = 9,
69  DiscTrapezoidal = 10,
70  Annulus = 11,
71  Other = 12
72 
73  };

◆ BoundValues

Enumerator
bv_rMinX 
bv_rMinY 
bv_rMaxX 
bv_rMaxY 
bv_averagePhi 
bv_halfPhiSector 
bv_length 

Definition at line 41 of file EllipseBounds.h.

42  {
43  bv_rMinX = 0,
44  bv_rMinY = 1,
45  bv_rMaxX = 2,
46  bv_rMaxY = 3,
47  bv_averagePhi = 4,
48  bv_halfPhiSector = 5,
49  bv_length = 6
50  };

Constructor & Destructor Documentation

◆ EllipseBounds() [1/5]

Trk::EllipseBounds::EllipseBounds ( )

Default Constructor.

Definition at line 20 of file EllipseBounds.cxx.

◆ EllipseBounds() [2/5]

Trk::EllipseBounds::EllipseBounds ( const EllipseBounds discbo)
default

Copy constructor.

◆ EllipseBounds() [3/5]

Trk::EllipseBounds::EllipseBounds ( EllipseBounds &&  discbo)
defaultnoexcept

Move constructor.

◆ ~EllipseBounds()

virtual Trk::EllipseBounds::~EllipseBounds ( )
virtualdefault

Destructor.

◆ EllipseBounds() [4/5]

Trk::EllipseBounds::EllipseBounds ( double  minrad1,
double  minrad2,
double  maxrad1,
double  maxrad2,
double  hphisec = M_PI 
)

Constructor for full of an ellipsoid disc around phi=0.

Definition at line 24 of file EllipseBounds.cxx.

◆ EllipseBounds() [5/5]

Trk::EllipseBounds::EllipseBounds ( double  minrad1,
double  minrad2,
double  maxrad1,
double  maxrad2,
double  avephi,
double  hphisec 
)

Constructor for an ellipsoid disc around phi != 0.

Definition at line 50 of file EllipseBounds.cxx.

Member Function Documentation

◆ averagePhi()

double Trk::EllipseBounds::averagePhi ( ) const
inline

This method returns the average phi.

Definition at line 213 of file EllipseBounds.h.

214 {
216 }

◆ clone()

EllipseBounds * Trk::EllipseBounds::clone ( ) const
inlinefinaloverridevirtual

Virtual constructor.

Implements Trk::SurfaceBounds.

Definition at line 134 of file EllipseBounds.h.

135 {
136  return new EllipseBounds(*this);
137 }

◆ dump() [1/2]

MsgStream & Trk::EllipseBounds::dump ( MsgStream &  sl) const
overridevirtual

Output Method for MsgStream.

Implements Trk::SurfaceBounds.

Definition at line 172 of file EllipseBounds.cxx.

173 {
174  sl << std::setiosflags(std::ios::fixed);
175  sl << std::setprecision(7);
176  sl << "Trk::EllipseBounds: (innerRadiusX, innerRadiusY, outerRadiusX, outerRadiusY, averagePhi, hPhiSector) = ";
177  sl << "(" << this->rMinX() << ", " << this->rMinY() << ", " << this->rMaxX() << ", " << this->rMaxY() << ", "
178  << this->averagePhi() << ", " << this->halfPhiSector() << ")";
179  sl << std::setprecision(-1);
180  return sl;
181 }

◆ dump() [2/2]

std::ostream & Trk::EllipseBounds::dump ( std::ostream &  sl) const
overridevirtual

Output Method for std::ostream.

Implements Trk::SurfaceBounds.

Definition at line 184 of file EllipseBounds.cxx.

185 {
186  sl << std::setiosflags(std::ios::fixed);
187  sl << std::setprecision(7);
188  sl << "Trk::EllipseBounds: (innerRadiusX, innerRadiusY, outerRadiusX, outerRadiusY, hPhiSector) = ";
189  sl << "(" << this->rMinX() << ", " << this->rMinY() << ", " << this->rMaxX() << ", " << this->rMaxY() << ", "
190  << this->averagePhi() << ", " << this->halfPhiSector() << ")";
191  sl << std::setprecision(-1);
192  return sl;
193 }

◆ halfPhiSector()

double Trk::EllipseBounds::halfPhiSector ( ) const
inline

This method returns the halfPhiSector which is covered by the disc.

Definition at line 218 of file EllipseBounds.h.

219 {
221 }

◆ initCache()

virtual void Trk::SurfaceBounds::initCache ( )
inlineprotectedvirtualinherited

virtual initCache method for object persistency

Reimplemented in Trk::RotatedTrapezoidBounds, Trk::ConeBounds, Trk::RotatedDiamondBounds, and Trk::DiamondBounds.

Definition at line 129 of file SurfaceBounds.h.

129 {}

◆ inside() [1/2]

bool Trk::EllipseBounds::inside ( const Amg::Vector2D locpo,
const BoundaryCheck bchk 
) const
inlinefinaloverridevirtual

Implements Trk::SurfaceBounds.

Definition at line 158 of file EllipseBounds.h.

159 {
160  return EllipseBounds::inside(locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
161 }

◆ inside() [2/2]

bool Trk::EllipseBounds::inside ( const Amg::Vector2D locpo,
double  tol1 = 0.,
double  tol2 = 0. 
) const
inlinefinaloverridevirtual

This method checks if the point given in the local coordinates is between two ellipsoids if only tol1 is given and additional in the phi sector is tol2 is given.

Implements Trk::SurfaceBounds.

Definition at line 140 of file EllipseBounds.h.

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 }

◆ insideLoc1()

bool Trk::EllipseBounds::insideLoc1 ( const Amg::Vector2D locpo,
double  tol1 = 0. 
) const
inlinefinaloverridevirtual

Check for inside first local coordinate.

Implements Trk::SurfaceBounds.

Definition at line 164 of file EllipseBounds.h.

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 }

◆ insideLoc2()

bool Trk::EllipseBounds::insideLoc2 ( const Amg::Vector2D locpo,
double  tol2 = 0. 
) const
inlinefinaloverridevirtual

Check for inside second local coordinate.

Implements Trk::SurfaceBounds.

Definition at line 178 of file EllipseBounds.h.

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 }

◆ minDistance()

double Trk::EllipseBounds::minDistance ( const Amg::Vector2D pos) const
finaloverridevirtual

Minimal distance to boundary ( > 0 if outside and <=0 if inside)

Implements Trk::SurfaceBounds.

Definition at line 98 of file EllipseBounds.cxx.

99 {
100  const double pi2 = 2. * M_PI;
101 
102  double r = sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
103  if (r == 0.) {
107  }
108 
109  const double inv_r = 1. / r;
110  double sn = pos[1] * inv_r;
111  double cs = pos[0] * inv_r;
112  double sf = 0.;
113  double dF = 0.;
114 
116  dF = atan2(cs, sn) - m_boundValues[EllipseBounds::bv_averagePhi];
117  dF += (dF > M_PI) ? -pi2 : (dF < -M_PI) ? pi2 : 0;
118  double df = std::abs(dF) - m_boundValues[EllipseBounds::bv_halfPhiSector];
119  sf = r * sin(df);
120  if (df > 0.){
121  r *= cos(df);
122  }
123  } else {
124  sf = -1.e+10;
125  }
126 
127  if (sf <= 0.) {
128 
129  double a = cs / m_boundValues[EllipseBounds::bv_rMaxX];
130  double b = sn / m_boundValues[EllipseBounds::bv_rMaxY];
131  double sr0 = r - 1. / std::sqrt(a * a + b * b);
132  if (sr0 >= 0.)
133  return sr0;
136  double sr1 = 1. / std::sqrt(a * a + b * b) - r;
137  if (sr1 >= 0.){
138  return sr1;
139  }
140  if (sf < sr0){
141  sf = sr0;
142  }
143  if (sf < sr1){
144  sf = sr1;
145  }
146  return sf;
147  }
148 
149  double fb;
152  sn = sin(fb);
153  cs = cos(fb);
154  double a = cs / m_boundValues[EllipseBounds::bv_rMaxX];
155  double b = sn / m_boundValues[EllipseBounds::bv_rMaxY];
156  double sr0 = r - 1. / std::sqrt(a * a + b * b);
157  if (sr0 >= 0.){
158  return std::sqrt(sr0 * sr0 + sf * sf);
159  }
162  double sr1 = 1. / sqrt(a * a + b * b) - r;
163  if (sr1 >= 0.){
164  return std::sqrt(sr1 * sr1 + sf * sf);
165  }
166  return sf;
167 }

◆ operator!=()

bool Trk::SurfaceBounds::operator!= ( const SurfaceBounds sb) const
inlinevirtualinherited

Non-Equality operator.

Reimplemented in Trk::InvalidBounds.

Definition at line 141 of file SurfaceBounds.h.

142 {
143  return !((*this) == sb);
144 }

◆ operator=() [1/2]

EllipseBounds& Trk::EllipseBounds::operator= ( const EllipseBounds discbo)
default

Assignment operator.

◆ operator=() [2/2]

EllipseBounds& Trk::EllipseBounds::operator= ( EllipseBounds &&  discbo)
defaultnoexcept

Move assignment operator.

◆ operator==()

bool Trk::EllipseBounds::operator== ( const SurfaceBounds sbo) const
overridevirtual

Equality operator.

Implements Trk::SurfaceBounds.

Definition at line 84 of file EllipseBounds.cxx.

85 {
86  // check the type first not to compare apples with oranges
87  const Trk::EllipseBounds* discbo = dynamic_cast<const Trk::EllipseBounds*>(&sbo);
88  if (!discbo)
89  return false;
90  return (m_boundValues == discbo->m_boundValues);
91 }

◆ r()

double Trk::EllipseBounds::r ( ) const
inlinefinaloverridevirtual

This method returns the maximum expansion on the plane (=max(rMaxX,rMaxY))

Implements Trk::SurfaceBounds.

Definition at line 208 of file EllipseBounds.h.

◆ rMaxX()

double Trk::EllipseBounds::rMaxX ( ) const
inline

This method returns first outer radius.

Definition at line 198 of file EllipseBounds.h.

199 {
201 }

◆ rMaxY()

double Trk::EllipseBounds::rMaxY ( ) const
inline

This method returns second outer radius.

Definition at line 203 of file EllipseBounds.h.

204 {
206 }

◆ rMinX()

double Trk::EllipseBounds::rMinX ( ) const
inline

This method returns first inner radius.

Definition at line 188 of file EllipseBounds.h.

189 {
191 }

◆ rMinY()

double Trk::EllipseBounds::rMinY ( ) const
inline

This method returns second inner radius.

Definition at line 193 of file EllipseBounds.h.

194 {
196 }

◆ square()

double Trk::EllipseBounds::square ( double  x) const
inlineprivate

helper function for squaring

Definition at line 130 of file EllipseBounds.h.

130 { return x * x; };

◆ swap()

void Trk::SurfaceBounds::swap ( double &  b1,
double &  b2 
)
inlineprotectedinherited

Swap method to be called from DiscBounds or TrapezoidalBounds.

Definition at line 133 of file SurfaceBounds.h.

134 {
135  double tmp = b1;
136  b1 = b2;
137  b2 = tmp;
138 }

◆ type()

virtual BoundsType Trk::EllipseBounds::type ( ) const
inlinefinaloverridevirtual

Return the type of the bounds for persistency.

Implements Trk::SurfaceBounds.

Definition at line 83 of file EllipseBounds.h.

83 { return SurfaceBounds::Ellipse; }

Member Data Documentation

◆ m_boundValues

std::vector<TDD_real_t> Trk::EllipseBounds::m_boundValues
private

The internal storage of the bounds can be float/double.

Definition at line 127 of file EllipseBounds.h.


The documentation for this class was generated from the following files:
Trk::EllipseBounds::bv_rMaxY
@ bv_rMaxY
Definition: EllipseBounds.h:46
Trk::SurfaceBounds::DiscTrapezoidal
@ DiscTrapezoidal
Definition: SurfaceBounds.h:69
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
max
#define max(a, b)
Definition: cfImp.cxx:41
Trk::SurfaceBounds::Cone
@ Cone
Definition: SurfaceBounds.h:60
Trk::locX
@ locX
Definition: ParamDefs.h:43
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
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
Trk::SurfaceBounds::Rectangle
@ Rectangle
Definition: SurfaceBounds.h:65
Trk::EllipseBounds
Definition: EllipseBounds.h:38
Trk::SurfaceBounds::swap
void swap(double &b1, double &b2)
Swap method to be called from DiscBounds or TrapezoidalBounds.
Definition: SurfaceBounds.h:133
python.PhysicalConstants.pi2
float pi2
Definition: PhysicalConstants.py:52
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::SurfaceBounds::Annulus
@ Annulus
Definition: SurfaceBounds.h:70
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::SurfaceBounds::Diamond
@ Diamond
Definition: SurfaceBounds.h:62
Trk::EllipseBounds::square
double square(double x) const
helper function for squaring
Definition: EllipseBounds.h:130
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::EllipseBounds::EllipseBounds
EllipseBounds()
Default Constructor.
Definition: EllipseBounds.cxx:20
Trk::EllipseBounds::bv_length
@ bv_length
Definition: EllipseBounds.h:49
Trk::EllipseBounds::rMinX
double rMinX() const
This method returns first inner radius.
Definition: EllipseBounds.h:188
Trk::EllipseBounds::rMinY
double rMinY() const
This method returns second inner radius.
Definition: EllipseBounds.h:193
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
Trk::EllipseBounds::bv_averagePhi
@ bv_averagePhi
Definition: EllipseBounds.h:47
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
keylayer_zslicemap.sb
sb
Definition: keylayer_zslicemap.py:192
Trk::EllipseBounds::bv_rMinY
@ bv_rMinY
Definition: EllipseBounds.h:44
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Trk::locPhi
@ locPhi
local polar
Definition: ParamDefs.h:51
Trk::SurfaceBounds::Trapezoid
@ Trapezoid
Definition: SurfaceBounds.h:67
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
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
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::EllipseBounds::bv_rMaxX
@ bv_rMaxX
Definition: EllipseBounds.h:45
Trk::SurfaceBounds::Disc
@ Disc
Definition: SurfaceBounds.h:63
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
Trk::EllipseBounds::bv_rMinX
@ bv_rMinX
Definition: EllipseBounds.h:43
Trk::SurfaceBounds::RotatedTrapezoid
@ RotatedTrapezoid
Definition: SurfaceBounds.h:66
Trk::SurfaceBounds::Other
@ Other
Definition: SurfaceBounds.h:71
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::x
@ x
Definition: ParamDefs.h:61
Trk::SurfaceBounds::Triangle
@ Triangle
Definition: SurfaceBounds.h:68
Trk::EllipseBounds::bv_halfPhiSector
@ bv_halfPhiSector
Definition: EllipseBounds.h:48
python.TriggerAPI.TriggerAPISession.df
df
Definition: TriggerAPISession.py:359
Trk::SurfaceBounds::Ellipse
@ Ellipse
Definition: SurfaceBounds.h:64
Trk::SurfaceBounds::Cylinder
@ Cylinder
Definition: SurfaceBounds.h:61