test
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 
)

Definition at line 38 of file ThirdHitPredictionFromCircle.cc.

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

40  : p1(P1.x(), P1.y()), theTolerance(tolerance)
41 {
42  Vector2D p2(P2.x(), P2.y());
43  Vector2D diff = 0.5 * (p2 - p1);
44  delta2 = diff.mag2();
46  axis = Vector2D(-diff.y(), diff.x()) / delta;
47  center = p1 + diff;
48 }
T y() const
Definition: PV3DBase.h:63
list diff
Definition: mps_update.py:85
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
T sqrt(T t)
Definition: SSEVec.h:18
double p2[4]
Definition: TauolaWrapper.h:90
T x() const
Definition: PV3DBase.h:62

Member Function Documentation

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

Definition at line 69 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().

70 {
71  if (unlikely(std::abs(curvature) < float(1.0e-5))) {
72  float sin = (center * axis) / radius;
73  return sin / clamped_sqrt(1 - sqr(sin));
74  } else {
75  float radius2 = sqr(1.0f / curvature);
76  float orthog = clamped_sqrt(radius2 - delta2);
78 
79  float cos = (radius2 + sqr(radius) - lcenter.mag2()) *
80  curvature / (2 * radius);
81  return - cos / clamped_sqrt(1.f - sqr(cos));
82  }
83 }
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 96 of file ThirdHitPredictionFromCircle.cc.

References funct::abs(), axis, center, constexpr, delta, delta2, alignCSCRings::e, HLT_25ns10e33_v2_cff::lip, FWPFMaths::sgn(), SMALL, funct::sqr(), mathSSE::sqrt(), std::swap(), HLT_25ns10e33_v2_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().

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  // VI fixed for finiteMath
117 
118  double u1=0, u2=0;
119  constexpr double SMALL = 1.0e-23;
120  constexpr double LARGE = 1.0e23;
121 
122  if (unlikely(tmp4 - tmp5 < 1.0e-15)) {
123  u1 = -SMALL;
124  u2 = +SMALL;
125  } else {
126  if (unlikely(std::abs(tmp2) < 1.0e-15)) {
127  // the denominator is zero
128  // this means that one of the tracks will be straight
129  // and the other can be computed from the limit of the equation
130  double tmp = lip2 - delta2;
131  u1 = LARGE;
132  u2 = (sqr(0.5 * tmp) - delta2 * tip2) / (tmp * tip);
133  if (tip < 0)
134  std::swap(u1, u2);
135  } else {
136  double tmp6 = (tmp4 - tmp5) * (tmp4 + tmp5);
137  if (unlikely(tmp6 < 1.0e-15)) {
138  u1 = -SMALL;
139  u2 = +SMALL;
140  } else {
141  double tmp7 = tmp6 > 0 ? (transverseIP * std::sqrt(tmp6) / tmp2) : 0.;
142  double tmp8 = tip * (tmp1 - delta2) / tmp2;
143  // the two quadratic solutions
144  u1 = tmp8 + tmp7;
145  u2 = tmp8 - tmp7;
146  }
147  }
148 
149  if (tmp4 <= std::abs(tmp3)) {
150  if ((tmp3 < 0) == (tip < 0))
151  u2 = +SMALL;
152  else
153  u1 = -SMALL;
154  }
155  }
156 
157  return Range(sgn(u1) / std::sqrt(sqr(u1) + delta2),
158  sgn(u2) / std::sqrt(sqr(u2) + delta2));
159 }
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:18
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 172 of file ThirdHitPredictionFromCircle.cc.

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

173 {
174  double invDist = invCenterOnAxis(p2);
175  double invDist2 = sqr(invDist);
176  double curv = std::sqrt(invDist2 / (1. + invDist2 * delta2));
177  return sgn(invDist) * curv;
178 }
Scalar invCenterOnAxis(const Vector2D &thirdPoint) const
float sgn(float val)
Definition: FWPFMaths.cc:9
T sqrt(T t)
Definition: SSEVec.h:18
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 162 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by curvature(), and transverseIP().

163 {
164  Vector2D del = p2 - p1;
165  Vector2D axis2 = Vector2D(-del.y(), del.x()) / del.mag();
166  Vector2D diff = p1 + 0.5f * del - center;
167  Scalar a = diff.y() * axis2.x() - diff.x() * axis2.y();
168  Scalar b = axis.y() * axis2.x() - axis.x() * axis2.y();
169  return b / a;
170 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
list diff
Definition: mps_update.py:85
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
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 86 of file ThirdHitPredictionFromCircle.cc.

References normalizedPhi(), phi(), proxim(), std::swap(), and theTolerance.

87 {
88  float phi1 = normalizedPhi(phi(curvature.second, radius));
89  float phi2 = proxim(phi(curvature.first, radius),phi1);
90  if(phi2 < phi1) std::swap(phi2,phi1);
91 
92  return Range(phi1 * radius - theTolerance, phi2 * radius + theTolerance);
93 }
Range curvature(double transverseIP) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T proxim(T b, T a)
Definition: normalizedPhi.h:13
float phi(float curvature, float radius) const
T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
float ThirdHitPredictionFromCircle::phi ( float  curvature,
float  radius 
) const

Definition at line 50 of file ThirdHitPredictionFromCircle.cc.

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

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

51 {
52  float phi;
53  if (unlikely(std::abs(curvature) < float(1.0e-5))) {
54  float cos = (center * axis) / radius;
55  phi = axis.phi() - clamped_acos(cos);
56  } else {
57  float sign = sgn(curvature);
58  float radius2 = sqr(1.0f / curvature);
59  float orthog = clamped_sqrt(radius2 - delta2);
61  float rc2 = lcenter.mag2();
62  float r2 = sqr(radius);
63  float cos = (rc2 + r2 - radius2)/std::sqrt(4.f*rc2*r2);
64  phi = f_phi(lcenter) + sign * clamped_acos(cos);
65  }
66  return phi; // not normalized
67 }
float sgn(float val)
Definition: FWPFMaths.cc:9
double sign(double x)
Range curvature(double transverseIP) const
#define unlikely(x)
T sqrt(T t)
Definition: SSEVec.h:18
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
Geom::Phi< T > phi() const
float phi(float curvature, float radius) const
double ThirdHitPredictionFromCircle::transverseIP ( const Vector2D thirdPoint) const

Definition at line 180 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().

181 {
182  double invDist = invCenterOnAxis(p2);
183  if (unlikely(std::abs(invDist) < 1.0e-5))
184  return std::abs(p2 * axis);
185  else {
186  double dist = 1.0 / invDist;
187  double radius = std::sqrt(sqr(dist) + delta2);
188  return std::abs((center + axis * dist).mag() - radius);
189  }
190 }
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:18
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()().