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
 
double curvature (const Vector2D &thirdPoint) const
 
Range curvature (double transverseIP) 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.

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 }

References axis, center, delta, delta2, change_name::diff, p1, 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.

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 }

References funct::abs(), axis, center, funct::cos(), curvature(), delta2, MillePedeFileConverter_cfg::e, f, Basic2DVector< T >::mag2(), CosmicsPD_Skims::radius, FWPFMaths::sgn(), funct::sin(), sqr(), and UNLIKELY.

Referenced by MatchedHitRZCorrectionFromBending::tibMatchedHitZFixup().

◆ curvature() [1/2]

double ThirdHitPredictionFromCircle::curvature ( const Vector2D thirdPoint) const

Definition at line 174 of file ThirdHitPredictionFromCircle.cc.

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 }

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

◆ curvature() [2/2]

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

Definition at line 102 of file ThirdHitPredictionFromCircle.cc.

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 }

References funct::abs(), axis, center, delta, delta2, MillePedeFileConverter_cfg::e, qcdUeDQM_cfi::lip, FWPFMaths::sgn(), SMALL, 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().

◆ invCenterOnAxis()

ThirdHitPredictionFromCircle::Scalar ThirdHitPredictionFromCircle::invCenterOnAxis ( const Vector2D thirdPoint) const
private

Definition at line 165 of file ThirdHitPredictionFromCircle.cc.

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 }

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

Referenced by curvature(), and transverseIP().

◆ operator()()

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

Definition at line 93 of file ThirdHitPredictionFromCircle.cc.

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 }

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

◆ phi()

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

Definition at line 61 of file ThirdHitPredictionFromCircle.cc.

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 }

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, sqr(), mathSSE::sqrt(), and UNLIKELY.

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

◆ transverseIP()

double ThirdHitPredictionFromCircle::transverseIP ( const Vector2D thirdPoint) const

Definition at line 181 of file ThirdHitPredictionFromCircle.cc.

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 }

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

Referenced by curvature().

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()().

change_name.diff
diff
Definition: change_name.py:13
ThirdHitPredictionFromCircle::delta2
Scalar delta2
Definition: ThirdHitPredictionFromCircle.h:57
Basic2DVector::phi
Geom::Phi< T > phi() const
Definition: extBasic2DVector.h:83
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
ThirdHitPredictionFromCircle::Scalar
double Scalar
Definition: ThirdHitPredictionFromCircle.h:12
sqr
int sqr(const T &t)
Definition: pfalgo_common_ref.h:9
proxim
constexpr T proxim(T b, T a)
Definition: normalizedPhi.h:14
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
ThirdHitPredictionFromCircle::p1
Vector2D p1
Definition: ThirdHitPredictionFromCircle.h:56
ThirdHitPredictionFromCircle::delta
Scalar delta
Definition: ThirdHitPredictionFromCircle.h:57
FWPFMaths::sgn
float sgn(float val)
Definition: FWPFMaths.cc:9
ThirdHitPredictionFromCircle::center
Vector2D center
Definition: ThirdHitPredictionFromCircle.h:56
ThirdHitPredictionFromCircle::Vector2D
Basic2DVector< Scalar > Vector2D
Definition: ThirdHitPredictionFromCircle.h:14
Basic2DVector::mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: extBasic2DVector.h:73
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
qcdUeDQM_cfi.lip
lip
Definition: qcdUeDQM_cfi.py:25
SMALL
static const double SMALL
Definition: herwig.h:289
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ThirdHitPredictionFromCircle::Range
PixelRecoRange< float > Range
Definition: ThirdHitPredictionFromCircle.h:13
ThirdHitPredictionFromCircle::curvature
Range curvature(double transverseIP) const
Definition: ThirdHitPredictionFromCircle.cc:102
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Basic2DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic2DVector.h:67
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
p2
double p2[4]
Definition: TauolaWrapper.h:90
normalizedPhi
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
Basic2DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic2DVector.h:64
b
double b
Definition: hdecay.h:118
ThirdHitPredictionFromCircle::phi
float phi(float curvature, float radius) const
Definition: ThirdHitPredictionFromCircle.cc:61
qcdUeDQM_cfi.tip
tip
Definition: qcdUeDQM_cfi.py:23
Basic2DVector< float >
a
double a
Definition: hdecay.h:119
Vector2D
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
ThirdHitPredictionFromCircle::theTolerance
float theTolerance
Definition: ThirdHitPredictionFromCircle.h:58
testProducerWithPsetDescEmpty_cfi.u1
u1
Definition: testProducerWithPsetDescEmpty_cfi.py:49
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:29
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
ThirdHitPredictionFromCircle::transverseIP
double transverseIP(const Vector2D &thirdPoint) const
Definition: ThirdHitPredictionFromCircle.cc:181
Basic2DVector::mag2
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Definition: extBasic2DVector.h:70
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MetAnalyzer.u2
u2
Definition: MetAnalyzer.py:61
ThirdHitPredictionFromCircle::invCenterOnAxis
Scalar invCenterOnAxis(const Vector2D &thirdPoint) const
Definition: ThirdHitPredictionFromCircle.cc:165
ThirdHitPredictionFromCircle::axis
Vector2D axis
Definition: ThirdHitPredictionFromCircle.h:56
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37