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

Bounds for a rotated trapezoidal, planar Surface. More...

#include <RotatedTrapezoidBounds.h>

Inheritance diagram for Trk::RotatedTrapezoidBounds:
Collaboration diagram for Trk::RotatedTrapezoidBounds:

Public Types

enum  BoundValues { bv_halfX = 0 , bv_minHalfY = 1 , bv_maxHalfY = 2 , bv_length = 3 }
 for readibility 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

 RotatedTrapezoidBounds ()
 Default Constructor, needed for persistency.
 RotatedTrapezoidBounds (const RotatedTrapezoidBounds &trabo)=default
 Copy constructor.
RotatedTrapezoidBoundsoperator= (const RotatedTrapezoidBounds &sbo)=default
 Assignment operator.
 RotatedTrapezoidBounds (RotatedTrapezoidBounds &&trabo) noexcept=default
 Move constructor.
RotatedTrapezoidBoundsoperator= (RotatedTrapezoidBounds &&sbo) noexcept=default
 Move Assignment operator.
virtual ~RotatedTrapezoidBounds ()=default
 Destructor.
 RotatedTrapezoidBounds (double halex, double minhalex, double maxhalex)
 Constructor for symmetric Trapezoid.
 RotatedTrapezoidBounds (double halex, double minhalex, double maxhalex, double alpha)
 Constructor for symmetric Trapezoid rotated around the X axis by alpha.
virtual RotatedTrapezoidBoundsclone () const override
 Virtual constructor.
virtual BoundsType type () const override
 Return the type of the bounds for persistency.
virtual bool operator== (const SurfaceBounds &trabo) const override final
 Equality operator.
double halflengthX () const
 This method returns the minimal halflength in X (first coordinate of local surface frame)
double minHalflengthY () const
 This method returns the maximal halflength in X (first coordinate of local surface frame)
double maxHalflengthY () const
 This method returns the halflength in Y (second coordinate of local surface frame)
virtual double r () const override
 This method returns the maximal extension on the local plane.
virtual bool inside (const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
 The orientation of the Trapezoid is according to the figure above, in words: the shorter of the two parallel sides of the trapezoid intersects with the negative \( y \) - axis of the local frame.
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 isBelow (double locX, double fabsLocY, double tol1, double tol2) const
 isBelow() method for checking whether a point lies above or under a straight line
virtual void initCache () override final
 Helper function for angle parameter initialization.
 AmgSymMatrix (2) m_rotMat
 Transformation matrix to define surface bounds which are tilted w.r.t.

Private Attributes

std::vector< TDD_real_tm_boundValues
 The internal storage of the bounds can be float/double.
TDD_real_t m_kappa {0}
TDD_real_t m_delta {0}

Friends

class ::RotatedTrapezoidBoundsCnv_p1

Detailed Description

Bounds for a rotated trapezoidal, planar Surface.

Contrary to the TrapezoidBounds the local x axis builds the symmetry axis for a symmetric Trapezoid.

An arbitrary rotated trapezoidal shape has not been implemented yet, the TrapezoidBounds may be taken instead.

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 44 of file RotatedTrapezoidBounds.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

for readibility

Enumerator
bv_halfX 
bv_minHalfY 
bv_maxHalfY 
bv_length 

Definition at line 49 of file RotatedTrapezoidBounds.h.

Constructor & Destructor Documentation

◆ RotatedTrapezoidBounds() [1/5]

Trk::RotatedTrapezoidBounds::RotatedTrapezoidBounds ( )

Default Constructor, needed for persistency.

Definition at line 19 of file RotatedTrapezoidBounds.cxx.

21{}
std::vector< TDD_real_t > m_boundValues
The internal storage of the bounds can be float/double.

◆ RotatedTrapezoidBounds() [2/5]

Trk::RotatedTrapezoidBounds::RotatedTrapezoidBounds ( const RotatedTrapezoidBounds & trabo)
default

Copy constructor.

◆ RotatedTrapezoidBounds() [3/5]

Trk::RotatedTrapezoidBounds::RotatedTrapezoidBounds ( RotatedTrapezoidBounds && trabo)
defaultnoexcept

Move constructor.

◆ ~RotatedTrapezoidBounds()

virtual Trk::RotatedTrapezoidBounds::~RotatedTrapezoidBounds ( )
virtualdefault

Destructor.

◆ RotatedTrapezoidBounds() [4/5]

Trk::RotatedTrapezoidBounds::RotatedTrapezoidBounds ( double halex,
double minhalex,
double maxhalex )

Constructor for symmetric Trapezoid.

Definition at line 28 of file RotatedTrapezoidBounds.cxx.

30
31{
35 // swap if needed
38 // assign kappa and delta
40}
virtual void initCache() override final
Helper function for angle parameter initialization.
void swap(double &b1, double &b2)
Swap method to be called from DiscBounds or TrapezoidalBounds.

◆ RotatedTrapezoidBounds() [5/5]

Trk::RotatedTrapezoidBounds::RotatedTrapezoidBounds ( double halex,
double minhalex,
double maxhalex,
double alpha )

Constructor for symmetric Trapezoid rotated around the X axis by alpha.

Definition at line 24 of file RotatedTrapezoidBounds.cxx.

24 :
25 RotatedTrapezoidBounds(halex, minhalex, maxhalex){
26 m_rotMat = Eigen::Rotation2D{alpha};
27}
RotatedTrapezoidBounds()
Default Constructor, needed for persistency.

Member Function Documentation

◆ AmgSymMatrix()

Trk::RotatedTrapezoidBounds::AmgSymMatrix ( 2 )
inlineprivate

Transformation matrix to define surface bounds which are tilted w.r.t.

the surfaces (e.g. Micromega stereo layers)

Definition at line 166 of file RotatedTrapezoidBounds.h.

166{AmgSymMatrix(2)::Identity()};
#define AmgSymMatrix(dim)

◆ clone()

virtual RotatedTrapezoidBounds * Trk::RotatedTrapezoidBounds::clone ( ) const
overridevirtual

Virtual constructor.

Implements Trk::SurfaceBounds.

◆ dump() [1/2]

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

Output Method for MsgStream.

Implements Trk::SurfaceBounds.

Definition at line 217 of file RotatedTrapezoidBounds.cxx.

218{
219 sl << std::setiosflags(std::ios::fixed);
220 sl << std::setprecision(7);
221 sl << "Trk::RotatedTrapezoidBounds: (halfX, minHalfX, maxHalfY) = "
224 << ")";
225 sl << std::setprecision(-1);
226 return sl;
227}

◆ dump() [2/2]

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

Output Method for std::ostream.

Implements Trk::SurfaceBounds.

Definition at line 230 of file RotatedTrapezoidBounds.cxx.

231{
232 sl << std::setiosflags(std::ios::fixed);
233 sl << std::setprecision(7);
234 sl << "Trk::RotatedTrapezoidBounds: (halfX, minHalfX, maxHalfY) = "
237 << ")";
238 sl << std::setprecision(-1);
239 return sl;
240}

◆ halflengthX()

double Trk::RotatedTrapezoidBounds::halflengthX ( ) const

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

◆ initCache()

void Trk::RotatedTrapezoidBounds::initCache ( )
finaloverrideprivatevirtual

◆ inside() [1/2]

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

Implements Trk::SurfaceBounds.

Definition at line 62 of file RotatedTrapezoidBounds.cxx.

64{
65 const Amg::Vector2D locpo = m_rotMat * pos;
66 if (bchk.bcType == 0)
68 locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
69
70 // a fast FALSE
71 const double fabsX = std::abs(locpo[Trk::locX]);
72 double max_ell = bchk.lCovariance(0, 0) > bchk.lCovariance(1, 1)
73 ? bchk.lCovariance(0, 0)
74 : bchk.lCovariance(1, 1);
75 double limit = bchk.nSigmas * sqrt(max_ell);
77 return false;
78 // a fast FALSE
79 const double fabsY = std::abs(locpo[Trk::locY]);
81 return false;
82 // a fast TRUE
83 double min_ell = bchk.lCovariance(0, 0) < bchk.lCovariance(1, 1)
84 ? bchk.lCovariance(0, 0)
85 : bchk.lCovariance(1, 1);
86 limit = bchk.nSigmas * sqrt(min_ell);
89 return true;
90
91 // compute KDOP and axes for surface polygon
92 std::vector<KDOP> elementKDOP(3);
93 std::vector<Amg::Vector2D> elementP(4);
94 float theta =
95 (bchk.lCovariance(1, 0) != 0 &&
96 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)) != 0)
97 ? .5 * bchk.FastArcTan(2 * bchk.lCovariance(1, 0) /
98 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)))
99 : 0.;
100 sincosCache scResult = bchk.FastSinCos(theta);
101 AmgMatrix(2, 2) rotMatrix;
102 rotMatrix << scResult.cosC, scResult.sinC, -scResult.sinC, scResult.cosC;
103 AmgMatrix(2, 2) normal;
104 // cppcheck-suppress constStatement
105 normal << 0, -1, 1, 0;
106 // ellipse is always at (0,0), surface is moved to ellipse position and then
107 // rotated
108 Amg::Vector2D p =
111 elementP[0] = (rotMatrix * (p - locpo));
112 p = Amg::Vector2D (-m_boundValues[RotatedTrapezoidBounds::bv_halfX],
114 elementP[1] = (rotMatrix * (p - locpo));
115 p = Amg::Vector2D (m_boundValues[RotatedTrapezoidBounds::bv_halfX],
117 elementP[2] = (rotMatrix * (p - locpo));
118 p = Amg::Vector2D (m_boundValues[RotatedTrapezoidBounds::bv_halfX],
120 elementP[3] = (rotMatrix * (p - locpo));
121 std::vector<Amg::Vector2D> axis = { normal * (elementP[1] - elementP[0]),
122 normal * (elementP[3] - elementP[1]),
123 normal * (elementP[2] - elementP[0]) };
124 bchk.ComputeKDOP(elementP, axis, elementKDOP);
125 // compute KDOP for error ellipse
126 std::vector<KDOP> errelipseKDOP(3);
127 bchk.ComputeKDOP(bchk.EllipseToPoly(3), axis, errelipseKDOP);
128 // check if KDOPs overlap and return result
129 return bchk.TestKDOPKDOP(elementKDOP, errelipseKDOP);
130}
#define AmgMatrix(rows, cols)
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
The orientation of the Trapezoid is according to the figure above, in words: the shorter of the two p...
Eigen::Matrix< double, 2, 1 > Vector2D
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
@ theta
Definition ParamDefs.h:66

◆ inside() [2/2]

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

The orientation of the Trapezoid is according to the figure above, in words: the shorter of the two parallel sides of the trapezoid intersects with the negative \( y \) - axis of the local frame.


The cases are:
(0) \( \eta \) or \( \phi \) bounds are 0 || 0
(1) LocalPosition is outside \( x \) bounds
(2) LocalPosition is inside \( x \) bounds, but outside maximum \( y \) bounds
(3) LocalPosition is inside \( x \) bounds AND inside minimum \( y \) bounds
(4) LocalPosition is inside \( x \) bounds AND inside maximum \( y \) bounds, so that it depends on the \( x \) coordinate (5) LocalPosition fails test of (4)

The inside check is done using single equations of straight lines and one has to take care if a point lies on the positive \( \phi \) half area(I) or the negative one(II). Denoting \( | y_{min}| \) and \( | y_{max} | \) as minHalfY respectively maxHalfX, such as \( | x_{H} | \) as halfX, the equations for the straing lines in (I) and (II) can be written as:

  • (I): \( y = \kappa_{I} x + \delta_{I} \)
  • (II): \( y = \kappa_{II} x + \delta_{II} \) ,

    where
    \( \kappa_{I} = - \kappa_{II} = \frac{y_{max}-y_{min}}{x_{H}} \)
    \( \delta_{I} = \frac{1}{2}\cdot (y_{max} + y_{min} ) \)

Implements Trk::SurfaceBounds.

Definition at line 134 of file RotatedTrapezoidBounds.cxx.

135{
136
137 // the cases:
138 const Amg::Vector2D locpo = m_rotMat * pos;
139 double fabsX = std::abs(locpo[Trk::locX]);
140 double fabsY = std::abs(locpo[Trk::locY]);
141 // (1) a fast FALSE
143 return false;
144 // (2) a fast FALSE
146 return false;
147 // (3) a fast TRUE
149 return true;
150 // (4) it is inside the rectangular shape solve the isBelow
151 return (isBelow(locpo[Trk::locX], fabsY, tol1, tol2));
152}
bool isBelow(double locX, double fabsLocY, double tol1, double tol2) const
isBelow() method for checking whether a point lies above or under a straight line

◆ insideLoc1()

virtual bool Trk::RotatedTrapezoidBounds::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::RotatedTrapezoidBounds::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.

◆ isBelow()

bool Trk::RotatedTrapezoidBounds::isBelow ( double locX,
double fabsLocY,
double tol1,
double tol2 ) const
private

isBelow() method for checking whether a point lies above or under a straight line

Definition at line 156 of file RotatedTrapezoidBounds.cxx.

157{
158 // the most tolerant approach for tol1 and tol2
159 return ((m_kappa * (locX + tol1) + m_delta) > fabsLocY - tol2);
160}

◆ maxHalflengthY()

double Trk::RotatedTrapezoidBounds::maxHalflengthY ( ) const

This method returns the halflength in Y (second coordinate of local surface frame)

◆ minDistance()

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

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

Implements Trk::SurfaceBounds.

Definition at line 163 of file RotatedTrapezoidBounds.cxx.

164{
165 const Amg::Vector2D pos = m_rotMat * locpo;
166 constexpr int Np = 4;
167
168 const std::array<double,4> X{ -m_boundValues[RotatedTrapezoidBounds::bv_halfX],
172 const std::array<double,4> Y{ -m_boundValues[RotatedTrapezoidBounds::bv_minHalfY],
176
177 double dm = 1.e+20;
178 double Ao = 0.;
179 bool in = true;
180
181 for (int i = 0; i != Np; ++i) {
182
183 int j = (i == Np-1 ? 0 : i+1);
184
185 double x = X[i] - pos[0];
186 double y = Y[i] - pos[1];
187 double dx = X[j] - X[i];
188 double dy = Y[j] - Y[i];
189 double A = x * dy - y * dx;
190 double S = -(x * dx + y * dy);
191
192 if (S <= 0.) {
193 double d = x * x + y * y;
194 if (d < dm)
195 dm = d;
196 } else {
197 double a = dx * dx + dy * dy;
198 if (S <= a) {
199 double d = (A * A) / a;
200 if (d < dm)
201 dm = d;
202 }
203 }
204 if (i && in && Ao * A < 0.)
205 in = false;
206 Ao = A;
207 }
208 if (in){
209 return -std::sqrt(dm);
210 }
211 return std::sqrt(dm);
212}
static Double_t a
@ x
Definition ParamDefs.h:55
@ y
Definition ParamDefs.h:56

◆ minHalflengthY()

double Trk::RotatedTrapezoidBounds::minHalflengthY ( ) const

This method returns the maximal halflength in X (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]

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

Assignment operator.

◆ operator=() [2/2]

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

Move Assignment operator.

◆ operator==()

bool Trk::RotatedTrapezoidBounds::operator== ( const SurfaceBounds & trabo) const
finaloverridevirtual

Equality operator.

Implements Trk::SurfaceBounds.

Definition at line 52 of file RotatedTrapezoidBounds.cxx.

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

◆ r()

virtual double Trk::RotatedTrapezoidBounds::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::RotatedTrapezoidBounds::type ( ) const
inlineoverridevirtual

Return the type of the bounds for persistency.

Implements Trk::SurfaceBounds.

Definition at line 85 of file RotatedTrapezoidBounds.h.

◆ ::RotatedTrapezoidBoundsCnv_p1

friend class ::RotatedTrapezoidBoundsCnv_p1
friend

Definition at line 152 of file RotatedTrapezoidBounds.h.

Member Data Documentation

◆ m_boundValues

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

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

Definition at line 161 of file RotatedTrapezoidBounds.h.

◆ m_delta

TDD_real_t Trk::RotatedTrapezoidBounds::m_delta {0}
private

Definition at line 163 of file RotatedTrapezoidBounds.h.

163{0};

◆ m_kappa

TDD_real_t Trk::RotatedTrapezoidBounds::m_kappa {0}
private

Definition at line 162 of file RotatedTrapezoidBounds.h.

162{0};

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