13 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
14 # define likely(expr) (__builtin_expect(!!(expr), 1))
15 # define unlikely(expr) (__builtin_expect(!!(expr), 0))
17 # define likely(expr) (expr)
18 # define unlikely(expr) (expr)
25 template<
class T>
static inline T sqr(
T t) {
return t *
t; }
26 template<
class T>
static inline T sgn(
T t) {
return std::signbit(t) ? -1. : 1.; }
27 template<
class T>
static inline T clamped_acos(
T t)
29 template<
class T>
static inline T clamped_sqrt(
T t)
35 :
p1(P1.
x(), P1.
y()), theTolerance(tolerance)
50 phi =
axis.
phi() - clamped_acos(cos);
52 double sign =
sgn(curvature);
53 double radius2 =
sqr(1.0 / curvature);
54 double orthog = clamped_sqrt(radius2 -
delta2);
56 double rc2 = lcenter.
mag2();
57 double cos = (rc2 +
sqr(radius) - radius2) /
59 phi = lcenter.
phi() + sign * clamped_acos(cos);
72 return sin / clamped_sqrt(1 -
sqr(sin));
74 double radius2 =
sqr(1.0 / curvature);
75 double orthog = clamped_sqrt(radius2 -
delta2);
78 double cos = (radius2 +
sqr(radius) - lcenter.
mag2()) *
79 curvature / (2. * radius);
80 return - cos / clamped_sqrt(1 -
sqr(cos));
87 double phi1 =
phi(curvature.second, radius);
88 double phi2 =
phi(curvature.first, radius);
100 transverseIP =
std::abs(transverseIP);
101 double transverseIP2 =
sqr(transverseIP);
103 double tip2 =
sqr(tip);
104 double lip =
axis.
x() * center.y() -
axis.
y() * center.x();
105 double lip2 =
sqr(lip);
108 double tmp1 = lip2 + tip2 - transverseIP2;
109 double tmp2 = 2. * (tip -
transverseIP) * (tip + transverseIP);
110 double tmp3 = 2. *
delta * origin;
111 double tmp4 = tmp1 +
delta2;
112 double tmp5 = 2. *
delta * lip;
118 if (
unlikely(tmp4 - tmp5 < 1.0e-5)) {
128 u2 = (
sqr(0.5 * tmp) - delta2 * tip2) / (tmp * tip);
132 double tmp6 = (tmp4 - tmp5) * (tmp4 + tmp5);
137 double tmp7 = tmp6 > 0 ? (transverseIP *
std::sqrt(tmp6) / tmp2) : 0.;
138 double tmp8 = tip * (tmp1 -
delta2) / tmp2;
146 if ((tmp3 < 0) == (tip < 0))
162 double a = diff.
y() * axis2.
x() - diff.
x() * axis2.
y();
170 double invDist2 =
sqr(invDist);
172 return sgn(invDist) * curv;
181 double dist = 1.0 / invDist;
194 if (
likely(absCurv > 1.0e-5)) {
207 static const double maxAngle =
M_PI;
208 double halfAngle = (0.5 * maxAngle) * (z2 - z1) / (z3 - z1);
218 double tip = circle->axis * circle->p1;
219 double lip = circle->axis.y() * circle->p1.x() -
220 circle->axis.x() * circle->p1.y();
225 double radius2 =
sqr(radius);
226 double orthog =
sgn(
curvature) * clamped_sqrt(radius2 - circle->delta2);
229 double b2 = center.
mag2();
232 double cos1 = 0.5 * (radius2 + b2 -
sqr(r)) *
curvature / b;
233 double cos2 = 0.5 * (radius2 + b2 - circle->p1.mag2()) *
curvature / b;
235 double phi1 = clamped_acos(cos1);
236 double phi2 = clamped_acos(cos2);
240 double u1 =
std::abs((phi1 - phi2) * radius);
241 double u2 =
std::abs((phi1 + phi2) * radius);
243 return z1 + ((u1 >= seg && u1 < u2)? u1 : u2) * dzdu;
252 double tip = circle->axis * circle->p1;
253 double lip = circle->axis.y() * circle->p1.x() -
254 circle->axis.x() * circle->p1.y();
259 double minR = (2. * circle->center - circle->p1).
mag();
277 double orthog =
sgn(
curvature) * clamped_sqrt(
sqr(radius) - circle->delta2);
285 center.
y() + s * rel.
x() + c * rel.
y());
Basic2DVector< double > p1
double phi(double curvature, double radius) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Sin< T >::type sin(const T &t)
Range operator()(Range curvature, double radius) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Range curvature(double transverseIP) const
Basic2DVector< double > Point2D
Basic3DVector< double > Point3D
T curvature(T InversePt, const edm::EventSetup &iSetup)
double rAtZ(double z) const
const T & max(const T &a, const T &b)
double transverseIP(const Basic2DVector< double > &thirdPoint) const
double angle(double curvature, double radius) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Cos< T >::type cos(const T &t)
double zAtR(double r) const
double invCenterOnAxis(const Basic2DVector< double > &thirdPoint) const
T y() const
Cartesian y coordinate.
ThirdHitPredictionFromCircle(const GlobalPoint &P1, const GlobalPoint &P2, float tolerance)
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
Basic2DVector< double > center
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
std::vector< std::vector< double > > tmp
PixelRecoRange< float > Range
Basic2DVector< double > axis
Square< F >::type sqr(const F &f)
Geom::Phi< T > phi() const
T x() const
Cartesian x coordinate.