CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HelixExtrapolatorToLine2Order Class Referencefinal

#include <HelixExtrapolatorToLine2Order.h>

Inheritance diagram for HelixExtrapolatorToLine2Order:
HelixLineExtrapolation

Public Member Functions

DirectionType direction (double s) const override
 Direction at pathlength s from the starting point. More...
 
DirectionTypeDouble directionInDouble (double s) const
 Direction at pathlength s from the starting point in double precision. More...
 
 HelixExtrapolatorToLine2Order (const double &x0, const double &y0, const double &z0, const double &cosPhi0, const double &sinPhi0, const double &cosTheta, const double &sinTheta, const double &rho, const PropagationDirection propDir=alongMomentum)
 Fast constructor (for use by IterativeHelixExtrapolatorToLine). More...
 
 HelixExtrapolatorToLine2Order (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum)
 Constructor using point, direction and (transverse!) curvature. More...
 
std::pair< bool, double > pathLength (const GlobalPoint &point) const override
 
std::pair< bool, double > pathLength (const Line &line) const override
 
PositionType position (double s) const override
 Position at pathlength s from the starting point. More...
 
PositionTypeDouble positionInDouble (double s) const
 Position at pathlength s from the starting point in double precision. More...
 
 ~HelixExtrapolatorToLine2Order () override
 
- Public Member Functions inherited from HelixLineExtrapolation
virtual ~HelixLineExtrapolation ()=default
 

Private Member Functions

virtual std::pair< bool, double > pathLengthFromCoefficients (const double ceq[4]) const
 common part for propagation to point and line More...
 
int solve2ndOrder (const double ceq[], double sol[]) const
 Solutions of 2nd order equation. More...
 
int solve3rdOrder (const double ceq[], double sol[]) const
 Solutions of 3rd order equation. More...
 

Private Attributes

DirectionTypeDouble theDirection
 
const PositionTypeDouble thePosition
 
const PropagationDirection thePropDir
 
const double theRho
 
double theSinTheta
 

Additional Inherited Members

- Public Types inherited from HelixLineExtrapolation
typedef Basic3DVector< float > DirectionType
 
typedef Basic3DVector< double > DirectionTypeDouble
 
typedef Basic3DVector< float > PositionType
 
typedef Basic3DVector< double > PositionTypeDouble
 

Detailed Description

Calculates intersections of a helix with planes of any orientation using a parabolic approximation.

Definition at line 11 of file HelixExtrapolatorToLine2Order.h.

Constructor & Destructor Documentation

◆ HelixExtrapolatorToLine2Order() [1/2]

HelixExtrapolatorToLine2Order::HelixExtrapolatorToLine2Order ( const PositionType point,
const DirectionType direction,
const float  curvature,
const PropagationDirection  propDir = alongMomentum 
)

Constructor using point, direction and (transverse!) curvature.

Definition at line 7 of file HelixExtrapolatorToLine2Order.cc.

12  //
13  // Components of direction vector (with correct normalisation)
14  //
15  double px = direction.x();
16  double py = direction.y();
17  double pz = direction.z();
18  double pt = px * px + py * py;
19  double p = sqrt(pt + pz * pz);
20  pt = sqrt(pt);
22  theSinTheta = pt / p;
23 }

References direction(), AlCaHLTBitMon_ParallelJobs::p, DiDispStaMuonMonitor_cfi::pt, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, mathSSE::sqrt(), theDirection, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

◆ HelixExtrapolatorToLine2Order() [2/2]

HelixExtrapolatorToLine2Order::HelixExtrapolatorToLine2Order ( const double &  x0,
const double &  y0,
const double &  z0,
const double &  cosPhi0,
const double &  sinPhi0,
const double &  cosTheta,
const double &  sinTheta,
const double &  rho,
const PropagationDirection  propDir = alongMomentum 
)
inline

Fast constructor (for use by IterativeHelixExtrapolatorToLine).

Definition at line 20 of file HelixExtrapolatorToLine2Order.h.

29  : thePosition(x0, y0, z0),
30  theDirection(cosPhi0, sinPhi0, cosTheta / sinTheta),
31  theSinTheta(sinTheta),
32  theRho(rho),
33  thePropDir(propDir) {}

◆ ~HelixExtrapolatorToLine2Order()

HelixExtrapolatorToLine2Order::~HelixExtrapolatorToLine2Order ( )
inlineoverride

Definition at line 36 of file HelixExtrapolatorToLine2Order.h.

36 {}

Member Function Documentation

◆ direction()

HelixLineExtrapolation::DirectionType HelixExtrapolatorToLine2Order::direction ( double  s) const
overridevirtual

Direction at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 208 of file HelixExtrapolatorToLine2Order.cc.

208  {
209  // use double precision result
210  // DirectionTypeDouble dir = directionInDouble(s);
211  // return DirectionType(dir.x(),dir.y(),dir.z());
213 }

References directionInDouble(), and alignCSCRings::s.

Referenced by HelixExtrapolatorToLine2Order().

◆ directionInDouble()

HelixExtrapolatorToLine2Order::DirectionTypeDouble HelixExtrapolatorToLine2Order::directionInDouble ( double  s) const

Direction at pathlength s from the starting point in double precision.

Definition at line 217 of file HelixExtrapolatorToLine2Order.cc.

217  {
218  // based on delta phi
219  double dph = s * theRho * theSinTheta;
220  return DirectionTypeDouble(theDirection.x() - (theDirection.y() + 0.5 * theDirection.x() * dph) * dph,
221  theDirection.y() + (theDirection.x() - 0.5 * theDirection.y() * dph) * dph,
222  theDirection.z());
223 }

References alignCSCRings::s, theDirection, theRho, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by direction(), and IterativeHelixExtrapolatorToLine::directionInDouble().

◆ pathLength() [1/2]

std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength ( const GlobalPoint point) const
overridevirtual

Propagation status (true if valid) and (signed) path length along the helix from the starting point to the closest approach to the point. The starting point is given in the constructor.

Implements HelixLineExtrapolation.

Definition at line 28 of file HelixExtrapolatorToLine2Order.cc.

28  {
29  //
31  DirectionTypeDouble helix2(-0.5 * theRho * theDirection.y(), 0.5 * theRho * theDirection.x(), 0.);
33  //
34  // coefficients of 3rd order equation
35  //
36  double ceq[4];
37  ceq[3] = 2 * helix2.mag2();
38  // ceq[2] = 3*theDirection.dot(helix2) = 0 since they are orthogonal
39  ceq[2] = 0.;
40  ceq[1] = theDirection.mag2() + 2 * deltaPos.dot(helix2);
41  ceq[0] = deltaPos.dot(theDirection);
42  //
43  return pathLengthFromCoefficients(ceq);
44 }

References Basic3DVector< T >::dot(), Basic3DVector< T >::mag2(), pathLengthFromCoefficients(), point, position(), theDirection, thePosition, theRho, Basic3DVector< T >::x(), and Basic3DVector< T >::y().

Referenced by IterativeHelixExtrapolatorToLine::genericPathLength().

◆ pathLength() [2/2]

std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength ( const Line line) const
overridevirtual

Propagation status (true if valid) and (signed) path length along the helix from the starting point to the closest approach to the line. The starting point is given in the constructor.

Implements HelixLineExtrapolation.

Definition at line 49 of file HelixExtrapolatorToLine2Order.cc.

49  {
50  //
51  // Auxiliary vectors. Assumes that line.direction().mag()=1 !
52  //
53  PositionTypeDouble linePosition(line.position());
54  DirectionTypeDouble lineDirection(line.direction());
55  DirectionTypeDouble helix2(-0.5 * theRho * theDirection.y(), 0.5 * theRho * theDirection.x(), 0.);
56  DirectionTypeDouble deltaPos(thePosition - linePosition);
57  DirectionTypeDouble helix1p(theDirection - lineDirection * theDirection.dot(lineDirection));
58  DirectionTypeDouble helix2p(helix2 - lineDirection * helix2.dot(lineDirection));
59  //
60  // coefficients of 3rd order equation
61  //
62  double ceq[4];
63  ceq[3] = 2 * helix2.dot(helix2p);
64  // ceq[2] = 3*helix1.dot(helix1p);
65  // since theDirection.dot(helix2)==0 equivalent to
66  ceq[2] = 3 * theDirection.dot(lineDirection) * helix2.dot(lineDirection);
67  ceq[1] = theDirection.dot(helix1p) + 2 * deltaPos.dot(helix2p);
68  ceq[0] = deltaPos.dot(helix1p);
69  //
70  return pathLengthFromCoefficients(ceq);
71 }

References Basic3DVector< T >::dot(), mps_splice::line, pathLengthFromCoefficients(), theDirection, thePosition, theRho, Basic3DVector< T >::x(), and Basic3DVector< T >::y().

◆ pathLengthFromCoefficients()

std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLengthFromCoefficients ( const double  ceq[4]) const
privatevirtual

common part for propagation to point and line

Definition at line 76 of file HelixExtrapolatorToLine2Order.cc.

76  {
77  //
78  // Solution of 3rd order equation
79  //
80  double solutions[3];
81  unsigned int nRaw = solve3rdOrder(ceq, solutions);
82  //
83  // check compatibility with propagation direction
84  //
85  unsigned int nDir(0);
86  for (unsigned int i = 0; i < nRaw; i++) {
87  if (thePropDir == anyDirection || (solutions[i] >= 0 && thePropDir == alongMomentum) ||
89  solutions[nDir++] = solutions[i];
90  }
91  if (nDir == 0)
92  return std::make_pair(false, 0.);
93  //
94  // check 2nd derivative
95  //
96  unsigned int nMin(0);
97  for (unsigned int i = 0; i < nDir; i++) {
98  double st = solutions[i];
99  double deri2 = (3 * ceq[3] * st + 2 * ceq[2]) * st + ceq[1];
100  if (deri2 > 0.)
101  solutions[nMin++] = st;
102  }
103  if (nMin == 0)
104  return std::make_pair(false, 0.);
105  //
106  // choose smallest path length
107  //
108  double dSt = solutions[0];
109  for (unsigned int i = 1; i < nMin; i++) {
110  if (fabs(solutions[i]) < fabs(dSt))
111  dSt = solutions[i];
112  }
113 
114  return std::make_pair(true, dSt / theSinTheta);
115 }

References alongMomentum, anyDirection, mps_fire::i, metDiagnosticParameterSet_cfi::nMin, oppositeToMomentum, StEvtSolProducer_cfi::solutions, solve3rdOrder(), thePropDir, and theSinTheta.

Referenced by pathLength().

◆ position()

HelixLineExtrapolation::PositionType HelixExtrapolatorToLine2Order::position ( double  s) const
overridevirtual

Position at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 189 of file HelixExtrapolatorToLine2Order.cc.

189  {
190  // use double precision result
191  // PositionTypeDouble pos = positionInDouble(s);
192  // return PositionType(pos.x(),pos.y(),pos.z());
194 }

References positionInDouble(), and alignCSCRings::s.

Referenced by pathLength().

◆ positionInDouble()

HelixExtrapolatorToLine2Order::PositionTypeDouble HelixExtrapolatorToLine2Order::positionInDouble ( double  s) const

Position at pathlength s from the starting point in double precision.

Definition at line 198 of file HelixExtrapolatorToLine2Order.cc.

198  {
199  // based on path length in the transverse plane
200  double st = s * theSinTheta;
201  return PositionTypeDouble(thePosition.x() + (theDirection.x() - st * 0.5 * theRho * theDirection.y()) * st,
202  thePosition.y() + (theDirection.y() + st * 0.5 * theRho * theDirection.x()) * st,
203  thePosition.z() + st * theDirection.z());
204 }

References alignCSCRings::s, theDirection, thePosition, theRho, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by position(), and IterativeHelixExtrapolatorToLine::positionInDouble().

◆ solve2ndOrder()

int HelixExtrapolatorToLine2Order::solve2ndOrder ( const double  ceq[],
double  sol[] 
) const
private

Solutions of 2nd order equation.

Definition at line 159 of file HelixExtrapolatorToLine2Order.cc.

159  {
160  //
161  double deq1 = coeff[1] * coeff[1];
162  double deq2 = coeff[2] * coeff[0];
163  if (fabs(deq1) < FLT_MIN || fabs(deq2 / deq1) > 1.e-6) {
164  //
165  // Standard solution for quadratic equations
166  //
167  double deq = deq1 + 2 * deq2;
168  if (deq < 0.)
169  return 0;
170  double ceq = -0.5 * (coeff[1] + (coeff[1] > 0 ? 1 : -1) * sqrt(deq));
171  solutions[0] = -2 * ceq / coeff[2];
172  solutions[1] = coeff[0] / ceq;
173  return 2;
174  } else {
175  //
176  // Solution by expansion of sqrt(1+deq)
177  //
178  double ceq = coeff[1] / coeff[2];
179  double deq = deq2 / deq1;
180  deq *= (1 - deq / 2);
181  solutions[0] = -ceq * deq;
182  solutions[1] = ceq * (2 + deq);
183  return 2;
184  }
185 }

References MillePedeFileConverter_cfg::e, StEvtSolProducer_cfi::solutions, and mathSSE::sqrt().

Referenced by solve3rdOrder().

◆ solve3rdOrder()

int HelixExtrapolatorToLine2Order::solve3rdOrder ( const double  ceq[],
double  sol[] 
) const
private

Solutions of 3rd order equation.

Definition at line 117 of file HelixExtrapolatorToLine2Order.cc.

117  {
118  //
119  // Real 3rd order equation? Follow numerical recipes ..
120  //
121  if (fabs(ceq[3]) > FLT_MIN) {
122  int result(0);
123  double q = (ceq[2] * ceq[2] - 3 * ceq[3] * ceq[1]) / (ceq[3] * ceq[3]) / 9.;
124  double r = (2 * ceq[2] * ceq[2] * ceq[2] - 9 * ceq[3] * ceq[2] * ceq[1] + 27 * ceq[3] * ceq[3] * ceq[0]) /
125  (ceq[3] * ceq[3] * ceq[3]) / 54.;
126  double q3 = q * q * q;
127  if (r * r < q3) {
128  double phi = acos(r / sqrt(q3)) / 3.;
129  double rootq = sqrt(q);
130  for (int i = 0; i < 3; i++) {
131  solutions[i] = -2 * rootq * cos(phi) - ceq[2] / ceq[3] / 3.;
132  phi += 2. / 3. * M_PI;
133  }
134  result = 3;
135  } else {
136  double a = pow(fabs(r) + sqrt(r * r - q3), 1. / 3.);
137  if (r > 0.)
138  a *= -1;
139  double b = fabs(a) > FLT_MIN ? q / a : 0.;
140  solutions[0] = a + b - ceq[2] / ceq[3] / 3.;
141  result = 1;
142  }
143  return result;
144  }
145  //
146  // Second order equation
147  //
148  else if (fabs(ceq[2]) > FLT_MIN) {
149  return solve2ndOrder(ceq, solutions);
150  } else {
151  //
152  // Special case: linear equation
153  //
154  solutions[0] = -ceq[0] / ceq[1];
155  return 1;
156  }
157 }

References a, b, funct::cos(), mps_fire::i, M_PI, phi, funct::pow(), submitPVResolutionJobs::q, alignCSCRings::r, mps_fire::result, StEvtSolProducer_cfi::solutions, solve2ndOrder(), and mathSSE::sqrt().

Referenced by pathLengthFromCoefficients().

Member Data Documentation

◆ theDirection

DirectionTypeDouble HelixExtrapolatorToLine2Order::theDirection
private

◆ thePosition

const PositionTypeDouble HelixExtrapolatorToLine2Order::thePosition
private

Definition at line 71 of file HelixExtrapolatorToLine2Order.h.

Referenced by pathLength(), and positionInDouble().

◆ thePropDir

const PropagationDirection HelixExtrapolatorToLine2Order::thePropDir
private

Definition at line 75 of file HelixExtrapolatorToLine2Order.h.

Referenced by pathLengthFromCoefficients().

◆ theRho

const double HelixExtrapolatorToLine2Order::theRho
private

Definition at line 74 of file HelixExtrapolatorToLine2Order.h.

Referenced by directionInDouble(), pathLength(), and positionInDouble().

◆ theSinTheta

double HelixExtrapolatorToLine2Order::theSinTheta
private
HelixExtrapolatorToLine2Order::theRho
const double theRho
Definition: HelixExtrapolatorToLine2Order.h:74
anyDirection
Definition: PropagationDirection.h:4
mps_fire.i
i
Definition: mps_fire.py:428
StEvtSolProducer_cfi.solutions
solutions
Definition: StEvtSolProducer_cfi.py:7
metDiagnosticParameterSet_cfi.nMin
nMin
Definition: metDiagnosticParameterSet_cfi.py:10
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
HelixExtrapolatorToLine2Order::directionInDouble
DirectionTypeDouble directionInDouble(double s) const
Direction at pathlength s from the starting point in double precision.
Definition: HelixExtrapolatorToLine2Order.cc:217
HelixExtrapolatorToLine2Order::position
PositionType position(double s) const override
Position at pathlength s from the starting point.
Definition: HelixExtrapolatorToLine2Order.cc:189
oppositeToMomentum
Definition: PropagationDirection.h:4
HelixExtrapolatorToLine2Order::solve2ndOrder
int solve2ndOrder(const double ceq[], double sol[]) const
Solutions of 2nd order equation.
Definition: HelixExtrapolatorToLine2Order.cc:159
PixelRecoUtilities::curvature
T curvature(T InversePt, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:42
Basic3DVector::mag2
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Definition: extBasic3DVector.h:113
HelixExtrapolatorToLine2Order::pathLengthFromCoefficients
virtual std::pair< bool, double > pathLengthFromCoefficients(const double ceq[4]) const
common part for propagation to point and line
Definition: HelixExtrapolatorToLine2Order.cc:76
alignCSCRings.s
s
Definition: alignCSCRings.py:92
Basic3DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic3DVector.h:97
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Basic3DVector::dot
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.
Definition: extBasic3DVector.h:189
HelixExtrapolatorToLine2Order::theSinTheta
double theSinTheta
Definition: HelixExtrapolatorToLine2Order.h:73
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
b
double b
Definition: hdecay.h:118
DDAxes::rho
HelixExtrapolatorToLine2Order::solve3rdOrder
int solve3rdOrder(const double ceq[], double sol[]) const
Solutions of 3rd order equation.
Definition: HelixExtrapolatorToLine2Order.cc:117
HelixExtrapolatorToLine2Order::thePropDir
const PropagationDirection thePropDir
Definition: HelixExtrapolatorToLine2Order.h:75
HelixLineExtrapolation::PositionType
Basic3DVector< float > PositionType
Definition: HelixLineExtrapolation.h:22
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HelixExtrapolatorToLine2Order::theDirection
DirectionTypeDouble theDirection
Definition: HelixExtrapolatorToLine2Order.h:72
HelixLineExtrapolation::DirectionType
Basic3DVector< float > DirectionType
Definition: HelixLineExtrapolation.h:23
HelixLineExtrapolation::PositionTypeDouble
Basic3DVector< double > PositionTypeDouble
Definition: HelixLineExtrapolation.h:24
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDAxes::phi
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
HelixExtrapolatorToLine2Order::direction
DirectionType direction(double s) const override
Direction at pathlength s from the starting point.
Definition: HelixExtrapolatorToLine2Order.cc:208
HelixExtrapolatorToLine2Order::thePosition
const PositionTypeDouble thePosition
Definition: HelixExtrapolatorToLine2Order.h:71
Basic3DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic3DVector.h:94
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
HelixLineExtrapolation::DirectionTypeDouble
Basic3DVector< double > DirectionTypeDouble
Definition: HelixLineExtrapolation.h:25
mps_fire.result
result
Definition: mps_fire.py:311
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
mps_splice.line
line
Definition: mps_splice.py:76
Basic3DVector::z
T z() const
Cartesian z coordinate.
Definition: extBasic3DVector.h:100
alongMomentum
Definition: PropagationDirection.h:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HelixExtrapolatorToLine2Order::positionInDouble
PositionTypeDouble positionInDouble(double s) const
Position at pathlength s from the starting point in double precision.
Definition: HelixExtrapolatorToLine2Order.cc:198