12 #include "GaudiKernel/MsgStream.h"
59 alpha = 2 *
M_PI - alpha;
77 double dx = bchk.
nSigmas * sqrt(bchk.lCovariance(0, 0));
79 bchk.
nSigmas * sqrt(scResult.
sinC * scResult.
sinC * bchk.lCovariance(0, 0) +
80 locpo(0, 0) * locpo(0, 0) * scResult.
cosC *
81 scResult.
cosC * bchk.lCovariance(1, 1) +
82 2 * scResult.
cosC * scResult.
sinC * locpo(0, 0) *
83 bchk.lCovariance(0, 1));
105 std::vector<double> innerPolygonCoef(m_maxIterations + 1);
106 std::vector<double> outerPolygonCoef(m_maxIterations + 1);
119 for (
int t = 1;
t <= m_maxIterations;
t++) {
120 int numNodes = 4 <<
t;
121 innerPolygonCoef[
t] = 0.5 /
cos(2.0*
M_PI / numNodes);
122 double c1x = (c0x + c2x) * innerPolygonCoef[
t];
123 double c1y = (c0y + c2y) * innerPolygonCoef[
t];
126 if (
tx *
tx + ty * ty <=
rr) {
129 double t2x = c2x - c1x;
130 double t2y = c2y - c1y;
131 if (
tx * t2x + ty * t2y >= 0 &&
132 tx * t2x + ty * t2y <= t2x * t2x + t2y * t2y &&
133 (ty * t2x -
tx * t2y >= 0 ||
134 rr * (t2x * t2x + t2y * t2y) >=
135 (ty * t2x -
tx * t2y) * (ty * t2x -
tx * t2y))) {
138 double t0x = c0x - c1x;
139 double t0y = c0y - c1y;
140 if (
tx * t0x + ty * t0y >= 0 &&
141 tx * t0x + ty * t0y <= t0x * t0x + t0y * t0y &&
142 (ty * t0x -
tx * t0y <= 0 ||
143 rr * (t0x * t0x + t0y * t0y) >=
144 (ty * t0x -
tx * t0y) * (ty * t0x -
tx * t0y))) {
147 outerPolygonCoef[
t] =
149 double c3x = (c0x + c1x) * outerPolygonCoef[
t];
150 double c3y = (c0y + c1y) * outerPolygonCoef[
t];
151 if ((c3x -
x) * (c3x -
x) + (c3y -
y) * (c3y -
y) <
rr) {
156 double c4x = c1x - c3x + c1x;
157 double c4y = c1y - c3y + c1y;
158 if ((c4x -
x) * (c4x -
x) + (c4y -
y) * (c4y -
y) <
rr) {
163 double t3x = c3x - c1x;
164 double t3y = c3y - c1y;
165 if (ty * t3x -
tx * t3y <= 0 ||
166 rr * (t3x * t3x + t3y * t3y) >
167 (ty * t3x -
tx * t3y) * (ty * t3x -
tx * t3y)) {
168 if (
tx * t3x + ty * t3y > 0) {
169 if (std::abs(
tx * t3x + ty * t3y) <= t3x * t3x + t3y * t3y ||
170 (
x - c3x) * (c0x - c3x) + (
y - c3y) * (c0y - c3y) >= 0) {
175 }
else if (-(
tx * t3x + ty * t3y) <= t3x * t3x + t3y * t3y ||
176 (
x - c4x) * (c2x - c4x) + (
y - c4y) * (c2y - c4y) >= 0) {
191 bool collide(
double x0,
199 double x = std::abs(
x1 - x0);
200 double y = std::abs(
y1 - y0);
201 if (
x *
x + (
h -
y) * (
h -
y) <=
r *
r ||
202 (
w -
x) * (
w -
x) +
y *
y <=
r *
r ||
204 || ((
x *
h +
y *
w -
w *
h) * (
x *
h +
y *
w -
w *
h) <=
205 r *
r * (
w *
w +
h *
h) &&
206 x *
w -
y *
h >= -
h *
h &&
207 x *
w -
y *
h <=
w *
w)) {
210 if ((
x -
w) * (
x -
w) + (
y -
h) * (
y -
h) <=
r *
r ||
211 (
x <=
w &&
y -
r <=
h) || (
y <=
h &&
x -
r <=
w)) {
229 covRotMatrix << scResult.
cosC, -locpo(0, 0) * scResult.
sinC, scResult.
sinC,
230 locpo(0, 0) * scResult.
cosC;
232 covRotMatrix * bchk.lCovariance * covRotMatrix.transpose();
233 Amg::Vector2D locpoCar(covRotMatrix(1, 1), -covRotMatrix(0, 1));
237 double w = bchk.
nSigmas * sqrt(lCovarianceCar(0, 0));
238 double h = bchk.
nSigmas * sqrt(lCovarianceCar(1, 1));
242 (lCovarianceCar(1, 0) != 0 &&
243 (lCovarianceCar(1, 1) - lCovarianceCar(0, 0)) != 0)
244 ? .5 * bchk.
FastArcTan(2 * lCovarianceCar(1, 0) /
245 (lCovarianceCar(1, 1) - lCovarianceCar(0, 0)))
251 double x1 =
tmp(0, 0);
252 double y1 =
tmp(1, 0);
300 return sqrt(sr0 * sr0 +
sf *
sf);
303 return sqrt(sr1 * sr1 +
sf *
sf);
312 sl << std::setiosflags(std::ios::fixed);
313 sl << std::setprecision(7);
314 sl <<
"Trk::DiscBounds: (innerRadius, outerRadius, averagePhi, hPhiSector) = ";
315 sl <<
"(" << this->rMin() <<
", " << this->rMax() <<
", " << this->averagePhi() <<
", " << this->halfPhiSector()
317 sl << std::setprecision(-1);
324 sl << std::setiosflags(std::ios::fixed);
325 sl << std::setprecision(7);
326 sl <<
"Trk::DiscBounds: (innerRadius, outerRadius, hPhiSector) = ";
327 sl <<
"(" << this->rMin() <<
", " << this->rMax() <<
", " << this->averagePhi() <<
", " << this->halfPhiSector()
329 sl << std::setprecision(-1);