CMS 3D CMS Logo

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