CMS 3D CMS Logo

StraightLinePropagator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GeomPropagators/interface/StraightLinePropagator.h"
00002 
00003 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00004 #include "DataFormats/GeometrySurface/interface/Plane.h"
00005 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00006 #include "TrackingTools/GeomPropagators/interface/PropagationExceptions.h"
00007 
00008 std::pair<TrajectoryStateOnSurface,double> 
00009 StraightLinePropagator::propagateWithPath(const FreeTrajectoryState& fts, 
00010                                           const Plane& plane) const
00011 {
00012   // propagate parameters
00013   LocalPoint x;
00014   LocalVector p;
00015   double s = 0;
00016   bool parametersOK = propagateParametersOnPlane(fts, plane, x, p, s);
00017   if(!parametersOK) return std::make_pair(TrajectoryStateOnSurface(), 0.);
00018 
00019   // compute propagated state
00020   if (fts.hasError()) {
00021     return std::make_pair( propagatedState(fts, plane, jacobian(s), x,  p), s);
00022   } else {
00023     // return state without errors
00024     return std::make_pair(TSOS(LocalTrajectoryParameters(x, p, fts.charge()), 
00025                           plane, theField), s);
00026   }
00027 }
00028 
00029 std::pair<TrajectoryStateOnSurface,double> 
00030 StraightLinePropagator::propagateWithPath(const FreeTrajectoryState& fts, 
00031                                           const Cylinder& cylinder) const
00032 {
00033   // propagate parameters
00034   GlobalPoint x;
00035   GlobalVector p;
00036   double s = 0;
00037   bool parametersOK = propagateParametersOnCylinder(fts, cylinder,  x, p, s);
00038   if(!parametersOK) return std::make_pair(TrajectoryStateOnSurface(), 0.);
00039 
00040   // compute propagated state
00041   if (fts.hasError()) {
00042     return std::make_pair( propagatedState(fts, cylinder, jacobian(s), x,  p), s);
00043   } else {
00044     // return state without errors
00045     return std::make_pair(TSOS(GlobalTrajectoryParameters(x, p, fts.charge(),theField),
00046                           cylinder), s);
00047   }
00048 }
00049 
00050 TrajectoryStateOnSurface 
00051 StraightLinePropagator::propagatedState(const FTS& fts,
00052                                         const Surface& surface,
00053                                         const AlgebraicMatrix& jacobian,
00054                                         const LocalPoint& x, 
00055                                         const LocalVector& p) const {
00056     return propagatedState(fts,surface,asSMatrix<5,5>(jacobian),x,p);
00057 }
00058 
00059 TrajectoryStateOnSurface 
00060 StraightLinePropagator::propagatedState(const FTS& fts,
00061                                         const Surface& surface,
00062                                         const AlgebraicMatrix55& jacobian,
00063                                         const LocalPoint& x, 
00064                                         const LocalVector& p) const {
00065   if(fts.hasError()) {
00066     // propagate error
00067     TSOS tmp( fts, surface);
00068     const AlgebraicSymMatrix55 & eLocal =tmp.localError().matrix();
00069     AlgebraicSymMatrix55 lte = ROOT::Math::Similarity(jacobian,eLocal);
00070     LocalTrajectoryError eloc(lte);
00071     LocalTrajectoryParameters ltp(x, p, fts.charge());
00072     return TSOS(ltp, eloc, surface, theField);
00073   } else {
00074     // return state without errors
00075     return TSOS(LocalTrajectoryParameters(x, p, fts.charge()), surface, theField);
00076   }
00077 }
00078 
00079 TrajectoryStateOnSurface 
00080 StraightLinePropagator::propagatedState(const FTS& fts,
00081                                         const Surface& surface,
00082                                         const AlgebraicMatrix& jacobian,
00083                                         const GlobalPoint& x, 
00084                                         const GlobalVector& p) const {
00085     return propagatedState(fts,surface,asSMatrix<5,5>(jacobian),x,p);
00086 }
00087 
00088 TrajectoryStateOnSurface 
00089 StraightLinePropagator::propagatedState(const FTS& fts,
00090                                         const Surface& surface,
00091                                         const AlgebraicMatrix55& jacobian,
00092                                         const GlobalPoint& x, 
00093                                         const GlobalVector& p) const {
00094 
00095   if(fts.hasError()) {
00096     // propagate error
00097     TSOS tmp(fts, surface);
00098     const AlgebraicSymMatrix55 & eLocal =tmp.localError().matrix();
00099     AlgebraicSymMatrix55 lte = ROOT::Math::Similarity(jacobian,eLocal);
00100     LocalTrajectoryError eloc(lte);
00101 
00102     TSOS tmp2(tmp.localParameters(), eloc, surface, theField);
00103     GlobalTrajectoryParameters gtp(x, p, fts.charge(), theField);
00104     return TSOS(gtp, tmp2.cartesianError(), surface);
00105   } else {
00106     // return state without errors
00107     return TSOS(GlobalTrajectoryParameters(x, p, fts.charge(), theField), surface);
00108   }
00109 }
00110 
00111 AlgebraicMatrix StraightLinePropagator::jacobian_old(double& s) const {
00112     return asHepMatrix(jacobian(s));
00113 }
00114 
00115 AlgebraicMatrix55 StraightLinePropagator::jacobian(double& s) const {
00116   //Jacobian for 5*5 local error matrix
00117   AlgebraicMatrix55 j = AlgebraicMatrixID(); //Jacobian
00118   
00119   double dir = (propagationDirection() == alongMomentum) ? 1. : -1.;
00120   if (s*dir < 0.) return j;
00121 
00122   j(3,1) = s; 
00123   j(4,2) = s; 
00124 
00125   return j;
00126 }
00127 
00128 bool StraightLinePropagator::propagateParametersOnCylinder(const FTS& fts, 
00129                                                 const Cylinder& cylinder, 
00130                                                            GlobalPoint& x, 
00131                                                            GlobalVector& p, 
00132                                                            double& s) const {
00133   GlobalPoint sp = cylinder.toGlobal(LocalPoint(0., 0.));
00134   if (sp.x()!=0. || sp.y()!=0.) {
00135     throw PropagationException("Cannot propagate to an arbitrary cylinder");
00136   }
00137 
00138   x = fts.position();
00139   p = fts.momentum();
00140   s = cylinder.radius() - x.perp();
00141 
00142   double dir = (propagationDirection() == alongMomentum) ? 1. : -1.;
00143   if(s*dir < 0.) return false;
00144 
00145   double dt = s/p.perp();
00146   x = GlobalPoint(x.x() + p.x()*dt, 
00147                   x.y() + p.y()*dt, 
00148                   x.z() + p.z()*dt);
00149 
00150   return true;
00151 }
00152   
00153 bool StraightLinePropagator::propagateParametersOnPlane(const FTS& fts, 
00154                                                         const Plane& plane, 
00155                                                         LocalPoint& x, 
00156                                                         LocalVector& p, 
00157                                                         double& s) const {
00158   
00159   //Do extrapolation in local frame of plane
00160   //  LocalPoint sp = plane.toLocal(plane.position());
00161   x = plane.toLocal(fts.position());
00162   p = plane.toLocal(fts.momentum());
00163   s = -x.z(); // sp.z() - x.z(); local z of plane always 0
00164   
00165   //double dir = (propagationDirection() == alongMomentum) ? 1. : -1.;
00166   //if(s*dir < 0.) return false;
00167 
00168   x = LocalPoint( x.x() + (p.x()/p.z())*s,
00169                   x.y() + (p.y()/p.z())*s,
00170                   x.z() + s);    
00171 
00172   return true;
00173 }
00174 
00175 
00176 
00177 
00178 

Generated on Tue Jun 9 17:48:17 2009 for CMSSW by  doxygen 1.5.4