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
 
using Scalar = double
 
typedef Basic2DVector< ScalarVector2D
 
typedef Basic2DVector< float > VectorF2D
 

Public Member Functions

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

Private Member Functions

Scalar invCenterOnAxis (const Vector2D &thirdPoint) const
 

Private Attributes

Vector2D axis
 
Vector2D center
 
Scalar delta
 
Scalar delta2
 
Vector2D p1
 
float theTolerance
 

Friends

class HelixRZ
 

Detailed Description

Definition at line 11 of file ThirdHitPredictionFromCircle.h.

Member Typedef Documentation

Definition at line 15 of file ThirdHitPredictionFromCircle.h.

Definition at line 14 of file ThirdHitPredictionFromCircle.h.

Definition at line 16 of file ThirdHitPredictionFromCircle.h.

Definition at line 17 of file ThirdHitPredictionFromCircle.h.

Constructor & Destructor Documentation

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

Member Function Documentation

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

Definition at line 59 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by MatchedHitRZCorrectionFromBending::tibMatchedHitZFixup().

60 {
61  if (unlikely(std::abs(curvature) < float(1.0e-5))) {
62  float sin = (center * axis) / radius;
63  return sin / clamped_sqrt(1 - sqr(sin));
64  } else {
65  float radius2 = sqr(1.0f / curvature);
66  float orthog = clamped_sqrt(radius2 - delta2);
68 
69  float cos = (radius2 + sqr(radius) - lcenter.mag2()) *
70  curvature / (2 * radius);
71  return - cos / clamped_sqrt(1.f - sqr(cos));
72  }
73 }
float sgn(float val)
Definition: FWPFMaths.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Range curvature(double transverseIP) const
#define unlikely(x)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
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 87 of file ThirdHitPredictionFromCircle.cc.

References funct::abs(), axis, center, constexpr, delta, delta2, alignCSCRings::e, HLT_25ns14e33_v1_cff::lip, FWPFMaths::sgn(), SMALL, funct::sqr(), mathSSE::sqrt(), std::swap(), HLT_25ns14e33_v1_cff::tip, tmp, transverseIP(), MetAnalyzer::u1, MetAnalyzer::u2, unlikely, Basic2DVector< T >::x(), and Basic2DVector< T >::y().

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

88 {
89  // this is a mess. Use a CAS and lots of drawings to verify...
90 
92  double transverseIP2 = sqr(transverseIP);
93  double tip = axis * center;
94  double tip2 = sqr(tip);
95  double lip = axis.x() * center.y() - axis.y() * center.x();
96  double lip2 = sqr(lip);
97 
98  double origin = std::sqrt(tip2 + lip2);
99  double tmp1 = lip2 + tip2 - transverseIP2;
100  double tmp2 = 2. * (tip - transverseIP) * (tip + transverseIP);
101  double tmp3 = 2. * delta * origin;
102  double tmp4 = tmp1 + delta2;
103  double tmp5 = 2. * delta * lip;
104 
105  // I am probably being overly careful here with border cases
106  // but you never know what crap you might get fed
107  // VI fixed for finiteMath
108 
109  double u1=0, u2=0;
110  constexpr double SMALL = 1.0e-23;
111  constexpr double LARGE = 1.0e23;
112 
113  if (unlikely(tmp4 - tmp5 < 1.0e-15)) {
114  u1 = -SMALL;
115  u2 = +SMALL;
116  } else {
117  if (unlikely(std::abs(tmp2) < 1.0e-15)) {
118  // the denominator is zero
119  // this means that one of the tracks will be straight
120  // and the other can be computed from the limit of the equation
121  double tmp = lip2 - delta2;
122  u1 = LARGE;
123  u2 = (sqr(0.5 * tmp) - delta2 * tip2) / (tmp * tip);
124  if (tip < 0)
125  std::swap(u1, u2);
126  } else {
127  double tmp6 = (tmp4 - tmp5) * (tmp4 + tmp5);
128  if (unlikely(tmp6 < 1.0e-15)) {
129  u1 = -SMALL;
130  u2 = +SMALL;
131  } else {
132  double tmp7 = tmp6 > 0 ? (transverseIP * std::sqrt(tmp6) / tmp2) : 0.;
133  double tmp8 = tip * (tmp1 - delta2) / tmp2;
134  // the two quadratic solutions
135  u1 = tmp8 + tmp7;
136  u2 = tmp8 - tmp7;
137  }
138  }
139 
140  if (tmp4 <= std::abs(tmp3)) {
141  if ((tmp3 < 0) == (tip < 0))
142  u2 = +SMALL;
143  else
144  u1 = -SMALL;
145  }
146  }
147 
148  return Range(sgn(u1) / std::sqrt(sqr(u1) + delta2),
149  sgn(u2) / std::sqrt(sqr(u2) + delta2));
150 }
double transverseIP(const Vector2D &thirdPoint) const
float sgn(float val)
Definition: FWPFMaths.cc:9
#define constexpr
#define unlikely(x)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const double SMALL
Definition: herwig.h:292
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 Vector2D thirdPoint) const

Definition at line 163 of file ThirdHitPredictionFromCircle.cc.

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

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

Definition at line 153 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by curvature(), and transverseIP().

154 {
155  Vector2D del = p2 - p1;
156  Vector2D axis2 = Vector2D(-del.y(), del.x()) / del.mag();
157  Vector2D diff = p1 + 0.5f * del - center;
158  Scalar a = diff.y() * axis2.x() - diff.x() * axis2.y();
159  Scalar b = axis.y() * axis2.x() - axis.x() * axis2.y();
160  return b / a;
161 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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,
float  radius 
) const

Definition at line 76 of file ThirdHitPredictionFromCircle.cc.

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

77 {
78  float phi1 = phi(curvature.second, radius);
79  float phi2 = phi(curvature.first, radius);
80 
81  while(unlikely(phi2 < phi1)) phi2 += float(2. * M_PI);
82 
83  return Range(phi1 * radius - theTolerance, phi2 * radius + theTolerance);
84 }
Range curvature(double transverseIP) const
#define unlikely(x)
#define M_PI
float phi(float curvature, float radius) const
float ThirdHitPredictionFromCircle::phi ( float  curvature,
float  radius 
) const

Definition at line 36 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by Particle.Particle::__str__(), MultiHitGeneratorFromChi2::hitSets(), operator()(), and ThirdHitPredictionFromCircle::HelixRZ::rAtZ().

37 {
38  float phi;
39  if (unlikely(std::abs(curvature) < float(1.0e-5))) {
40  float cos = (center * axis) / radius;
41  phi = axis.phi() - clamped_acos(cos);
42  } else {
43  float sign = sgn(curvature);
44  float radius2 = sqr(1.0f / curvature);
45  float orthog = clamped_sqrt(radius2 - delta2);
47  float rc2 = lcenter.mag2();
48  float cos = (rc2 + sqr(radius) - radius2) /
49  (2.f *std:: sqrt(rc2) * radius);
50  phi = lcenter.barePhi() + sign * clamped_acos(cos);
51  }
52 
53  while(unlikely(phi >= float(M_PI))) phi -= float(2. * M_PI);
54  while(unlikely(phi < -float(M_PI))) phi += float(2. * M_PI);
55 
56  return phi;
57 }
float sgn(float val)
Definition: FWPFMaths.cc:9
double sign(double x)
T barePhi() const
Range curvature(double transverseIP) const
#define unlikely(x)
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
#define M_PI
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
float phi(float curvature, float radius) const
double ThirdHitPredictionFromCircle::transverseIP ( const Vector2D thirdPoint) const

Definition at line 171 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by curvature().

172 {
173  double invDist = invCenterOnAxis(p2);
174  if (unlikely(std::abs(invDist) < 1.0e-5))
175  return std::abs(p2 * axis);
176  else {
177  double dist = 1.0 / invDist;
178  double radius = std::sqrt(sqr(dist) + delta2);
179  return std::abs((center + axis * dist).mag() - radius);
180  }
181 }
Scalar invCenterOnAxis(const Vector2D &thirdPoint) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define unlikely(x)
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 57 of file ThirdHitPredictionFromCircle.h.

Member Data Documentation

Vector2D ThirdHitPredictionFromCircle::axis
private
Vector2D ThirdHitPredictionFromCircle::center
private
Scalar ThirdHitPredictionFromCircle::delta
private
Scalar ThirdHitPredictionFromCircle::delta2
private
Vector2D ThirdHitPredictionFromCircle::p1
private

Definition at line 61 of file ThirdHitPredictionFromCircle.h.

Referenced by invCenterOnAxis(), and ThirdHitPredictionFromCircle().

float ThirdHitPredictionFromCircle::theTolerance
private

Definition at line 63 of file ThirdHitPredictionFromCircle.h.

Referenced by operator()().