13 inline float sqr(
float x) {
return x *
x; }
31 theTTRecHitBuilder = ttrhbESH.
product();
37 r0 =
region.originRBound();
50 arc_0m = findArcIntersection(findMinimalCircles(
rm), findTouchingCircles(r0),
keep);
69 float s = dif.mag2() / (
p -
p1).
mag2();
76 pair<float, float>
a(0., 0.);
78 if (dif.mag2() < 2 *
sqr(
r))
79 a = pair<float, float>(dif.phi(), 0.5 * acos(1 - 0.5 * dif.mag2() /
sqr(
r)));
89 pair<float, float>
a(0., 0.);
90 a = pair<float, float>((
c -
p2).phi(), 0.5 * acos(1 - 2 *
sqr(
r) / (
c -
p2).
mag2()));
98 while (
b.first <
a.first -
M_PI)
100 while (
b.first >
a.first +
M_PI)
105 if (
a.first -
a.second >
b.first -
b.second)
106 min =
a.first -
a.second;
108 min =
b.first -
b.second;
112 if (
a.first +
a.second <
b.first +
b.second)
113 max =
a.first +
a.second;
115 max =
b.first +
b.second;
119 pair<float, float>
c(0., 0.);
131 float s2 =
sqr(x[0]) * (y[1] - y[2]) +
sqr(x[1]) * (y[2] - y[0]) +
sqr(x[2]) * (y[0] - y[1]);
133 float s1 = x[0] * (y[1] - y[2]) + x[1] * (y[2] - y[0]) + x[2] * (y[0] - y[1]);
135 float s3 = (x[0] - x[1]) * (x[1] - x[2]) * (x[2] - x[0]);
137 x[0] * x[1] * y[2] * (x[0] - x[1]) + x[0] * y[1] * x[2] * (x[2] - x[0]) + y[0] * x[1] * x[2] * (x[1] - x[2]);
146 const float x[3],
const float y[3],
const float par[3],
float phi[2],
float z[2]) {
148 phi[0] =
min(x[0], x[2]);
149 z[0] =
min(y[0], y[2]);
150 phi[1] =
max(x[0], x[2]);
151 z[1] =
max(y[0], y[2]);
154 float xe = -par[1] / (2 * par[2]);
155 float ye = par[0] -
sqr(par[1]) / (4 * par[2]);
158 if (phi[0] < xe && xe < phi[1]) {
168 return a.x() *
b.y() -
a.y() *
b.x();
175 float a12 = asin(fabsf(areaParallelogram(
p1 -
c,
p2 -
c)) / rad2);
176 float a23 = asin(fabsf(areaParallelogram(
p2 -
c,
p3 -
c)) / rad2);
183 while (phi[1] < phi[0] -
M_PI)
185 while (phi[1] > phi[0] +
M_PI)
188 while (phi[2] < phi[1] -
M_PI)
190 while (phi[2] > phi[1] +
M_PI)
196 pair<float, float> arc_all = findArcIntersection(arc_0m, findTouchingCircles(r3),
keep);
198 if (arc_all.second != 0.) {
200 invertCircle(c3, r3);
203 angle[0] = arc_all.first - arc_all.second;
204 angle[1] = arc_all.first;
205 angle[2] = arc_all.first + arc_all.second;
207 float phi3[3], z3[3];
210 for (
int i = 0;
i < 3;
i++) {
220 if (
keep &&
i == 1) {
237 fitParabola(phi3, z3, par);
238 findRectangle(phi3, z3, par, phi, z);
245 angle[0] = arc_0m.first - arc_0m.second;
246 angle[1] = arc_0m.first;
247 angle[2] = arc_0m.first + arc_0m.second;
252 float phi3[3], r3[3];
254 for (
int i = 0;
i < 3;
i++) {
257 if (
keep &&
i == 1) {
268 float a12 = asin(areaParallelogram(
p1 -
c,
p2 -
c) / rad2);
269 float a23 =
ratio * a12;
283 fitParabola(phi3, r3, par);
284 findRectangle(phi3, r3, par, phi,
r);
298 calculateRangesBarrel(rz3, phi, rz,
keep);
300 calculateRangesForward(rz3, phi, rz,
keep);
310 float phi_inner[2], rz_inner[2];
311 calculateRanges(theDetRange.min(), phi_inner, rz_inner);
313 float phi_outer[2], rz_outer[2];
314 calculateRanges(theDetRange.max(), phi_outer, rz_outer);
316 if ((phi_inner[0] == 0. && phi_inner[1] == 0.) || (phi_outer[0] == 0. && phi_outer[1] == 0.)) {
323 while (phi_outer[0] > phi_inner[0] +
M_PI) {
324 phi_outer[0] -= 2 *
M_PI;
325 phi_outer[1] -= 2 *
M_PI;
328 while (phi_outer[0] < phi_inner[0] -
M_PI) {
329 phi_outer[0] += 2 *
M_PI;
330 phi_outer[1] += 2 *
M_PI;
333 phi[0] =
min(phi_inner[0], phi_outer[0]);
334 phi[1] =
max(phi_inner[1], phi_outer[1]);
336 rz[0] =
min(rz_inner[0], rz_outer[0]);
337 rz[1] =
max(rz_inner[1], rz_outer[1]);
346 const vector<const TrackingRecHit*>&
h,
347 vector<GlobalVector>& globalDirs,
355 if (circle.curvature() != 0.) {
359 float a12 = asin(fabsf(areaParallelogram(
p1 -
c,
p2 -
c)) / rad2);
360 float a23 = asin(fabsf(areaParallelogram(
p2 -
c,
p3 -
c)) / rad2);
364 float rz3 =
g2.z() +
slope * a23;
365 float delta_z = g3.
z() - rz3;
368 vector<TransientTrackingRecHit::RecHitPointer> th;
369 for (vector<const TrackingRecHit*>::const_iterator ih =
h.begin(); ih !=
h.end(); ih++)
370 th.push_back(theTTRecHitBuilder->build(*ih));
372 float sigma1_le2 =
max(th[0]->parametersError()[0][0], th[0]->parametersError()[1][1]);
373 float sigma2_le2 =
max(th[1]->parametersError()[0][0], th[1]->parametersError()[1][1]);
375 float sigma_z2 = (1 + a23 / a12) * (1 + a23 / a12) * sigma2_le2 + (a23 / a12) * (a23 / a12) * sigma1_le2;
377 float cotTheta =
slope * circle.curvature();
378 float coshEta =
sqrt(1 +
sqr(cotTheta));
380 float pt = Bz / circle.curvature();
381 float p =
pt * coshEta;
383 float m_pi = 0.13957018;
389 float sigma_z = msp(
pt, cotTheta, rz2) /
beta;
392 float sinTheta = 1. / coshEta;
393 float cosTheta = cotTheta * sinTheta;
396 if (areaParallelogram(
p1 -
c,
p2 -
c) > 0)
405 globalDirs.push_back(
GlobalVector(-
v.y() * sinTheta,
v.x() * sinTheta, cosTheta));
410 globalDirs.push_back(
GlobalVector(-
v.y() * sinTheta,
v.x() * sinTheta, cosTheta));
415 globalDirs.push_back(
GlobalVector(-
v.y() * sinTheta,
v.x() * sinTheta, cosTheta));
419 float sigma_ms = sigma_z * coshEta;
422 float sigma_le2 =
max(th[2]->parametersError()[0][0], th[2]->parametersError()[1][1]);
424 return (delta_z * delta_z / (sigma_ms * sigma_ms + sigma_le2 + sigma_z2) <
nSigma *
nSigma);
445 theDetRange =
Range(zLayer - halfThickness, zLayer + halfThickness);