ATLAS Offline Software
Loading...
Searching...
No Matches
RectangleBounds.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// RectangleBounds.cxx, (c) ATLAS Detector Software
8
9// Trk
11// Gaudi
12#include "GaudiKernel/MsgStream.h"
13// STD
14#include <iomanip>
15#include <iostream>
16
17// default constructor
21
22// rectangle constructor
29
30// copy constructor
35
36
39{
40 if (this != &recbo)
42 return *this;
43}
44
45bool
47{
48 // check the type first not to compare apples with oranges
49 const Trk::RectangleBounds* recbo = dynamic_cast<const Trk::RectangleBounds*>(&sbo);
50 if (!recbo)
51 return false;
52 return (m_boundValues == recbo->m_boundValues);
53}
54
55bool
57 const BoundaryCheck& bchk) const
58{
59 if (bchk.bcType == 0)
61 locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
62
63 // a fast FALSE
64 double max_ell = bchk.lCovariance(0, 0) > bchk.lCovariance(1, 1)
65 ? bchk.lCovariance(0, 0)
66 : bchk.lCovariance(1, 1);
67 double limit = bchk.nSigmas * sqrt(max_ell);
68 if (!RectangleBounds::inside(locpo, limit, limit))
69 return false;
70 // a fast TRUE
71 double min_ell = bchk.lCovariance(0, 0) < bchk.lCovariance(1, 1)
72 ? bchk.lCovariance(0, 0)
73 : bchk.lCovariance(1, 1);
74 limit = bchk.nSigmas * sqrt(min_ell);
75 if (RectangleBounds::inside(locpo, limit, limit))
76 return true;
77
78 // compute KDOP and axes for surface polygon
79 std::vector<KDOP> elementKDOP(4);
80 std::vector<Amg::Vector2D> elementP(4);
81 float theta =
82 (bchk.lCovariance(1, 0) != 0 &&
83 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)) != 0)
84 ? .5 * bchk.FastArcTan(2 * bchk.lCovariance(1, 0) /
85 (bchk.lCovariance(1, 1) - bchk.lCovariance(0, 0)))
86 : 0.;
87 sincosCache scResult = bchk.FastSinCos(theta);
88 AmgMatrix(2, 2) rotMatrix;
89 rotMatrix << scResult.cosC, scResult.sinC, -scResult.sinC, scResult.cosC;
90 // ellipse is always at (0,0), surface is moved to ellipse position and then
91 // rotated
95 elementP[0] = (rotMatrix * (p - locpo));
98 elementP[1] = (rotMatrix * (p - locpo));
101 elementP[2] = (rotMatrix * (p - locpo));
104 elementP[3] = (rotMatrix * (p - locpo));
105 std::vector<Amg::Vector2D> axis = { elementP[0] - elementP[1],
106 elementP[0] - elementP[2],
107 elementP[0] - elementP[3],
108 elementP[1] - elementP[2] };
109 bchk.ComputeKDOP(elementP, axis, elementKDOP);
110 // compute KDOP for error ellipse
111 std::vector<KDOP> errelipseKDOP(4);
112 bchk.ComputeKDOP(bchk.EllipseToPoly(3), axis, errelipseKDOP);
113 // check if KDOPs overlap and return result
114 return bchk.TestKDOPKDOP(elementKDOP, errelipseKDOP);
115}
116
117double
119{
120 double dx = std::abs(pos[0]) - m_boundValues[RectangleBounds::bv_halfX];
121 double dy = std::abs(pos[1]) - m_boundValues[RectangleBounds::bv_halfY];
122
123 if (dx <= 0. || dy <= 0.) {
124 if (dx > dy){
125 return dx;
126 }
127 return dy;
128 }
129 return sqrt(dx * dx + dy * dy);
130}
131
132// ostream operator overload
133MsgStream&
134Trk::RectangleBounds::dump(MsgStream& sl) const
135{
136 sl << std::setiosflags(std::ios::fixed);
137 sl << std::setprecision(7);
138 sl << "Trk::RectangleBounds: (halflenghtX, halflengthY) = "
140 sl << std::setprecision(-1);
141 return sl;
142}
143
144std::ostream&
145Trk::RectangleBounds::dump(std::ostream& sl) const
146{
147 sl << std::setiosflags(std::ios::fixed);
148 sl << std::setprecision(7);
149 sl << "Trk::RectangleBounds: (halflenghtX, halflengthY) = "
151 sl << std::setprecision(-1);
152 return sl;
153}
#define AmgMatrix(rows, cols)
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
int nSigmas
allowed sigmas for chi2 boundary check
BoundaryCheckType bcType
std::vector< Amg::Vector2D > EllipseToPoly(int resolution=3) const
bool TestKDOPKDOP(const std::vector< KDOP > &a, const std::vector< KDOP > &b) const
void ComputeKDOP(const std::vector< Amg::Vector2D > &v, const std::vector< Amg::Vector2D > &KDOPAxes, std::vector< KDOP > &kdop) const
Each Bounds has a method inside, which checks if a LocalPosition is inside the bounds.
double toleranceLoc2
absolute tolerance in local 2 coordinate
double FastArcTan(double x) const
sincosCache FastSinCos(double x) const
double toleranceLoc1
absolute tolerance in local 1 coordinate
Bounds for a rectangular, planar surface.
std::vector< TDD_real_t > m_boundValues
The internal version of the bounds can be float/double.
virtual double minDistance(const Amg::Vector2D &pos) const override final
Minimal distance to boundary ( > 0 if outside and <=0 if inside)
virtual bool operator==(const SurfaceBounds &sbo) const override final
Equality operator.
RectangleBounds & operator=(const RectangleBounds &recbo)
Assignment Operator.
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.
virtual MsgStream & dump(MsgStream &sl) const override
Output Method for MsgStream.
RectangleBounds()
Default Constructor - needed for persistency.
Abstract base class for surface bounds to be specified.
SurfaceBounds()=default
Default Constructor.
Eigen::Matrix< double, 2, 1 > Vector2D
Ensure that the ATLAS eigen extensions are properly loaded.
@ theta
Definition ParamDefs.h:66