CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

VertexDistanceXY Class Reference

#include <VertexDistanceXY.h>

Inheritance diagram for VertexDistanceXY:
VertexDistance

List of all members.

Public Member Functions

virtual VertexDistanceXYclone () const
virtual Measurement1D signedDistance (const reco::Vertex &primVtx, const reco::Vertex &secVtx, const GlobalVector &momentum) const
 VertexDistanceXY ()

Private Member Functions

virtual float compatibility (const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
virtual Measurement1D distance (const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const

Private Attributes

AlgebraicSymMatrix theNullMatrix

Detailed Description

Computes the distance between two vertices as the chi-squared formed with their positions in the transverse plane.

Definition at line 11 of file VertexDistanceXY.h.


Constructor & Destructor Documentation

VertexDistanceXY::VertexDistanceXY ( ) [inline]

Definition at line 15 of file VertexDistanceXY.h.

Referenced by clone().

: theNullMatrix(3, 0) {}

Member Function Documentation

virtual VertexDistanceXY* VertexDistanceXY::clone ( void  ) const [inline, virtual]

Implements VertexDistance.

Definition at line 29 of file VertexDistanceXY.h.

References VertexDistanceXY().

  {
    return new VertexDistanceXY(*this);
  }
float VertexDistanceXY::compatibility ( const GlobalPoint vtx1Position,
const GlobalError vtx1PositionError,
const GlobalPoint vtx2Position,
const GlobalError vtx2PositionError 
) const [private, virtual]

Implements VertexDistance.

Definition at line 49 of file VertexDistanceXY.cc.

References diffTreeTool::diff, error, Exception, GlobalErrorBase< T, ErrorWeightType >::matrix(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

{
  // error matrix of residuals
  AlgebraicSymMatrix err1 = vtx1PositionError.matrix();
  AlgebraicSymMatrix err2 = vtx2PositionError.matrix();
  AlgebraicSymMatrix error(2, 0); 
  error[0][0] = err1[0][0] + err2[0][0];
  error[0][1] = err1[0][1] + err2[0][1];
  error[1][1] = err1[1][1] + err2[1][1];
  if (error == theNullMatrix) return FLT_MAX;

  // position residuals
  GlobalVector diff = vtx2Position - vtx1Position;
  AlgebraicVector vDiff(2);
  vDiff[0] = diff.x();
  vDiff[1] = diff.y();

  // Invert error matrix of residuals
  int ifail;
  error.invert(ifail);
  if (ifail != 0) {
    throw cms::Exception("VertexDistanceXY::matrix inversion problem");
  }

  return error.similarity(vDiff);
}
Measurement1D VertexDistanceXY::distance ( const GlobalPoint vtx1Position,
const GlobalError vtx1PositionError,
const GlobalPoint vtx2Position,
const GlobalError vtx2PositionError 
) const [private, virtual]

Implements VertexDistance.

Definition at line 25 of file VertexDistanceXY.cc.

References diffTreeTool::diff, error, GlobalErrorBase< T, ErrorWeightType >::matrix(), funct::pow(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

{
    AlgebraicSymMatrix error = vtx1PositionError.matrix()
      + vtx2PositionError.matrix();
    GlobalVector diff = vtx1Position - vtx2Position;
    AlgebraicVector vDiff(3);
    vDiff[0] = diff.x();
    vDiff[1] = diff.y();
    vDiff[2] = 0.;
    
    double dist=sqrt(pow(diff.x(),2)+pow(diff.y(),2));
    
    double err2 = error.similarity(vDiff);
    double err  = 0;
    if( dist != 0) err = sqrt(err2)/dist;
       
    return Measurement1D(dist,err);
}
Measurement1D VertexDistanceXY::signedDistance ( const reco::Vertex primVtx,
const reco::Vertex secVtx,
const GlobalVector momentum 
) const [virtual]

The signed distance is computed using a vector from the primary to the secondary vertex and a given reference vector. The sign is determined by the scalar product of the x,y component of the vector connecting the vertices and the reference vector: if the scalar product is greater than zero, the sign is +1, else -1

Implements VertexDistance.

Definition at line 11 of file VertexDistanceXY.cc.

References diffTreeTool::diff, Measurement1D::error(), reco::Vertex::position(), Measurement1D::value(), PV3DBase< T, PVType, FrameType >::x(), Basic3DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), and Basic3DVector< T >::y().

{
  Measurement1D unsignedDistance = distance(vtx1, vtx2);
  Basic3DVector<float> diff = Basic3DVector<float> (vtx2.position()) - 
    Basic3DVector<float> (vtx1.position());
  if ((momentum.x()*diff.x() + momentum.y()*diff.y()) < 0 )
    return Measurement1D(-1.0*unsignedDistance.value(),unsignedDistance.error());
  return unsignedDistance;
}

Member Data Documentation

Definition at line 40 of file VertexDistanceXY.h.