#include <RecoVertex/VertexTools/interface/VertexDistanceXY.h>
Public Member Functions | |
virtual VertexDistanceXY * | clone () const |
virtual Measurement1D | signedDistance (const reco::Vertex &primVtx, const reco::Vertex &secVtx, const GlobalVector &momentum) const |
The signed distance is computed using a vector from the primary to the secondary vertex and a given reference vector. | |
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 |
Definition at line 11 of file VertexDistanceXY.h.
VertexDistanceXY::VertexDistanceXY | ( | ) | [inline] |
Definition at line 15 of file VertexDistanceXY.h.
Referenced by clone().
00015 : theNullMatrix(3, 0) {}
virtual VertexDistanceXY* VertexDistanceXY::clone | ( | void | ) | const [inline, virtual] |
Implements VertexDistance.
Definition at line 29 of file VertexDistanceXY.h.
References VertexDistanceXY().
00030 { 00031 return new VertexDistanceXY(*this); 00032 }
float VertexDistanceXY::compatibility | ( | const GlobalPoint & | vtx1Position, | |
const GlobalError & | vtx1PositionError, | |||
const GlobalPoint & | vtx2Position, | |||
const GlobalError & | vtx2PositionError | |||
) | const [private, virtual] |
Implements VertexDistance.
Definition at line 50 of file VertexDistanceXY.cc.
References diff, err1, err2, error, Exception, GlobalErrorBase< T, ErrorWeightType >::matrix(), theNullMatrix, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
00054 { 00055 // error matrix of residuals 00056 AlgebraicSymMatrix err1 = vtx1PositionError.matrix(); 00057 AlgebraicSymMatrix err2 = vtx2PositionError.matrix(); 00058 AlgebraicSymMatrix error(2, 0); 00059 error[0][0] = err1[0][0] + err2[0][0]; 00060 error[0][1] = err1[0][1] + err2[0][1]; 00061 error[1][1] = err1[1][1] + err2[1][1]; 00062 if (error == theNullMatrix) return FLT_MAX; 00063 00064 // position residuals 00065 GlobalVector diff = vtx2Position - vtx1Position; 00066 AlgebraicVector vDiff(2); 00067 vDiff[0] = diff.x(); 00068 vDiff[1] = diff.y(); 00069 00070 // Invert error matrix of residuals 00071 int ifail; 00072 error.invert(ifail); 00073 if (ifail != 0) { 00074 throw cms::Exception("VertexDistanceXY::matrix inversion problem"); 00075 } 00076 00077 return error.similarity(vDiff); 00078 }
Measurement1D VertexDistanceXY::distance | ( | const GlobalPoint & | vtx1Position, | |
const GlobalError & | vtx1PositionError, | |||
const GlobalPoint & | vtx2Position, | |||
const GlobalError & | vtx2PositionError | |||
) | const [private, virtual] |
Implements VertexDistance.
Definition at line 26 of file VertexDistanceXY.cc.
References diff, dist(), err, err2, error, GlobalErrorBase< T, ErrorWeightType >::matrix(), funct::pow(), funct::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
Referenced by signedDistance().
00030 { 00031 AlgebraicSymMatrix error = vtx1PositionError.matrix() 00032 + vtx2PositionError.matrix(); 00033 GlobalVector diff = vtx1Position - vtx2Position; 00034 AlgebraicVector vDiff(3); 00035 vDiff[0] = diff.x(); 00036 vDiff[1] = diff.y(); 00037 vDiff[2] = 0.; 00038 00039 double dist=sqrt(pow(diff.x(),2)+pow(diff.y(),2)); 00040 00041 double err2 = error.similarity(vDiff); 00042 double err = 0; 00043 if( dist != 0) err = sqrt(err2)/dist; 00044 00045 return Measurement1D(dist,err); 00046 }
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 12 of file VertexDistanceXY.cc.
References diff, distance(), Measurement1D::error(), reco::Vertex::position(), Measurement1D::value(), PV3DBase< T, PVType, FrameType >::x(), Basic3DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), and Basic3DVector< T >::y().
00014 { 00015 Measurement1D unsignedDistance = distance(vtx1, vtx2); 00016 Basic3DVector<float> diff = Basic3DVector<float> (vtx2.position()) - 00017 Basic3DVector<float> (vtx1.position()); 00018 if ((momentum.x()*diff.x() + momentum.y()*diff.y()) < 0 ) 00019 return Measurement1D(-1.0*unsignedDistance.value(),unsignedDistance.error()); 00020 return unsignedDistance; 00021 }