CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoVertex/KalmanVertexFit/src/KalmanTrackToTrackCovCalculator.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KalmanVertexFit/interface/KalmanTrackToTrackCovCalculator.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 
00004 template <unsigned int N>
00005 typename CachingVertex<N>::TrackToTrackMap
00006 KalmanTrackToTrackCovCalculator<N>::operator() 
00007         (const CachingVertex<N> & vertex) const
00008 {
00009   typedef ROOT::Math::SMatrix<double,N,3,ROOT::Math::MatRepStd<double,N,3> > AlgebraicMatrixN3;
00010   typedef ROOT::Math::SMatrix<double,N,N-2,ROOT::Math::MatRepStd<double,N,N-2> > AlgebraicMatrixNM;
00011   typedef ROOT::Math::SMatrix<double,N-2,3,ROOT::Math::MatRepStd<double,N-2,3> > AlgebraicMatrixM3;
00012   typedef ROOT::Math::SMatrix<double,3,N-2,ROOT::Math::MatRepStd<double,3,N-2> > AlgebraicMatrix3M;
00013   typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepSym<double,N> > AlgebraicSymMatrixNN;
00014   typedef ROOT::Math::SMatrix<double,N-2,N-2,ROOT::Math::MatRepSym<double,N-2> > AlgebraicSymMatrixMM;
00015   typedef ROOT::Math::SMatrix<double,N-2,N-2,ROOT::Math::MatRepStd<double,N-2,N-2> > AlgebraicMatrixMM;
00016 
00017   typename CachingVertex<N>::TrackToTrackMap returnMap;
00018   int ifail = 0;
00019   std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
00020 
00021 //vertex initial data needed
00022   AlgebraicSymMatrix33 vertexC = vertex.error().matrix_new();
00023 
00024   for(typename std::vector<RefCountedVertexTrack>::iterator i = tracks.begin(); 
00025         i != tracks.end(); i++)
00026   {        
00027     const AlgebraicMatrixN3 & leftA = (*i)->linearizedTrack()->positionJacobian();
00028     const AlgebraicMatrixNM & leftB = (*i)->linearizedTrack()->momentumJacobian();
00029     AlgebraicSymMatrixNN leftG = (*i)->linearizedTrack()->predictedStateWeight(ifail);
00030     AlgebraicSymMatrixMM leftW = ROOT::Math::SimilarityT(leftB,leftG);
00031 
00032     ifail = ! leftW.Invert();
00033     if(ifail != 0) throw VertexException
00034         ("KalmanTrackToTrackCovarianceCalculator::leftW matrix inversion failed");
00035     AlgebraicMatrixM3 leftPart = leftW * (ROOT::Math::Transpose(leftB)) * leftG * leftA;
00036     typename CachingVertex<N>::TrackMap internalMap;
00037     for(typename std::vector<RefCountedVertexTrack>::iterator j = tracks.begin(); j != tracks.end(); j++)
00038     {
00039 
00040       if(*i < *j)
00041       {
00042 
00043         const AlgebraicMatrixN3 & rightA = (*j)->linearizedTrack()->positionJacobian();
00044         const AlgebraicMatrixNM & rightB = (*j)->linearizedTrack()->momentumJacobian();
00045         AlgebraicSymMatrixNN rightG = (*j)->linearizedTrack()->predictedStateWeight(ifail);
00046         AlgebraicSymMatrixMM rightW = ROOT::Math::SimilarityT(rightB,rightG);
00047 
00048         ifail = ! rightW.Invert();
00049 
00050         if(ifail != 0) throw VertexException
00051           ("KalmanTrackToTrackCovarianceCalculator::rightW matrix inversion failed");
00052         AlgebraicMatrix3M rightPart = (ROOT::Math::Transpose(rightA)) * rightG * rightB * rightW;
00053         internalMap[(*j)] = leftPart * vertexC * rightPart;
00054       }       
00055     }        
00056     returnMap[*i] = internalMap;
00057   }
00058   return returnMap;
00059 }
00060 
00061 template class KalmanTrackToTrackCovCalculator<5>;
00062 template class KalmanTrackToTrackCovCalculator<6>;