CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoVertex/TertiaryTracksVertexFinder/interface/DistanceOfVertices.h

Go to the documentation of this file.
00001 #ifndef DISTANCEOFVERTICES_H  
00002 #define DISTANCEOFVERTICES_H 
00003 
00004 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00005 
00006 #include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
00007 #include "CLHEP/Vector/ThreeVector.h"
00008 
00009 // class to compute distance, error, significance of 2 Vertices
00010 // This is the ABC
00011 
00012 class DistanceOfVertices {
00013 
00014 public:
00015 
00016   DistanceOfVertices  () {}
00017   virtual ~DistanceOfVertices () {}
00018 
00019   virtual Measurement1D distance       ( const TransientVertex & , const TransientVertex &                      ) = 0 ;
00020   virtual Measurement1D signedDistance ( const TransientVertex & , const TransientVertex & , const CLHEP::Hep3Vector & ) = 0 ;
00021   
00022   
00023 protected:
00024 
00025   CLHEP::Hep3Vector   deltaV2V1 ( const TransientVertex & v1 , const TransientVertex & v2 ) {
00026     return CLHEP::Hep3Vector ( v2.position().x() - v1.position().x() ,
00027                         v2.position().y() - v1.position().y() ,
00028                         v2.position().z() - v1.position().z() ) ;
00029   }
00030 
00031   
00032   double terms2D ( const TransientVertex & v1 , const TransientVertex & v2 ) {
00033     // better to have meaningful variables ...
00034     double deltaX = deltaV2V1(v1,v2).x() ;
00035     double deltaY = deltaV2V1(v1,v2).y() ;
00036 
00037     // covariance matrix of the diff. = sum of ind. cov. matr.
00038     GlobalError covDelta = v1.positionError() + v2.positionError() ;
00039 
00040     double covDeltaXX = covDelta.cxx() ;
00041     double covDeltaYY = covDelta.cyy() ;
00042     double covDeltaXY = covDelta.cyx() ;
00043 
00044     return (   deltaX*deltaX * covDeltaXX  +
00045                deltaY*deltaY * covDeltaYY  +
00046              2*deltaX*deltaY * covDeltaXY    ) ; 
00047   }
00048 
00049 
00050   double terms3D ( const TransientVertex & v1 , const TransientVertex & v2 ) {
00051     //
00052     double deltaX = deltaV2V1(v1,v2).x() ;
00053     double deltaY = deltaV2V1(v1,v2).y() ;
00054     double deltaZ = deltaV2V1(v1,v2).z() ;
00055 
00056     // covariance matrix of the diff. = sum of ind. cov. matr.
00057     GlobalError covDelta = v1.positionError() + v2.positionError() ;
00058 
00059     double covDeltaZZ = covDelta.czz() ;
00060     double covDeltaXZ = covDelta.czx() ;
00061     double covDeltaYZ = covDelta.czy() ;
00062 
00063     
00064     return (   terms2D ( v1 , v2 )         +
00065                deltaZ*deltaZ * covDeltaZZ  +
00066              2*deltaX*deltaZ * covDeltaXZ  +  
00067              2*deltaY*deltaZ * covDeltaYZ   ) ;
00068   }
00069   
00070 };
00071 #endif
00072