Belle II Software development
Belle2::DistanceTools Namespace Reference

This namespace contains a collection of function that are useful to compute distances between tracks and vertices. More...

Functions

ROOT::Math::XYZVector poca (ROOT::Math::XYZVector const &trackPos, ROOT::Math::XYZVector const &trackP, ROOT::Math::XYZVector const &vtxPos)
 Returns the Point Of Closest Approach of a track to a vertex.
 
ROOT::Math::XYZVector trackToVtxVec (ROOT::Math::XYZVector const &trackPos, ROOT::Math::XYZVector const &trackP, ROOT::Math::XYZVector const &vtxPos)
 Returns the 3D vector between a vertex and a track's point of closest approach to that vertex.
 
double trackToVtxDist (ROOT::Math::XYZVector const &trackPos, ROOT::Math::XYZVector const &trackP, ROOT::Math::XYZVector const &vtxPos)
 Returns the distance between a vertex and a track's point of closest approach to that vertex.
 
TMatrixDSym trackToVtxCovmat (ROOT::Math::XYZVector const &trackP, TMatrixDSym const &trackPosCovMat, TMatrixDSym const &vtxPosCovMat)
 Returns the covariance (error) matrix of the 3D vector between a vertex and a track's point of closest approach to that vertex.
 
double trackToVtxDistErr (ROOT::Math::XYZVector const &trackPos, ROOT::Math::XYZVector const &trackP, ROOT::Math::XYZVector const &vtxPos, TMatrixDSym const &trackPosCovMat, TMatrixDSym const &vtxPosCovMat)
 Returns the estimated uncertainty between a vertex and a track's point of closest approach to that vertex.
 
ROOT::Math::XYZVector vtxToVtxVec (ROOT::Math::XYZVector const &vtx1Pos, ROOT::Math::XYZVector const &vtx2Pos)
 Returns the 3D vector between two vertices, ie vtxPos2 - vtxPos1.
 
double vtxToVtxDist (ROOT::Math::XYZVector const &vtx1Pos, ROOT::Math::XYZVector const &vtx2Pos)
 Returns the distance between two vertices.
 
TMatrixDSym vtxToVtxCovMat (TMatrixDSym const &vtx1CovMat, TMatrixDSym const &vtx2CovMat)
 Returns the covariance (error) matrix related to the vector linking two vertices.
 
double vtxToVtxDistErr (ROOT::Math::XYZVector const &vtx1Pos, ROOT::Math::XYZVector const &vtx2Pos, TMatrixDSym const &vtx1CovMat, TMatrixDSym const &vtx2CovMat)
 Returns the estimated uncertainty on the distance between two vertices.
 

Detailed Description

This namespace contains a collection of function that are useful to compute distances between tracks and vertices.

All tracks are assumed to be straight in the current implementation.

Function Documentation

◆ poca()

ROOT::Math::XYZVector poca ( ROOT::Math::XYZVector const & trackPos,
ROOT::Math::XYZVector const & trackP,
ROOT::Math::XYZVector const & vtxPos )

Returns the Point Of Closest Approach of a track to a vertex.

Definition at line 17 of file DistanceTools.cc.

19{
20 ROOT::Math::XYZVector trackDir(trackP.Unit());
21 ROOT::Math::XYZVector r(vtxPos - trackPos);
22 return trackPos + r.Dot(trackDir) * trackDir;
23}

◆ trackToVtxCovmat()

TMatrixDSym trackToVtxCovmat ( ROOT::Math::XYZVector const & trackP,
TMatrixDSym const & trackPosCovMat,
TMatrixDSym const & vtxPosCovMat )

Returns the covariance (error) matrix of the 3D vector between a vertex and a track's point of closest approach to that vertex.

Definition at line 39 of file DistanceTools.cc.

41{
42 if (trackPosCovMat.GetNcols() != 3 || vtxPosCovMat.GetNcols() != 3) {
43 B2ERROR("in DistanceTools::trackToVtxCovmat, matrices must be of size 3");
44 return TMatrixDSym(3);
45 }
46
47 TMatrixDSym rCovMat(trackPosCovMat + vtxPosCovMat);
48 ROOT::Math::XYZVector trackDir(trackP.Unit());
49 //d_j = r_j - v_j * v_k r_k
50 //Jij = del_i d_j = delta_ij - v_i * v_j
51 //Since the vector of closest approach is a linear function of r, its
52 //propagation of errors is exact
53 TMatrixDSym Jacobian(3);
54 // Jacobian_ij = delta_ij -v(i)v(j)
55 for (int i(0); i < 3; ++i) {
56 for (int j(0); j < 3; ++j) {
57 double trackDir_i = (i == 0) ? trackDir.X() : (i == 1) ? trackDir.Y() : trackDir.Z();
58 double trackDir_j = (j == 0) ? trackDir.X() : (j == 1) ? trackDir.Y() : trackDir.Z();
59 Jacobian(i, j) = -trackDir_i * trackDir_j;
60 }
61 }
62 for (int i(0); i < 3; ++i)
63 Jacobian(i, i) += 1;
64
65 return rCovMat.Similarity(Jacobian); //calculates J * rCovMat * J^T, and returns it
66
67}

◆ trackToVtxDist()

double trackToVtxDist ( ROOT::Math::XYZVector const & trackPos,
ROOT::Math::XYZVector const & trackP,
ROOT::Math::XYZVector const & vtxPos )

Returns the distance between a vertex and a track's point of closest approach to that vertex.

Definition at line 33 of file DistanceTools.cc.

35{
36 return trackToVtxVec(trackPos, trackP, vtxPos).R();
37}
ROOT::Math::XYZVector trackToVtxVec(ROOT::Math::XYZVector const &trackPos, ROOT::Math::XYZVector const &trackP, ROOT::Math::XYZVector const &vtxPos)
Returns the 3D vector between a vertex and a track's point of closest approach to that vertex.

◆ trackToVtxDistErr()

double trackToVtxDistErr ( ROOT::Math::XYZVector const & trackPos,
ROOT::Math::XYZVector const & trackP,
ROOT::Math::XYZVector const & vtxPos,
TMatrixDSym const & trackPosCovMat,
TMatrixDSym const & vtxPosCovMat )

Returns the estimated uncertainty between a vertex and a track's point of closest approach to that vertex.

Definition at line 69 of file DistanceTools.cc.

72{
73 TMatrixDSym covMat(trackToVtxCovmat(trackP, trackPosCovMat, vtxPosCovMat));
74 ROOT::Math::XYZVector dVec(trackToVtxVec(trackPos, trackP, vtxPos));
75 // n is the normalise vector in the direction of the POCA between the track and the vtx
76 ROOT::Math::XYZVector n((1. / dVec.R()) * dVec);
77
78 double ret(0);
79
80 //error on the distance computed as d^T * covMat * d
81 for (int i(0); i < 3; ++i) {
82 for (int j(0); j < 3; ++j) {
83 double n_i = (i == 0) ? n.X() : (i == 1) ? n.Y() : n.Z();
84 double n_j = (j == 0) ? n.X() : (j == 1) ? n.Y() : n.Z();
85 ret += n_i * covMat(i, j) * n_j;
86 }
87 }
88
89 return TMath::Sqrt(ret);
90}
TMatrixDSym trackToVtxCovmat(ROOT::Math::XYZVector const &trackP, TMatrixDSym const &trackPosCovMat, TMatrixDSym const &vtxPosCovMat)
Returns the covariance (error) matrix of the 3D vector between a vertex and a track's point of closes...

◆ trackToVtxVec()

ROOT::Math::XYZVector trackToVtxVec ( ROOT::Math::XYZVector const & trackPos,
ROOT::Math::XYZVector const & trackP,
ROOT::Math::XYZVector const & vtxPos )

Returns the 3D vector between a vertex and a track's point of closest approach to that vertex.

Definition at line 25 of file DistanceTools.cc.

27{
28 ROOT::Math::XYZVector trackDir(trackP.Unit());
29 ROOT::Math::XYZVector r(vtxPos - trackPos);
30 return r - (r.Dot(trackDir)) * trackDir;
31}

◆ vtxToVtxCovMat()

TMatrixDSym vtxToVtxCovMat ( TMatrixDSym const & vtx1CovMat,
TMatrixDSym const & vtx2CovMat )

Returns the covariance (error) matrix related to the vector linking two vertices.

Definition at line 103 of file DistanceTools.cc.

104{
105 if (vtx1CovMat.GetNcols() != 3 || vtx2CovMat.GetNcols() != 3) {
106 B2ERROR("in DistanceTools::vtxToVtxCovMat, matrices must be of size 3");
107 return TMatrixDSym(3);
108 }
109
110 return vtx1CovMat + vtx2CovMat;
111}

◆ vtxToVtxDist()

double vtxToVtxDist ( ROOT::Math::XYZVector const & vtx1Pos,
ROOT::Math::XYZVector const & vtx2Pos )

Returns the distance between two vertices.

Definition at line 98 of file DistanceTools.cc.

99{
100 return vtxToVtxVec(vtx1Pos, vtx2Pos).R();
101}
ROOT::Math::XYZVector vtxToVtxVec(ROOT::Math::XYZVector const &vtx1Pos, ROOT::Math::XYZVector const &vtx2Pos)
Returns the 3D vector between two vertices, ie vtxPos2 - vtxPos1.

◆ vtxToVtxDistErr()

double vtxToVtxDistErr ( ROOT::Math::XYZVector const & vtx1Pos,
ROOT::Math::XYZVector const & vtx2Pos,
TMatrixDSym const & vtx1CovMat,
TMatrixDSym const & vtx2CovMat )

Returns the estimated uncertainty on the distance between two vertices.

Definition at line 113 of file DistanceTools.cc.

115{
116 TMatrixDSym covMat(vtxToVtxCovMat(vtx1CovMat, vtx2CovMat));
117 ROOT::Math::XYZVector dVec(vtxToVtxVec(vtx1Pos, vtx2Pos));
118 ROOT::Math::XYZVector n((1. / dVec.R()) * dVec);
119
120 double ret(0);
121
122 //error on the distance computed as d^T * covMat * d
123 for (int i(0); i < 3; ++i) {
124 for (int j(0); j < 3; ++j) {
125 double n_i = (i == 0) ? n.X() : (i == 1) ? n.Y() : n.Z();
126 double n_j = (j == 0) ? n.X() : (j == 1) ? n.Y() : n.Z();
127 ret += n_i * covMat(i, j) * n_j;
128 }
129 }
130
131 return TMath::Sqrt(ret);
132}
TMatrixDSym vtxToVtxCovMat(TMatrixDSym const &vtx1CovMat, TMatrixDSym const &vtx2CovMat)
Returns the covariance (error) matrix related to the vector linking two vertices.

◆ vtxToVtxVec()

ROOT::Math::XYZVector vtxToVtxVec ( ROOT::Math::XYZVector const & vtx1Pos,
ROOT::Math::XYZVector const & vtx2Pos )

Returns the 3D vector between two vertices, ie vtxPos2 - vtxPos1.

Definition at line 93 of file DistanceTools.cc.

94{
95 return vtx2Pos - vtx1Pos;
96}