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.
 
B2Vector3D trackToVtxVec (B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D const &vtxPos)
 Returns the 3D vector between a vertex and a track's point of closest approach to that vertex.
 
double trackToVtxDist (B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D const &vtxPos)
 Returns the distance between a vertex and a track's point of closest approach to that vertex.
 
TMatrixDSym trackToVtxCovmat (B2Vector3D 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 (B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D 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.
 
B2Vector3D vtxToVtxVec (B2Vector3D const &vtx1Pos, B2Vector3D const &vtx2Pos)
 Returns the 3D vector between two vertices, ie vtxPos2 - vtxPos1.
 
double vtxToVtxDist (B2Vector3D const &vtx1Pos, B2Vector3D 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 (B2Vector3D const &vtx1Pos, B2Vector3D 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 ( B2Vector3D 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 37 of file DistanceTools.cc.

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

◆ trackToVtxDist()

double trackToVtxDist ( B2Vector3D const &  trackPos,
B2Vector3D const &  trackP,
B2Vector3D const &  vtxPos 
)

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

Definition at line 32 of file DistanceTools.cc.

33{
34 return trackToVtxVec(trackPos, trackP, vtxPos).Mag();
35}
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition: B2Vector3.h:159
B2Vector3D trackToVtxVec(B2Vector3D const &trackPos, B2Vector3D const &trackP, B2Vector3D const &vtxPos)
Returns the 3D vector between a vertex and a track's point of closest approach to that vertex.

◆ trackToVtxDistErr()

double trackToVtxDistErr ( B2Vector3D const &  trackPos,
B2Vector3D const &  trackP,
B2Vector3D 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 63 of file DistanceTools.cc.

65{
66 TMatrixDSym covMat(trackToVtxCovmat(trackP, trackPosCovMat, vtxPosCovMat));
67 B2Vector3D dVec(trackToVtxVec(trackPos, trackP, vtxPos));
68 // n is the normalise vector in the direction of the POCA between the track and the vtx
69 B2Vector3D n((1. / dVec.Mag()) * dVec);
70
71 double ret(0);
72
73 //error on the distance computed as d^T * covMat * d
74 for (int i(0); i < 3; ++i)
75 for (int j(0); j < 3; ++j)
76 ret += n(i) * covMat(i, j) * n(j);
77
78 return TMath::Sqrt(ret);
79}
TMatrixDSym trackToVtxCovmat(B2Vector3D 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()

B2Vector3D trackToVtxVec ( B2Vector3D const &  trackPos,
B2Vector3D const &  trackP,
B2Vector3D 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.

26{
27 B2Vector3D trackDir(trackP.Unit());
28 B2Vector3D r(vtxPos - trackPos);
29 return r - (r.Dot(trackDir)) * trackDir;
30}

◆ vtxToVtxCovMat()

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

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

Definition at line 92 of file DistanceTools.cc.

93{
94 if (vtx1CovMat.GetNcols() != 3 || vtx2CovMat.GetNcols() != 3) {
95 B2ERROR("in DistanceTools::vtxToVtxCovMat, matrices must be of size 3");
96 return TMatrixDSym(3);
97 }
98
99 return vtx1CovMat + vtx2CovMat;
100}

◆ vtxToVtxDist()

double vtxToVtxDist ( B2Vector3D const &  vtx1Pos,
B2Vector3D const &  vtx2Pos 
)

Returns the distance between two vertices.

Definition at line 87 of file DistanceTools.cc.

88{
89 return vtxToVtxVec(vtx1Pos, vtx2Pos).Mag();
90}
B2Vector3D vtxToVtxVec(B2Vector3D const &vtx1Pos, B2Vector3D const &vtx2Pos)
Returns the 3D vector between two vertices, ie vtxPos2 - vtxPos1.

◆ vtxToVtxDistErr()

double vtxToVtxDistErr ( B2Vector3D const &  vtx1Pos,
B2Vector3D const &  vtx2Pos,
TMatrixDSym const &  vtx1CovMat,
TMatrixDSym const &  vtx2CovMat 
)

Returns the estimated uncertainty on the distance between two vertices.

Definition at line 102 of file DistanceTools.cc.

104{
105 TMatrixDSym covMat(vtxToVtxCovMat(vtx1CovMat, vtx2CovMat));
106 B2Vector3D dVec(vtxToVtxVec(vtx1Pos, vtx2Pos));
107 B2Vector3D n((1. / dVec.Mag()) * dVec);
108
109 double ret(0);
110
111 //error on the distance computed as d^T * covMat * d
112 for (int i(0); i < 3; ++i)
113 for (int j(0); j < 3; ++j)
114 ret += n(i) * covMat(i, j) * n(j);
115
116 return TMath::Sqrt(ret);
117}
TMatrixDSym vtxToVtxCovMat(TMatrixDSym const &vtx1CovMat, TMatrixDSym const &vtx2CovMat)
Returns the covariance (error) matrix related to the vector linking two vertices.

◆ vtxToVtxVec()

B2Vector3D vtxToVtxVec ( B2Vector3D const &  vtx1Pos,
B2Vector3D const &  vtx2Pos 
)

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

Definition at line 82 of file DistanceTools.cc.

83{
84 return vtx2Pos - vtx1Pos;
85}