CMS 3D CMS Logo

IterativeHelixExtrapolatorToLine Class Reference

Calculates closest approach of a helix to a line or a point by iterative use of a 2nd order expansion of the helix. More...

#include <TrackingTools/GeomPropagators/interface/IterativeHelixExtrapolatorToLine.h>

Inheritance diagram for IterativeHelixExtrapolatorToLine:

HelixLineExtrapolation

List of all members.

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.
 IterativeHelixExtrapolatorToLine (const PositionType &point, const DirectionType &direction, const float curvature, const PropagationDirection propDir=anyDirection)
 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.
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 ~IterativeHelixExtrapolatorToLine ()

Private Member Functions

template<class T>
std::pair< bool, double > genericPathLength (const T &object) const
 common functionality for extrapolation to line or point

Private Attributes

double theCachedCDPhi
double theCachedDPhi
double theCachedS
double theCachedSDPhi
double theCosPhi0
double theCosTheta
const PropagationDirection thePropDir
HelixExtrapolatorToLine2Order theQuadraticSolutionFromStart
const double theRho
double theSinPhi0
double theSinTheta
const double theX0
const double theY0
const double theZ0


Detailed Description

Calculates closest approach of a helix to a line or a point by iterative use of a 2nd order expansion of the helix.

Definition at line 12 of file IterativeHelixExtrapolatorToLine.h.


Constructor & Destructor Documentation

IterativeHelixExtrapolatorToLine::IterativeHelixExtrapolatorToLine ( const PositionType point,
const DirectionType direction,
const float  curvature,
const PropagationDirection  propDir = anyDirection 
)

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

Definition at line 5 of file IterativeHelixExtrapolatorToLine.cc.

References p, funct::sqrt(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

00008                                      :
00009   theX0(point.x()),
00010   theY0(point.y()),
00011   theZ0(point.z()),
00012   theRho(curvature),
00013   theQuadraticSolutionFromStart(point,direction,curvature,propDir),
00014   thePropDir(propDir),
00015   theCachedS(0),
00016   theCachedDPhi(0.),
00017   theCachedSDPhi(0.),
00018   theCachedCDPhi(1.)
00019 {
00020   //
00021   // Components of direction vector (with correct normalisation)
00022   //
00023   double px = direction.x();
00024   double py = direction.y();
00025   double pz = direction.z();
00026   double pt = px*px+py*py;
00027   double p = sqrt(pt+pz*pz);
00028   pt = sqrt(pt);
00029   theCosPhi0 = px/pt;
00030   theSinPhi0 = py/pt;
00031   theCosTheta = pz/p;
00032   theSinTheta = pt/p;
00033 }
//

virtual IterativeHelixExtrapolatorToLine::~IterativeHelixExtrapolatorToLine (  )  [inline, virtual]

Definition at line 21 of file IterativeHelixExtrapolatorToLine.h.

00021 {}


Member Function Documentation

HelixLineExtrapolation::DirectionType IterativeHelixExtrapolatorToLine::direction ( double  s  )  const [virtual]

Direction at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 163 of file IterativeHelixExtrapolatorToLine.cc.

References directionInDouble().

Referenced by AnalyticalTrajectoryExtrapolatorToLine::propagateWithHelix(), and AnalyticalImpactPointExtrapolator::propagateWithHelix().

00163                                                            {
00164   // use result in double precision
00165 //   DirectionTypeDouble dir = directionInDouble(s);
00166 //   return DirectionType(dir.x(),dir.y(),dir.z());
00167   return DirectionType(directionInDouble(s));
00168 }

HelixLineExtrapolation::DirectionTypeDouble IterativeHelixExtrapolatorToLine::directionInDouble ( double  s  )  const

Direction at pathlength s from the starting point.

Definition at line 174 of file IterativeHelixExtrapolatorToLine.cc.

References funct::cos(), HelixExtrapolatorToLine2Order::directionInDouble(), e, funct::sin(), theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticSolutionFromStart, theRho, theSinPhi0, and theSinTheta.

Referenced by direction(), and genericPathLength().

00174                                                                    {
00175   //
00176   // Calculate delta phi (if not already available)
00177   //
00178   if ( s!=theCachedS ) {
00179     theCachedS = s;
00180     theCachedDPhi = theCachedS*theRho*theSinTheta;
00181     theCachedSDPhi = sin(theCachedDPhi);
00182     theCachedCDPhi = cos(theCachedDPhi);
00183   }
00184 
00185   if ( fabs(theCachedDPhi)>1.e-4 ) {
00186     // full helix formula
00187     return DirectionTypeDouble(theCosPhi0*theCachedCDPhi-theSinPhi0*theCachedSDPhi,
00188                                theSinPhi0*theCachedCDPhi+theCosPhi0*theCachedSDPhi,
00189                                theCosTheta/theSinTheta);
00190   }
00191   else {
00192     // 1st order
00193     return theQuadraticSolutionFromStart.directionInDouble(theCachedS);
00194   }
00195 }

template<class T>
std::pair< bool, double > IterativeHelixExtrapolatorToLine::genericPathLength ( const T &  object  )  const [inline, private]

common functionality for extrapolation to line or point

Definition at line 38 of file IterativeHelixExtrapolatorToLine.cc.

References alongMomentum, anyDirection, directionInDouble(), first, iteration, oppositeToMomentum, HelixExtrapolatorToLine2Order::pathLength(), positionInDouble(), theCosPhi0, theCosTheta, thePropDir, theQuadraticSolutionFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, theZ0, Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

Referenced by pathLength().

00038                                                                           {
00039   //
00040   // Constants used for control of convergence
00041   //
00042   const int maxIterations(100);
00043   //
00044   // Prepare internal value of the propagation direction and position / direction vectors for iteration 
00045   //
00046   PropagationDirection propDir = thePropDir;
00047   PositionTypeDouble xnew(theX0,theY0,theZ0);
00048   DirectionTypeDouble pnew(theCosPhi0,theSinPhi0,theCosTheta/theSinTheta);
00049   //
00050   // Prepare iterations: count and total pathlength
00051   //
00052   int iteration(maxIterations);
00053   double dSTotal(0.);
00054   //
00055   // Convergence criterion: maximal lateral displacement in a step < 1um
00056   //
00057   double maxDeltaS2 = 2*1.e-4/theSinTheta/theSinTheta/fabs(theRho);
00058   //
00059   bool first(true);
00060   while ( true ) {
00061     //
00062     // return empty solution vector if no convergence after maxIterations iterations
00063     //
00064     if ( --iteration<0 ) {
00065       return std::pair<bool,double>(false,0);
00066     }
00067     //
00068     // Use existing second order object at first pass, create temporary object
00069     // for subsequent passes.
00070     //
00071     std::pair<bool,double> deltaS1;
00072     if ( first ) {
00073       first = false;
00074       deltaS1 = theQuadraticSolutionFromStart.pathLength(object);
00075     }
00076     else {
00077       HelixExtrapolatorToLine2Order linearCrossing(xnew.x(),xnew.y(),xnew.z(),
00078                                                    pnew.x(),pnew.y(),
00079                                                    theCosTheta,theSinTheta,
00080                                                    theRho,anyDirection);
00081       deltaS1 = linearCrossing.pathLength(object);
00082     }
00083     if ( !deltaS1.first )  return deltaS1;
00084     //
00085     // Calculate total pathlength
00086     //
00087     dSTotal += deltaS1.second;
00088     PropagationDirection newDir = dSTotal>=0 ? alongMomentum : oppositeToMomentum;
00089     if ( propDir == anyDirection ) {
00090       propDir = newDir;
00091     }
00092     else {
00093       if ( newDir!=propDir )  return std::pair<bool,double>(false,0);
00094     }
00095     //
00096     // Check convergence
00097     //
00098     if ( deltaS1.second*deltaS1.second<maxDeltaS2 )  break;
00099     //
00100     // Step forward by dSTotal.
00101     //
00102     xnew = positionInDouble(dSTotal);
00103     pnew = directionInDouble(dSTotal);
00104   }
00105   //
00106   // Return result
00107   //
00108   return std::pair<bool,double>(true,dSTotal);
00109 }

virtual std::pair<bool,double> IterativeHelixExtrapolatorToLine::pathLength ( const Line line  )  const [inline, 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 35 of file IterativeHelixExtrapolatorToLine.h.

References genericPathLength().

00035                                                                    {
00036     return genericPathLength(line);
00037   }

virtual std::pair<bool,double> IterativeHelixExtrapolatorToLine::pathLength ( const GlobalPoint point  )  const [inline, 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 27 of file IterativeHelixExtrapolatorToLine.h.

References genericPathLength().

Referenced by AnalyticalTrajectoryExtrapolatorToLine::propagateWithHelix(), and AnalyticalImpactPointExtrapolator::propagateWithHelix().

00027                                                                            {
00028     return genericPathLength(point);
00029   }

HelixLineExtrapolation::PositionType IterativeHelixExtrapolatorToLine::position ( double  s  )  const [virtual]

Position at pathlength s from the starting point.

Implements HelixLineExtrapolation.

Definition at line 115 of file IterativeHelixExtrapolatorToLine.cc.

References positionInDouble().

Referenced by AnalyticalTrajectoryExtrapolatorToLine::propagateWithHelix(), and AnalyticalImpactPointExtrapolator::propagateWithHelix().

00115                                                           {
00116   // use result in double precision
00117   return PositionType(positionInDouble(s));
00118 }

HelixLineExtrapolation::PositionTypeDouble IterativeHelixExtrapolatorToLine::positionInDouble ( double  s  )  const

Position at pathlength s from the starting point.

Definition at line 124 of file IterativeHelixExtrapolatorToLine.cc.

References funct::cos(), e, HelixExtrapolatorToLine2Order::positionInDouble(), funct::sin(), theCachedCDPhi, theCachedDPhi, theCachedS, theCachedSDPhi, theCosPhi0, theCosTheta, theQuadraticSolutionFromStart, theRho, theSinPhi0, theSinTheta, theX0, theY0, and theZ0.

Referenced by genericPathLength(), and position().

00124                                                                   {
00125   //
00126   // Calculate delta phi (if not already available)
00127   //
00128   if ( s!=theCachedS ) {
00129     theCachedS = s;
00130     theCachedDPhi = theCachedS*theRho*theSinTheta;
00131     theCachedSDPhi = sin(theCachedDPhi);
00132     theCachedCDPhi = cos(theCachedDPhi);
00133   }
00134   //
00135   // Calculate with appropriate formulation of full helix formula or with 
00136   //   1st order approximation.
00137   //
00138 //    if ( fabs(theCachedDPhi)>1.e-1 ) {
00139   if ( fabs(theCachedDPhi)>1.e-4 ) {
00140     // "standard" helix formula
00141     return PositionTypeDouble(theX0+(-theSinPhi0*(1.-theCachedCDPhi)+theCosPhi0*theCachedSDPhi)/theRho,
00142                               theY0+(theCosPhi0*(1.-theCachedCDPhi)+theSinPhi0*theCachedSDPhi)/theRho,
00143                               theZ0+theCachedS*theCosTheta);
00144     }
00145 //    else if ( fabs(theCachedDPhi)>theNumericalPrecision ) {
00146 //      // full helix formula, but avoiding (1-cos(deltaPhi)) for small angles
00147 //      return PositionTypeDouble(theX0+(-theSinPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
00148 //                                   theCosPhi0*theCachedSDPhi)/theRho,
00149 //                            theY0+(theCosPhi0*theCachedSDPhi*theCachedSDPhi/(1.+theCachedCDPhi)+
00150 //                                   theSinPhi0*theCachedSDPhi)/theRho,
00151 //                            theZ0+theCachedS*theCosTheta);
00152 //    }
00153   else {
00154     // Use 1st order.
00155     return theQuadraticSolutionFromStart.positionInDouble(theCachedS);
00156   }
00157 }


Member Data Documentation

double IterativeHelixExtrapolatorToLine::theCachedCDPhi [mutable, private]

Definition at line 73 of file IterativeHelixExtrapolatorToLine.h.

Referenced by directionInDouble(), and positionInDouble().

double IterativeHelixExtrapolatorToLine::theCachedDPhi [mutable, private]

Definition at line 71 of file IterativeHelixExtrapolatorToLine.h.

Referenced by directionInDouble(), and positionInDouble().

double IterativeHelixExtrapolatorToLine::theCachedS [mutable, private]

Definition at line 70 of file IterativeHelixExtrapolatorToLine.h.

Referenced by directionInDouble(), and positionInDouble().

double IterativeHelixExtrapolatorToLine::theCachedSDPhi [mutable, private]

Definition at line 72 of file IterativeHelixExtrapolatorToLine.h.

Referenced by directionInDouble(), and positionInDouble().

double IterativeHelixExtrapolatorToLine::theCosPhi0 [private]

Definition at line 62 of file IterativeHelixExtrapolatorToLine.h.

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

double IterativeHelixExtrapolatorToLine::theCosTheta [private]

Definition at line 63 of file IterativeHelixExtrapolatorToLine.h.

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

const PropagationDirection IterativeHelixExtrapolatorToLine::thePropDir [private]

Definition at line 68 of file IterativeHelixExtrapolatorToLine.h.

Referenced by genericPathLength().

HelixExtrapolatorToLine2Order IterativeHelixExtrapolatorToLine::theQuadraticSolutionFromStart [private]

Definition at line 66 of file IterativeHelixExtrapolatorToLine.h.

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

const double IterativeHelixExtrapolatorToLine::theRho [private]

Definition at line 64 of file IterativeHelixExtrapolatorToLine.h.

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

double IterativeHelixExtrapolatorToLine::theSinPhi0 [private]

Definition at line 62 of file IterativeHelixExtrapolatorToLine.h.

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

double IterativeHelixExtrapolatorToLine::theSinTheta [private]

Definition at line 63 of file IterativeHelixExtrapolatorToLine.h.

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

const double IterativeHelixExtrapolatorToLine::theX0 [private]

Definition at line 61 of file IterativeHelixExtrapolatorToLine.h.

Referenced by genericPathLength(), and positionInDouble().

const double IterativeHelixExtrapolatorToLine::theY0 [private]

Definition at line 61 of file IterativeHelixExtrapolatorToLine.h.

Referenced by genericPathLength(), and positionInDouble().

const double IterativeHelixExtrapolatorToLine::theZ0 [private]

Definition at line 61 of file IterativeHelixExtrapolatorToLine.h.

Referenced by genericPathLength(), and positionInDouble().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:00 2009 for CMSSW by  doxygen 1.5.4