CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoVertex/TertiaryTracksVertexFinder/src/DistanceOfVertices2D.cc

Go to the documentation of this file.
00001 
00002 #include "RecoVertex/TertiaryTracksVertexFinder/interface/DistanceOfVertices2D.h"
00003 
00004 Measurement1D DistanceOfVertices2D::distance ( const TransientVertex & v1 , const TransientVertex & v2 ) {
00005   
00006   double FlightDistance2D = deltaV2V1(v1,v2).perp() ; 
00007   
00008   // for the significances, we need the error on the difference:
00009   // => take into account the full correlation matrices of both vertices
00010   //    (but neglect correl. between them, they are not easily available)
00011   
00012   double sigmaFlightDistance2D2;
00013   if(  FlightDistance2D > 0.000001 )
00014     sigmaFlightDistance2D2 = ( 1 / ( FlightDistance2D*FlightDistance2D ) ) * terms2D ( v1 , v2 ) ; 
00015   else
00016     sigmaFlightDistance2D2 = 0.0;
00017   
00018   double sigmaFlightDistance2D ;
00019   if ( sigmaFlightDistance2D2 >= 0 ) {
00020     sigmaFlightDistance2D = sqrt ( sigmaFlightDistance2D2 ) ;
00021   }
00022   else {
00023     std::cout << "DistanceOfVertices2D::distance : sigmaFlightDistance2D2 <= 0 : " << sigmaFlightDistance2D2 << std::endl ;
00024     sigmaFlightDistance2D = 0.0 ;
00025   }
00026 
00027   return Measurement1D ( FlightDistance2D , sigmaFlightDistance2D ) ;
00028 }
00029 
00030 
00031 Measurement1D DistanceOfVertices2D::signedDistance ( const TransientVertex & v1 , const TransientVertex & v2 , const CLHEP::Hep3Vector & direction ) {
00032   // give a sign to the distance of Vertices v1 and v2:
00033   // + if (v2-v1) is along direction, - if in opposite direction
00034   
00035   CLHEP::Hep3Vector v1ToV2 = deltaV2V1 ( v1, v2 ) ;
00036   int sign2d = -1 ;
00037   if ( ( direction.x()*v1ToV2.x() + direction.y()*v1ToV2.y() ) > 0 )  sign2d = 1 ;
00038   
00039   Measurement1D unsignedFlightDistance = distance ( v1 , v2 ) ;
00040 
00041   return Measurement1D ( sign2d * unsignedFlightDistance.value() , unsignedFlightDistance.error() ) ; 
00042 }
00043