CMS 3D CMS Logo

VertexDistanceXY.cc
Go to the documentation of this file.
5 #include <cfloat>
6 
7 
8 using namespace reco;
9 
12  const GlobalVector & momentum) const
13 {
14  Measurement1D unsignedDistance = distance(vtx1, vtx2);
17  if ((momentum.x()*diff.x() + momentum.y()*diff.y()) < 0 )
18  return Measurement1D(-1.0*unsignedDistance.value(),unsignedDistance.error());
19  return unsignedDistance;
20 }
21 
22 
23 
26  const GlobalError & vtx1PositionError,
27  const GlobalPoint & vtx2Position,
28  const GlobalError & vtx2PositionError) const
29 {
30  AlgebraicSymMatrix33 error = vtx1PositionError.matrix()
31  + vtx2PositionError.matrix();
32  GlobalVector diff = vtx1Position - vtx2Position;
33  AlgebraicVector3 vDiff;
34  vDiff[0] = diff.x();
35  vDiff[1] = diff.y();
36  vDiff[2] = 0.;
37 
38  double dist=sqrt(pow(diff.x(),2)+pow(diff.y(),2));
39 
40  double err2 = ROOT::Math::Similarity(error,vDiff);
41  double err = 0;
42  if( dist != 0) err = sqrt(err2)/dist;
43 
44  return Measurement1D(dist,err);
45 }
46 
47 
48 float
50  const GlobalError & vtx1PositionError,
51  const GlobalPoint & vtx2Position,
52  const GlobalError & vtx2PositionError) const
53 {
54  // error matrix of residuals
55  AlgebraicSymMatrix33 err1 = vtx1PositionError.matrix();
56  AlgebraicSymMatrix33 err2 = vtx2PositionError.matrix();
58  error[0][0] = err1[0][0] + err2[0][0];
59  error[0][1] = err1[0][1] + err2[0][1];
60  error[1][1] = err1[1][1] + err2[1][1];
61  if (error == theNullMatrix) return FLT_MAX;
62 
63  // position residuals
64  GlobalVector diff = vtx2Position - vtx1Position;
65  AlgebraicVector2 vDiff;
66  vDiff[0] = diff.x();
67  vDiff[1] = diff.y();
68 
69  // Invert error matrix of residuals
70  bool ifail = !error.Invert();
71  if (ifail) {
72  throw cms::Exception("VertexDistanceXY::matrix inversion problem");
73  }
74 
75  return ROOT::Math::Similarity(error,vDiff);
76 }
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
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:109
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
T sqrt(T t)
Definition: SSEVec.h:18
virtual Measurement1D signedDistance(const reco::Vertex &primVtx, const reco::Vertex &secVtx, const GlobalVector &momentum) const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
double value() const
Definition: Measurement1D.h:28
fixed size matrix
T x() const
Definition: PV3DBase.h:62
virtual float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
ROOT::Math::SVector< double, 2 > AlgebraicVector2
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40