CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/TrackingTools/GeomPropagators/src/StraightLinePropagator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GeomPropagators/interface/StraightLinePropagator.h"
00002 
00003 #include "DataFormats/Math/interface/AlgebraicROOTObjects.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 AlgebraicMatrix55& jacobian,
00054                                         const LocalPoint& x, 
00055                                         const LocalVector& p) const {
00056   if(fts.hasError()) {
00057     // propagate error
00058     TSOS tmp( fts, surface);
00059     const AlgebraicSymMatrix55 & eLocal =tmp.localError().matrix();
00060     AlgebraicSymMatrix55 lte = ROOT::Math::Similarity(jacobian,eLocal);
00061     LocalTrajectoryError eloc(lte);
00062     LocalTrajectoryParameters ltp(x, p, fts.charge());
00063     return TSOS(ltp, eloc, surface, theField);
00064   } else {
00065     // return state without errors
00066     return TSOS(LocalTrajectoryParameters(x, p, fts.charge()), surface, theField);
00067   }
00068 }
00069 
00070 TrajectoryStateOnSurface 
00071 StraightLinePropagator::propagatedState(const FTS& fts,
00072                                         const Surface& surface,
00073                                         const AlgebraicMatrix55& jacobian,
00074                                         const GlobalPoint& x, 
00075                                         const GlobalVector& p) const {
00076 
00077   if(fts.hasError()) {
00078     // propagate error
00079     TSOS tmp(fts, surface);
00080     const AlgebraicSymMatrix55 & eLocal =tmp.localError().matrix();
00081     AlgebraicSymMatrix55 lte = ROOT::Math::Similarity(jacobian,eLocal);
00082     LocalTrajectoryError eloc(lte);
00083 
00084     TSOS tmp2(tmp.localParameters(), eloc, surface, theField);
00085     GlobalTrajectoryParameters gtp(x, p, fts.charge(), theField);
00086     return TSOS(gtp, tmp2.cartesianError(), surface);
00087   } else {
00088     // return state without errors
00089     return TSOS(GlobalTrajectoryParameters(x, p, fts.charge(), theField), surface);
00090   }
00091 }
00092 
00093 AlgebraicMatrix55 StraightLinePropagator::jacobian(double& s) const {
00094   //Jacobian for 5*5 local error matrix
00095   AlgebraicMatrix55 j = AlgebraicMatrixID(); //Jacobian
00096   
00097   double dir = (propagationDirection() == alongMomentum) ? 1. : -1.;
00098   if (s*dir < 0.) return j;
00099 
00100   j(3,1) = s; 
00101   j(4,2) = s; 
00102 
00103   return j;
00104 }
00105 
00106 bool StraightLinePropagator::propagateParametersOnCylinder(const FTS& fts, 
00107                                                 const Cylinder& cylinder, 
00108                                                            GlobalPoint& x, 
00109                                                            GlobalVector& p, 
00110                                                            double& s) const {
00111   GlobalPoint sp = cylinder.toGlobal(LocalPoint(0., 0.));
00112   if (sp.x()!=0. || sp.y()!=0.) {
00113     throw PropagationException("Cannot propagate to an arbitrary cylinder");
00114   }
00115 
00116   x = fts.position();
00117   p = fts.momentum();
00118   s = cylinder.radius() - x.perp();
00119 
00120   double dir = (propagationDirection() == alongMomentum) ? 1. : -1.;
00121   if(s*dir < 0.) return false;
00122 
00123   double dt = s/p.perp();
00124   x = GlobalPoint(x.x() + p.x()*dt, 
00125                   x.y() + p.y()*dt, 
00126                   x.z() + p.z()*dt);
00127 
00128   return true;
00129 }
00130   
00131 bool StraightLinePropagator::propagateParametersOnPlane(const FTS& fts, 
00132                                                         const Plane& plane, 
00133                                                         LocalPoint& x, 
00134                                                         LocalVector& p, 
00135                                                         double& s) const {
00136   
00137   //Do extrapolation in local frame of plane
00138   //  LocalPoint sp = plane.toLocal(plane.position());
00139   x = plane.toLocal(fts.position());
00140   p = plane.toLocal(fts.momentum());
00141   s = -x.z(); // sp.z() - x.z(); local z of plane always 0
00142   
00143   //double dir = (propagationDirection() == alongMomentum) ? 1. : -1.;
00144   //if(s*dir < 0.) return false;
00145   if ((p.x() != 0 || p.y() != 0) && p.z() == 0 && s!= 0) return false;
00146 
00147   x = LocalPoint( x.x() + (p.x()/p.z())*s,
00148                   x.y() + (p.y()/p.z())*s,
00149                   x.z() + s);    
00150 
00151   return true;
00152 }
00153 
00154 
00155 
00156 
00157