13 inline float sqr(
float x) {
return x *
x; }
26 theTTRecHitBuilder = &ttrhBuilder;
32 r0 =
region.originRBound();
45 arc_0m = findArcIntersection(findMinimalCircles(
rm), findTouchingCircles(r0),
keep);
64 float s = dif.mag2() / (
p -
p1).
mag2();
71 pair<float, float>
a(0., 0.);
73 if (dif.mag2() < 2 *
sqr(r))
74 a = pair<float, float>(dif.phi(), 0.5 * acos(1 - 0.5 * dif.mag2() /
sqr(r)));
84 pair<float, float>
a(0., 0.);
85 a = pair<float, float>((
c -
p2).phi(), 0.5 * acos(1 - 2 *
sqr(r) / (
c -
p2).
mag2()));
93 while (
b.first <
a.first -
M_PI)
95 while (
b.first >
a.first +
M_PI)
100 if (
a.first -
a.second >
b.first -
b.second)
101 min =
a.first -
a.second;
103 min =
b.first -
b.second;
107 if (
a.first +
a.second <
b.first +
b.second)
108 max =
a.first +
a.second;
110 max =
b.first +
b.second;
114 pair<float, float>
c(0., 0.);
126 float s2 =
sqr(
x[0]) * (y[1] - y[2]) +
sqr(
x[1]) * (y[2] - y[0]) +
sqr(
x[2]) * (y[0] - y[1]);
128 float s1 =
x[0] * (y[1] - y[2]) +
x[1] * (y[2] - y[0]) +
x[2] * (y[0] - y[1]);
130 float s3 = (
x[0] -
x[1]) * (
x[1] -
x[2]) * (
x[2] -
x[0]);
132 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]);
141 const float x[3],
const float y[3],
const float par[3],
float phi[2],
float z[2]) {
143 phi[0] =
min(
x[0],
x[2]);
144 z[0] =
min(y[0], y[2]);
145 phi[1] =
max(
x[0],
x[2]);
146 z[1] =
max(y[0], y[2]);
149 float xe = -par[1] / (2 * par[2]);
150 float ye = par[0] -
sqr(par[1]) / (4 * par[2]);
153 if (phi[0] < xe && xe < phi[1]) {
163 return a.x() *
b.y() -
a.y() *
b.x();
170 float a12 = asin(fabsf(areaParallelogram(
p1 -
c,
p2 -
c)) / rad2);
171 float a23 = asin(fabsf(areaParallelogram(
p2 -
c,
p3 -
c)) / rad2);
178 while (phi[1] < phi[0] -
M_PI)
180 while (phi[1] > phi[0] +
M_PI)
183 while (phi[2] < phi[1] -
M_PI)
185 while (phi[2] > phi[1] +
M_PI)
191 pair<float, float> arc_all = findArcIntersection(arc_0m, findTouchingCircles(r3),
keep);
193 if (arc_all.second != 0.) {
195 invertCircle(c3, r3);
198 angle[0] = arc_all.first - arc_all.second;
199 angle[1] = arc_all.first;
200 angle[2] = arc_all.first + arc_all.second;
202 float phi3[3], z3[3];
205 for (
int i = 0;
i < 3;
i++) {
215 if (
keep &&
i == 1) {
222 ratio = angleRatio(
p3,
c);
225 z3[
i] =
g2.z() + (
g2.z() -
g1.z()) * ratio;
232 fitParabola(phi3, z3, par);
233 findRectangle(phi3, z3, par, phi, z);
240 angle[0] = arc_0m.first - arc_0m.second;
241 angle[1] = arc_0m.first;
242 angle[2] = arc_0m.first + arc_0m.second;
244 float ratio = (z3 -
g2.z()) / (
g2.z() -
g1.z());
246 if (0 < ratio && ratio < maxRatio) {
247 float phi3[3], r3[3];
249 for (
int i = 0;
i < 3;
i++) {
252 if (
keep &&
i == 1) {
263 float a12 = asin(areaParallelogram(
p1 -
c,
p2 -
c) / rad2);
264 float a23 = ratio * a12;
278 fitParabola(phi3, r3, par);
279 findRectangle(phi3, r3, par, phi, r);
293 calculateRangesBarrel(rz3, phi, rz,
keep);
295 calculateRangesForward(rz3, phi, rz,
keep);
305 float phi_inner[2], rz_inner[2];
306 calculateRanges(theDetRange.min(), phi_inner, rz_inner);
308 float phi_outer[2], rz_outer[2];
309 calculateRanges(theDetRange.max(), phi_outer, rz_outer);
311 if ((phi_inner[0] == 0. && phi_inner[1] == 0.) || (phi_outer[0] == 0. && phi_outer[1] == 0.)) {
318 while (phi_outer[0] > phi_inner[0] +
M_PI) {
319 phi_outer[0] -= 2 *
M_PI;
320 phi_outer[1] -= 2 *
M_PI;
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 phi[0] =
min(phi_inner[0], phi_outer[0]);
329 phi[1] =
max(phi_inner[1], phi_outer[1]);
331 rz[0] =
min(rz_inner[0], rz_outer[0]);
332 rz[1] =
max(rz_inner[1], rz_outer[1]);
341 const vector<const TrackingRecHit*>&
h,
342 vector<GlobalVector>& globalDirs,
350 if (circle.curvature() != 0.) {
354 float a12 = asin(fabsf(areaParallelogram(
p1 -
c,
p2 -
c)) / rad2);
355 float a23 = asin(fabsf(areaParallelogram(
p2 -
c,
p3 -
c)) / rad2);
359 float rz3 =
g2.z() +
slope * a23;
360 float delta_z = g3.
z() - rz3;
363 vector<TransientTrackingRecHit::RecHitPointer> th;
364 for (vector<const TrackingRecHit*>::const_iterator ih =
h.begin(); ih !=
h.end(); ih++)
365 th.push_back(theTTRecHitBuilder->build(*ih));
367 float sigma1_le2 =
max(th[0]->parametersError()[0][0], th[0]->parametersError()[1][1]);
368 float sigma2_le2 =
max(th[1]->parametersError()[0][0], th[1]->parametersError()[1][1]);
370 float sigma_z2 = (1 + a23 / a12) * (1 + a23 / a12) * sigma2_le2 + (a23 / a12) * (a23 / a12) * sigma1_le2;
372 float cotTheta =
slope * circle.curvature();
373 float coshEta =
sqrt(1 +
sqr(cotTheta));
375 float pt = Bz / circle.curvature();
376 float p =
pt * coshEta;
378 float m_pi = 0.13957018;
387 float sinTheta = 1. / coshEta;
388 float cosTheta = cotTheta * sinTheta;
391 if (areaParallelogram(
p1 -
c,
p2 -
c) > 0)
400 globalDirs.push_back(
GlobalVector(-
v.y() * sinTheta,
v.x() * sinTheta, cosTheta));
405 globalDirs.push_back(
GlobalVector(-
v.y() * sinTheta,
v.x() * sinTheta, cosTheta));
410 globalDirs.push_back(
GlobalVector(-
v.y() * sinTheta,
v.x() * sinTheta, cosTheta));
414 float sigma_ms =
sigma_z * coshEta;
417 float sigma_le2 =
max(th[2]->parametersError()[0][0], th[2]->parametersError()[1][1]);
419 return (delta_z * delta_z / (sigma_ms * sigma_ms + sigma_le2 + sigma_z2) <
nSigma *
nSigma);
440 theDetRange =
Range(zLayer - halfThickness, zLayer + halfThickness);
void findRectangle(const float x[3], const float y[3], const float par[3], float phi[2], float z[2])
virtual const Surface::PositionType & position() const
Returns position of the surface.
void invertCircle(Global2DVector &c, float &r)
void initLayer(const DetLayer *layer)
Vector2DBase< float, GlobalTag > Global2DVector
const BoundSurface & surface() const final
GeometricSearchDet interface.
PixelRecoRange< float > Range
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
static const double slope[3]
Sin< T >::type sin(const T &t)
void calculateRangesForward(float z3, float phi[2], float r[2], bool keep)
void calculateRangesBarrel(float r3, float phi[2], float z[2], bool keep)
float angleRatio(const Global2DVector &p3, const Global2DVector &c)
T curvature(T InversePt, const MagneticField &field)
virtual float thickness() const =0
MultipleScatteringParametrisation parametrisation(const DetLayer *layer, X0Source x0Source=X0Source::useX0AtEta) const
Cos< T >::type cos(const T &t)
float areaParallelogram(const Global2DVector &a, const Global2DVector &b)
std::pair< float, float > findMinimalCircles(float r)
ThirdHitPrediction(const TrackingRegion ®ion, GlobalPoint inner, GlobalPoint outer, const MagneticField &magfield, const TransientTrackingRecHitBuilder &ttrhBuilder, double nSigMultipleScattering, double maxAngleRatio)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
void spinCloser(float phi[3])
std::pair< float, float > findArcIntersection(std::pair< float, float > a, std::pair< float, float > b, bool &keep)
void invertPoint(Global2DVector &p)
void fitParabola(const float x[3], const float y[3], float par[3])
void calculateRanges(float rz3, float phi[2], float rz[2])
void getRanges(const DetLayer *layer, float phi[], float rz[])
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::pair< float, float > findTouchingCircles(float r)
bool isCompatibleWithMultipleScattering(GlobalPoint g3, const std::vector< const TrackingRecHit *> &h, std::vector< GlobalVector > &localDirs, const MultipleScatteringParametrisationMaker &msmaker)
Global3DVector GlobalVector
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
const Bounds & bounds() const