13 inline float sqr(
float x) {
return x*
x; }
30 theTTRecHitBuilder = ttrhbESH.
product();
50 arc_0m = findArcIntersection(findMinimalCircles (
rm),
51 findTouchingCircles(r0),
keep);
65 float s = dif.mag2() / ((c -
p1).
mag2() -
sqr(r));
74 float s = dif.mag2() / (p -
p1).
mag2();
82 pair<float,float>
a(0.,0.);
84 if(dif.mag2() < 2 *
sqr(r))
85 a = pair<float,float>( dif.phi(),
86 0.5*acos(1 - 0.5 * dif.mag2()/
sqr(r)) );
97 pair<float,float>
a(0.,0.);
98 a = pair<float,float>( (c -
p2).phi(),
106 (pair<float,float>
a, pair<float,float>
b,
bool&
keep)
109 while(b.first < a.first -
M_PI) b.first += 2*
M_PI;
110 while(b.first > a.first +
M_PI) b.first -= 2*
M_PI;
114 if(a.first - a.second > b.first - b.second)
115 min = a.first - a.second;
117 { min = b.first - b.second; keep =
false; }
119 if(a.first + a.second < b.first + b.second)
120 max = a.first + a.second;
122 { max = b.first + b.second; keep =
false; }
124 pair<float,float>
c(0.,0.);
128 c.first = 0.5*(max +
min);
129 c.second = 0.5*(max -
min);
137 (
const float x[3],
const float y[3],
float par[3])
139 float s2 =
sqr(x[0]) * (y[1] - y[2]) +
140 sqr(x[1]) * (y[2] - y[0]) +
141 sqr(x[2]) * (y[0] - y[1]);
143 float s1 = x[0] * (y[1] - y[2]) +
144 x[1] * (y[2] - y[0]) +
145 x[2] * (y[0] - y[1]);
147 float s3 = (x[0] - x[1]) * (x[1] - x[2]) * (x[2] - x[0]);
148 float s4 = x[0]*x[1]*y[2] * (x[0] - x[1]) +
149 x[0]*y[1]*x[2] * (x[2] - x[0]) +
150 y[0]*x[1]*x[2] * (x[1] - x[2]);
159 (
const float x[3],
const float y[3],
const float par[3],
160 float phi[2],
float z[2])
163 phi[0] =
min(x[0],x[2]); z[0] =
min(y[0],y[2]);
164 phi[1] =
max(x[0],x[2]); z[1] =
max(y[0],y[2]);
167 float xe = -par[1]/(2*par[2]);
168 float ye = par[0] -
sqr(par[1])/(4*par[2]);
171 if(phi[0] < xe && xe < phi[1])
173 if(ye < z[0]) z[0] = ye;
174 if(ye > z[1]) z[1] = ye;
182 return a.
x() * b.
y() - a.
y() * b.
x();
191 float a12 = asin(fabsf(areaParallelogram(
p1 - c,
p2 - c)) / rad2);
192 float a23 = asin(fabsf(areaParallelogram(
p2 - c, p3 - c)) / rad2);
200 while(phi[1] < phi[0] -
M_PI) phi[1] += 2*
M_PI;
201 while(phi[1] > phi[0] +
M_PI) phi[1] -= 2*
M_PI;
203 while(phi[2] < phi[1] -
M_PI) phi[2] += 2*
M_PI;
204 while(phi[2] > phi[1] +
M_PI) phi[2] -= 2*
M_PI;
209 (
float r3,
float phi[2],
float z[2],
bool keep)
211 pair<float,float> arc_all =
212 findArcIntersection(arc_0m, findTouchingCircles(r3), keep);
214 if(arc_all.second != 0.)
220 angle[0] = arc_all.first - arc_all.second;
221 angle[1] = arc_all.first;
222 angle[2] = arc_all.first + arc_all.second;
224 float phi3[3], z3[3];
227 for(
int i=0;
i<3;
i++)
230 float lambda = delta*vec -
sqrt(
sqr(delta*vec) - delta*delta +
sqr(r3));
248 ratio = angleRatio(p3,c);
251 z3[
i] =
g2.z() + (
g2.z() -
g1.z()) * ratio;
258 fitParabola (phi3,z3, par);
259 findRectangle(phi3,z3, par, phi,z);
265 (
float z3,
float phi[2],
float r[2],
bool keep)
268 angle[0] = arc_0m.first - arc_0m.second;
269 angle[1] = arc_0m.first;
270 angle[2] = arc_0m.first + arc_0m.second;
274 if(0 < ratio && ratio < maxRatio)
276 float phi3[3], r3[3];
278 for(
int i=0;
i<3;
i++)
284 p3 =
p2 + ratio * (
p2 -
p1);
296 float a12 = asin(areaParallelogram(
p1 - c,
p2 - c) / rad2);
297 float a23 = ratio * a12;
311 fitParabola (phi3,r3, par);
312 findRectangle(phi3,r3, par, phi,r);
318 (
float rz3,
float phi[2],
float rz[2])
321 phi[0] = 0.; rz[0] = 0.;
322 phi[1] = 0.; rz[1] = 0.;
325 if(theBarrel) calculateRangesBarrel (rz3, phi,rz, keep);
326 else calculateRangesForward(rz3, phi,rz, keep);
335 if (layer) initLayer(layer);
337 float phi_inner[2],rz_inner[2];
338 calculateRanges(theDetRange.min(), phi_inner,rz_inner);
340 float phi_outer[2],rz_outer[2];
341 calculateRanges(theDetRange.max(), phi_outer,rz_outer);
343 if( (phi_inner[0] == 0. && phi_inner[1] == 0.) ||
344 (phi_outer[0] == 0. && phi_outer[1] == 0.) )
354 while(phi_outer[0] > phi_inner[0] +
M_PI)
355 { phi_outer[0] -= 2*
M_PI; phi_outer[1] -= 2*
M_PI; }
357 while(phi_outer[0] < phi_inner[0] -
M_PI)
358 { phi_outer[0] += 2*
M_PI; phi_outer[1] += 2*
M_PI; }
360 phi[0] =
min(phi_inner[0],phi_outer[0]);
361 phi[1] =
max(phi_inner[1],phi_outer[1]);
363 rz[0] =
min( rz_inner[0], rz_outer[0]);
364 rz[1] =
max( rz_inner[1], rz_outer[1]);
370 (
float rz3,
float phi[],
float rz[])
372 calculateRanges(rz3, phi,rz);
386 if(circle.curvature() != 0.)
391 float a12 = asin(fabsf(areaParallelogram(
p1 - c,
p2 - c)) / rad2);
392 float a23 = asin(fabsf(areaParallelogram(
p2 - c, p3 - c)) / rad2);
396 float rz3 =
g2.z() + slope * a23;
397 float delta_z = g3.
z() - rz3;
400 vector<TransientTrackingRecHit::RecHitPointer> th;
401 for(vector<const TrackingRecHit*>::const_iterator ih = h.begin(); ih!= h.end(); ih++)
402 th.push_back(theTTRecHitBuilder->build(*ih));
404 float sigma1_le2 =
max(th[0]->parametersError()[0][0],
405 th[0]->parametersError()[1][1]);
406 float sigma2_le2 =
max(th[1]->parametersError()[0][0],
407 th[1]->parametersError()[1][1]);
409 float sigma_z2 = (1 + a23/a12)*(1 + a23/a12) * sigma2_le2 +
410 ( a23/a12)*( a23/a12) * sigma1_le2;
412 float cotTheta = slope * circle.curvature();
413 float coshEta =
sqrt(1 +
sqr(cotTheta));
415 float pt = Bz / circle.curvature();
416 float p = pt * coshEta;
418 float m_pi = 0.13957018;
424 float sigma_z =
msp(pt, cotTheta, rz2) /
beta;
427 float sinTheta = 1. / coshEta;
428 float cosTheta = cotTheta * sinTheta;
431 if(areaParallelogram(
p1 - c,
p2 - c) > 0) dir = 1;
else dir = -1;
437 globalDirs.push_back(
GlobalVector(-v.
y()*sinTheta,v.
x()*sinTheta,cosTheta));
442 globalDirs.push_back(
GlobalVector(-v.
y()*sinTheta,v.
x()*sinTheta,cosTheta));
447 globalDirs.push_back(
GlobalVector(-v.
y()*sinTheta,v.
x()*sinTheta,cosTheta));
451 float sigma_ms = sigma_z * coshEta;
454 float sigma_le2 =
max(th[2]->parametersError()[0][0],
455 th[2]->parametersError()[1][1]);
457 return (delta_z*delta_z / (sigma_ms*sigma_ms + sigma_le2 + sigma_z2)
473 theDetRange =
Range(radius-halfThickness, radius+halfThickness);
480 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])
void invertCircle(Global2DVector &c, float &r)
void initLayer(const DetLayer *layer)
GlobalPoint const & origin() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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
Vector2DBase< float, GlobalTag > Global2DVector
T angle(T x1, T y1, T z1, T x2, T y2, T z2)