16 Double_t w = (C[0] +
V[0]) * (C[2] +
V[2]) - (C[1] +
V[1]) * (C[1] +
V[1]);
17 if (w < 1.E-20 || !
finite(w)) {
24 Double_t W[3] = {w * (C[2] +
V[2]), -w * (C[1] +
V[1]), w * (C[0] +
V[0])};
25 Double_t zeta[2] = {T[0] -
x, T[1] -
y};
27 track.
GetRefChi2() += zeta[0] * zeta[0] * W[0] + 2 * zeta[0] * zeta[1] * W[1]
28 + zeta[1] * zeta[1] * W[2];
32 {C[0] * W[0] + C[1] * W[1], C[0] * W[1] + C[1] * W[2]},
33 {C[1] * W[0] + C[2] * W[1], C[1] * W[1] + C[2] * W[2]},
34 {C[3] * W[0] + C[4] * W[1], C[3] * W[1] + C[4] * W[2]},
35 {C[6] * W[0] + C[7] * W[1], C[6] * W[1] + C[7] * W[2]},
36 {C[10] * W[0] + C[11] * W[1], C[10] * W[1] + C[11] * W[2]},
39 T[0] -= K[0][0] * zeta[0] + K[0][1] * zeta[1];
40 T[1] -= K[1][0] * zeta[0] + K[1][1] * zeta[1];
41 T[2] -= K[2][0] * zeta[0] + K[2][1] * zeta[1];
42 T[3] -= K[3][0] * zeta[0] + K[3][1] * zeta[1];
43 T[4] -= K[4][0] * zeta[0] + K[4][1] * zeta[1];
45 Double_t KHC[15] = {C[0] * K[0][0] + C[1] * K[0][1],
46 C[0] * K[1][0] + C[1] * K[1][1],
47 C[1] * K[1][0] + C[2] * K[1][1],
49 C[0] * K[2][0] + C[1] * K[2][1],
50 C[1] * K[2][0] + C[2] * K[2][1],
51 C[3] * K[2][0] + C[4] * K[2][1],
53 C[0] * K[3][0] + C[1] * K[3][1],
54 C[1] * K[3][0] + C[2] * K[3][1],
55 C[3] * K[3][0] + C[4] * K[3][1],
56 C[6] * K[3][0] + C[7] * K[3][1],
58 C[0] * K[4][0] + C[1] * K[4][1],
59 C[1] * K[4][0] + C[2] * K[4][1],
60 C[3] * K[4][0] + C[4] * K[4][1],
61 C[6] * K[4][0] + C[7] * K[4][1],
62 C[10] * K[4][0] + C[11] * K[4][1]};
97 vector<CbmKFPixelMeasurement*>& vm,
100 vector<double>& vProb) {
101 const double Pdetect = 0.90;
102 const double gateEff =
109 double gateArea = gateX * gateY;
110 double chi2, zeta[2];
111 int ndf = 2, idx,
i, j, k;
113 vector<double> vResidX;
114 vector<double> vResidY;
115 vector<double> vChi2;
119 cout <<
"PDAF: " << vm->size() <<
" hits validated" << endl;
120 cout <<
"Initial params: x=" << T[0] <<
" y=" << T[1] <<
" tx=" << T[2]
121 <<
" ty=" << T[3] <<
" Q=" << T[4] << endl;
122 cout <<
"GateX=" << gateX <<
" GateY=" << gateY << endl;
132 const double*
V = (*vm.begin())->
V;
136 Sk = (C[0] +
V[0]) * (C[2] +
V[2]) - (C[1] +
V[1]) * (C[1] +
V[1]);
140 double Lambda = 1. / 1.;
142 Ck = 2.0 * 3.1415926 *
sqrt(Sk) * (1.0 - Pdetect * gateEff)
143 / (gateArea * Pdetect * gateEff) * Lambda;
146 if (w < 1.E-20)
return;
151 double W[3] = {w * (C[2] +
V[2]), -w * (C[1] +
V[1]), w * (C[0] +
V[0])};
153 {C[0] * W[0] + C[1] * W[1], C[0] * W[1] + C[1] * W[2]},
154 {C[1] * W[0] + C[2] * W[1], C[1] * W[1] + C[2] * W[2]},
155 {C[3] * W[0] + C[4] * W[1], C[3] * W[1] + C[4] * W[2]},
156 {C[6] * W[0] + C[7] * W[1], C[6] * W[1] + C[7] * W[2]},
157 {C[10] * W[0] + C[11] * W[1], C[10] * W[1] + C[11] * W[2]},
162 for (vector<CbmKFPixelMeasurement*>::iterator pmIt = vm.begin();
165 double resX = (*pmIt)->x - T[0];
166 double resY = (*pmIt)->y - T[1];
167 chi2 = resX * resX * W[0] + 2 * resY * resX * W[1] + resY * resY * W[2];
169 cout <<
"resX=" << resX <<
" resY=" << resY <<
" chi2dist=" << chi2 << endl;
171 vChi2.push_back(chi2);
172 vResidX.push_back(resX);
173 vResidY.push_back(resY);
174 vExp.push_back(
exp(-0.5 * chi2));
180 vector<double>::iterator eIt;
181 for (eIt = vExp.begin(); eIt != vExp.end(); ++eIt) {
185 double P0 = Ck * Sum;
187 cout <<
"No-detect probability = " << P0 << endl;
189 for (eIt = vExp.begin(); eIt != vExp.end(); ++eIt) {
190 vProb.push_back(Sum * (*eIt));
200 for (eIt = vProb.begin(); eIt != vProb.end(); ++eIt) {
201 zeta[0] += vResidX[idx] * (*eIt);
202 zeta[1] += vResidY[idx] * (*eIt);
203 chi2 += vChi2[idx] * (*eIt);
205 cout <<
"Hit " << idx <<
" Assignment probability = " << (*eIt) << endl;
210 cout <<
"Merged resX=" << zeta[0] <<
" resY=" << zeta[1] << endl;
216 CR[0][0] = -zeta[0] * zeta[0];
217 CR[0][1] = -zeta[0] * zeta[1];
218 CR[1][0] = -zeta[1] * zeta[0];
219 CR[1][1] = -zeta[1] * zeta[1];
221 for (eIt = vProb.begin(); eIt != vProb.end(); ++eIt) {
222 CR[0][0] += (*eIt) * vResidX[idx] * vResidX[idx];
223 CR[0][1] += (*eIt) * vResidX[idx] * vResidY[idx];
224 CR[1][0] += (*eIt) * vResidY[idx] * vResidX[idx];
225 CR[1][1] += (*eIt) * vResidY[idx] * vResidY[idx];
229 for (
i = 0;
i < 5;
i++)
230 for (j = 0; j < 2; j++) {
232 for (k = 0; k < 2; k++)
233 KD[
i][j] += K[
i][k] * CR[k][j];
239 for (
i = 0;
i < 5;
i++)
240 for (j = 0; j < 5; j++) {
242 for (k = 0; k < 2; k++)
243 Ga[
i][j] += KD[
i][k] * K[j][k];
249 T[0] += K[0][0] * zeta[0] + K[0][1] * zeta[1];
250 T[1] += K[1][0] * zeta[0] + K[1][1] * zeta[1];
251 T[2] += K[2][0] * zeta[0] + K[2][1] * zeta[1];
252 T[3] += K[3][0] * zeta[0] + K[3][1] * zeta[1];
253 T[4] += K[4][0] * zeta[0] + K[4][1] * zeta[1];
255 double KHC[15] = {C[0] * K[0][0] + C[1] * K[0][1],
256 C[0] * K[1][0] + C[1] * K[1][1],
257 C[1] * K[1][0] + C[2] * K[1][1],
259 C[0] * K[2][0] + C[1] * K[2][1],
260 C[1] * K[2][0] + C[2] * K[2][1],
261 C[3] * K[2][0] + C[4] * K[2][1],
263 C[0] * K[3][0] + C[1] * K[3][1],
264 C[1] * K[3][0] + C[2] * K[3][1],
265 C[3] * K[3][0] + C[4] * K[3][1],
266 C[6] * K[3][0] + C[7] * K[3][1],
268 C[0] * K[4][0] + C[1] * K[4][1],
269 C[1] * K[4][0] + C[2] * K[4][1],
270 C[3] * K[4][0] + C[4] * K[4][1],
271 C[6] * K[4][0] + C[7] * K[4][1],
272 C[10] * K[4][0] + C[11] * K[4][1]};
275 for (
i = 0;
i < 15;
i++)
300 for (
i = 0;
i < 5;
i++)
301 for (j = 0; j <=
i; j++) {
302 C[idx] = P0 * C[idx] + (1 - P0) * Gs[idx] + Ga[
i][j];
306 cout <<
"Updated params: x=" << T[0] <<
" y=" << T[1] <<
" tx=" << T[2]
307 <<
" ty=" << T[3] <<
" Q=" << T[4] << endl;
308 cout <<
"chi2 contrib.=" << chi2 << endl;