22 Double_t w = (C[0] +
V[0]) * (C[2] +
V[2]) - (C[1] +
V[1]) * (C[1] +
V[1]);
23 if (w < 1.E-20 || !isfinite(w)) {
32 Double_t W[3] = {w * (C[2] +
V[2]), -w * (C[1] +
V[1]), w * (C[0] +
V[0])};
33 Double_t zeta[2] = {T[0] -
x, T[1] -
y};
35 track.
GetRefChi2() += zeta[0] * zeta[0] * W[0] + 2 * zeta[0] * zeta[1] * W[1] + zeta[1] * zeta[1] * W[2];
39 {C[0] * W[0] + C[1] * W[1], C[0] * W[1] + C[1] * W[2]}, {C[1] * W[0] + C[2] * W[1], C[1] * W[1] + C[2] * W[2]},
40 {C[3] * W[0] + C[4] * W[1], C[3] * W[1] + C[4] * W[2]}, {C[6] * W[0] + C[7] * W[1], C[6] * W[1] + C[7] * W[2]},
41 {C[10] * W[0] + C[11] * W[1], C[10] * W[1] + C[11] * W[2]},
44 T[0] -= K[0][0] * zeta[0] + K[0][1] * zeta[1];
45 T[1] -= K[1][0] * zeta[0] + K[1][1] * zeta[1];
46 T[2] -= K[2][0] * zeta[0] + K[2][1] * zeta[1];
47 T[3] -= K[3][0] * zeta[0] + K[3][1] * zeta[1];
48 T[4] -= K[4][0] * zeta[0] + K[4][1] * zeta[1];
51 C[0] * K[0][0] + C[1] * K[0][1], C[0] * K[1][0] + C[1] * K[1][1], C[1] * K[1][0] + C[2] * K[1][1],
53 C[0] * K[2][0] + C[1] * K[2][1], C[1] * K[2][0] + C[2] * K[2][1], C[3] * K[2][0] + C[4] * K[2][1],
55 C[0] * K[3][0] + C[1] * K[3][1], C[1] * K[3][0] + C[2] * K[3][1], 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], C[1] * K[4][0] + C[2] * K[4][1], C[3] * K[4][0] + C[4] * K[4][1],
59 C[6] * K[4][0] + C[7] * K[4][1], C[10] * K[4][0] + C[11] * K[4][1]};
94 double gateY, vector<double>& vProb)
96 const double Pdetect = 0.90;
97 const double gateEff = 0.99;
103 double gateArea = gateX * gateY;
104 double chi2, zeta[2];
105 int ndf = 2, idx, i, j, k;
107 vector<double> vResidX;
108 vector<double> vResidY;
109 vector<double> vChi2;
113 cout <<
"PDAF: " << vm->size() <<
" hits validated" << endl;
114 cout <<
"Initial params: x=" << T[0] <<
" y=" << T[1] <<
" tx=" << T[2] <<
" ty=" << T[3] <<
" Q=" << T[4] << endl;
115 cout <<
"GateX=" << gateX <<
" GateY=" << gateY << endl;
125 const double*
V = (*vm.begin())->V;
129 Sk = (C[0] +
V[0]) * (C[2] +
V[2]) - (C[1] +
V[1]) * (C[1] +
V[1]);
133 double Lambda = 1. / 1.;
135 Ck = 2.0 * 3.1415926 *
sqrt(Sk) * (1.0 - Pdetect * gateEff) / (gateArea * Pdetect * gateEff) * Lambda;
145 double W[3] = {w * (C[2] +
V[2]), -w * (C[1] +
V[1]), w * (C[0] +
V[0])};
147 {C[0] * W[0] + C[1] * W[1], C[0] * W[1] + C[1] * W[2]}, {C[1] * W[0] + C[2] * W[1], C[1] * W[1] + C[2] * W[2]},
148 {C[3] * W[0] + C[4] * W[1], C[3] * W[1] + C[4] * W[2]}, {C[6] * W[0] + C[7] * W[1], C[6] * W[1] + C[7] * W[2]},
149 {C[10] * W[0] + C[11] * W[1], C[10] * W[1] + C[11] * W[2]},
154 for (vector<CbmKFPixelMeasurement*>::iterator pmIt = vm.begin(); pmIt != vm.end(); ++pmIt) {
155 double resX = (*pmIt)->x - T[0];
156 double resY = (*pmIt)->y - T[1];
157 chi2 = resX * resX * W[0] + 2 * resY * resX * W[1] + resY * resY * W[2];
159 cout <<
"resX=" << resX <<
" resY=" << resY <<
" chi2dist=" << chi2 << endl;
161 vChi2.push_back(chi2);
162 vResidX.push_back(resX);
163 vResidY.push_back(resY);
164 vExp.push_back(
exp(-0.5 * chi2));
170 vector<double>::iterator eIt;
171 for (eIt = vExp.begin(); eIt != vExp.end(); ++eIt) {
175 double P0 = Ck * Sum;
177 cout <<
"No-detect probability = " << P0 << endl;
179 for (eIt = vExp.begin(); eIt != vExp.end(); ++eIt) {
180 vProb.push_back(Sum * (*eIt));
190 for (eIt = vProb.begin(); eIt != vProb.end(); ++eIt) {
191 zeta[0] += vResidX[idx] * (*eIt);
192 zeta[1] += vResidY[idx] * (*eIt);
193 chi2 += vChi2[idx] * (*eIt);
195 cout <<
"Hit " << idx <<
" Assignment probability = " << (*eIt) << endl;
200 cout <<
"Merged resX=" << zeta[0] <<
" resY=" << zeta[1] << endl;
206 CR[0][0] = -zeta[0] * zeta[0];
207 CR[0][1] = -zeta[0] * zeta[1];
208 CR[1][0] = -zeta[1] * zeta[0];
209 CR[1][1] = -zeta[1] * zeta[1];
211 for (eIt = vProb.begin(); eIt != vProb.end(); ++eIt) {
212 CR[0][0] += (*eIt) * vResidX[idx] * vResidX[idx];
213 CR[0][1] += (*eIt) * vResidX[idx] * vResidY[idx];
214 CR[1][0] += (*eIt) * vResidY[idx] * vResidX[idx];
215 CR[1][1] += (*eIt) * vResidY[idx] * vResidY[idx];
219 for (i = 0; i < 5; i++) {
220 for (j = 0; j < 2; j++) {
222 for (k = 0; k < 2; k++)
223 KD[i][j] += K[i][k] * CR[k][j];
230 for (i = 0; i < 5; i++) {
231 for (j = 0; j < 5; j++) {
233 for (k = 0; k < 2; k++)
234 Ga[i][j] += KD[i][k] * K[j][k];
241 T[0] += K[0][0] * zeta[0] + K[0][1] * zeta[1];
242 T[1] += K[1][0] * zeta[0] + K[1][1] * zeta[1];
243 T[2] += K[2][0] * zeta[0] + K[2][1] * zeta[1];
244 T[3] += K[3][0] * zeta[0] + K[3][1] * zeta[1];
245 T[4] += K[4][0] * zeta[0] + K[4][1] * zeta[1];
247 double KHC[15] = {C[0] * K[0][0] + C[1] * K[0][1], C[0] * K[1][0] + C[1] * K[1][1], C[1] * K[1][0] + C[2] * K[1][1],
249 C[0] * K[2][0] + C[1] * K[2][1], C[1] * K[2][0] + C[2] * K[2][1], C[3] * K[2][0] + C[4] * K[2][1],
251 C[0] * K[3][0] + C[1] * K[3][1], C[1] * K[3][0] + C[2] * K[3][1], C[3] * K[3][0] + C[4] * K[3][1],
252 C[6] * K[3][0] + C[7] * K[3][1],
254 C[0] * K[4][0] + C[1] * K[4][1], C[1] * K[4][0] + C[2] * K[4][1], C[3] * K[4][0] + C[4] * K[4][1],
255 C[6] * K[4][0] + C[7] * K[4][1], C[10] * K[4][0] + C[11] * K[4][1]};
258 for (i = 0; i < 15; i++) {
284 for (i = 0; i < 5; i++) {
285 for (j = 0; j <= i; j++) {
286 C[idx] = P0 * C[idx] + (1 - P0) * Gs[idx] + Ga[i][j];
291 cout <<
"Updated params: x=" << T[0] <<
" y=" << T[1] <<
" tx=" << T[2] <<
" ty=" << T[3] <<
" Q=" << T[4] << endl;
292 cout <<
"chi2 contrib.=" << chi2 << endl;