CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VertexDistance3D.cc
Go to the documentation of this file.
2 #include <cfloat>
3 
4 
5 using namespace reco;
6 
8 VertexDistance3D::signedDistance(const Vertex& vtx1, const Vertex & vtx2,
9  const GlobalVector & momentum) const
10 {
11  Measurement1D unsignedDistance = distance(vtx1, vtx2);
14 // Basic3DVector<float> (vtx2 - vtx1);
15  if ((momentum.x()*diff.x() + momentum.y()*diff.y() * momentum.z()*diff.z()) < 0 )
16  return Measurement1D(-1.0*unsignedDistance.value(),unsignedDistance.error());
17  return unsignedDistance;
18 }
19 
20 
23  const GlobalError & vtx1PositionError,
24  const GlobalPoint & vtx2Position,
25  const GlobalError & vtx2PositionError) const
26 {
27  AlgebraicSymMatrix33 error = vtx1PositionError.matrix()
28  + vtx2PositionError.matrix();
29  GlobalVector diff = vtx1Position - vtx2Position;
30  AlgebraicVector3 vDiff;
31  vDiff[0] = diff.x();
32  vDiff[1] = diff.y();
33  vDiff[2] = diff.z();
34 
35  double dist=diff.mag();
36 
37  double err2 = ROOT::Math::Similarity(error,vDiff);
38  double err = 0.;
39  if (dist != 0) err = sqrt(err2)/dist;
40 
41  return Measurement1D(dist,err);
42 }
43 
44 
45 
46 float
48  const GlobalError & vtx1PositionError,
49  const GlobalPoint & vtx2Position,
50  const GlobalError & vtx2PositionError) const
51 {
52  // error matrix of residuals
53  AlgebraicSymMatrix33 err1 = vtx1PositionError.matrix();
54  AlgebraicSymMatrix33 err2 = vtx2PositionError.matrix();
55  AlgebraicSymMatrix33 error = err1 + err2;
56  if (error == theNullMatrix) return FLT_MAX;
57 
58  // position residuals
59  GlobalVector diff = vtx2Position - vtx1Position;
60  AlgebraicVector3 vDiff;
61  vDiff[0] = diff.x();
62  vDiff[1] = diff.y();
63  vDiff[2] = diff.z();
64 
65  // Invert error matrix of residuals
66  bool ifail = !error.InvertChol();
67  if (ifail) {
68  throw cms::Exception("VertexDistance3D::matrix inversion problem");
69  }
70 
71  return ROOT::Math::Similarity(error,vDiff);
72 }
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
const AlgebraicSymMatrix33 & matrix() const
T y() const
Definition: PV3DBase.h:63
double error() const
Definition: Measurement1D.h:30
const Point & position() const
position
Definition: Vertex.h:93
T mag() const
Definition: PV3DBase.h:67
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
T z() const
Cartesian z coordinate.
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
ROOT::Math::SVector< double, 3 > AlgebraicVector3
virtual Measurement1D signedDistance(const reco::Vertex &primVtx, const reco::Vertex &secVtx, const GlobalVector &momentum) const
double value() const
Definition: Measurement1D.h:28
T x() const
Definition: PV3DBase.h:62
virtual float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const