CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
ThirdHitPredictionFromCircle Class Reference

#include <ThirdHitPredictionFromCircle.h>

Classes

class  HelixRZ
 

Public Types

typedef PixelRecoRange< float > Range
 

Public Member Functions

double angle (double curvature, double radius) const
 
Range curvature (double transverseIP) const
 
double curvature (const Basic2DVector< double > &thirdPoint) const
 
Range operator() (Range curvature, double radius) const
 
double phi (double curvature, double radius) const
 
 ThirdHitPredictionFromCircle (const GlobalPoint &P1, const GlobalPoint &P2, float tolerance)
 
double transverseIP (const Basic2DVector< double > &thirdPoint) const
 

Private Member Functions

double invCenterOnAxis (const Basic2DVector< double > &thirdPoint) const
 

Private Attributes

Basic2DVector< double > axis
 
Basic2DVector< double > center
 
double delta
 
double delta2
 
Basic2DVector< double > p1
 
double theTolerance
 

Friends

class HelixRZ
 

Detailed Description

Definition at line 11 of file ThirdHitPredictionFromCircle.h.

Member Typedef Documentation

Definition at line 14 of file ThirdHitPredictionFromCircle.h.

Constructor & Destructor Documentation

ThirdHitPredictionFromCircle::ThirdHitPredictionFromCircle ( const GlobalPoint P1,
const GlobalPoint P2,
float  tolerance 
)

Definition at line 33 of file ThirdHitPredictionFromCircle.cc.

References axis, center, delta, delta2, diffTreeTool::diff, p1, p2, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

35  : p1(P1.x(), P1.y()), theTolerance(tolerance)
36 {
37  Point2D p2(P2.x(), P2.y());
38  Point2D diff = 0.5 * (p2 - p1);
39  delta2 = diff.mag2();
41  axis = Point2D(-diff.y(), diff.x()) / delta;
42  center = p1 + diff;
43 }
T y() const
Definition: PV3DBase.h:62
Basic2DVector< double > Point2D
T sqrt(T t)
Definition: SSEVec.h:46
double p2[4]
Definition: TauolaWrapper.h:90
T x() const
Definition: PV3DBase.h:61

Member Function Documentation

double ThirdHitPredictionFromCircle::angle ( double  curvature,
double  radius 
) const

Definition at line 68 of file ThirdHitPredictionFromCircle.cc.

References abs, axis, center, funct::cos(), delta2, alignCSCRings::e, Basic2DVector< T >::mag2(), FWPFMaths::sgn(), funct::sin(), funct::sqr(), and unlikely.

Referenced by MatchedHitRZCorrectionFromBending::tibMatchedHitZFixup().

69 {
70  if (unlikely(std::abs(curvature) < 1.0e-5)) {
71  double sin = (center * axis) / radius;
72  return sin / clamped_sqrt(1 - sqr(sin));
73  } else {
74  double radius2 = sqr(1.0 / curvature);
75  double orthog = clamped_sqrt(radius2 - delta2);
76  Basic2DVector<double> lcenter = center - sgn(curvature) * orthog * axis;
77 
78  double cos = (radius2 + sqr(radius) - lcenter.mag2()) *
79  curvature / (2. * radius);
80  return - cos / clamped_sqrt(1 - sqr(cos));
81  }
82 }
float sgn(float val)
Definition: FWPFMaths.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
#define unlikely(expr)
Range curvature(double transverseIP) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Square< F >::type sqr(const F &f)
Definition: Square.h:13
ThirdHitPredictionFromCircle::Range ThirdHitPredictionFromCircle::curvature ( double  transverseIP) const

Definition at line 96 of file ThirdHitPredictionFromCircle.cc.

References abs, axis, center, delta, delta2, alignCSCRings::e, FWPFMaths::sgn(), funct::sqr(), mathSSE::sqrt(), std::swap(), tmp, transverseIP(), unlikely, Basic2DVector< T >::x(), and Basic2DVector< T >::y().

Referenced by ThirdHitPredictionFromCircle::HelixRZ::rAtZ(), and ThirdHitPredictionFromCircle::HelixRZ::zAtR().

97 {
98  // this is a mess. Use a CAS and lots of drawings to verify...
99 
101  double transverseIP2 = sqr(transverseIP);
102  double tip = axis * center;
103  double tip2 = sqr(tip);
104  double lip = axis.x() * center.y() - axis.y() * center.x();
105  double lip2 = sqr(lip);
106 
107  double origin = std::sqrt(tip2 + lip2);
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;
113 
114  // I am probably being overly careful here with border cases
115  // but you never know what crap you might get fed
116 
117  double u1, u2;
118  if (unlikely(tmp4 - tmp5 < 1.0e-5)) {
119  u1 = -0.; // yes, I am making use of signed zero
120  u2 = +0.; // -> no -ffast-math please
121  } else {
122  if (unlikely(std::abs(tmp2) < 1.0e-5)) {
123  // the denominator is zero
124  // this means that one of the tracks will be straight
125  // and the other can be computed from the limit of the equation
126  double tmp = lip2 - delta2;
127  u1 = INFINITY; // and require 1 / sqrt(inf^2 + x) = 0 (with x > 0)
128  u2 = (sqr(0.5 * tmp) - delta2 * tip2) / (tmp * tip);
129  if (tip < 0)
130  std::swap(u1, u2);
131  } else {
132  double tmp6 = (tmp4 - tmp5) * (tmp4 + tmp5);
133  if (unlikely(tmp6 < 1.0e-5)) {
134  u1 = -0.;
135  u2 = +0.;
136  } else {
137  double tmp7 = tmp6 > 0 ? (transverseIP * std::sqrt(tmp6) / tmp2) : 0.;
138  double tmp8 = tip * (tmp1 - delta2) / tmp2;
139  // the two quadratic solutions
140  u1 = tmp8 + tmp7;
141  u2 = tmp8 - tmp7;
142  }
143  }
144 
145  if (tmp4 <= std::abs(tmp3)) {
146  if ((tmp3 < 0) == (tip < 0))
147  u2 = +0.;
148  else
149  u1 = -0.;
150  }
151  }
152 
153  return Range(sgn(u1) / std::sqrt(sqr(u1) + delta2),
154  sgn(u2) / std::sqrt(sqr(u2) + delta2));
155 }
float sgn(float val)
Definition: FWPFMaths.cc:9
#define abs(x)
Definition: mlp_lapack.h:159
#define unlikely(expr)
double transverseIP(const Basic2DVector< double > &thirdPoint) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:46
T y() const
Cartesian y coordinate.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Square< F >::type sqr(const F &f)
Definition: Square.h:13
T x() const
Cartesian x coordinate.
double ThirdHitPredictionFromCircle::curvature ( const Basic2DVector< double > &  thirdPoint) const

Definition at line 167 of file ThirdHitPredictionFromCircle.cc.

References delta2, invCenterOnAxis(), FWPFMaths::sgn(), funct::sqr(), and mathSSE::sqrt().

168 {
169  double invDist = invCenterOnAxis(p2);
170  double invDist2 = sqr(invDist);
171  double curv = std::sqrt(invDist2 / (1. + invDist2 * delta2));
172  return sgn(invDist) * curv;
173 }
float sgn(float val)
Definition: FWPFMaths.cc:9
T sqrt(T t)
Definition: SSEVec.h:46
double invCenterOnAxis(const Basic2DVector< double > &thirdPoint) const
double p2[4]
Definition: TauolaWrapper.h:90
Square< F >::type sqr(const F &f)
Definition: Square.h:13
double ThirdHitPredictionFromCircle::invCenterOnAxis ( const Basic2DVector< double > &  thirdPoint) const
private

Definition at line 157 of file ThirdHitPredictionFromCircle.cc.

References a, axis, b, center, delta, diffTreeTool::diff, Basic2DVector< T >::mag(), p1, Basic2DVector< T >::x(), and Basic2DVector< T >::y().

Referenced by curvature(), and transverseIP().

158 {
159  Point2D delta = p2 - p1;
160  Point2D axis2 = Point2D(-delta.y(), delta.x()) / delta.mag();
161  Point2D diff = p1 + 0.5 * delta - center;
162  double a = diff.y() * axis2.x() - diff.x() * axis2.y();
163  double b = axis.y() * axis2.x() - axis.x() * axis2.y();
164  return b / a;
165 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Basic2DVector< double > Point2D
double p2[4]
Definition: TauolaWrapper.h:90
T y() const
Cartesian y coordinate.
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
T x() const
Cartesian x coordinate.
ThirdHitPredictionFromCircle::Range ThirdHitPredictionFromCircle::operator() ( Range  curvature,
double  radius 
) const

Definition at line 85 of file ThirdHitPredictionFromCircle.cc.

References M_PI, phi(), theTolerance, and unlikely.

86 {
87  double phi1 = phi(curvature.second, radius);
88  double phi2 = phi(curvature.first, radius);
89 
90  while(unlikely(phi2 < phi1)) phi2 += 2. * M_PI;
91 
92  return Range(phi1 * radius - theTolerance, phi2 * radius + theTolerance);
93 }
double phi(double curvature, double radius) const
#define unlikely(expr)
Range curvature(double transverseIP) const
#define M_PI
Definition: BFit3D.cc:3
double ThirdHitPredictionFromCircle::phi ( double  curvature,
double  radius 
) const

Definition at line 45 of file ThirdHitPredictionFromCircle.cc.

References abs, axis, center, funct::cos(), delta2, alignCSCRings::e, M_PI, Basic2DVector< T >::mag2(), Basic2DVector< T >::phi(), CosmicsPD_Skims::radius, FWPFMaths::sgn(), funct::sqr(), mathSSE::sqrt(), and unlikely.

Referenced by operator()(), and ThirdHitPredictionFromCircle::HelixRZ::rAtZ().

46 {
47  double phi;
48  if (unlikely(std::abs(curvature) < 1.0e-5)) {
49  double cos = (center * axis) / radius;
50  phi = axis.phi() - clamped_acos(cos);
51  } else {
52  double sign = sgn(curvature);
53  double radius2 = sqr(1.0 / curvature);
54  double orthog = clamped_sqrt(radius2 - delta2);
55  Basic2DVector<double> lcenter = center - sign * orthog * axis;
56  double rc2 = lcenter.mag2();
57  double cos = (rc2 + sqr(radius) - radius2) /
58  (2. *std:: sqrt(rc2) * radius);
59  phi = lcenter.phi() + sign * clamped_acos(cos);
60  }
61 
62  while(unlikely(phi >= M_PI)) phi -= 2. * M_PI;
63  while(unlikely(phi < -M_PI)) phi += 2. * M_PI;
64 
65  return phi;
66 }
double phi(double curvature, double radius) const
float sgn(float val)
Definition: FWPFMaths.cc:9
#define abs(x)
Definition: mlp_lapack.h:159
#define unlikely(expr)
Range curvature(double transverseIP) const
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
Definition: BFit3D.cc:3
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Square< F >::type sqr(const F &f)
Definition: Square.h:13
Geom::Phi< T > phi() const
double ThirdHitPredictionFromCircle::transverseIP ( const Basic2DVector< double > &  thirdPoint) const

Definition at line 175 of file ThirdHitPredictionFromCircle.cc.

References abs, axis, center, delta2, alignCSCRings::e, invCenterOnAxis(), mag(), CosmicsPD_Skims::radius, funct::sqr(), mathSSE::sqrt(), and unlikely.

Referenced by curvature().

176 {
177  double invDist = invCenterOnAxis(p2);
178  if (unlikely(std::abs(invDist) < 1.0e-5))
179  return std::abs(p2 * axis);
180  else {
181  double dist = 1.0 / invDist;
182  double radius = std::sqrt(sqr(dist) + delta2);
183  return std::abs((center + axis * dist).mag() - radius);
184  }
185 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define abs(x)
Definition: mlp_lapack.h:159
#define unlikely(expr)
T sqrt(T t)
Definition: SSEVec.h:46
double invCenterOnAxis(const Basic2DVector< double > &thirdPoint) const
double p2[4]
Definition: TauolaWrapper.h:90
Square< F >::type sqr(const F &f)
Definition: Square.h:13

Friends And Related Function Documentation

friend class HelixRZ
friend

Definition at line 48 of file ThirdHitPredictionFromCircle.h.

Member Data Documentation

Basic2DVector<double> ThirdHitPredictionFromCircle::axis
private
Basic2DVector<double> ThirdHitPredictionFromCircle::center
private
double ThirdHitPredictionFromCircle::delta
private
double ThirdHitPredictionFromCircle::delta2
private
Basic2DVector<double> ThirdHitPredictionFromCircle::p1
private

Definition at line 52 of file ThirdHitPredictionFromCircle.h.

Referenced by invCenterOnAxis(), and ThirdHitPredictionFromCircle().

double ThirdHitPredictionFromCircle::theTolerance
private

Definition at line 53 of file ThirdHitPredictionFromCircle.h.

Referenced by operator()().