CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 10 of file ThirdHitPredictionFromCircle.h.

Member Typedef Documentation

Definition at line 13 of file ThirdHitPredictionFromCircle.h.

Definition at line 12 of file ThirdHitPredictionFromCircle.h.

Definition at line 14 of file ThirdHitPredictionFromCircle.h.

Definition at line 15 of file ThirdHitPredictionFromCircle.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file ThirdHitPredictionFromCircle.cc.

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

52  : p1(P1.x(), P1.y()), theTolerance(tolerance) {
53  Vector2D p2(P2.x(), P2.y());
54  Vector2D diff = 0.5 * (p2 - p1);
55  delta2 = diff.mag2();
57  axis = Vector2D(-diff.y(), diff.x()) / delta;
58  center = p1 + diff;
59 }
const TString p2
Definition: fwPaths.cc:13
const double tolerance
T y() const
Definition: PV3DBase.h:60
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
T sqrt(T t)
Definition: SSEVec.h:19
T x() const
Definition: PV3DBase.h:59

Member Function Documentation

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

Definition at line 79 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by MatchedHitRZCorrectionFromBending::tibMatchedHitZFixup().

79  {
80  if (UNLIKELY(std::abs(curvature) < float(1.0e-5))) {
81  float sin = (center * axis) / radius;
82  return sin / clamped_sqrt(1 - sqr(sin));
83  } else {
84  float radius2 = sqr(1.0f / curvature);
85  float orthog = clamped_sqrt(radius2 - delta2);
87 
88  float cos = (radius2 + sqr(radius) - lcenter.mag2()) * curvature / (2 * radius);
89  return -cos / clamped_sqrt(1.f - sqr(cos));
90  }
91 }
float sgn(float val)
Definition: FWPFMaths.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int sqr(const T &t)
Range curvature(double transverseIP) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
#define UNLIKELY(x)
Definition: Likely.h:21
ThirdHitPredictionFromCircle::Range ThirdHitPredictionFromCircle::curvature ( double  transverseIP) const

Definition at line 102 of file ThirdHitPredictionFromCircle.cc.

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

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

102  {
103  // this is a mess. Use a CAS and lots of drawings to verify...
104 
106  double transverseIP2 = sqr(transverseIP);
107  double tip = axis * center;
108  double tip2 = sqr(tip);
109  double lip = axis.x() * center.y() - axis.y() * center.x();
110  double lip2 = sqr(lip);
111 
112  double origin = std::sqrt(tip2 + lip2);
113  double tmp1 = lip2 + tip2 - transverseIP2;
114  double tmp2 = 2. * (tip - transverseIP) * (tip + transverseIP);
115  double tmp3 = 2. * delta * origin;
116  double tmp4 = tmp1 + delta2;
117  double tmp5 = 2. * delta * lip;
118 
119  // I am probably being overly careful here with border cases
120  // but you never know what crap you might get fed
121  // VI fixed for finiteMath
122 
123  double u1 = 0, u2 = 0;
124  constexpr double SMALL = 1.0e-23;
125  constexpr double LARGE = 1.0e23;
126 
127  if (UNLIKELY(tmp4 - tmp5 < 1.0e-15)) {
128  u1 = -SMALL;
129  u2 = +SMALL;
130  } else {
131  if (UNLIKELY(std::abs(tmp2) < 1.0e-15)) {
132  // the denominator is zero
133  // this means that one of the tracks will be straight
134  // and the other can be computed from the limit of the equation
135  double tmp = lip2 - delta2;
136  u1 = LARGE;
137  u2 = (sqr(0.5 * tmp) - delta2 * tip2) / (tmp * tip);
138  if (tip < 0)
139  std::swap(u1, u2);
140  } else {
141  double tmp6 = (tmp4 - tmp5) * (tmp4 + tmp5);
142  if (UNLIKELY(tmp6 < 1.0e-15)) {
143  u1 = -SMALL;
144  u2 = +SMALL;
145  } else {
146  double tmp7 = tmp6 > 0 ? (transverseIP * std::sqrt(tmp6) / tmp2) : 0.;
147  double tmp8 = tip * (tmp1 - delta2) / tmp2;
148  // the two quadratic solutions
149  u1 = tmp8 + tmp7;
150  u2 = tmp8 - tmp7;
151  }
152  }
153 
154  if (tmp4 <= std::abs(tmp3)) {
155  if ((tmp3 < 0) == (tip < 0))
156  u2 = +SMALL;
157  else
158  u1 = -SMALL;
159  }
160  }
161 
162  return Range(sgn(u1) / std::sqrt(sqr(u1) + delta2), sgn(u2) / std::sqrt(sqr(u2) + delta2));
163 }
double transverseIP(const Vector2D &thirdPoint) const
float sgn(float val)
Definition: FWPFMaths.cc:9
int sqr(const T &t)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const double SMALL
Definition: herwig.h:289
T y() const
Cartesian y coordinate.
#define UNLIKELY(x)
Definition: Likely.h:21
tmp
align.sh
Definition: createJobs.py:716
T x() const
Cartesian x coordinate.
double ThirdHitPredictionFromCircle::curvature ( const Vector2D thirdPoint) const

Definition at line 174 of file ThirdHitPredictionFromCircle.cc.

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

174  {
175  double invDist = invCenterOnAxis(p2);
176  double invDist2 = sqr(invDist);
177  double curv = std::sqrt(invDist2 / (1. + invDist2 * delta2));
178  return sgn(invDist) * curv;
179 }
Scalar invCenterOnAxis(const Vector2D &thirdPoint) const
const TString p2
Definition: fwPaths.cc:13
float sgn(float val)
Definition: FWPFMaths.cc:9
int sqr(const T &t)
T sqrt(T t)
Definition: SSEVec.h:19
ThirdHitPredictionFromCircle::Scalar ThirdHitPredictionFromCircle::invCenterOnAxis ( const Vector2D thirdPoint) const
private

Definition at line 165 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by curvature(), and transverseIP().

165  {
166  Vector2D del = p2 - p1;
167  Vector2D axis2 = Vector2D(-del.y(), del.x()) / del.mag();
168  Vector2D diff = p1 + 0.5f * del - center;
169  Scalar a = diff.y() * axis2.x() - diff.x() * axis2.y();
170  Scalar b = axis.y() * axis2.x() - axis.x() * axis2.y();
171  return b / a;
172 }
const TString p2
Definition: fwPaths.cc:13
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
T y() const
Cartesian y coordinate.
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
T x() const
Cartesian x coordinate.
ThirdHitPredictionFromCircle::Range ThirdHitPredictionFromCircle::operator() ( Range  curvature,
float  radius 
) const

Definition at line 93 of file ThirdHitPredictionFromCircle.cc.

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

93  {
94  float phi1 = normalizedPhi(phi(curvature.second, radius));
95  float phi2 = proxim(phi(curvature.first, radius), phi1);
96  if (phi2 < phi1)
97  std::swap(phi2, phi1);
98 
99  return Range(phi1 * radius - theTolerance, phi2 * radius + theTolerance);
100 }
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
constexpr T proxim(T b, T a)
Definition: normalizedPhi.h:14
Range curvature(double transverseIP) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
float phi(float curvature, float radius) const
float ThirdHitPredictionFromCircle::phi ( float  curvature,
float  radius 
) const

Definition at line 61 of file ThirdHitPredictionFromCircle.cc.

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

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

61  {
62  float phi;
63  if (UNLIKELY(std::abs(curvature) < float(1.0e-5))) {
64  float cos = (center * axis) / radius;
65  phi = axis.phi() - clamped_acos(cos);
66  } else {
67  float sign = sgn(curvature);
68  float radius2 = sqr(1.0f / curvature);
69  float orthog = clamped_sqrt(radius2 - delta2);
71  float rc2 = lcenter.mag2();
72  float r2 = sqr(radius);
73  float cos = (rc2 + r2 - radius2) / std::sqrt(4.f * rc2 * r2);
74  phi = f_phi(lcenter) + sign * clamped_acos(cos);
75  }
76  return phi; // not normalized
77 }
float sgn(float val)
Definition: FWPFMaths.cc:9
double sign(double x)
int sqr(const T &t)
Range curvature(double transverseIP) const
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
#define UNLIKELY(x)
Definition: Likely.h:21
Geom::Phi< T > phi() const
float phi(float curvature, float radius) const
double ThirdHitPredictionFromCircle::transverseIP ( const Vector2D thirdPoint) const

Definition at line 181 of file ThirdHitPredictionFromCircle.cc.

References funct::abs(), axis, center, delta2, alignCSCRings::e, invCenterOnAxis(), mag(), CosmicsPD_Skims::radius, 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
const TString p2
Definition: fwPaths.cc:13
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int sqr(const T &t)
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define UNLIKELY(x)
Definition: Likely.h:21

Friends And Related Function Documentation

friend class HelixRZ
friend

Definition at line 52 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 56 of file ThirdHitPredictionFromCircle.h.

Referenced by invCenterOnAxis(), and ThirdHitPredictionFromCircle().

float ThirdHitPredictionFromCircle::theTolerance
private

Definition at line 58 of file ThirdHitPredictionFromCircle.h.

Referenced by operator()().