CMS 3D CMS Logo

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 }
Vector3DBase
Definition: Vector3DBase.h:8
change_name.diff
diff
Definition: change_name.py:13
AlgebraicVector3
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition: AlgebraicROOTObjects.h:12
Measurement1D
Definition: Measurement1D.h:11
AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Definition: AlgebraicROOTObjects.h:21
VertexDistance3D::signedDistance
Measurement1D signedDistance(const reco::Vertex &primVtx, const reco::Vertex &secVtx, const GlobalVector &momentum) const override
Definition: VertexDistance3D.cc:6
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
Measurement1D::value
double value() const
Definition: Measurement1D.h:25
VertexDistance3D::distance
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
Definition: VertexDistance3D.cc:17
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
GlobalErrorBase::matrix
const AlgebraicSymMatrix33 matrix() const
Definition: GlobalErrorBase.h:121
VertexDistance3D.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
relativeConstraints.error
error
Definition: relativeConstraints.py:53
VertexDistance3D::compatibility
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
Definition: VertexDistance3D.cc:38
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Point3DBase< float, GlobalTag >
Measurement1D::error
double error() const
Definition: Measurement1D.h:27
runTheMatrix.err
err
Definition: runTheMatrix.py:288
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
GlobalErrorBase< double, ErrorMatrixTag >
Exception
Definition: hltDiff.cc:246
Basic3DVector< float >
reco::Vertex
Definition: Vertex.h:35