#include <TrackingTools/GeomPropagators/interface/HelixArbitraryPlaneCrossing.h>
Public Types | |
typedef Basic3DVector< double > | DirectionTypeDouble |
typedef Basic3DVector< double > | PositionTypeDouble |
Public Member Functions | |
virtual DirectionType | direction (double s) const |
Direction at pathlength s from the starting point. | |
DirectionTypeDouble | directionInDouble (double s) const |
Direction at pathlength s from the starting point. | |
HelixArbitraryPlaneCrossing (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=alongMomentum) | |
Constructor using point, direction and (transverse!) curvature. | |
virtual std::pair< bool, double > | pathLength (const Plane &plane) |
Propagation status (true if valid) and (signed) path length along the helix from the starting point to the plane. | |
virtual PositionType | position (double s) const |
Position at pathlength s from the starting point. | |
PositionTypeDouble | positionInDouble (double s) const |
Position at pathlength s from the starting point. | |
virtual | ~HelixArbitraryPlaneCrossing () |
Private Member Functions | |
bool | notAtSurface (const Plane &, const PositionTypeDouble &, const float) const |
Iteration control: check for significant distance to plane. | |
Private Attributes | |
double | theCachedCDPhi |
double | theCachedDPhi |
double | theCachedS |
double | theCachedSDPhi |
double | theCosPhi0 |
double | theCosTheta |
const PropagationDirection | thePropDir |
HelixArbitraryPlaneCrossing2Order | theQuadraticCrossingFromStart |
const double | theRho |
double | theSinPhi0 |
double | theSinTheta |
const double | theX0 |
const double | theY0 |
const double | theZ0 |
Static Private Attributes | |
static const float | theMaxDistToPlane = 1.e-4 |
static const float | theNumericalPrecision = 5.e-7 |
Definition at line 9 of file HelixArbitraryPlaneCrossing.h.
typedef Basic3DVector<double> HelixArbitraryPlaneCrossing::DirectionTypeDouble |
Definition at line 37 of file HelixArbitraryPlaneCrossing.h.
typedef Basic3DVector<double> HelixArbitraryPlaneCrossing::PositionTypeDouble |
Definition at line 36 of file HelixArbitraryPlaneCrossing.h.
HelixArbitraryPlaneCrossing::HelixArbitraryPlaneCrossing | ( | const PositionType & | point, | |
const DirectionType & | direction, | |||
const float | curvature, | |||
const PropagationDirection | propDir = alongMomentum | |||
) |
Constructor using point, direction and (transverse!) curvature.
Definition at line 8 of file HelixArbitraryPlaneCrossing.cc.
References p, funct::sqrt(), theCosPhi0, theCosTheta, theSinPhi0, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
00011 : 00012 theX0(point.x()), 00013 theY0(point.y()), 00014 theZ0(point.z()), 00015 theRho(curvature), 00016 theQuadraticCrossingFromStart(point,direction,curvature,propDir), 00017 thePropDir(propDir), 00018 theCachedS(0), 00019 theCachedDPhi(0.), 00020 theCachedSDPhi(0.), 00021 theCachedCDPhi(1.) 00022 { 00023 // 00024 // Components of direction vector (with correct normalisation) 00025 // 00026 double px = direction.x(); 00027 double py = direction.y(); 00028 double pz = direction.z(); 00029 double pt = px*px+py*py; 00030 double p = sqrt(pt+pz*pz); 00031 pt = sqrt(pt); 00032 theCosPhi0 = px/pt; 00033 theSinPhi0 = py/pt; 00034 theCosTheta = pz/p; 00035 theSinTheta = pt/p; 00036 } //
virtual HelixArbitraryPlaneCrossing::~HelixArbitraryPlaneCrossing | ( | ) | [inline, virtual] |
HelixPlaneCrossing::DirectionType HelixArbitraryPlaneCrossing::direction | ( | double | s | ) | const [virtual] |
Direction at pathlength s from the starting point.
Implements HelixPlaneCrossing.
Definition at line 163 of file HelixArbitraryPlaneCrossing.cc.
References dir, directionInDouble(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
00163 { 00164 // use result in double precision 00165 DirectionTypeDouble dir = directionInDouble(s); 00166 return DirectionType(dir.x(),dir.y(),dir.z()); 00167 }
HelixArbitraryPlaneCrossing::DirectionTypeDouble HelixArbitraryPlaneCrossing::directionInDouble | ( | double | s | ) | const |
Direction at pathlength s from the starting point.
Definition at line 172 of file HelixArbitraryPlaneCrossing.cc.
References funct::cos(), HelixArbitraryPlaneCrossing2Order::directionInDouble(), e, funct::sin(), theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticCrossingFromStart, theRho, theSinPhi0, and theSinTheta.
Referenced by direction(), and pathLength().
00172 { 00173 // 00174 // Calculate delta phi (if not already available) 00175 // 00176 if ( s!=theCachedS ) { 00177 theCachedS = s; 00178 theCachedDPhi = theCachedS*theRho*theSinTheta; 00179 theCachedSDPhi = sin(theCachedDPhi); 00180 theCachedCDPhi = cos(theCachedDPhi); 00181 } 00182 00183 if ( fabs(theCachedDPhi)>1.e-4 ) { 00184 // full helix formula 00185 return DirectionTypeDouble(theCosPhi0*theCachedCDPhi-theSinPhi0*theCachedSDPhi, 00186 theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi, 00187 theCosTheta/theSinTheta); 00188 } 00189 else { 00190 // 2nd order 00191 return theQuadraticCrossingFromStart.directionInDouble(theCachedS); 00192 } 00193 }
bool HelixArbitraryPlaneCrossing::notAtSurface | ( | const Plane & | plane, | |
const PositionTypeDouble & | point, | |||
const | float | |||
) | const [inline, private] |
Iteration control: check for significant distance to plane.
Definition at line 196 of file HelixArbitraryPlaneCrossing.cc.
References Plane::localZ(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
Referenced by pathLength().
00198 { 00199 float dz = plane.localZ(Surface::GlobalPoint(point.x(),point.y(),point.z())); 00200 return fabs(dz)>maxDist; 00201 }
Propagation status (true if valid) and (signed) path length along the helix from the starting point to the plane.
The starting point is given in the constructor.
Implements HelixPlaneCrossing.
Definition at line 41 of file HelixArbitraryPlaneCrossing.cc.
References alongMomentum, anyDirection, directionInDouble(), first, iteration, Basic3DVector< T >::mag(), notAtSurface(), oppositeToMomentum, HelixArbitraryPlaneCrossing2Order::pathLength(), GloballyPositioned< T >::position(), positionInDouble(), theCosPhi0, theCosTheta, theMaxDistToPlane, theNumericalPrecision, thePropDir, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, theZ0, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
00041 { 00042 // 00043 // Constants used for control of convergence 00044 // 00045 const int maxIterations(100); 00046 // 00047 // maximum distance to plane (taking into account numerical precision) 00048 // 00049 float maxNumDz = theNumericalPrecision*plane.position().mag(); 00050 float safeMaxDist = (theMaxDistToPlane>maxNumDz?theMaxDistToPlane:maxNumDz); 00051 // 00052 // Prepare internal value of the propagation direction and position / direction vectors for iteration 00053 // 00054 PropagationDirection propDir = thePropDir; 00055 PositionTypeDouble xnew(theX0,theY0,theZ0); 00056 DirectionTypeDouble pnew(theCosPhi0,theSinPhi0,theCosTheta/theSinTheta); 00057 // 00058 // Prepare iterations: count and total pathlength 00059 // 00060 int iteration(maxIterations); 00061 double dSTotal(0.); 00062 // 00063 bool first(true); 00064 while ( notAtSurface(plane,xnew,safeMaxDist) ) { 00065 // 00066 // return empty solution vector if no convergence after maxIterations iterations 00067 // 00068 if ( --iteration<0 ) { 00069 edm::LogInfo("HelixArbitraryPlaneCrossing") << "pathLength : no convergence"; 00070 return std::pair<bool,double>(false,0); 00071 } 00072 // 00073 // Use existing 2nd order object at first pass, create temporary object 00074 // for subsequent passes. 00075 // 00076 std::pair<bool,double> deltaS2; 00077 if ( first ) { 00078 first = false; 00079 deltaS2 = theQuadraticCrossingFromStart.pathLength(plane); 00080 } 00081 else { 00082 HelixArbitraryPlaneCrossing2Order quadraticCrossing(xnew.x(),xnew.y(),xnew.z(), 00083 pnew.x(),pnew.y(), 00084 theCosTheta,theSinTheta, 00085 theRho, 00086 anyDirection); 00087 deltaS2 = quadraticCrossing.pathLength(plane); 00088 } 00089 if ( !deltaS2.first ) return deltaS2; 00090 // 00091 // Calculate and sort total pathlength (max. 2 solutions) 00092 // 00093 dSTotal += deltaS2.second; 00094 PropagationDirection newDir = dSTotal>=0 ? alongMomentum : oppositeToMomentum; 00095 if ( propDir == anyDirection ) { 00096 propDir = newDir; 00097 } 00098 else { 00099 if ( newDir!=propDir ) return std::pair<bool,double>(false,0); 00100 } 00101 // 00102 // Step forward by dSTotal. 00103 // 00104 xnew = positionInDouble(dSTotal); 00105 pnew = directionInDouble(dSTotal); 00106 } 00107 // 00108 // Return result 00109 // 00110 return std::pair<bool,double>(true,dSTotal); 00111 }
HelixPlaneCrossing::PositionType HelixArbitraryPlaneCrossing::position | ( | double | s | ) | const [virtual] |
Position at pathlength s from the starting point.
Implements HelixPlaneCrossing.
Definition at line 116 of file HelixArbitraryPlaneCrossing.cc.
References positionInDouble(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
00116 { 00117 // use result in double precision 00118 PositionTypeDouble pos = positionInDouble(s); 00119 return PositionType(pos.x(),pos.y(),pos.z()); 00120 }
HelixArbitraryPlaneCrossing::PositionTypeDouble HelixArbitraryPlaneCrossing::positionInDouble | ( | double | s | ) | const |
Position at pathlength s from the starting point.
Definition at line 125 of file HelixArbitraryPlaneCrossing.cc.
References funct::cos(), e, HelixArbitraryPlaneCrossing2Order::positionInDouble(), funct::sin(), theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticCrossingFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, and theZ0.
Referenced by pathLength(), and position().
00125 { 00126 // 00127 // Calculate delta phi (if not already available) 00128 // 00129 if ( s!=theCachedS ) { 00130 theCachedS = s; 00131 theCachedDPhi = theCachedS*theRho*theSinTheta; 00132 theCachedSDPhi = sin(theCachedDPhi); 00133 theCachedCDPhi = cos(theCachedDPhi); 00134 } 00135 // 00136 // Calculate with appropriate formulation of full helix formula or with 00137 // 2nd order approximation. 00138 // 00139 // if ( fabs(theCachedDPhi)>1.e-1 ) { 00140 if ( fabs(theCachedDPhi)>1.e-4 ) { 00141 // "standard" helix formula 00142 return PositionTypeDouble(theX0+(-theSinPhi0*(1.-theCachedCDPhi)+theCosPhi0*theCachedSDPhi)/theRho, 00143 theY0+(theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)/theRho, 00144 theZ0+theCachedS*theCosTheta); 00145 } 00146 // else if ( fabs(theCachedDPhi)>theNumericalPrecision ) { 00147 // // full helix formula, but avoiding (1-cos(deltaPhi)) for small angles 00148 // return PositionTypeDouble(theX0+(-theSinPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+ 00149 // theCosPhi0*theCachedSDPhi)/theRho, 00150 // theY0+(theCosPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+ 00151 // theSinPhi0*theCachedSDPhi)/theRho, 00152 // theZ0+theCachedS*theCosTheta); 00153 // } 00154 else { 00155 // Use 2nd order. 00156 return theQuadraticCrossingFromStart.positionInDouble(theCachedS); 00157 } 00158 }
double HelixArbitraryPlaneCrossing::theCachedCDPhi [mutable, private] |
Definition at line 67 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theCachedDPhi [mutable, private] |
Definition at line 65 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theCachedS [mutable, private] |
Definition at line 64 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theCachedSDPhi [mutable, private] |
Definition at line 66 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theCosPhi0 [private] |
Definition at line 56 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), HelixArbitraryPlaneCrossing(), pathLength(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theCosTheta [private] |
Definition at line 57 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), HelixArbitraryPlaneCrossing(), pathLength(), and positionInDouble().
const float HelixArbitraryPlaneCrossing::theMaxDistToPlane = 1.e-4 [static, private] |
const float HelixArbitraryPlaneCrossing::theNumericalPrecision = 5.e-7 [static, private] |
const PropagationDirection HelixArbitraryPlaneCrossing::thePropDir [private] |
HelixArbitraryPlaneCrossing2Order HelixArbitraryPlaneCrossing::theQuadraticCrossingFromStart [private] |
Definition at line 60 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), pathLength(), and positionInDouble().
const double HelixArbitraryPlaneCrossing::theRho [private] |
Definition at line 58 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), pathLength(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theSinPhi0 [private] |
Definition at line 56 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), HelixArbitraryPlaneCrossing(), pathLength(), and positionInDouble().
double HelixArbitraryPlaneCrossing::theSinTheta [private] |
Definition at line 57 of file HelixArbitraryPlaneCrossing.h.
Referenced by directionInDouble(), HelixArbitraryPlaneCrossing(), pathLength(), and positionInDouble().
const double HelixArbitraryPlaneCrossing::theX0 [private] |
Definition at line 55 of file HelixArbitraryPlaneCrossing.h.
Referenced by pathLength(), and positionInDouble().
const double HelixArbitraryPlaneCrossing::theY0 [private] |
Definition at line 55 of file HelixArbitraryPlaneCrossing.h.
Referenced by pathLength(), and positionInDouble().
const double HelixArbitraryPlaneCrossing::theZ0 [private] |
Definition at line 55 of file HelixArbitraryPlaneCrossing.h.
Referenced by pathLength(), and positionInDouble().