CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DistanceOfVertices2D.cc
Go to the documentation of this file.
1 
3 
5 
6  double FlightDistance2D = deltaV2V1(v1,v2).perp() ;
7 
8  // for the significances, we need the error on the difference:
9  // => take into account the full correlation matrices of both vertices
10  // (but neglect correl. between them, they are not easily available)
11 
12  double sigmaFlightDistance2D2;
13  if( FlightDistance2D > 0.000001 )
14  sigmaFlightDistance2D2 = ( 1 / ( FlightDistance2D*FlightDistance2D ) ) * terms2D ( v1 , v2 ) ;
15  else
16  sigmaFlightDistance2D2 = 0.0;
17 
18  double sigmaFlightDistance2D ;
19  if ( sigmaFlightDistance2D2 >= 0 ) {
20  sigmaFlightDistance2D = sqrt ( sigmaFlightDistance2D2 ) ;
21  }
22  else {
23  std::cout << "DistanceOfVertices2D::distance : sigmaFlightDistance2D2 <= 0 : " << sigmaFlightDistance2D2 << std::endl ;
24  sigmaFlightDistance2D = 0.0 ;
25  }
26 
27  return Measurement1D ( FlightDistance2D , sigmaFlightDistance2D ) ;
28 }
29 
30 
31 Measurement1D DistanceOfVertices2D::signedDistance ( const TransientVertex & v1 , const TransientVertex & v2 , const CLHEP::Hep3Vector & direction ) {
32  // give a sign to the distance of Vertices v1 and v2:
33  // + if (v2-v1) is along direction, - if in opposite direction
34 
35  CLHEP::Hep3Vector v1ToV2 = deltaV2V1 ( v1, v2 ) ;
36  int sign2d = -1 ;
37  if ( ( direction.x()*v1ToV2.x() + direction.y()*v1ToV2.y() ) > 0 ) sign2d = 1 ;
38 
39  Measurement1D unsignedFlightDistance = distance ( v1 , v2 ) ;
40 
41  return Measurement1D ( sign2d * unsignedFlightDistance.value() , unsignedFlightDistance.error() ) ;
42 }
43 
double terms2D(const TransientVertex &v1, const TransientVertex &v2)
CLHEP::Hep3Vector deltaV2V1(const TransientVertex &v1, const TransientVertex &v2)
double error() const
Definition: Measurement1D.h:30
virtual Measurement1D distance(const TransientVertex &, const TransientVertex &)
T sqrt(T t)
Definition: SSEVec.h:28
virtual Measurement1D signedDistance(const TransientVertex &, const TransientVertex &, const CLHEP::Hep3Vector &)
double value() const
Definition: Measurement1D.h:28
tuple cout
Definition: gather_cfg.py:41