#include <TrackingTools/GeomPropagators/interface/HelixExtrapolatorToLine2Order.h>
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 in double precision. | |
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). | |
HelixExtrapolatorToLine2Order (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 Line &line) const |
Propagation status (true if valid) and (signed) path length along the helix from the starting point to the closest approach to the line. | |
virtual std::pair< bool, double > | pathLength (const GlobalPoint &point) const |
Propagation status (true if valid) and (signed) path length along the helix from the starting point to the closest approach to the point. | |
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 in double precision. | |
virtual | ~HelixExtrapolatorToLine2Order () |
Private Member Functions | |
virtual std::pair< bool, double > | pathLengthFromCoefficients (const double ceq[4]) const |
common part for propagation to point and line | |
int | solve2ndOrder (const double ceq[], double sol[]) const |
Solutions of 2nd order equation. | |
int | solve3rdOrder (const double ceq[], double sol[]) const |
Solutions of 3rd order equation. | |
Private Attributes | |
DirectionTypeDouble | theDirection |
const PositionTypeDouble | thePosition |
const PropagationDirection | thePropDir |
const double | theRho |
double | theSinTheta |
Definition at line 10 of file HelixExtrapolatorToLine2Order.h.
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.
References p, funct::sqrt(), theDirection, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
00010 : 00011 thePosition(point), 00012 theRho(curvature), 00013 thePropDir(propDir) 00014 { 00015 // 00016 // Components of direction vector (with correct normalisation) 00017 // 00018 double px = direction.x(); 00019 double py = direction.y(); 00020 double pz = direction.z(); 00021 double pt = px*px+py*py; 00022 double p = sqrt(pt+pz*pz); 00023 pt = sqrt(pt); 00024 theDirection = DirectionTypeDouble(px/pt,py/pt,pz/pt); 00025 theSinTheta = pt/p; 00026 }
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 19 of file HelixExtrapolatorToLine2Order.h.
00023 : 00024 thePosition(x0,y0,z0), 00025 theDirection(cosPhi0,sinPhi0,cosTheta/sinTheta), 00026 theSinTheta(sinTheta), 00027 theRho(rho), 00028 thePropDir(propDir) {}
virtual HelixExtrapolatorToLine2Order::~HelixExtrapolatorToLine2Order | ( | ) | [inline, virtual] |
HelixLineExtrapolation::DirectionType HelixExtrapolatorToLine2Order::direction | ( | double | s | ) | const [virtual] |
Direction at pathlength s from the starting point.
Implements HelixLineExtrapolation.
Definition at line 226 of file HelixExtrapolatorToLine2Order.cc.
References directionInDouble().
00226 { 00227 // use double precision result 00228 // DirectionTypeDouble dir = directionInDouble(s); 00229 // return DirectionType(dir.x(),dir.y(),dir.z()); 00230 return DirectionType(directionInDouble(s)); 00231 }
HelixExtrapolatorToLine2Order::DirectionTypeDouble HelixExtrapolatorToLine2Order::directionInDouble | ( | double | s | ) | const |
Direction at pathlength s from the starting point in double precision.
Definition at line 236 of file HelixExtrapolatorToLine2Order.cc.
References theDirection, theRho, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
Referenced by direction(), and IterativeHelixExtrapolatorToLine::directionInDouble().
00236 { 00237 // based on delta phi 00238 double dph = s*theRho*theSinTheta; 00239 return DirectionTypeDouble(theDirection.x()-(theDirection.y()+0.5*theDirection.x()*dph)*dph, 00240 theDirection.y()+(theDirection.x()-0.5*theDirection.y()*dph)*dph, 00241 theDirection.z()); 00242 }
std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength | ( | const Line & | line | ) | const [virtual] |
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 56 of file HelixExtrapolatorToLine2Order.cc.
References Line::direction(), Basic3DVector< T >::dot(), pathLengthFromCoefficients(), Line::position(), theDirection, thePosition, theRho, Basic3DVector< T >::x(), and Basic3DVector< T >::y().
00056 { 00057 // 00058 // Auxiliary vectors. Assumes that line.direction().mag()=1 ! 00059 // 00060 PositionTypeDouble linePosition(line.position()); 00061 DirectionTypeDouble lineDirection(line.direction()); 00062 DirectionTypeDouble helix2(-0.5*theRho*theDirection.y(), 00063 0.5*theRho*theDirection.x(), 00064 0.); 00065 DirectionTypeDouble deltaPos(thePosition-linePosition); 00066 DirectionTypeDouble helix1p(theDirection-lineDirection*theDirection.dot(lineDirection)); 00067 DirectionTypeDouble helix2p(helix2-lineDirection*helix2.dot(lineDirection)); 00068 // 00069 // coefficients of 3rd order equation 00070 // 00071 double ceq[4]; 00072 ceq[3] = 2*helix2.dot(helix2p); 00073 // ceq[2] = 3*helix1.dot(helix1p); 00074 // since theDirection.dot(helix2)==0 equivalent to 00075 ceq[2] = 3*theDirection.dot(lineDirection)*helix2.dot(lineDirection); 00076 ceq[1] = theDirection.dot(helix1p)+2*deltaPos.dot(helix2p); 00077 ceq[0] = deltaPos.dot(helix1p); 00078 // 00079 return pathLengthFromCoefficients(ceq); 00080 }
std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLength | ( | const GlobalPoint & | point | ) | const [virtual] |
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 32 of file HelixExtrapolatorToLine2Order.cc.
References Basic3DVector< T >::dot(), Basic3DVector< T >::mag2(), pathLengthFromCoefficients(), position(), theDirection, thePosition, theRho, Basic3DVector< T >::x(), and Basic3DVector< T >::y().
Referenced by IterativeHelixExtrapolatorToLine::genericPathLength().
00032 { 00033 // 00034 PositionTypeDouble position(point); 00035 DirectionTypeDouble helix2(-0.5*theRho*theDirection.y(), 00036 0.5*theRho*theDirection.x(), 00037 0.); 00038 DirectionTypeDouble deltaPos(thePosition-position); 00039 // 00040 // coefficients of 3rd order equation 00041 // 00042 double ceq[4]; 00043 ceq[3] = 2*helix2.mag2(); 00044 // ceq[2] = 3*theDirection.dot(helix2) = 0 since they are orthogonal 00045 ceq[2] = 0.; 00046 ceq[1] = theDirection.mag2()+2*deltaPos.dot(helix2); 00047 ceq[0] = deltaPos.dot(theDirection); 00048 // 00049 return pathLengthFromCoefficients(ceq); 00050 }
std::pair< bool, double > HelixExtrapolatorToLine2Order::pathLengthFromCoefficients | ( | const double | ceq[4] | ) | const [private, virtual] |
common part for propagation to point and line
Definition at line 86 of file HelixExtrapolatorToLine2Order.cc.
References alongMomentum, anyDirection, i, oppositeToMomentum, TtSemiEvtSolProducer_cfi::solutions, solve3rdOrder(), st, thePropDir, and theSinTheta.
Referenced by pathLength().
00087 { 00088 // 00089 // Solution of 3rd order equation 00090 // 00091 double solutions[3]; 00092 int nRaw = solve3rdOrder(ceq,solutions); 00093 // 00094 // check compatibility with propagation direction 00095 // 00096 int nDir(0); 00097 for ( int i=0; i<nRaw; i++ ) { 00098 if ( thePropDir==anyDirection || 00099 (solutions[i]>=0&&thePropDir==alongMomentum) || 00100 (solutions[i]<=0&&thePropDir==oppositeToMomentum) ) 00101 solutions[nDir++] = solutions[i]; 00102 } 00103 if ( nDir==0 ) return std::make_pair(false,0.); 00104 // 00105 // check 2nd derivative 00106 // 00107 int nMin(0); 00108 for ( int i=0; i<nDir; i++ ) { 00109 double st = solutions[i]; 00110 double deri2 = (3*ceq[3]*st+2*ceq[2])*st+ceq[1]; 00111 if ( deri2>0. ) solutions[nMin++] = st; 00112 } 00113 if ( nMin==0 ) return std::make_pair(false,0.); 00114 // 00115 // choose smallest path length 00116 // 00117 double dSt = solutions[0]; 00118 for ( int i=1; i<nMin; i++ ) { 00119 if ( fabs(solutions[i])<fabs(dSt) ) dSt = solutions[i]; 00120 } 00121 00122 return std::make_pair(true,dSt/theSinTheta); 00123 }
HelixLineExtrapolation::PositionType HelixExtrapolatorToLine2Order::position | ( | double | s | ) | const [virtual] |
Position at pathlength s from the starting point.
Implements HelixLineExtrapolation.
Definition at line 205 of file HelixExtrapolatorToLine2Order.cc.
References positionInDouble().
Referenced by pathLength().
00205 { 00206 // use double precision result 00207 // PositionTypeDouble pos = positionInDouble(s); 00208 // return PositionType(pos.x(),pos.y(),pos.z()); 00209 return PositionType(positionInDouble(s)); 00210 }
HelixExtrapolatorToLine2Order::PositionTypeDouble HelixExtrapolatorToLine2Order::positionInDouble | ( | double | s | ) | const |
Position at pathlength s from the starting point in double precision.
Definition at line 215 of file HelixExtrapolatorToLine2Order.cc.
References st, theDirection, thePosition, theRho, theSinTheta, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().
Referenced by position(), and IterativeHelixExtrapolatorToLine::positionInDouble().
00215 { 00216 // based on path length in the transverse plane 00217 double st = s*theSinTheta; 00218 return PositionTypeDouble(thePosition.x()+(theDirection.x()-st*0.5*theRho*theDirection.y())*st, 00219 thePosition.y()+(theDirection.y()+st*0.5*theRho*theDirection.x())*st, 00220 thePosition.z()+st*theDirection.z()); 00221 }
int HelixExtrapolatorToLine2Order::solve2ndOrder | ( | const double | ceq[], | |
double | sol[] | |||
) | const [private] |
Solutions of 2nd order equation.
Definition at line 172 of file HelixExtrapolatorToLine2Order.cc.
References e, and funct::sqrt().
Referenced by solve3rdOrder().
00174 { 00175 // 00176 double deq1 = coeff[1]*coeff[1]; 00177 double deq2 = coeff[2]*coeff[0]; 00178 if ( fabs(deq1)<FLT_MIN || fabs(deq2/deq1)>1.e-6 ) { 00179 // 00180 // Standard solution for quadratic equations 00181 // 00182 double deq = deq1+2*deq2; 00183 if ( deq<0. ) return 0; 00184 double ceq = -0.5*(coeff[1]+(coeff[1]>0?1:-1)*sqrt(deq)); 00185 solutions[0] = -2*ceq/coeff[2]; 00186 solutions[1] = coeff[0]/ceq; 00187 return 2; 00188 } 00189 else { 00190 // 00191 // Solution by expansion of sqrt(1+deq) 00192 // 00193 double ceq = coeff[1]/coeff[2]; 00194 double deq = deq2/deq1; 00195 deq *= (1-deq/2); 00196 solutions[0] = -ceq*deq; 00197 solutions[1] = ceq*(2+deq); 00198 return 2; 00199 } 00200 }
int HelixExtrapolatorToLine2Order::solve3rdOrder | ( | const double | ceq[], | |
double | sol[] | |||
) | const [private] |
Solutions of 3rd order equation.
Definition at line 126 of file HelixExtrapolatorToLine2Order.cc.
References a, b, funct::cos(), i, phi, funct::pow(), r, HLT_VtxMuL3::result, solve2ndOrder(), and funct::sqrt().
Referenced by pathLengthFromCoefficients().
00128 { 00129 // 00130 // Real 3rd order equation? Follow numerical recipes .. 00131 // 00132 if ( fabs(ceq[3])>FLT_MIN ) { 00133 int result(0); 00134 double q = (ceq[2]*ceq[2]-3*ceq[3]*ceq[1]) / (ceq[3]*ceq[3]) / 9.; 00135 double r = (2*ceq[2]*ceq[2]*ceq[2]-9*ceq[3]*ceq[2]*ceq[1]+27*ceq[3]*ceq[3]*ceq[0]) 00136 / (ceq[3]*ceq[3]*ceq[3]) / 54.; 00137 double q3 = q*q*q; 00138 if ( r*r<q3 ) { 00139 double phi = acos(r/sqrt(q3))/3.; 00140 double rootq = sqrt(q); 00141 for ( int i=0; i<3; i++ ) { 00142 solutions[i] = -2*rootq*cos(phi) - ceq[2]/ceq[3]/3.; 00143 phi += 2./3.*M_PI; 00144 } 00145 result = 3; 00146 } 00147 else { 00148 double a = pow(fabs(r)+sqrt(r*r-q3),1./3.); 00149 if ( r>0. ) a *= -1; 00150 double b = fabs(a)>FLT_MIN ? q/a : 0.; 00151 solutions[0] = a + b - ceq[2]/ceq[3]/3.; 00152 result = 1; 00153 } 00154 return result; 00155 } 00156 // 00157 // Second order equation 00158 // 00159 else if ( fabs(ceq[2])>FLT_MIN ) { 00160 return solve2ndOrder(ceq,solutions); 00161 } 00162 else { 00163 // 00164 // Special case: linear equation 00165 // 00166 solutions[0] = -ceq[0]/ceq[1]; 00167 return 1; 00168 } 00169 }
Definition at line 67 of file HelixExtrapolatorToLine2Order.h.
Referenced by directionInDouble(), HelixExtrapolatorToLine2Order(), pathLength(), and positionInDouble().
const PositionTypeDouble HelixExtrapolatorToLine2Order::thePosition [private] |
Definition at line 66 of file HelixExtrapolatorToLine2Order.h.
Referenced by pathLength(), and positionInDouble().
const PropagationDirection HelixExtrapolatorToLine2Order::thePropDir [private] |
Definition at line 70 of file HelixExtrapolatorToLine2Order.h.
Referenced by pathLengthFromCoefficients().
const double HelixExtrapolatorToLine2Order::theRho [private] |
Definition at line 69 of file HelixExtrapolatorToLine2Order.h.
Referenced by directionInDouble(), pathLength(), and positionInDouble().
double HelixExtrapolatorToLine2Order::theSinTheta [private] |
Definition at line 68 of file HelixExtrapolatorToLine2Order.h.
Referenced by directionInDouble(), HelixExtrapolatorToLine2Order(), pathLengthFromCoefficients(), and positionInDouble().