13 inline float sqr(
float x) {
return x *
x; }
31 theTTRecHitBuilder = ttrhbESH.
product();
50 arc_0m = findArcIntersection(findMinimalCircles(
rm), findTouchingCircles(r0),
keep);
61 float s = dif.mag2() / ((c -
p1).
mag2() -
sqr(r));
63 c =
p1 + (c -
p1) * s;
69 float s = dif.mag2() / (p -
p1).
mag2();
71 p =
p1 + (p -
p1) * s;
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.);
122 c.first = 0.5 * (max +
min);
123 c.second = 0.5 * (max -
min);
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++) {
212 float lambda = delta * vec -
sqrt(
sqr(delta * vec) - delta * delta +
sqr(r3));
220 if (keep && i == 1) {
227 ratio = angleRatio(p3, c);
230 z3[
i] =
g2.z() + (
g2.z() -
g1.z()) * ratio;
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;
251 if (0 < ratio && ratio <
maxRatio) {
252 float phi3[3], r3[3];
254 for (
int i = 0;
i < 3;
i++) {
257 if (keep &&
i == 1) {
258 p3 =
p2 + ratio * (
p2 -
p1);
268 float a12 = asin(areaParallelogram(
p1 - c,
p2 - c) / rad2);
269 float a23 = ratio * a12;
272 (
p2 - c).x() *
sin(a23) + (
p2 - c).y() *
cos(a23));
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);
438 theDetRange =
Range(radius - halfThickness, radius + halfThickness);
445 theDetRange =
Range(zLayer - halfThickness, zLayer + halfThickness);
float originRBound() const
bounds the particle vertex in the transverse plane
void findRectangle(const float x[3], const float y[3], const float par[3], float phi[2], float z[2])
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void invertCircle(Global2DVector &c, float &r)
void initLayer(const DetLayer *layer)
GlobalPoint const & origin() const
Vector2DBase< float, GlobalTag > Global2DVector
PixelRecoRange< float > Range
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static const double slope[3]
Sin< T >::type sin(const T &t)
void calculateRangesForward(float z3, float phi[2], float r[2], bool keep)
virtual Location location() const =0
Which part of the detector (barrel, endcap)
void calculateRangesBarrel(float r3, float phi[2], float z[2], bool keep)
const Bounds & bounds() const
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
float angleRatio(const Global2DVector &p3, const Global2DVector &c)
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Geom::Phi< T > phi() const
T curvature(T InversePt, const edm::EventSetup &iSetup)
Cos< T >::type cos(const T &t)
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
float areaParallelogram(const Global2DVector &a, const Global2DVector &b)
std::pair< float, float > findMinimalCircles(float r)
virtual float thickness() const =0
virtual const Surface::PositionType & position() const
Returns position of the surface.
float ptMin() const
minimal pt of interest
ThirdHitPrediction(const TrackingRegion ®ion, GlobalPoint inner, GlobalPoint outer, const edm::EventSetup &es, double nSigMultipleScattering, double maxAngleRatio, std::string builderName)
void spinCloser(float phi[3])
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
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])
bool isCompatibleWithMultipleScattering(GlobalPoint g3, const std::vector< const TrackingRecHit * > &h, std::vector< GlobalVector > &localDirs, const edm::EventSetup &es)
void getRanges(const DetLayer *layer, float phi[], float rz[])
std::pair< float, float > findTouchingCircles(float r)
T const * product() const
const BoundSurface & surface() const final
GeometricSearchDet interface.
Global3DVector GlobalVector
T angle(T x1, T y1, T z1, T x2, T y2, T z2)