CMS 3D CMS Logo

IterativeHelixExtrapolatorToLine.cc
Go to the documentation of this file.
2 #include <iostream>
3 
5  const DirectionType& direction,
6  const float curvature,
7  const PropagationDirection propDir)
8  : theX0(point.x()),
9  theY0(point.y()),
10  theZ0(point.z()),
11  theRho(curvature),
12  theQuadraticSolutionFromStart(point, direction, curvature, propDir),
13  thePropDir(propDir),
14  theCachedS(0),
15  theCachedDPhi(0.),
16  theCachedSDPhi(0.),
17  theCachedCDPhi(1.) {
18  //
19  // Components of direction vector (with correct normalisation)
20  //
21  double px = direction.x();
22  double py = direction.y();
23  double pz = direction.z();
24  double pt = px * px + py * py;
25  double p = sqrt(pt + pz * pz);
26  pt = sqrt(pt);
27  theCosPhi0 = px / pt;
28  theSinPhi0 = py / pt;
29  theCosTheta = pz / p;
30  theSinTheta = pt / p;
31 }
32 
37 std::pair<bool, double> IterativeHelixExtrapolatorToLine::pathLength(const GlobalPoint& point) const {
38  return genericPathLength(point);
39 }
40 
45 std::pair<bool, double> IterativeHelixExtrapolatorToLine::pathLength(const Line& line) const {
46  return genericPathLength(line);
47 }
48 
49 //
50 // Propagation status and path length to intersection
51 //
52 template <class T>
53 std::pair<bool, double> IterativeHelixExtrapolatorToLine::genericPathLength(const T& object) const {
54  //
55  // Constants used for control of convergence
56  //
57  const int maxIterations(100);
58  //
59  // Prepare internal value of the propagation direction and position / direction vectors for iteration
60  //
64  //
65  // Prepare iterations: count and total pathlength
66  //
67  unsigned int iteration(maxIterations + 1);
68  double dSTotal(0.);
69  //
70  // Convergence criterion: maximal lateral displacement in a step < 1um
71  //
72  double maxDeltaS2 = 2 * 1.e-4 / theSinTheta / theSinTheta / fabs(theRho);
73  //
74  bool first(true);
75  while (true) {
76  //
77  // return empty solution vector if no convergence after maxIterations iterations
78  //
79  if (--iteration == 0) {
80  return std::pair<bool, double>(false, 0);
81  }
82  //
83  // Use existing second order object at first pass, create temporary object
84  // for subsequent passes.
85  //
86  std::pair<bool, double> deltaS1;
87  if (first) {
88  first = false;
89  deltaS1 = theQuadraticSolutionFromStart.pathLength(object);
90  } else {
91  HelixExtrapolatorToLine2Order linearCrossing(
92  xnew.x(), xnew.y(), xnew.z(), pnew.x(), pnew.y(), theCosTheta, theSinTheta, theRho, anyDirection);
93  deltaS1 = linearCrossing.pathLength(object);
94  }
95  if (!deltaS1.first)
96  return deltaS1;
97  //
98  // Calculate total pathlength
99  //
100  dSTotal += deltaS1.second;
101  PropagationDirection newDir = dSTotal >= 0 ? alongMomentum : oppositeToMomentum;
102  if (propDir == anyDirection) {
103  propDir = newDir;
104  } else {
105  if (newDir != propDir)
106  return std::pair<bool, double>(false, 0);
107  }
108  //
109  // Check convergence
110  //
111  if (deltaS1.second * deltaS1.second < maxDeltaS2)
112  break;
113  //
114  // Step forward by dSTotal.
115  //
116  xnew = positionInDouble(dSTotal);
117  pnew = directionInDouble(dSTotal);
118  }
119  //
120  // Return result
121  //
122  return std::pair<bool, double>(true, dSTotal);
123 }
124 
125 //
126 // Position on helix after a step of path length s.
127 //
129  // use result in double precision
131 }
132 
133 //
134 // Position on helix after a step of path length s in double precision.
135 //
137  //
138  // Calculate delta phi (if not already available)
139  //
140  if (s != theCachedS) {
141  theCachedS = s;
145  }
146  //
147  // Calculate with appropriate formulation of full helix formula or with
148  // 1st order approximation.
149  //
150  // if ( fabs(theCachedDPhi)>1.e-1 ) {
151  if (fabs(theCachedDPhi) > 1.e-4) {
152  // "standard" helix formula
156  }
157  // else if ( fabs(theCachedDPhi)>theNumericalPrecision ) {
158  // // full helix formula, but avoiding (1-cos(deltaPhi)) for small angles
159  // return PositionTypeDouble(theX0+(-theSinPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
160  // theCosPhi0*theCachedSDPhi)/theRho,
161  // theY0+(theCosPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
162  // theSinPhi0*theCachedSDPhi)/theRho,
163  // theZ0+theCachedS*theCosTheta);
164  // }
165  else {
166  // Use 1st order.
168  }
169 }
170 
171 //
172 // Direction vector on helix after a step of path length s.
173 //
175  // use result in double precision
176  // DirectionTypeDouble dir = directionInDouble(s);
177  // return DirectionType(dir.x(),dir.y(),dir.z());
179 }
180 
181 //
182 // Direction vector on helix after a step of path length s in double precision.
183 //
185  //
186  // Calculate delta phi (if not already available)
187  //
188  if (s != theCachedS) {
189  theCachedS = s;
193  }
194 
195  if (fabs(theCachedDPhi) > 1.e-4) {
196  // full helix formula
200  } else {
201  // 1st order
203  }
204 }
IterativeHelixExtrapolatorToLine.h
IterativeHelixExtrapolatorToLine::theCosPhi0
double theCosPhi0
Definition: IterativeHelixExtrapolatorToLine.h:59
anyDirection
Definition: PropagationDirection.h:4
IterativeHelixExtrapolatorToLine::theCachedSDPhi
double theCachedSDPhi
Definition: IterativeHelixExtrapolatorToLine.h:69
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
IterativeHelixExtrapolatorToLine::theCachedS
double theCachedS
Definition: IterativeHelixExtrapolatorToLine.h:67
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HelixExtrapolatorToLine2Order::directionInDouble
DirectionTypeDouble directionInDouble(double s) const
Direction at pathlength s from the starting point in double precision.
Definition: HelixExtrapolatorToLine2Order.cc:217
IterativeHelixExtrapolatorToLine::theCachedCDPhi
double theCachedCDPhi
Definition: IterativeHelixExtrapolatorToLine.h:70
oppositeToMomentum
Definition: PropagationDirection.h:4
IterativeHelixExtrapolatorToLine::pathLength
std::pair< bool, double > pathLength(const GlobalPoint &point) const override
Definition: IterativeHelixExtrapolatorToLine.cc:37
PixelRecoUtilities::curvature
T curvature(T InversePt, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:42
dqmdumpme.first
first
Definition: dqmdumpme.py:55
HelixExtrapolatorToLine2Order
Definition: HelixExtrapolatorToLine2Order.h:11
IterativeHelixExtrapolatorToLine::theCosTheta
double theCosTheta
Definition: IterativeHelixExtrapolatorToLine.h:60
IterativeHelixExtrapolatorToLine::theQuadraticSolutionFromStart
HelixExtrapolatorToLine2Order theQuadraticSolutionFromStart
Definition: IterativeHelixExtrapolatorToLine.h:63
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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
vertices_cff.x
x
Definition: vertices_cff.py:29
IterativeHelixExtrapolatorToLine::theCachedDPhi
double theCachedDPhi
Definition: IterativeHelixExtrapolatorToLine.h:68
IterativeHelixExtrapolatorToLine::directionInDouble
DirectionTypeDouble directionInDouble(double s) const
Definition: IterativeHelixExtrapolatorToLine.cc:184
IterativeHelixExtrapolatorToLine::position
PositionType position(double s) const override
Definition: IterativeHelixExtrapolatorToLine.cc:128
Point3DBase< float, GlobalTag >
IterativeHelixExtrapolatorToLine::theZ0
const double theZ0
Definition: IterativeHelixExtrapolatorToLine.h:58
IterativeHelixExtrapolatorToLine::IterativeHelixExtrapolatorToLine
IterativeHelixExtrapolatorToLine(const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=anyDirection)
Definition: IterativeHelixExtrapolatorToLine.cc:4
HelixLineExtrapolation::PositionType
Basic3DVector< float > PositionType
Definition: HelixLineExtrapolation.h:22
IterativeHelixExtrapolatorToLine::thePropDir
const PropagationDirection thePropDir
Definition: IterativeHelixExtrapolatorToLine.h:65
HelixLineExtrapolation::DirectionType
Basic3DVector< float > DirectionType
Definition: HelixLineExtrapolation.h:23
Line
Definition: Line.h:10
HelixLineExtrapolation::PositionTypeDouble
Basic3DVector< double > PositionTypeDouble
Definition: HelixLineExtrapolation.h:24
IterativeHelixExtrapolatorToLine::theX0
const double theX0
Definition: IterativeHelixExtrapolatorToLine.h:58
IterativeHelixExtrapolatorToLine::theSinTheta
double theSinTheta
Definition: IterativeHelixExtrapolatorToLine.h:60
IterativeHelixExtrapolatorToLine::theSinPhi0
double theSinPhi0
Definition: IterativeHelixExtrapolatorToLine.h:59
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
T
long double T
Definition: Basic3DVectorLD.h:48
HLT_2018_cff.maxIterations
maxIterations
Definition: HLT_2018_cff.py:11849
IterativeHelixExtrapolatorToLine::genericPathLength
std::pair< bool, double > genericPathLength(const T &object) const
common functionality for extrapolation to line or point
Definition: IterativeHelixExtrapolatorToLine.cc:53
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
IterativeHelixExtrapolatorToLine::direction
DirectionType direction(double s) const override
Definition: IterativeHelixExtrapolatorToLine.cc:174
IterativeHelixExtrapolatorToLine::theRho
const double theRho
Definition: IterativeHelixExtrapolatorToLine.h:61
Basic3DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic3DVector.h:94
HelixExtrapolatorToLine2Order::pathLength
std::pair< bool, double > pathLength(const GlobalPoint &point) const override
Definition: HelixExtrapolatorToLine2Order.cc:28
HelixLineExtrapolation::DirectionTypeDouble
Basic3DVector< double > DirectionTypeDouble
Definition: HelixLineExtrapolation.h:25
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
align_cfg.iteration
iteration
Definition: align_cfg.py:5
Basic3DVector::z
T z() const
Cartesian z coordinate.
Definition: extBasic3DVector.h:100
IterativeHelixExtrapolatorToLine::positionInDouble
PositionTypeDouble positionInDouble(double s) const
Definition: IterativeHelixExtrapolatorToLine.cc:136
IterativeHelixExtrapolatorToLine::theY0
const double theY0
Definition: IterativeHelixExtrapolatorToLine.h:58
alongMomentum
Definition: PropagationDirection.h:4
Basic3DVector< float >
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