CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/TrackingTools/TrajectoryState/src/FreeTrajectoryState.cc

Go to the documentation of this file.
00001 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00002 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCurvilinearToCartesian.h"
00003 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCartesianToCurvilinear.h"
00004 
00005 #include <cmath>
00006 
00007 
00008 void FreeTrajectoryState::missingError() {
00009  throw TrajectoryStateException(
00010       "FreeTrajectoryState: attempt to access errors when none available");
00011 }
00012 
00013 // implementation of non-trivial methods of FreeTrajectoryState
00014 
00015 // Warning: these methods violate constness
00016 
00017 // convert curvilinear errors to cartesian
00018 void FreeTrajectoryState::createCartesianError() const{
00019   
00020   JacobianCurvilinearToCartesian curv2Cart(theGlobalParameters);
00021   const AlgebraicMatrix65& jac = curv2Cart.jacobian();
00022 
00023   theCartesianError = 
00024     ROOT::Math::Similarity(jac, theCurvilinearError.matrix());
00025   theCartesianErrorValid = true;
00026 }
00027 
00028 // convert cartesian errors to curvilinear
00029 void FreeTrajectoryState::createCurvilinearError() const{
00030   
00031   JacobianCartesianToCurvilinear cart2Curv(theGlobalParameters);
00032   const AlgebraicMatrix56& jac = cart2Curv.jacobian();
00033   
00034   theCurvilinearError = 
00035     ROOT::Math::Similarity(jac, theCartesianError.matrix());
00036   theCurvilinearErrorValid = true;
00037 } 
00038 
00039 
00040 void FreeTrajectoryState::rescaleError(double factor) {
00041   bool zeroField = parameters().magneticFieldInInverseGeV(GlobalPoint(0,0,0)).mag2()==0;
00042   if unlikely(zeroField) {
00043     if (theCartesianErrorValid){
00044       if (!theCurvilinearErrorValid) createCurvilinearError();
00045       theCurvilinearError.zeroFieldScaling(factor*factor);
00046       createCartesianError();
00047     }else
00048       if (theCurvilinearErrorValid) theCurvilinearError.zeroFieldScaling(factor*factor);
00049   } else{
00050     if (theCartesianErrorValid){
00051       theCartesianError *= (factor*factor);
00052     }
00053     if (theCurvilinearErrorValid){
00054       theCurvilinearError *= (factor*factor);
00055     }
00056   }
00057 }
00058 
00059 
00060 // check if trajectory can reach given radius
00061 
00062 bool FreeTrajectoryState::canReach(double radius) const {
00063   GlobalPoint x = position();
00064   GlobalVector p = momentum().unit();
00065   double rho = transverseCurvature()*p.perp();
00066   double rx = rho*x.x();
00067   double ry = rho*x.y();
00068   double rr = rho*radius;
00069   double ax = p.x()*rx + p.y()*ry;
00070   double ay = p.x()*ry - p.y()*rx + p.perp2();
00071   double cospsi = (.5*(rx*rx + ry*ry - rr*rr) + ay)/sqrt(ax*ax + ay*ay);
00072   return fabs(cospsi) <= 1.;
00073 }
00074 
00075 
00076 
00077 
00078 
00079 
00080