CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoVertex/TertiaryTracksVertexFinder/src/GetLineCovMatrix.cc

Go to the documentation of this file.
00001 
00002 #include "RecoVertex/TertiaryTracksVertexFinder/interface/GetLineCovMatrix.h"
00003 
00004 GetLineCovMatrix::GetLineCovMatrix(GlobalPoint pointOne, GlobalPoint pointTwo, GlobalError ErrorOne, GlobalError ErrorTwo)
00005 {
00006 
00007   PointOne = pointOne;
00008   PointTwo = pointTwo;
00009 
00010   CombinedErrorMatrix = CLHEP::HepMatrix(6, 6, 0);
00011  
00012   CombinedErrorMatrix[0][0] = ErrorOne.cxx();
00013   CombinedErrorMatrix[1][0] = ErrorOne.cyx(); 
00014   CombinedErrorMatrix[0][1] = ErrorOne.cyx();
00015   CombinedErrorMatrix[1][1] = ErrorOne.cyy();
00016   CombinedErrorMatrix[2][0] = ErrorOne.czx();
00017   CombinedErrorMatrix[0][2] = ErrorOne.czx(); 
00018   CombinedErrorMatrix[2][1] = ErrorOne.czy();
00019   CombinedErrorMatrix[1][2] = ErrorOne.czy(); 
00020   CombinedErrorMatrix[2][2] = ErrorOne.czz();
00021     
00022   CombinedErrorMatrix[3][3] = ErrorTwo.cxx();
00023   CombinedErrorMatrix[4][3] = ErrorTwo.cyx(); 
00024   CombinedErrorMatrix[3][4] = ErrorTwo.cyx();
00025   CombinedErrorMatrix[4][4] = ErrorTwo.cyy();
00026   CombinedErrorMatrix[5][3] = ErrorTwo.czx();
00027   CombinedErrorMatrix[3][5] = ErrorTwo.czx(); 
00028   CombinedErrorMatrix[5][4] = ErrorTwo.czy();
00029   CombinedErrorMatrix[4][5] = ErrorTwo.czy(); 
00030   CombinedErrorMatrix[5][5] = ErrorTwo.czz();
00031 
00032   B = CLHEP::HepMatrix(3, 6, 0);  
00033 }
00034 
00035 
00036 GlobalError GetLineCovMatrix::GetMatrix(GlobalPoint PointThree) 
00037 { 
00038   // the linear equation is  K = PointOne + (PointTwo-PointOne)*s
00039   double s;  
00040   if( !fabs(PointTwo.x() - PointOne.x()) < 0.00000001 ) 
00041     s =  (PointThree.x() - PointOne.x()) / (PointTwo.x() -  PointOne.x()) ; 
00042   else {
00043     if( !fabs(PointTwo.y() - PointOne.y()) < 0.00000001 ) 
00044       s =  (PointThree.y() - PointOne.y()) / (PointTwo.y() -  PointOne.y()) ;   
00045     else { 
00046       if( !fabs(PointTwo.z() - PointOne.z()) < 0.00000001 ) 
00047         s =  (PointThree.z() - PointOne.z()) / (PointTwo.z() -  PointOne.z()) ;
00048       else {
00049         GlobalError EmptyError(0, 0, 0, 0, 0, 0);
00050         return EmptyError;
00051       }
00052     }
00053   }
00054 
00055   B[0][0] = 1-s;    
00056   B[0][3] = s;
00057   B[1][1] = 1-s;   
00058   B[1][4] = s;
00059   B[2][2] = 1-s;  
00060   B[2][5] = s;
00061 
00062   CLHEP::HepMatrix Result = B * CombinedErrorMatrix * B.T();
00063   
00064   GlobalError TheGlobalError( Result[0][0],  Result[1][0],  Result[1][1], Result[2][0],  Result[2][1],  Result[2][2] );
00065   return TheGlobalError;
00066 }
00067