CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/TrackingTools/TrajectoryState/src/TrajectoryStateTransform.cc

Go to the documentation of this file.
00001 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00002 #include "DataFormats/TrackReco/interface/Track.h" 
00003 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00004 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" 
00005 #include "DataFormats/GeometrySurface/interface/Surface.h" 
00006 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00007 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00008 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00009 
00010 using namespace SurfaceSideDefinition;
00011 
00012 PTrajectoryStateOnDet* 
00013 TrajectoryStateTransform::persistentState( const TrajectoryStateOnSurface& ts,
00014                                            unsigned int detid) const
00015 {
00016   AlgebraicSymMatrix55 m = ts.localError().matrix();
00017   
00018   int dim = 5; 
00019 
00020   float localErrors[15];
00021   int k = 0;
00022   for (int i=0; i<dim; i++) {
00023     for (int j=0; j<=i; j++) {
00024       localErrors[k++] = m(i,j);
00025     }
00026   }
00027   int surfaceSide = static_cast<int>(ts.surfaceSide());
00028 
00029   return new PTrajectoryStateOnDet( ts.localParameters(),
00030                                     localErrors, detid,
00031                                     surfaceSide);
00032 }
00033 
00034 TrajectoryStateOnSurface 
00035 TrajectoryStateTransform::transientState( const PTrajectoryStateOnDet& ts,
00036                                           const Surface* surface,
00037                                           const MagneticField* field) const
00038 {
00039   int dim = 5;
00040   AlgebraicSymMatrix55 m;
00041   const std::vector<float> &errs = ts.errorMatrix();  
00042   int k = 0;
00043   for (int i=0; i<dim; i++) {
00044     for (int j=0; j<=i; j++) {
00045       m(i,j) = errs[k++];       // NOTE: here we do a cast float => double.     
00046     }
00047   }
00048   
00049 
00050   return TrajectoryStateOnSurface( ts.parameters(),
00051                                    LocalTrajectoryError(m), 
00052                                    *surface, field,
00053                                    static_cast<SurfaceSide>(ts.surfaceSide()));
00054 
00055 }
00056 
00057 FreeTrajectoryState TrajectoryStateTransform::initialFreeState( const reco::Track& tk,
00058                                                               const MagneticField* field) const
00059 {
00060   Basic3DVector<float> pos( tk.vertex());
00061   GlobalPoint gpos( pos);
00062   Basic3DVector<float> mom( tk.momentum());
00063   GlobalVector gmom( mom);
00064   GlobalTrajectoryParameters par( gpos, gmom, tk.charge(), field);
00065   CurvilinearTrajectoryError err( tk.covariance());
00066   return FreeTrajectoryState( par, err);
00067 }
00068 
00069 FreeTrajectoryState TrajectoryStateTransform::innerFreeState( const reco::Track& tk,
00070                                                               const MagneticField* field) const
00071 {
00072   Basic3DVector<float> pos( tk.innerPosition());
00073   GlobalPoint gpos( pos);
00074   Basic3DVector<float> mom( tk.innerMomentum());
00075   GlobalVector gmom( mom);
00076   GlobalTrajectoryParameters par( gpos, gmom, tk.charge(), field);
00077   CurvilinearTrajectoryError err( tk.extra()->innerStateCovariance());
00078   return FreeTrajectoryState( par, err);
00079 }
00080 
00081 
00082 FreeTrajectoryState TrajectoryStateTransform::outerFreeState( const reco::Track& tk,
00083                                                               const MagneticField* field) const
00084 {
00085   Basic3DVector<float> pos( tk.outerPosition());
00086   GlobalPoint gpos( pos);
00087   Basic3DVector<float> mom( tk.outerMomentum());
00088   GlobalVector gmom( mom);
00089   GlobalTrajectoryParameters par( gpos, gmom, tk.charge(), field);
00090   CurvilinearTrajectoryError err( tk.extra()->outerStateCovariance());
00091   return FreeTrajectoryState( par, err);
00092 }
00093 
00094 
00095 TrajectoryStateOnSurface TrajectoryStateTransform::innerStateOnSurface( const reco::Track& tk, 
00096                                                                         const TrackingGeometry& geom,
00097                                                                         const MagneticField* field) const
00098 {
00099   const Surface& surface = geom.idToDet( DetId( tk.extra()->innerDetId()))->surface();
00100   return TrajectoryStateOnSurface( innerFreeState( tk, field), surface);
00101 }
00102 
00103 TrajectoryStateOnSurface TrajectoryStateTransform::outerStateOnSurface( const reco::Track& tk, 
00104                                                                         const TrackingGeometry& geom,
00105                                                                         const MagneticField* field) const
00106 {
00107   const Surface& surface = geom.idToDet( DetId( tk.extra()->outerDetId()))->surface();
00108   return TrajectoryStateOnSurface( outerFreeState( tk, field), surface);
00109 }