Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
TrackingTools
GeomPropagators
src
IterativeHelixExtrapolatorToLine.cc
Go to the documentation of this file.
1
#include "
TrackingTools/GeomPropagators/interface/IterativeHelixExtrapolatorToLine.h
"
2
#include <iostream>
3
4
IterativeHelixExtrapolatorToLine::IterativeHelixExtrapolatorToLine
(
const
PositionType
&
point
,
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
//
61
PropagationDirection
propDir =
thePropDir
;
62
PositionTypeDouble
xnew(
theX0
,
theY0
,
theZ0
);
63
DirectionTypeDouble
pnew(
theCosPhi0
,
theSinPhi0
,
theCosTheta
/
theSinTheta
);
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
//
128
HelixLineExtrapolation::PositionType
IterativeHelixExtrapolatorToLine::position
(
double
s
)
const
{
129
// use result in double precision
130
return
PositionType
(
positionInDouble
(s));
131
}
132
133
//
134
// Position on helix after a step of path length s in double precision.
135
//
136
HelixLineExtrapolation::PositionTypeDouble
IterativeHelixExtrapolatorToLine::positionInDouble
(
double
s
)
const
{
137
//
138
// Calculate delta phi (if not already available)
139
//
140
if
(s !=
theCachedS
) {
141
theCachedS
=
s
;
142
theCachedDPhi
=
theCachedS
*
theRho
*
theSinTheta
;
143
theCachedSDPhi
=
sin
(
theCachedDPhi
);
144
theCachedCDPhi
=
cos
(
theCachedDPhi
);
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
153
return
PositionTypeDouble
(
theX0
+ (-
theSinPhi0
* (1. -
theCachedCDPhi
) +
theCosPhi0
*
theCachedSDPhi
) /
theRho
,
154
theY0
+ (
theCosPhi0
* (1. -
theCachedCDPhi
) +
theSinPhi0
* theCachedSDPhi) /
theRho
,
155
theZ0
+
theCachedS
*
theCosTheta
);
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.
167
return
theQuadraticSolutionFromStart
.
positionInDouble
(
theCachedS
);
168
}
169
}
170
171
//
172
// Direction vector on helix after a step of path length s.
173
//
174
HelixLineExtrapolation::DirectionType
IterativeHelixExtrapolatorToLine::direction
(
double
s
)
const
{
175
// use result in double precision
176
// DirectionTypeDouble dir = directionInDouble(s);
177
// return DirectionType(dir.x(),dir.y(),dir.z());
178
return
DirectionType
(
directionInDouble
(s));
179
}
180
181
//
182
// Direction vector on helix after a step of path length s in double precision.
183
//
184
HelixLineExtrapolation::DirectionTypeDouble
IterativeHelixExtrapolatorToLine::directionInDouble
(
double
s
)
const
{
185
//
186
// Calculate delta phi (if not already available)
187
//
188
if
(s !=
theCachedS
) {
189
theCachedS
=
s
;
190
theCachedDPhi
=
theCachedS
*
theRho
*
theSinTheta
;
191
theCachedSDPhi
=
sin
(
theCachedDPhi
);
192
theCachedCDPhi
=
cos
(
theCachedDPhi
);
193
}
194
195
if
(fabs(
theCachedDPhi
) > 1.
e
-4) {
196
// full helix formula
197
return
DirectionTypeDouble
(
theCosPhi0
*
theCachedCDPhi
-
theSinPhi0
*
theCachedSDPhi
,
198
theSinPhi0
*
theCachedCDPhi
+
theCosPhi0
* theCachedSDPhi,
199
theCosTheta
/
theSinTheta
);
200
}
else
{
201
// 1st order
202
return
theQuadraticSolutionFromStart
.
directionInDouble
(
theCachedS
);
203
}
204
}
IterativeHelixExtrapolatorToLine::positionInDouble
PositionTypeDouble positionInDouble(double s) const
Definition:
IterativeHelixExtrapolatorToLine.cc:136
first
auto first
Definition:
CAHitNtupletGeneratorKernelsImpl.h:125
HelixExtrapolatorToLine2Order::positionInDouble
PositionTypeDouble positionInDouble(double s) const
Position at pathlength s from the starting point in double precision.
Definition:
HelixExtrapolatorToLine2Order.cc:198
IterativeHelixExtrapolatorToLine::theX0
const double theX0
Definition:
IterativeHelixExtrapolatorToLine.h:58
Basic3DVector::y
T y() const
Cartesian y coordinate.
Definition:
extBasic3DVector.h:97
IterativeHelixExtrapolatorToLine::theSinPhi0
double theSinPhi0
Definition:
IterativeHelixExtrapolatorToLine.h:59
Basic3DVector::x
T x() const
Cartesian x coordinate.
Definition:
extBasic3DVector.h:94
DiDispStaMuonMonitor_cfi.pt
tuple pt
Definition:
DiDispStaMuonMonitor_cfi.py:39
IterativeHelixExtrapolatorToLine::IterativeHelixExtrapolatorToLine
IterativeHelixExtrapolatorToLine(const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=anyDirection)
Definition:
IterativeHelixExtrapolatorToLine.cc:4
IterativeHelixExtrapolatorToLine::directionInDouble
DirectionTypeDouble directionInDouble(double s) const
Definition:
IterativeHelixExtrapolatorToLine.cc:184
anyDirection
Definition:
PropagationDirection.h:4
Line
Definition:
Line.h:10
HelixLineExtrapolation::PositionTypeDouble
Basic3DVector< double > PositionTypeDouble
Definition:
HelixLineExtrapolation.h:24
funct::sin
Sin< T >::type sin(const T &t)
Definition:
Sin.h:22
alongMomentum
Definition:
PropagationDirection.h:4
IterativeHelixExtrapolatorToLine::theCosTheta
double theCosTheta
Definition:
IterativeHelixExtrapolatorToLine.h:60
PropagationDirection
PropagationDirection
Definition:
PropagationDirection.h:4
HelixLineExtrapolation::DirectionTypeDouble
Basic3DVector< double > DirectionTypeDouble
Definition:
HelixLineExtrapolation.h:25
detailsBasic3DVector::z
float float float z
Definition:
extBasic3DVector.h:14
PixelRecoUtilities::curvature
T curvature(T InversePt, const MagneticField &field)
Definition:
PixelRecoUtilities.h:23
IterativeHelixExtrapolatorToLine::genericPathLength
std::pair< bool, double > genericPathLength(const T &object) const
common functionality for extrapolation to line or point
Definition:
IterativeHelixExtrapolatorToLine.cc:53
HelixLineExtrapolation::DirectionType
Basic3DVector< float > DirectionType
Definition:
HelixLineExtrapolation.h:23
geometryCSVtoXML.line
tuple line
Definition:
geometryCSVtoXML.py:16
align_cfg.iteration
tuple iteration
Definition:
align_cfg.py:5
IterativeHelixExtrapolatorToLine::position
PositionType position(double s) const override
Definition:
IterativeHelixExtrapolatorToLine.cc:128
HelixLineExtrapolation::PositionType
Basic3DVector< float > PositionType
Definition:
HelixLineExtrapolation.h:22
Basic3DVector::z
T z() const
Cartesian z coordinate.
Definition:
extBasic3DVector.h:100
IterativeHelixExtrapolatorToLine::theY0
const double theY0
Definition:
IterativeHelixExtrapolatorToLine.h:58
Basic3DVector< float >
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:19
funct::cos
Cos< T >::type cos(const T &t)
Definition:
Cos.h:22
HelixExtrapolatorToLine2Order
Definition:
HelixExtrapolatorToLine2Order.h:11
gpuClustering::x
uint16_t const *__restrict__ x
Definition:
gpuClustering.h:39
IterativeHelixExtrapolatorToLine::direction
DirectionType direction(double s) const override
Definition:
IterativeHelixExtrapolatorToLine.cc:174
IterativeHelixExtrapolatorToLine::theRho
const double theRho
Definition:
IterativeHelixExtrapolatorToLine.h:61
IterativeHelixExtrapolatorToLine::theCachedCDPhi
double theCachedCDPhi
Definition:
IterativeHelixExtrapolatorToLine.h:70
IterativeHelixExtrapolatorToLine::theCachedSDPhi
double theCachedSDPhi
Definition:
IterativeHelixExtrapolatorToLine.h:69
IterativeHelixExtrapolatorToLine::theCachedS
double theCachedS
Definition:
IterativeHelixExtrapolatorToLine.h:67
IterativeHelixExtrapolatorToLine::pathLength
std::pair< bool, double > pathLength(const GlobalPoint &point) const override
Definition:
IterativeHelixExtrapolatorToLine.cc:37
detailsBasic3DVector::y
float float y
Definition:
extBasic3DVector.h:14
alignCSCRings.s
list s
Definition:
alignCSCRings.py:92
IterativeHelixExtrapolatorToLine::theCachedDPhi
double theCachedDPhi
Definition:
IterativeHelixExtrapolatorToLine.h:68
alignCSCRings.e
list e
Definition:
alignCSCRings.py:91
HelixExtrapolatorToLine2Order::directionInDouble
DirectionTypeDouble directionInDouble(double s) const
Direction at pathlength s from the starting point in double precision.
Definition:
HelixExtrapolatorToLine2Order.cc:217
AlCaHLTBitMon_ParallelJobs.p
tuple p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
Point3DBase< float, GlobalTag >
IterativeHelixExtrapolatorToLine.h
IterativeHelixExtrapolatorToLine::theQuadraticSolutionFromStart
HelixExtrapolatorToLine2Order theQuadraticSolutionFromStart
Definition:
IterativeHelixExtrapolatorToLine.h:63
IterativeHelixExtrapolatorToLine::theSinTheta
double theSinTheta
Definition:
IterativeHelixExtrapolatorToLine.h:60
IterativeHelixExtrapolatorToLine::theCosPhi0
double theCosPhi0
Definition:
IterativeHelixExtrapolatorToLine.h:59
IterativeHelixExtrapolatorToLine::thePropDir
const PropagationDirection thePropDir
Definition:
IterativeHelixExtrapolatorToLine.h:65
HelixExtrapolatorToLine2Order::pathLength
std::pair< bool, double > pathLength(const GlobalPoint &point) const override
Definition:
HelixExtrapolatorToLine2Order.cc:28
IterativeHelixExtrapolatorToLine::theZ0
const double theZ0
Definition:
IterativeHelixExtrapolatorToLine.h:58
T
long double T
Definition:
Basic3DVectorLD.h:48
oppositeToMomentum
Definition:
PropagationDirection.h:4
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
Generated for CMSSW Reference Manual by
1.8.5