Processing math: 100%
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Trk::TriangleBounds Class Referencefinal

#include <TriangleBounds.h>

Inheritance diagram for Trk::TriangleBounds:
Collaboration diagram for Trk::TriangleBounds:

Public Types

enum  BoundValues {
  bv_x1 = 0, bv_y1 = 1, bv_x2 = 2, bv_y2 = 3,
  bv_x3 = 4, bv_y3 = 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

 TriangleBounds ()
 Default Constructor - needed for persistency. More...
 
 TriangleBounds (const TriangleBounds &tribo)=default
 Copy constructor. More...
 
TriangleBoundsoperator= (const TriangleBounds &recbo)=default
 Assignment Operator. More...
 
 TriangleBounds (TriangleBounds &&tribo) noexcept=default
 Move constructor. More...
 
TriangleBoundsoperator= (TriangleBounds &&recbo) noexcept=default
 Move Assignment Operator. More...
 
virtual ~TriangleBounds ()=default
 Destructor. More...
 
 TriangleBounds (const std::vector< std::pair< float, float >> &)
 Constructor with coordinates of vertices - floats. More...
 
 TriangleBounds (const std::vector< std::pair< double, double >> &)
 Constructor with coordinates of vertices - double. More...
 
 TriangleBounds (const Amg::Vector2D &p1, const Amg::Vector2D &p2, const Amg::Vector2D &p3)
 Constructor from three 2 Vectors. More...
 
virtual bool operator== (const SurfaceBounds &sbo) const override
 Equality operator. More...
 
virtual TriangleBoundsclone () const override
 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 provided local coordinates are inside the surface bounds. 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
 This method checks inside bounds in loc1. More...
 
virtual bool insideLoc2 (const Amg::Vector2D &locpo, double tol2=0.) const override final
 This method checks inside bounds in loc2. More...
 
virtual double minDistance (const Amg::Vector2D &pos) const override final
 Minimal distance to boundary ( > 0 if outside and <=0 if inside) More...
 
std::vector< std::pair< TDD_real_t, TDD_real_t > > vertices () const
 This method returns the coordinates of vertices. More...
 
virtual double r () const override final
 This method returns the maximal extension on the local plane, i.e. 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 Attributes

std::vector< TDD_real_tm_boundValues
 

Detailed Description

Bounds for a triangular, planar surface.

Author
sarka.nosp@m..tod.nosp@m.orova.nosp@m.@cer.nosp@m.n.ch

Definition at line 38 of file TriangleBounds.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

for readability

Enumerator
bv_x1 
bv_y1 
bv_x2 
bv_y2 
bv_x3 
bv_y3 
bv_length 

Definition at line 43 of file TriangleBounds.h.

44  {
45  bv_x1 = 0,
46  bv_y1 = 1,
47  bv_x2 = 2,
48  bv_y2 = 3,
49  bv_x3 = 4,
50  bv_y3 = 5,
51  bv_length = 6
52  };

Constructor & Destructor Documentation

◆ TriangleBounds() [1/6]

Trk::TriangleBounds::TriangleBounds ( )

Default Constructor - needed for persistency.

Definition at line 19 of file TriangleBounds.cxx.

◆ TriangleBounds() [2/6]

Trk::TriangleBounds::TriangleBounds ( const TriangleBounds tribo)
default

Copy constructor.

◆ TriangleBounds() [3/6]

Trk::TriangleBounds::TriangleBounds ( TriangleBounds &&  tribo)
defaultnoexcept

Move constructor.

◆ ~TriangleBounds()

virtual Trk::TriangleBounds::~TriangleBounds ( )
virtualdefault

Destructor.

◆ TriangleBounds() [4/6]

Trk::TriangleBounds::TriangleBounds ( const std::vector< std::pair< float, float >> &  vertices)

Constructor with coordinates of vertices - floats.

Definition at line 24 of file TriangleBounds.cxx.

26 {
27  size_t ib = 0;
28  for (const std::pair<float, float>& p : vertices) {
29  m_boundValues[2 * ib] = p.first;
30  m_boundValues[2 * ib + 1] = p.second;
31  if (ib == 2)
32  break;
33  ++ib;
34  }
35 }

◆ TriangleBounds() [5/6]

ATH_FLATTEN Trk::TriangleBounds::TriangleBounds ( const std::vector< std::pair< double, double >> &  vertices)

Constructor with coordinates of vertices - double.

Definition at line 40 of file TriangleBounds.cxx.

42 {
43  size_t ib = 0;
44  for (const std::pair<double, double>& p : vertices) {
45  m_boundValues[2 * ib] = p.first;
46  m_boundValues[2 * ib + 1] = p.second;
47  if (ib == 2)
48  break;
49  ++ib;
50  }
51 }

◆ TriangleBounds() [6/6]

Trk::TriangleBounds::TriangleBounds ( const Amg::Vector2D p1,
const Amg::Vector2D p2,
const Amg::Vector2D p3 
)

Constructor from three 2 Vectors.

Definition at line 54 of file TriangleBounds.cxx.

Member Function Documentation

◆ clone()

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

Virtual constructor.

Implements Trk::SurfaceBounds.

◆ dump() [1/2]

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

Output Method for MsgStream.

Implements Trk::SurfaceBounds.

Definition at line 229 of file TriangleBounds.cxx.

230 {
231  sl << std::setiosflags(std::ios::fixed);
232  sl << std::setprecision(7);
233  sl << "Trk::TriangleBounds: generating vertices (X, Y) " << '\n';
234  sl << "(" << m_boundValues[TriangleBounds::bv_x1] << " , " << m_boundValues[TriangleBounds::bv_y1] << ") " << '\n';
235  sl << "(" << m_boundValues[TriangleBounds::bv_x2] << " , " << m_boundValues[TriangleBounds::bv_y2] << ") " << '\n';
236  sl << "(" << m_boundValues[TriangleBounds::bv_x3] << " , " << m_boundValues[TriangleBounds::bv_y3] << ") ";
237  sl << std::setprecision(-1);
238  return sl;
239 }

◆ dump() [2/2]

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

Output Method for std::ostream.

Implements Trk::SurfaceBounds.

Definition at line 242 of file TriangleBounds.cxx.

243 {
244  sl << std::setiosflags(std::ios::fixed);
245  sl << std::setprecision(7);
246  sl << "Trk::TriangleBounds: generating vertices (X, Y)";
247  sl << "(" << m_boundValues[TriangleBounds::bv_x1] << " , " << m_boundValues[TriangleBounds::bv_y1] << ") " << '\n';
248  sl << "(" << m_boundValues[TriangleBounds::bv_x2] << " , " << m_boundValues[TriangleBounds::bv_y2] << ") " << '\n';
249  sl << "(" << m_boundValues[TriangleBounds::bv_x3] << " , " << m_boundValues[TriangleBounds::bv_y3] << ") ";
250  sl << std::setprecision(-1);
251  return sl;
252 }

◆ 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::TriangleBounds::inside ( const Amg::Vector2D locpo,
const BoundaryCheck bchk 
) const
finaloverridevirtual

Implements Trk::SurfaceBounds.

Definition at line 122 of file TriangleBounds.cxx.

124 {
125  if (bchk.bcType == 0)
126  return TriangleBounds::inside(
127  locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
128 
129  // a fast FALSE
130  double fabsR = std::sqrt(locpo[Trk::locX] * locpo[Trk::locX] +
131  locpo[Trk::locY] * locpo[Trk::locY]);
132  double max_ell = bchk.lCovariance(0, 0) > bchk.lCovariance(1, 1)
133  ? bchk.lCovariance(0, 0)
134  : bchk.lCovariance(1, 1);
135  double limit = bchk.nSigmas * std::sqrt(max_ell);
136  double r_max = TriangleBounds::r();
137  if (fabsR > (r_max + limit))
138  return false;
139 
140  // compute KDOP and axes for surface polygon
141  std::vector<KDOP> elementKDOP(3);
142  std::vector<Amg::Vector2D> elementP(3);
143  float theta =
144  (bchk.lCovariance(1, 0) != 0 &&
145  (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)) != 0)
146  ? .5 * bchk.FastArcTan(2 * bchk.lCovariance(1, 0) /
147  (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)))
148  : 0.;
149  sincosCache scResult = bchk.FastSinCos(theta);
150  AmgMatrix(2, 2) rotMatrix;
151  rotMatrix << scResult.cosC, scResult.sinC, -scResult.sinC, scResult.cosC;
152  AmgMatrix(2, 2) normal;
153  // cppcheck-suppress constStatement
154  normal << 0, -1, 1, 0;
155  // ellipse is always at (0,0), surface is moved to ellipse position and then
156  // rotated
157  Amg::Vector2D p;
160  elementP[0] = (rotMatrix * (p - locpo));
163  elementP[1] = (rotMatrix * (p - locpo));
166  elementP[2] = (rotMatrix * (p - locpo));
167  std::vector<Amg::Vector2D> axis = { normal * (elementP[1] - elementP[0]),
168  normal * (elementP[2] - elementP[1]),
169  normal * (elementP[2] - elementP[0]) };
170  bchk.ComputeKDOP(elementP, axis, elementKDOP);
171  // compute KDOP for error ellipse
172  std::vector<KDOP> errelipseKDOP(3);
173  bchk.ComputeKDOP(bchk.EllipseToPoly(3), axis, errelipseKDOP);
174  // check if KDOPs overlap and return result
175  return bchk.TestKDOPKDOP(elementKDOP, errelipseKDOP);
176 }

◆ inside() [2/2]

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

This method checks if the provided local coordinates are inside the surface bounds.

Implements Trk::SurfaceBounds.

Definition at line 76 of file TriangleBounds.cxx.

79 {
80  std::pair<double, double> locB(m_boundValues[TriangleBounds::bv_x2] -
84  std::pair<double, double> locT(
87  std::pair<double, double> locV(
90 
91  // special case :: third vertex ?
92  if (locT.first * locT.first + locT.second * locT.second < tol1 * tol1)
93  return true;
94 
95  // special case : lies on base ?
96  double db = locB.first * locV.second - locB.second * locV.first;
97  if (std::abs(db) < tol1) {
98  double a =
99  (locB.first != 0) ? -locV.first / locB.first : -locV.second / locB.second;
100  return a > -tol2 && a - 1. < tol2;
101  }
102 
103  double dn = locB.first * locT.second - locB.second * locT.first;
104 
105  if (std::abs(dn) > std::abs(tol1)) {
106  double t = (locB.first * locV.second - locB.second * locV.first) / dn;
107  if (t > 0.)
108  return false;
109 
110  double a = (locB.first != 0.)
111  ? (t * locT.first - locV.first) / locB.first
112  : (t * locT.second - locV.second) / locB.second;
113  if (a < -tol2 || a - 1. > tol2)
114  return false;
115  } else {
116  return false;
117  }
118  return true;
119 }

◆ insideLoc1()

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

Implements Trk::SurfaceBounds.

◆ insideLoc2()

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

Implements Trk::SurfaceBounds.

◆ minDistance()

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

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

Implements Trk::SurfaceBounds.

Definition at line 179 of file TriangleBounds.cxx.

180 {
181  const int Np = 3;
182 
183  double X[3] = { m_boundValues[TriangleBounds::bv_x1],
186  double Y[3] = { m_boundValues[TriangleBounds::bv_y1],
189 
190  double dm = 1.e+20;
191  double Ao = 0.;
192  bool in = true;
193 
194  for (int i = 0; i != Np; ++i) {
195 
196  int j = (i == Np-1 ? 0 : i+1);
197 
198  double x = X[i] - pos[0];
199  double y = Y[i] - pos[1];
200  double dx = X[j] - X[i];
201  double dy = Y[j] - Y[i];
202  double A = x * dy - y * dx;
203  double S = -(x * dx + y * dy);
204 
205  if (S <= 0.) {
206  double d = x * x + y * y;
207  if (d < dm)
208  dm = d;
209  } else {
210  double a = dx * dx + dy * dy;
211  if (S <= a) {
212  double d = (A * A) / a;
213  if (d < dm)
214  dm = d;
215  }
216  }
217  if (i && in && Ao * A < 0.)
218  in = false;
219  Ao = A;
220  }
221  if (in){
222  return -sqrt(dm);
223  }
224  return sqrt(dm);
225 }

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

TriangleBounds& Trk::TriangleBounds::operator= ( const TriangleBounds recbo)
default

Assignment Operator.

◆ operator=() [2/2]

TriangleBounds& Trk::TriangleBounds::operator= ( TriangleBounds &&  recbo)
defaultnoexcept

Move Assignment Operator.

◆ operator==()

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

Equality operator.

Implements Trk::SurfaceBounds.

Definition at line 66 of file TriangleBounds.cxx.

67 {
68  // check the type first not to compare apples with oranges
69  const Trk::TriangleBounds* tribo = dynamic_cast<const Trk::TriangleBounds*>(&sbo);
70  if (!tribo)
71  return false;
72  return (m_boundValues == tribo->m_boundValues);
73 }

◆ r()

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

This method returns the maximal extension on the local plane, i.e.

s\sqrt{h_{\phi}^2 + h_{\eta}^2}

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

Return the type of the bounds for persistency.

Implements Trk::SurfaceBounds.

Definition at line 88 of file TriangleBounds.h.

88 { return SurfaceBounds::Triangle; }

◆ vertices()

std::vector<std::pair<TDD_real_t, TDD_real_t> > Trk::TriangleBounds::vertices ( ) const

This method returns the coordinates of vertices.

Member Data Documentation

◆ m_boundValues

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

Definition at line 118 of file TriangleBounds.h.


The documentation for this class was generated from the following files:
Trk::y
@ y
Definition: ParamDefs.h:56
Trk::AmgMatrix
AmgMatrix(3, 3) NeutralParticleParameterCalculator
Definition: NeutralParticleParameterCalculator.cxx:233
Trk::SurfaceBounds::DiscTrapezoidal
@ DiscTrapezoidal
Definition: SurfaceBounds.h:69
Trk::SurfaceBounds::Cone
@ Cone
Definition: SurfaceBounds.h:60
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::SurfaceBounds::Rectangle
@ Rectangle
Definition: SurfaceBounds.h:65
hist_file_dump.d
d
Definition: hist_file_dump.py:143
Trk::TriangleBounds::inside
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
This method checks if the provided local coordinates are inside the surface bounds.
Definition: TriangleBounds.cxx:76
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
Trk::TriangleBounds::r
virtual double r() const override final
This method returns the maximal extension on the local plane, i.e.
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
Trk::TriangleBounds::bv_length
@ bv_length
Definition: TriangleBounds.h:51
Trk::TriangleBounds::vertices
std::vector< std::pair< TDD_real_t, TDD_real_t > > vertices() const
This method returns the coordinates of vertices.
Trk::SurfaceBounds::Annulus
@ Annulus
Definition: SurfaceBounds.h:70
Trk::SurfaceBounds::Diamond
@ Diamond
Definition: SurfaceBounds.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::TriangleBounds::bv_x3
@ bv_x3
Definition: TriangleBounds.h:49
JetTiledMap::S
@ S
Definition: TiledEtaPhiMap.h:44
Trk::TriangleBounds::m_boundValues
std::vector< TDD_real_t > m_boundValues
Definition: TriangleBounds.h:118
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
Trk::TriangleBounds::bv_y2
@ bv_y2
Definition: TriangleBounds.h:48
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
A
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::TriangleBounds
Definition: TriangleBounds.h:39
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::theta
@ theta
Definition: ParamDefs.h:66
vector
Definition: MultiHisto.h:13
python.getCurrentFolderTag.dn
dn
Definition: getCurrentFolderTag.py:64
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
ReadCellNoiseFromCool.dm
dm
Definition: ReadCellNoiseFromCool.py:235
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
keylayer_zslicemap.sb
sb
Definition: keylayer_zslicemap.py:192
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::TriangleBounds::bv_x2
@ bv_x2
Definition: TriangleBounds.h:47
Trk::SurfaceBounds::Trapezoid
@ Trapezoid
Definition: SurfaceBounds.h:67
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::SurfaceBounds::Disc
@ Disc
Definition: SurfaceBounds.h:63
Trk::TriangleBounds::bv_y3
@ bv_y3
Definition: TriangleBounds.h:50
Trk::TriangleBounds::bv_x1
@ bv_x1
Definition: TriangleBounds.h:45
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
Trk::SurfaceBounds::RotatedTrapezoid
@ RotatedTrapezoid
Definition: SurfaceBounds.h:66
Trk::SurfaceBounds::Other
@ Other
Definition: SurfaceBounds.h:71
Trk::x
@ x
Definition: ParamDefs.h:55
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
Trk::SurfaceBounds::Triangle
@ Triangle
Definition: SurfaceBounds.h:68
updateCoolNtuple.limit
int limit
Definition: updateCoolNtuple.py:45
Trk::SurfaceBounds::Ellipse
@ Ellipse
Definition: SurfaceBounds.h:64
Trk::TriangleBounds::bv_y1
@ bv_y1
Definition: TriangleBounds.h:46
Trk::TriangleBounds::TriangleBounds
TriangleBounds()
Default Constructor - needed for persistency.
Definition: TriangleBounds.cxx:19
Trk::SurfaceBounds::Cylinder
@ Cylinder
Definition: SurfaceBounds.h:61