CMS 3D CMS Logo

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

◆ Range

Definition at line 13 of file ThirdHitPredictionFromCircle.h.

◆ Scalar

Definition at line 12 of file ThirdHitPredictionFromCircle.h.

◆ Vector2D

Definition at line 14 of file ThirdHitPredictionFromCircle.h.

◆ VectorF2D

Definition at line 15 of file ThirdHitPredictionFromCircle.h.

Constructor & Destructor Documentation

◆ ThirdHitPredictionFromCircle()

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, SiStripOfflineCRack_cfg::p2, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Member Function Documentation

◆ angle()

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

Definition at line 79 of file ThirdHitPredictionFromCircle.cc.

References funct::abs(), axis, center, funct::cos(), curvature(), delta2, MillePedeFileConverter_cfg::e, f, Basic2DVector< T >::mag2(), CosmicsPD_Skims::radius, FWPFMaths::sgn(), funct::sin(), funct::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 }
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
float sgn(float val)
Definition: FWPFMaths.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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]
Square< F >::type sqr(const F &f)
Definition: Square.h:14
#define UNLIKELY(x)
Definition: Likely.h:21
Range curvature(double transverseIP) const

◆ curvature() [1/2]

ThirdHitPredictionFromCircle::Range ThirdHitPredictionFromCircle::curvature ( double  transverseIP) const

Definition at line 102 of file ThirdHitPredictionFromCircle.cc.

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

Referenced by angle(), CAHitTripletGenerator::hitNtuplets(), MultiHitGeneratorFromChi2::hitSets(), operator()(), phi(), 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 }
float sgn(float val)
Definition: FWPFMaths.cc:9
T y() const
Cartesian y coordinate.
double transverseIP(const Vector2D &thirdPoint) const
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
Square< F >::type sqr(const F &f)
Definition: Square.h:14
#define UNLIKELY(x)
Definition: Likely.h:21
tmp
align.sh
Definition: createJobs.py:716
T x() const
Cartesian x coordinate.

◆ curvature() [2/2]

double ThirdHitPredictionFromCircle::curvature ( const Vector2D thirdPoint) const

Definition at line 174 of file ThirdHitPredictionFromCircle.cc.

References delta2, invCenterOnAxis(), SiStripOfflineCRack_cfg::p2, FWPFMaths::sgn(), funct::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 }
float sgn(float val)
Definition: FWPFMaths.cc:9
Scalar invCenterOnAxis(const Vector2D &thirdPoint) const
T sqrt(T t)
Definition: SSEVec.h:19
Square< F >::type sqr(const F &f)
Definition: Square.h:14

◆ invCenterOnAxis()

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, SiStripOfflineCRack_cfg::p2, 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 }
T y() const
Cartesian y coordinate.
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
double b
Definition: hdecay.h:118
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double a
Definition: hdecay.h:119
T x() const
Cartesian x coordinate.

◆ operator()()

ThirdHitPredictionFromCircle::Range ThirdHitPredictionFromCircle::operator() ( Range  curvature,
float  radius 
) const

Definition at line 93 of file ThirdHitPredictionFromCircle.cc.

References curvature(), normalizedPhi(), phi(), proxim(), CosmicsPD_Skims::radius, 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
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
float phi(float curvature, float radius) const
Range curvature(double transverseIP) const

◆ phi()

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

Definition at line 61 of file ThirdHitPredictionFromCircle.cc.

References funct::abs(), axis, center, funct::cos(), curvature(), delta2, MillePedeFileConverter_cfg::e, f, Basic2DVector< T >::mag2(), Basic2DVector< T >::phi(), diffTwoXMLs::r2, CosmicsPD_Skims::radius, FWPFMaths::sgn(), Validation_hcalonly_cfi::sign, funct::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 }
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
float sgn(float val)
Definition: FWPFMaths.cc:9
Geom::Phi< T > phi() 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
double f[11][100]
Square< F >::type sqr(const F &f)
Definition: Square.h:14
#define UNLIKELY(x)
Definition: Likely.h:21
float phi(float curvature, float radius) const
Range curvature(double transverseIP) const

◆ transverseIP()

double ThirdHitPredictionFromCircle::transverseIP ( const Vector2D thirdPoint) const

Definition at line 181 of file ThirdHitPredictionFromCircle.cc.

References funct::abs(), axis, center, delta2, MillePedeFileConverter_cfg::e, invCenterOnAxis(), mag(), SiStripOfflineCRack_cfg::p2, 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 sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Square< F >::type sqr(const F &f)
Definition: Square.h:14
#define UNLIKELY(x)
Definition: Likely.h:21

Friends And Related Function Documentation

◆ HelixRZ

friend class HelixRZ
friend

Definition at line 52 of file ThirdHitPredictionFromCircle.h.

Member Data Documentation

◆ axis

Vector2D ThirdHitPredictionFromCircle::axis
private

◆ center

Vector2D ThirdHitPredictionFromCircle::center
private

◆ delta

Scalar ThirdHitPredictionFromCircle::delta
private

◆ delta2

Scalar ThirdHitPredictionFromCircle::delta2
private

◆ p1

Vector2D ThirdHitPredictionFromCircle::p1
private

Definition at line 56 of file ThirdHitPredictionFromCircle.h.

Referenced by invCenterOnAxis(), and ThirdHitPredictionFromCircle().

◆ theTolerance

float ThirdHitPredictionFromCircle::theTolerance
private

Definition at line 58 of file ThirdHitPredictionFromCircle.h.

Referenced by operator()().