CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/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 "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include "MagneticField/Engine/interface/MagneticField.h"
00008 
00009 #include <cmath>
00010 #include<sstream>
00011 
00012 
00013 void FreeTrajectoryState::missingError() const {
00014   std::stringstream form;
00015   form<< "FreeTrajectoryState: attempt to access errors when none available" <<
00016     "\nCurvilinear error valid/values :"<< theCurvilinearError.valid() << "\n" 
00017       <<  theCurvilinearError.matrix();
00018     edm::LogWarning("FreeTrajectoryState") << "(was exception) " << form.str();
00019 //  throw TrajectoryStateException(form.str());
00020 }
00021 
00022 // implementation of non-trivial methods of FreeTrajectoryState
00023 
00024 // Warning: these methods violate constness
00025 
00026 // convert curvilinear errors to cartesian
00027 void FreeTrajectoryState::createCartesianError(CartesianTrajectoryError & aCartesianError) const{
00028   
00029   JacobianCurvilinearToCartesian curv2Cart(theGlobalParameters);
00030   const AlgebraicMatrix65& jac = curv2Cart.jacobian();
00031 
00032   aCartesianError = 
00033     ROOT::Math::Similarity(jac, theCurvilinearError.matrix());
00034 }
00035 
00036 // convert cartesian errors to curvilinear
00037 void FreeTrajectoryState::createCurvilinearError(CartesianTrajectoryError const& aCartesianError) const{
00038   
00039   JacobianCartesianToCurvilinear cart2Curv(theGlobalParameters);
00040   const AlgebraicMatrix56& jac = cart2Curv.jacobian();
00041   
00042   theCurvilinearError = 
00043     ROOT::Math::Similarity(jac, aCartesianError.matrix());
00044 
00045 } 
00046 
00047 
00048 void FreeTrajectoryState::rescaleError(double factor) {
00049   if unlikely(!hasError()) return;
00050   bool zeroField = (parameters().magneticField().nominalValue()==0);  
00051   if unlikely(zeroField)  theCurvilinearError.zeroFieldScaling(factor*factor);
00052   else theCurvilinearError *= (factor*factor);
00053 }
00054 
00055 // check if trajectory can reach given radius
00056 
00057 bool FreeTrajectoryState::canReach(double radius) const {
00058   GlobalPoint x = position();
00059   GlobalVector p = momentum().unit();
00060   double rho = transverseCurvature()*p.perp();
00061   double rx = rho*x.x();
00062   double ry = rho*x.y();
00063   double rr = rho*radius;
00064   double ax = p.x()*rx + p.y()*ry;
00065   double ay = p.x()*ry - p.y()*rx + p.perp2();
00066   double cospsi = (.5*(rx*rx + ry*ry - rr*rr) + ay)/sqrt(ax*ax + ay*ay);
00067   return fabs(cospsi) <= 1.;
00068 }
00069 
00070 
00071 
00072 
00073 
00074 
00075