ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::DiamondBounds Class Referencefinal

Bounds for a double trapezoidal ("diamond"), planar Surface. More...

#include <DiamondBounds.h>

Inheritance diagram for Trk::DiamondBounds:
Collaboration diagram for Trk::DiamondBounds:

Public Types

enum  BoundValues {
  bv_minHalfX = 0 , bv_medHalfX = 1 , bv_maxHalfX = 2 , bv_halfY1 = 3 ,
  bv_halfY2 = 4 , bv_length = 5
}
 BoundValues for better readability. More...
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
}
 This enumerator simplifies the persistency, by saving a dynamic_cast to happen. More...

Public Member Functions

 DiamondBounds ()
 Default Constructor, needed for persistency.
 DiamondBounds (const DiamondBounds &diabo)=default
 Copy constructor.
DiamondBoundsoperator= (const DiamondBounds &sbo)=default
 Assignment operator.
 DiamondBounds (DiamondBounds &&diabo) noexcept=default
 Copy constructor.
DiamondBoundsoperator= (DiamondBounds &&sbo) noexcept=default
 Assignment operator.
virtual ~DiamondBounds ()=default
 Destructor.
 DiamondBounds (double minhalex, double medhalex, double maxhalex, double haley1, double haley2)
 Constructor for symmetric Diamond.
DiamondBoundsclone () const override
 Virtual constructor.
virtual bool operator== (const SurfaceBounds &diabo) const override
 Equality operator.
virtual BoundsType type () const override final
 Return the bounds type.
double minHalflengthX () const
 This method returns the halflength in X at minimal Y (first coordinate of local surface frame)
double medHalflengthX () const
 This method returns the (maximal) halflength in X (first coordinate of local surface frame)
double maxHalflengthX () const
 This method returns the halflength in X at maximal Y (first coordinate of local surface frame)
double halflengthY1 () const
 This method returns the halflength in Y of trapezoid at negative/positive Y (second coordinate)
double halflengthY2 () const
virtual double r () const override final
 This method returns the maximal extension on the local plane.
double alpha1 () const
 This method returns the opening angle alpha in point A.
double alpha2 () const
 This method returns the opening angle alpha in point A'.
virtual bool inside (const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
 The orientation of the Diamond is according to the figure.
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
 This method checks inside bounds in loc1.
virtual bool insideLoc2 (const Amg::Vector2D &locpo, double tol2=0.) const override final
 This method checks inside bounds in loc2.
virtual double minDistance (const Amg::Vector2D &pos) const override final
 Minimal distance to boundary ( > 0 if outside and <=0 if inside)
virtual MsgStream & dump (MsgStream &sl) const override final
 Output Method for MsgStream.
virtual std::ostream & dump (std::ostream &sl) const override final
 Output Method for std::ostream.
virtual bool operator!= (const SurfaceBounds &sb) const
 Non-Equality operator.

Protected Member Functions

void swap (double &b1, double &b2)
 Swap method to be called from DiscBounds or TrapezoidalBounds.

Private Member Functions

bool insideFull (const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const
 inside() method for a full symmetric diamond
virtual void initCache () override
 initialize the alpha1/2 cache - needed also for object persistency

Private Attributes

std::vector< TDD_real_tm_boundValues
 Internal parameters stored in the geometry.
TDD_real_t m_alpha1
TDD_real_t m_alpha2

Friends

class ::DiamondBoundsCnv_p1

Detailed Description

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.

◆ BoundValues

BoundValues for better readability.

Enumerator
bv_minHalfX 
bv_medHalfX 
bv_maxHalfX 
bv_halfY1 
bv_halfY2 
bv_length 

Definition at line 41 of file DiamondBounds.h.

Constructor & Destructor Documentation

◆ DiamondBounds() [1/4]

Trk::DiamondBounds::DiamondBounds ( )

Default Constructor, needed for persistency.

Definition at line 19 of file DiamondBounds.cxx.

21 , m_alpha1(0.)
22 , m_alpha2(0.)
23{}
std::vector< TDD_real_t > m_boundValues
Internal parameters stored in the geometry.

◆ DiamondBounds() [2/4]

Trk::DiamondBounds::DiamondBounds ( const DiamondBounds & diabo)
default

Copy constructor.

◆ DiamondBounds() [3/4]

Trk::DiamondBounds::DiamondBounds ( DiamondBounds && diabo)
defaultnoexcept

Copy constructor.

◆ ~DiamondBounds()

virtual Trk::DiamondBounds::~DiamondBounds ( )
virtualdefault

Destructor.

◆ DiamondBounds() [4/4]

Trk::DiamondBounds::DiamondBounds ( double minhalex,
double medhalex,
double maxhalex,
double haley1,
double haley2 )

Constructor for symmetric Diamond.

Definition at line 26 of file DiamondBounds.cxx.

34 if (minhalex > maxhalex)
38}
virtual void initCache() override
initialize the alpha1/2 cache - needed also for object persistency
void swap(double &b1, double &b2)
Swap method to be called from DiscBounds or TrapezoidalBounds.

Member Function Documentation

◆ alpha1()

double Trk::DiamondBounds::alpha1 ( ) const

This method returns the opening angle alpha in point A.

Definition at line 179 of file DiamondBounds.cxx.

180{
181 return m_alpha1;
182}

◆ alpha2()

double Trk::DiamondBounds::alpha2 ( ) const

This method returns the opening angle alpha in point A'.

Definition at line 186 of file DiamondBounds.cxx.

187{
188 return m_alpha2;
189}

◆ clone()

DiamondBounds * Trk::DiamondBounds::clone ( ) const
overridevirtual

Virtual constructor.

Implements Trk::SurfaceBounds.

◆ dump() [1/2]

MsgStream & Trk::DiamondBounds::dump ( MsgStream & sl) const
finaloverridevirtual

Output Method for MsgStream.

Implements Trk::SurfaceBounds.

Definition at line 243 of file DiamondBounds.cxx.

244{
245 sl << std::setiosflags(std::ios::fixed);
246 sl << std::setprecision(7);
247 sl << "Trk::DiamondBounds: (minHlenghtX, medHlengthX, maxHlengthX, hlengthY1, hlengthY2 ) = ";
251 sl << std::setprecision(-1);
252 return sl;
253}

◆ dump() [2/2]

std::ostream & Trk::DiamondBounds::dump ( std::ostream & sl) const
finaloverridevirtual

Output Method for std::ostream.

Implements Trk::SurfaceBounds.

Definition at line 256 of file DiamondBounds.cxx.

257{
258 sl << std::setiosflags(std::ios::fixed);
259 sl << std::setprecision(7);
260 sl << "Trk::DiamondBounds: (minHlenghtX, medHlengthX, maxHlengthX, hlengthY1, hlengthY2 ) = ";
264 sl << std::setprecision(-1);
265 return sl;
266}

◆ halflengthY1()

double Trk::DiamondBounds::halflengthY1 ( ) const

This method returns the halflength in Y of trapezoid at negative/positive Y (second coordinate)

◆ halflengthY2()

double Trk::DiamondBounds::halflengthY2 ( ) const

◆ initCache()

void Trk::DiamondBounds::initCache ( )
overrideprivatevirtual

initialize the alpha1/2 cache - needed also for object persistency

Reimplemented from Trk::SurfaceBounds.

Definition at line 40 of file DiamondBounds.cxx.

◆ inside() [1/2]

bool Trk::DiamondBounds::inside ( const Amg::Vector2D & locpo,
const BoundaryCheck & bchk ) const
finaloverridevirtual

Implements Trk::SurfaceBounds.

Definition at line 67 of file DiamondBounds.cxx.

69{
70 if (bchk.bcType == 0)
71 return DiamondBounds::inside(locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
72
73 // a fast FALSE
74 double max_ell = bchk.lCovariance(0, 0) > bchk.lCovariance(1, 1)
75 ? bchk.lCovariance(0, 0)
76 : bchk.lCovariance(1, 1);
77 double limit = bchk.nSigmas * sqrt(max_ell);
78 if (locpo[Trk::locY] < -2 * m_boundValues[DiamondBounds::bv_halfY1] - limit)
79 return false;
80 if (locpo[Trk::locY] > 2 * m_boundValues[DiamondBounds::bv_halfY2] + limit)
81 return false;
82 // a fast FALSE
83 double fabsX = std::abs(locpo[Trk::locX]);
84 if (fabsX > (m_boundValues[DiamondBounds::bv_medHalfX] + limit))
85 return false;
86 // a fast TRUE
87 double min_ell = bchk.lCovariance(0, 0) < bchk.lCovariance(1, 1)
88 ? bchk.lCovariance(0, 0)
89 : bchk.lCovariance(1, 1);
90 limit = bchk.nSigmas * sqrt(min_ell);
93 limit))
94 return true;
95 // a fast TRUE
96 if (std::abs(locpo[Trk::locY]) < (fmin(m_boundValues[DiamondBounds::bv_halfY1],
98 limit))
99 return true;
100
101 // compute KDOP and axes for surface polygon
102 std::vector<KDOP> elementKDOP(5);
103 std::vector<Amg::Vector2D> elementP(6);
104 float theta =
105 (bchk.lCovariance(1, 0) != 0 &&
106 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)) != 0)
107 ? .5 * bchk.FastArcTan(2 * bchk.lCovariance(1, 0) /
108 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)))
109 : 0.;
110 sincosCache scResult = bchk.FastSinCos(theta);
111 AmgMatrix(2, 2) rotMatrix;
112 rotMatrix << scResult.cosC, scResult.sinC, -scResult.sinC, scResult.cosC;
113 AmgMatrix(2, 2) normal;
114 // cppcheck-suppress constStatement
115 normal << 0, -1, 1, 0;
116 // ellipse is always at (0,0), surface is moved to ellipse position and then
117 // rotated
118 Amg::Vector2D p =
119 Amg::Vector2D(-m_boundValues[DiamondBounds::bv_minHalfX],
121 elementP[0] = (rotMatrix * (p - locpo));
122 p = Amg::Vector2D (-m_boundValues[DiamondBounds::bv_medHalfX], 0.);
123 elementP[1] = (rotMatrix * (p - locpo));
124 p = Amg::Vector2D (-m_boundValues[DiamondBounds::bv_maxHalfX],
126 elementP[2] = (rotMatrix * (p - locpo));
127 p = Amg::Vector2D (m_boundValues[DiamondBounds::bv_maxHalfX],
129 elementP[3] = (rotMatrix * (p - locpo));
130 p = Amg::Vector2D (m_boundValues[DiamondBounds::bv_medHalfX], 0.);
131 elementP[4] = (rotMatrix * (p - locpo));
132 p = Amg::Vector2D (m_boundValues[DiamondBounds::bv_minHalfX],
134 elementP[5] = (rotMatrix * (p - locpo));
135 std::vector<Amg::Vector2D> axis = { normal * (elementP[1] - elementP[0]),
136 normal * (elementP[2] - elementP[1]),
137 normal * (elementP[3] - elementP[2]),
138 normal * (elementP[4] - elementP[3]),
139 normal * (elementP[5] - elementP[4]) };
140 bchk.ComputeKDOP(elementP, axis, elementKDOP);
141 // compute KDOP for error ellipse
142 std::vector<KDOP> errelipseKDOP(5);
143 bchk.ComputeKDOP(bchk.EllipseToPoly(3), axis, errelipseKDOP);
144 // check if KDOPs overlap and return result
145 return bchk.TestKDOPKDOP(elementKDOP, errelipseKDOP);
146}
#define AmgMatrix(rows, cols)
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
The orientation of the Diamond is according to the figure.
DiamondBounds()
Default Constructor, needed for persistency.
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
@ theta
Definition ParamDefs.h:66

◆ inside() [2/2]

bool Trk::DiamondBounds::inside ( const Amg::Vector2D & locpo,
double tol1 = 0.,
double tol2 = 0. ) const
finaloverridevirtual

The orientation of the Diamond is according to the figure.

Implements Trk::SurfaceBounds.

Definition at line 61 of file DiamondBounds.cxx.

62{
63 return this->insideFull(locpo, tol1, tol2);
64}
bool insideFull(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const
inside() method for a full symmetric diamond

◆ insideFull()

bool Trk::DiamondBounds::insideFull ( const Amg::Vector2D & locpo,
double tol1 = 0.,
double tol2 = 0. ) const
private

inside() method for a full symmetric diamond

use basic calculation of a straight line

Definition at line 150 of file DiamondBounds.cxx.

151{
152 // validity check
154
155 // quick False (radial direction)
156 if (locpo[Trk::locY] < -2. * m_boundValues[DiamondBounds::bv_halfY1] - tol2) return false;
157 if (locpo[Trk::locY] > 2. * m_boundValues[DiamondBounds::bv_halfY2] + tol2) return false;
158
159 double absX = std::abs(locpo[Trk::locX]);
160
161 // quick False (transverse directon)
162 if (absX > m_boundValues[DiamondBounds::bv_medHalfX] + tol1) return false;
163
164 // quick True
165 if (absX < std::min(m_boundValues[DiamondBounds::bv_minHalfX], m_boundValues[DiamondBounds::bv_maxHalfX]) + tol1) return true;
166
171 double k = halfH ? 0.5*(halfBaseUp - halfBaseLo)/halfH : 0.;
172 double sign = (k < 0) ? -1. : 1.;
173 return (absX - tol1 <= m_boundValues[DiamondBounds::bv_medHalfX] + k * (locpo[Trk::locY] + sign*tol2));
174
175}
int sign(int a)

◆ insideLoc1()

virtual bool Trk::DiamondBounds::insideLoc1 ( const Amg::Vector2D & locpo,
double tol1 = 0. ) const
finaloverridevirtual

This method checks inside bounds in loc1.

  • loc1/loc2 correspond to the natural coordinates of the surface
  • As loc1/loc2 are correlated the single check doesn't make sense : -> check is done on enclosing Rectangle !

Implements Trk::SurfaceBounds.

◆ insideLoc2()

virtual bool Trk::DiamondBounds::insideLoc2 ( const Amg::Vector2D & locpo,
double tol2 = 0. ) const
finaloverridevirtual

This method checks inside bounds in loc2.

  • loc1/loc2 correspond to the natural coordinates of the surface
  • As loc1/loc2 are correlated the single check doesn't make sense : -> check is done on enclosing Rectangle !

Implements Trk::SurfaceBounds.

◆ maxHalflengthX()

double Trk::DiamondBounds::maxHalflengthX ( ) const

This method returns the halflength in X at maximal Y (first coordinate of local surface frame)

◆ medHalflengthX()

double Trk::DiamondBounds::medHalflengthX ( ) const

This method returns the (maximal) halflength in X (first coordinate of local surface frame)

◆ minDistance()

double Trk::DiamondBounds::minDistance ( const Amg::Vector2D & pos) const
finaloverridevirtual

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

Implements Trk::SurfaceBounds.

Definition at line 192 of file DiamondBounds.cxx.

193{
194 const int Np = 6;
195
198
202 double Y[6] = { -y1, 0., y2, y2, 0., -y1 };
203
204 double dm = 1.e+20;
205 double Ao = 0.;
206 bool in = true;
207
208 for (int i = 0; i != Np; ++i) {
209
210 int j = (i == Np-1 ? 0 : i+1);
211
212 double x = X[i] - pos[0];
213 double y = Y[i] - pos[1];
214 double dx = X[j] - X[i];
215 double dy = Y[j] - Y[i];
216 double A = x * dy - y * dx;
217 double S = -(x * dx + y * dy);
218
219 if (S <= 0.) {
220 double d = x * x + y * y;
221 if (d < dm)
222 dm = d;
223 } else {
224 double a = dx * dx + dy * dy;
225 if (S <= a) {
226 double d = (A * A) / a;
227 if (d < dm)
228 dm = d;
229 }
230 }
231 if (i && in && Ao * A < 0.)
232 in = false;
233 Ao = A;
234 }
235 if (in)
236 return -sqrt(dm);
237 return sqrt(dm);
238}
static Double_t a
@ x
Definition ParamDefs.h:55
@ y
Definition ParamDefs.h:56

◆ minHalflengthX()

double Trk::DiamondBounds::minHalflengthX ( ) const

This method returns the halflength in X at minimal Y (first coordinate of local surface frame)

◆ 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]

DiamondBounds & Trk::DiamondBounds::operator= ( const DiamondBounds & sbo)
default

Assignment operator.

◆ operator=() [2/2]

DiamondBounds & Trk::DiamondBounds::operator= ( DiamondBounds && sbo)
defaultnoexcept

Assignment operator.

◆ operator==()

bool Trk::DiamondBounds::operator== ( const SurfaceBounds & diabo) const
overridevirtual

Equality operator.

Implements Trk::SurfaceBounds.

Definition at line 50 of file DiamondBounds.cxx.

51{
52 // check the type first not to compare apples with oranges
53 const Trk::DiamondBounds* diabo = dynamic_cast<const Trk::DiamondBounds*>(&sbo);
54 if (!diabo)
55 return false;
56 return (m_boundValues == diabo->m_boundValues);
57}

◆ r()

virtual double Trk::DiamondBounds::r ( ) const
finaloverridevirtual

This method returns the maximal extension on the local plane.

Implements Trk::SurfaceBounds.

◆ 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::DiamondBounds::type ( ) const
inlinefinaloverridevirtual

Return the bounds type.

Implements Trk::SurfaceBounds.

Definition at line 79 of file DiamondBounds.h.

79{ return SurfaceBounds::Diamond; }

◆ ::DiamondBoundsCnv_p1

friend class ::DiamondBoundsCnv_p1
friend

Definition at line 131 of file DiamondBounds.h.

Member Data Documentation

◆ m_alpha1

TDD_real_t Trk::DiamondBounds::m_alpha1
private

Definition at line 141 of file DiamondBounds.h.

◆ m_alpha2

TDD_real_t Trk::DiamondBounds::m_alpha2
private

Definition at line 142 of file DiamondBounds.h.

◆ m_boundValues

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

Internal parameters stored in the geometry.

Definition at line 140 of file DiamondBounds.h.


The documentation for this class was generated from the following files: