CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "RecoVertex/KalmanVertexFit/interface/KVFHelper.h"
00002 using namespace std;
00003 
00004 template <unsigned int N>
00005 double KVFHelper<N>::vertexChi2(const CachingVertex<N> & vertexA, 
00006         const CachingVertex<N> & vertexB) const
00007 {
00008   return vertexChi2(vertexA.vertexState(), vertexB.vertexState());
00009 }
00010 
00011 
00012 template <unsigned int N>
00013 double KVFHelper<N>::vertexChi2(const VertexState & vertexA,
00014         const VertexState & vertexB) const
00015 {
00016 // std::cout <<"Start\n";
00017   GlobalPoint inPosition = vertexA.position();
00018   GlobalPoint fnPosition = vertexB.position();
00019 //   std::cout << inPosition<< fnPosition<<std::endl;
00020 
00021   AlgebraicVector3 oldVertexPositionV;
00022   oldVertexPositionV(0) = inPosition.x();
00023   oldVertexPositionV(1) = inPosition.y();
00024   oldVertexPositionV(2) = inPosition.z();
00025 
00026   AlgebraicVector3 newVertexPositionV;
00027   newVertexPositionV(0) = fnPosition.x();
00028   newVertexPositionV(1) = fnPosition.y();
00029   newVertexPositionV(2) = fnPosition.z();
00030 
00031 
00032   AlgebraicVector3 positionResidual = newVertexPositionV - oldVertexPositionV;
00033 
00034   return ROOT::Math::Similarity(positionResidual, vertexA.weight().matrix_new());
00035 }
00036 
00037 
00038 template <unsigned int N>
00039 typename KVFHelper<N>::BDpair KVFHelper<N>::trackParameterChi2(const RefCountedVertexTrack track) const
00040 {
00041   return trackParameterChi2(track->linearizedTrack(), track->refittedState());
00042 }
00043 
00044 
00045 template <unsigned int N>
00046 typename KVFHelper<N>::BDpair KVFHelper<N>::trackParameterChi2(
00047         const RefCountedLinearizedTrackState linTrack,
00048         const RefCountedRefittedTrackState refittedTrackState) const
00049 {
00050 
00051   typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepSym<double,N> > AlgebraicSymMatrixNN;
00052   typedef ROOT::Math::SVector<double,N> AlgebraicVectorN;
00053 
00054   AlgebraicVectorN parameterResiduals = linTrack->predictedStateParameters() -
00055         linTrack->refittedParamFromEquation(refittedTrackState);
00056   linTrack->checkParameters(parameterResiduals);
00057   int error;
00058   float lChi2 = ROOT::Math::Similarity(parameterResiduals, linTrack->predictedStateWeight(error));
00059   if (error != 0) return BDpair(false, -1.);
00060   return BDpair(true, lChi2);
00061 }
00062 
00063 template class KVFHelper<5>;
00064 template class KVFHelper<6>;