CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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   ((FreeTrajectoryState*)this)->theCartesianError = 
00024     ROOT::Math::Similarity(jac, theCurvilinearError.matrix());
00025 
00026   ((FreeTrajectoryState*)this)->theCartesianErrorValid = true;
00027 }
00028 
00029 // convert cartesian errors to curvilinear
00030 void FreeTrajectoryState::createCurvilinearError() const{
00031   
00032   JacobianCartesianToCurvilinear cart2Curv(theGlobalParameters);
00033   const AlgebraicMatrix56& jac = cart2Curv.jacobian();
00034   
00035   ((FreeTrajectoryState*)this)->theCurvilinearError = 
00036     ROOT::Math::Similarity(jac, theCartesianError.matrix());
00037   ((FreeTrajectoryState*)this)->theCurvilinearErrorValid = true;
00038 } 
00039 
00040 
00041 void FreeTrajectoryState::rescaleError(double factor) {
00042   bool zeroField = parameters().magneticFieldInInverseGeV(GlobalPoint(0,0,0)).mag2()==0;
00043   if (zeroField) {
00044     if (theCartesianErrorValid){
00045       if (!theCurvilinearErrorValid) createCurvilinearError();
00046       theCurvilinearError.zeroFieldScaling(factor*factor);
00047       createCartesianError();
00048     }else
00049       if (theCurvilinearErrorValid) theCurvilinearError.zeroFieldScaling(factor*factor);
00050   } else{
00051     if (theCartesianErrorValid){
00052       theCartesianError *= (factor*factor);
00053     }
00054     if (theCurvilinearErrorValid){
00055       theCurvilinearError *= (factor*factor);
00056     }
00057   }
00058 }
00059 
00060 
00061 // check if trajectory can reach given radius
00062 
00063 bool FreeTrajectoryState::canReach(double radius) const {
00064   GlobalPoint x = position();
00065   GlobalVector p = momentum().unit();
00066   double rho = transverseCurvature()*p.perp();
00067   double rx = rho*x.x();
00068   double ry = rho*x.y();
00069   double rr = rho*radius;
00070   double ax = p.x()*rx + p.y()*ry;
00071   double ay = p.x()*ry - p.y()*rx + p.perp2();
00072   double cospsi = (.5*(rx*rx + ry*ry - rr*rr) + ay)/sqrt(ax*ax + ay*ay);
00073   return fabs(cospsi) <= 1.;
00074 }
00075 
00076 
00077 
00078 
00079 
00080 
00081