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

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

#include <RotatedDiamondBounds.h>

Inheritance diagram for Trk::RotatedDiamondBounds:
Collaboration diagram for Trk::RotatedDiamondBounds:

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

 RotatedDiamondBounds ()
 Default Constructor, needed for persistency.
 RotatedDiamondBounds (const RotatedDiamondBounds &diabo)=default
 Copy constructor.
RotatedDiamondBoundsoperator= (const RotatedDiamondBounds &sbo)=default
 Assignment operator.
 RotatedDiamondBounds (RotatedDiamondBounds &&diabo) noexcept=default
 Move constructor.
RotatedDiamondBoundsoperator= (RotatedDiamondBounds &&sbo) noexcept=default
 Assignment operator.
virtual ~RotatedDiamondBounds ()=default
 Destructor.
 RotatedDiamondBounds (double minhalex, double medhalex, double maxhalex, double haley1, double haley2)
 Constructor for symmetric Diamond.
RotatedDiamondBoundsclone () const override
 Virtual constructor.
virtual bool operator== (const SurfaceBounds &diabo) const override
 Equality operator.
virtual BoundsType type () const override
 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
 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
 The orientation of the Diamond is according to the figure.
virtual bool inside (const Amg::Vector2D &locpo, const BoundaryCheck &bchk) const override
virtual bool insideLoc1 (const Amg::Vector2D &locpo, double tol1=0.) const override
 This method checks inside bounds in loc1.
virtual bool insideLoc2 (const Amg::Vector2D &locpo, double tol2=0.) const override
 This method checks inside bounds in loc2.
virtual double minDistance (const Amg::Vector2D &pos) const override
 Minimal distance to boundary ( > 0 if outside and <=0 if inside)
virtual MsgStream & dump (MsgStream &sl) const override
 Output Method for MsgStream.
virtual std::ostream & dump (std::ostream &sl) const override
 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 ::RotatedDiamondBoundsCnv_p1

Detailed Description

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

The RotatedDiamondBounds Class specifies the same diamond as the DiamondBounds Class. The local X and Y coordinates will be interchanged internally for boundary checks. (This is opposed to the TrapezoidBounds, where X and Y are interchanged in the constructor.)

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch, Sarka.nosp@m..Tod.nosp@m.orova.nosp@m.@cer.nosp@m.n.ch, Peter.nosp@m..Klu.nosp@m.it@ce.nosp@m.rn.c.nosp@m.h, Alice.nosp@m..Alf.nosp@m.onsi@.nosp@m.cern.nosp@m..ch, Michi.nosp@m.el.J.nosp@m.an.Ve.nosp@m.en@c.nosp@m.ern.c.nosp@m.h

Definition at line 41 of file RotatedDiamondBounds.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.

◆ BoundValues

BoundValues for better readability.

Enumerator
bv_minHalfX 
bv_medHalfX 
bv_maxHalfX 
bv_halfY1 
bv_halfY2 
bv_length 

Definition at line 46 of file RotatedDiamondBounds.h.

Constructor & Destructor Documentation

◆ RotatedDiamondBounds() [1/4]

Trk::RotatedDiamondBounds::RotatedDiamondBounds ( )

Default Constructor, needed for persistency.

Definition at line 19 of file RotatedDiamondBounds.cxx.

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

◆ RotatedDiamondBounds() [2/4]

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

Copy constructor.

◆ RotatedDiamondBounds() [3/4]

Trk::RotatedDiamondBounds::RotatedDiamondBounds ( RotatedDiamondBounds && diabo)
defaultnoexcept

Move constructor.

◆ ~RotatedDiamondBounds()

virtual Trk::RotatedDiamondBounds::~RotatedDiamondBounds ( )
virtualdefault

Destructor.

◆ RotatedDiamondBounds() [4/4]

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

Constructor for symmetric Diamond.

Definition at line 26 of file RotatedDiamondBounds.cxx.

32 , m_alpha1(0.)
33 , m_alpha2(0.)
34{
40 if (minhalex > maxhalex)
43}
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::RotatedDiamondBounds::alpha1 ( ) const

This method returns the opening angle alpha in point A.

Definition at line 190 of file RotatedDiamondBounds.cxx.

191{
192 return m_alpha1;
193}

◆ alpha2()

double Trk::RotatedDiamondBounds::alpha2 ( ) const

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

Definition at line 197 of file RotatedDiamondBounds.cxx.

198{
199 return m_alpha2;
200}

◆ clone()

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

Virtual constructor.

Implements Trk::SurfaceBounds.

◆ dump() [1/2]

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

Output Method for MsgStream.

Implements Trk::SurfaceBounds.

Definition at line 255 of file RotatedDiamondBounds.cxx.

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

◆ dump() [2/2]

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

Output Method for std::ostream.

Implements Trk::SurfaceBounds.

Definition at line 269 of file RotatedDiamondBounds.cxx.

270{
271 sl << std::setiosflags(std::ios::fixed);
272 sl << std::setprecision(7);
273 sl << "Trk::RotatedDiamondBounds: (minHlenghtX, medHlengthX, maxHlengthX, hlengthY1, hlengthY2 ) = ";
277 << ")";
278 sl << std::setprecision(-1);
279 return sl;
280}

◆ halflengthY1()

double Trk::RotatedDiamondBounds::halflengthY1 ( ) const

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

◆ halflengthY2()

double Trk::RotatedDiamondBounds::halflengthY2 ( ) const

◆ initCache()

void Trk::RotatedDiamondBounds::initCache ( )
overrideprivatevirtual

◆ inside() [1/2]

bool Trk::RotatedDiamondBounds::inside ( const Amg::Vector2D & locpo,
const BoundaryCheck & bchk ) const
overridevirtual

Implements Trk::SurfaceBounds.

Definition at line 65 of file RotatedDiamondBounds.cxx.

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

◆ inside() [2/2]

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

The orientation of the Diamond is according to the figure.

Implements Trk::SurfaceBounds.

Definition at line 155 of file RotatedDiamondBounds.cxx.

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

◆ insideFull()

bool Trk::RotatedDiamondBounds::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 162 of file RotatedDiamondBounds.cxx.

163{
164 // validity check
166
167 // quick False (radial direction)
168 if (locpo[Trk::locX] < -2. * m_boundValues[RotatedDiamondBounds::bv_halfY1] - tol1) return false;
169 if (locpo[Trk::locX] > 2. * m_boundValues[RotatedDiamondBounds::bv_halfY2] + tol1) return false;
170
171 double absY = std::abs(locpo[Trk::locY]);
172
173 // quick False (transverse direction)
174 if (absY > (m_boundValues[RotatedDiamondBounds::bv_medHalfX] + tol2)) return false;
175
176 // quick True
178
183 double k = halfH ? 0.5*(halfBaseUp - halfBaseLo)/halfH : 0.;
184 double sign = (k < 0) ? -1. : 1.;
185 return (absY - tol2 <= m_boundValues[RotatedDiamondBounds::bv_medHalfX] + k * (locpo[Trk::locX] + sign*tol1));
186}
int sign(int a)

◆ insideLoc1()

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

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::RotatedDiamondBounds::insideLoc2 ( const Amg::Vector2D & locpo,
double tol2 = 0. ) const
overridevirtual

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::RotatedDiamondBounds::maxHalflengthX ( ) const

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

◆ medHalflengthX()

double Trk::RotatedDiamondBounds::medHalflengthX ( ) const

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

◆ minDistance()

double Trk::RotatedDiamondBounds::minDistance ( const Amg::Vector2D & pos) const
overridevirtual

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

Implements Trk::SurfaceBounds.

Definition at line 203 of file RotatedDiamondBounds.cxx.

204{
205 const int Np = 6;
206
209
213 double Y[6] = { -y1, 0., y2, y2, 0., -y1 };
214
215 double dm = 1.e+20;
216 double Ao = 0.;
217 bool in = true;
218
219 for (int i = 0; i != Np; ++i) {
220
221 int j = (i == Np-1 ? 0 : i+1);
222
223 // interchange locx and locy
224 double x = X[i] - pos[1];
225 double y = Y[i] - pos[0];
226 double dx = X[j] - X[i];
227 double dy = Y[j] - Y[i];
228 double A = x * dy - y * dx;
229 double S = -(x * dx + y * dy);
230
231 if (S <= 0.) {
232 double d = x * x + y * y;
233 if (d < dm)
234 dm = d;
235 } else {
236 double a = dx * dx + dy * dy;
237 if (S <= a) {
238 double d = (A * A) / a;
239 if (d < dm)
240 dm = d;
241 }
242 }
243 if (i && in && Ao * A < 0.)
244 in = false;
245 Ao = A;
246 }
247 if (in)
248 return -sqrt(dm);
249 return sqrt(dm);
250}
static Double_t a
@ x
Definition ParamDefs.h:55
@ y
Definition ParamDefs.h:56

◆ minHalflengthX()

double Trk::RotatedDiamondBounds::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]

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

Assignment operator.

◆ operator=() [2/2]

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

Assignment operator.

◆ operator==()

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

Equality operator.

Implements Trk::SurfaceBounds.

Definition at line 55 of file RotatedDiamondBounds.cxx.

56{
57 // check the type first not to compare apples with oranges
58 const Trk::RotatedDiamondBounds* diabo = dynamic_cast<const Trk::RotatedDiamondBounds*>(&sbo);
59 if (!diabo)
60 return false;
61 return (m_boundValues == diabo->m_boundValues);
62}

◆ r()

virtual double Trk::RotatedDiamondBounds::r ( ) const
overridevirtual

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::RotatedDiamondBounds::type ( ) const
inlineoverridevirtual

Return the bounds type.

Implements Trk::SurfaceBounds.

Definition at line 84 of file RotatedDiamondBounds.h.

84{ return SurfaceBounds::Diamond; }

◆ ::RotatedDiamondBoundsCnv_p1

friend class ::RotatedDiamondBoundsCnv_p1
friend

Definition at line 136 of file RotatedDiamondBounds.h.

Member Data Documentation

◆ m_alpha1

TDD_real_t Trk::RotatedDiamondBounds::m_alpha1
private

Definition at line 146 of file RotatedDiamondBounds.h.

◆ m_alpha2

TDD_real_t Trk::RotatedDiamondBounds::m_alpha2
private

Definition at line 147 of file RotatedDiamondBounds.h.

◆ m_boundValues

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

Internal parameters stored in the geometry.

Definition at line 145 of file RotatedDiamondBounds.h.


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