BmnRoot
26.10.0-235-g524af169
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
CbmKFPrimaryVertexFinder.cxx
Go to the documentation of this file.
1
/** Implementation of the CbmKFPrimaryVertexFinder class
2
*
3
* @author S.Gorbunov, I.Kisel
4
* @version 1.0
5
* @since 06.02.06
6
*
7
*/
8
#include "
CbmKFPrimaryVertexFinder.h
"
9
10
#include "
CbmKF.h
"
11
#include "
CbmKFTrack.h
"
12
13
#include <vector>
14
15
using
std::vector;
16
17
void
CbmKFPrimaryVertexFinder::Clear
()
18
{
19
Tracks
.clear();
20
}
21
22
void
CbmKFPrimaryVertexFinder::AddTrack
(
CbmKFTrackInterface
* Track)
23
{
24
Tracks
.push_back(Track);
25
}
26
27
void
CbmKFPrimaryVertexFinder::SetTracks
(vector<CbmKFTrackInterface*>& vTr)
28
{
29
Tracks
= vTr;
30
}
31
32
void
CbmKFPrimaryVertexFinder::Fit
(
CbmKFVertexInterface
& vtx)
33
{
34
//* Constants
35
36
const
Double_t
CutChi2 = 3.5 * 3.5;
37
const
Int_t
MaxIter = 3;
38
39
//* Vertex state vector and the covariance matrix
40
41
Double_t
r[3], *
C
= vtx.
GetCovMatrix
();
42
43
//* Initialize the vertex
44
45
for
(
Int_t
i
= 0;
i
< 6;
i
++)
46
C
[
i
] = 0;
47
if
(
CbmKF::Instance
()->vTargets.empty()) {
48
r[0] = r[1] = r[2] = 0.;
49
C
[0] =
C
[2] = 5.;
50
C
[5] = 0.25;
51
}
else
{
52
CbmKFTube
& t =
CbmKF::Instance
()->
vTargets
[0];
53
r[0] = r[1] = 0.;
54
r[2] = t.
z
;
55
C
[0] =
C
[2] = t.
RR
/ 3.5 / 3.5;
56
C
[5] = (t.
dz
/ 2 / 3.5) * (t.
dz
/ 2 / 3.5);
57
r[0] = 0.4;
// AZ-210923 - run 8
58
// cout << t.x << " " << t.y << " " << t.z << endl; //AZ-180923
59
// cout << t.RR << " " << t.dz << endl; //AZ-180923
60
// exit(0); //AZ-180923
61
}
62
63
//* Iteratively fit vertex - number of iterations fixed at MaxIter
64
65
for
(
Int_t
iteration = 0; iteration < MaxIter; ++iteration) {
66
67
//* Store vertex from previous iteration
68
69
Double_t
r0[3], C0[6];
70
71
for
(
Int_t
i
= 0;
i
< 3;
i
++)
72
r0[
i
] = r[
i
];
73
for
(
Int_t
i
= 0;
i
< 6;
i
++)
74
C0[
i
] =
C
[
i
];
75
76
//* Initialize the vertex covariance, Chi^2 & NDF
77
78
C
[0] = 100.;
79
C
[1] = 0.;
80
C
[2] = 100.;
81
C
[3] = 0.;
82
C
[4] = 0.;
83
C
[5] = 100.;
84
85
// AZ-210923 vtx.GetRefNDF() = -3;
86
vtx.
GetRefNDF
() = 0;
// AZ-210923
87
vtx.
GetRefChi2
() = 0.;
88
vtx.
GetRefNTracks
() = 0;
89
90
for
(vector<CbmKFTrackInterface*>::iterator itr =
Tracks
.begin(); itr !=
Tracks
.end(); ++itr) {
91
92
CbmKFTrack
T(**itr);
93
Bool_t
err = T.Extrapolate(r0[2]);
94
if
(err)
95
continue
;
96
97
Double_t
*
m
= T.GetTrack();
98
Double_t
* V = T.GetCovMatrix();
99
std::vector<Double_t> covMatr(V, V + 15);
// AZ-190923
100
if
(iteration == 0) {
101
for
(
unsigned
int
j = 0; j < covMatr.size(); ++j)
102
covMatr[j] *= 10;
103
};
// AZ-190923
104
V = covMatr.data();
// AZ-190923
105
Double_t
a = 0, b = 0;
106
{
107
Double_t
zeta[2] = {r0[0] -
m
[0], r0[1] -
m
[1]};
108
109
//* Check track Chi^2 deviation from the r0 vertex estimate
110
111
// AZ-190923 Double_t S[3] = { (C0[2]+V[2]), -(C0[1]+V[1]), (C0[0]+V[0]) };
112
Double_t
S[3] = {(C0[0] + V[0]), -(C0[1] + V[1]), (C0[2] + V[2])};
// AZ-190923
113
Double_t
s = S[2] * S[0] - S[1] * S[1];
114
Double_t
chi2 = zeta[0] * zeta[0] * S[0] + 2 * zeta[0] * zeta[1] * S[1] + zeta[1] * zeta[1] * S[2];
115
if
(chi2 > s * CutChi2)
116
continue
;
117
118
//* Fit of vertex track slopes (a,b) to r0 vertex
119
120
s = V[0] * V[2] - V[1] * V[1];
121
if
(s < 1.E-20)
122
continue
;
123
s = 1. / s;
124
a =
m
[2] + s * ((V[3] * V[2] - V[4] * V[1]) * zeta[0] + (-V[3] * V[1] + V[4] * V[0]) * zeta[1]);
125
b =
m
[3] + s * ((V[6] * V[2] - V[7] * V[1]) * zeta[0] + (-V[6] * V[1] + V[7] * V[0]) * zeta[1]);
126
}
127
128
//** Update the vertex (r,C) with the track estimate (m,V) :
129
130
//* Linearized measurement matrix H = { { 1, 0, -a}, { 0, 1, -b} };
131
132
//* Residual (measured - estimated)
133
134
Double_t
zeta[2] = {
m
[0] - (r[0] - a * (r[2] - r0[2])),
m
[1] - (r[1] - b * (r[2] - r0[2]))};
135
136
//* CHt = CH'
137
138
Double_t
CHt[3][2] = {{
C
[0] - a *
C
[3],
C
[1] - b *
C
[3]},
139
{
C
[1] - a *
C
[4],
C
[2] - b *
C
[4]},
140
{
C
[3] - a *
C
[5],
C
[4] - b *
C
[5]}};
141
142
//* S = (H*C*H' + V )^{-1}
143
144
Double_t
S[3] = {V[0] + CHt[0][0] - a * CHt[2][0], V[1] + CHt[1][0] - b * CHt[2][0],
145
V[2] + CHt[1][1] - b * CHt[2][1]};
146
147
//* Invert S
148
{
149
Double_t
w = S[0] * S[2] - S[1] * S[1];
150
if
(w < 1.E-20)
151
continue
;
152
w = 1. / w;
153
Double_t
S0 = S[0];
154
S[0] = w * S[2];
155
S[1] = -w * S[1];
156
S[2] = w * S0;
157
}
158
159
//* Calculate Chi^2
160
161
vtx.
GetRefChi2
() += zeta[0] * zeta[0] * S[0]
162
+ 2 * zeta[0] * zeta[1] * S[1]
163
// AZ-190923 + zeta[1]*zeta[1]*S[2] + T.GetRefChi2();
164
+ zeta[1] * zeta[1] * S[2];
// AZ-190923
165
// AZ-190923 vtx.GetRefNDF() += 2 + T.GetRefNDF();
166
vtx.
GetRefNDF
() += 2;
// AZ-190923
167
vtx.
GetRefNTracks
()++;
168
169
//* Kalman gain K = CH'*S
170
171
Double_t
K
[3][2];
172
173
for
(
Int_t
i
= 0;
i
< 3; ++
i
) {
174
K
[
i
][0] = CHt[
i
][0] * S[0] + CHt[
i
][1] * S[1];
175
K
[
i
][1] = CHt[
i
][0] * S[1] + CHt[
i
][1] * S[2];
176
}
177
178
//* New estimation of the vertex position r += K*zeta
179
180
for
(
Int_t
i
= 0;
i
< 3; ++
i
)
181
r[
i
] +=
K
[
i
][0] * zeta[0] +
K
[
i
][1] * zeta[1];
182
183
//* New covariance matrix C -= K*(CH')'
184
185
C
[0] -=
K
[0][0] * CHt[0][0] +
K
[0][1] * CHt[0][1];
186
C
[1] -=
K
[1][0] * CHt[0][0] +
K
[1][1] * CHt[0][1];
187
C
[2] -=
K
[1][0] * CHt[1][0] +
K
[1][1] * CHt[1][1];
188
C
[3] -=
K
[2][0] * CHt[0][0] +
K
[2][1] * CHt[0][1];
189
C
[4] -=
K
[2][0] * CHt[1][0] +
K
[2][1] * CHt[1][1];
190
C
[5] -=
K
[2][0] * CHt[2][0] +
K
[2][1] * CHt[2][1];
191
192
}
//* itr
193
194
}
//* finished iterations
195
196
//* Copy state vector to output (covariance matrix was used directly )
197
198
vtx.
GetRefX
() = r[0];
199
vtx.
GetRefY
() = r[1];
200
vtx.
GetRefZ
() = r[2];
201
}
CbmKFPrimaryVertexFinder.h
CbmKFTrack.h
CbmKF.h
i
int i
Definition
P4_F32vec4.h:22
m
__m128 m
Definition
P4_F32vec4.h:27
Bool_t
bool Bool_t
Int_t
int Int_t
Double_t
double Double_t
CbmKFPrimaryVertexFinder::SetTracks
void SetTracks(std::vector< CbmKFTrackInterface * > &vTracks)
Definition
CbmKFPrimaryVertexFinder.cxx:27
CbmKFPrimaryVertexFinder::AddTrack
void AddTrack(CbmKFTrackInterface *Track)
Definition
CbmKFPrimaryVertexFinder.cxx:22
CbmKFPrimaryVertexFinder::Tracks
std::vector< CbmKFTrackInterface * > Tracks
Definition
CbmKFPrimaryVertexFinder.h:21
CbmKFPrimaryVertexFinder::Clear
void Clear()
Definition
CbmKFPrimaryVertexFinder.cxx:17
CbmKFPrimaryVertexFinder::Fit
void Fit(CbmKFVertexInterface &vtx)
Definition
CbmKFPrimaryVertexFinder.cxx:32
CbmKFTrackInterface
Definition
CbmKFTrackInterface.h:26
CbmKFTrack
Definition
CbmKFTrack.h:22
CbmKFTube
Definition
CbmKFMaterial.h:72
CbmKFTube::RR
Double_t RR
Definition
CbmKFMaterial.h:90
CbmKFTube::dz
Double_t dz
Definition
CbmKFMaterial.h:89
CbmKFTube::z
Double_t z
Definition
CbmKFMaterial.h:89
CbmKFVertexInterface
Definition
CbmKFVertexInterface.h:25
CbmKFVertexInterface::GetRefY
virtual Double_t & GetRefY()
Definition
CbmKFVertexInterface.cxx:28
CbmKFVertexInterface::GetRefX
virtual Double_t & GetRefX()
I/O parameters for vertex fit routines.
Definition
CbmKFVertexInterface.cxx:24
CbmKFVertexInterface::GetRefNTracks
virtual Int_t & GetRefNTracks()
Number of Degrees of Freedom after fit.
Definition
CbmKFVertexInterface.cxx:48
CbmKFVertexInterface::GetRefZ
virtual Double_t & GetRefZ()
Definition
CbmKFVertexInterface.cxx:32
CbmKFVertexInterface::GetRefChi2
virtual Double_t & GetRefChi2()
Array[6] of covariance matrix.
Definition
CbmKFVertexInterface.cxx:40
CbmKFVertexInterface::GetRefNDF
virtual Int_t & GetRefNDF()
Chi^2 after fit.
Definition
CbmKFVertexInterface.cxx:44
CbmKFVertexInterface::GetCovMatrix
virtual Double_t * GetCovMatrix()
Definition
CbmKFVertexInterface.cxx:36
CbmKF::Instance
static CbmKF * Instance()
Definition
CbmKF.h:34
CbmKF::vTargets
std::vector< CbmKFTube > vTargets
Definition
CbmKF.h:62
TMath::C
constexpr Double_t C()
TMath::K
constexpr Double_t K()
reconstruction
KF
CbmKFPrimaryVertexFinder.cxx
Generated on
for BmnRoot by
1.17.0