51 static const litfloat ONE = 1., TWO = 2.;
67 / ((cIn[0] + dxx) * ((cIn[6] + dyy) * (cIn[20] + dtt) - cIn[10] * cIn[10])
68 - (cIn[1] + dxy) * ((cIn[1] + dxy) * (cIn[20] + dtt) - cIn[5] * cIn[10])
69 + cIn[5] * ((cIn[1] + dxy) * cIn[10] - (cIn[6] + dyy) * cIn[5]));
73 litfloat R00 = ((cIn[6] + dyy) * (cIn[20] + dtt) - cIn[10] * cIn[10]) * t;
74 litfloat R01 = (cIn[5] * cIn[10] - (cIn[1] + dxy) * (cIn[20] + dtt)) * t;
75 litfloat R02 = ((cIn[1] + dxy) * cIn[10] - (cIn[6] + dyy) * cIn[5]) * t;
76 litfloat R11 = ((cIn[0] + dxx) * (cIn[20] + dtt) - cIn[5] * cIn[5]) * t;
77 litfloat R12 = ((cIn[1] + dxy) * cIn[5] - (cIn[0] + dxx) * cIn[10]) * t;
78 litfloat R22 = ((cIn[0] + dxx) * (cIn[6] + dyy) - (cIn[1] + dxy) * (cIn[1] + dxy)) * t;
100 litfloat K00 = cIn[0] * R00 + cIn[1] * R01 + cIn[5] * R02;
101 litfloat K01 = cIn[0] * R01 + cIn[1] * R11 + cIn[5] * R12;
102 litfloat K02 = cIn[0] * R02 + cIn[1] * R12 + cIn[5] * R22;
103 litfloat K10 = cIn[1] * R00 + cIn[6] * R01 + cIn[10] * R02;
104 litfloat K11 = cIn[1] * R01 + cIn[6] * R11 + cIn[10] * R12;
105 litfloat K12 = cIn[1] * R02 + cIn[6] * R12 + cIn[10] * R22;
106 litfloat K20 = cIn[2] * R00 + cIn[7] * R01 + cIn[14] * R02;
107 litfloat K21 = cIn[2] * R01 + cIn[7] * R11 + cIn[14] * R12;
108 litfloat K22 = cIn[2] * R02 + cIn[7] * R12 + cIn[14] * R22;
109 litfloat K30 = cIn[3] * R00 + cIn[8] * R01 + cIn[17] * R02;
110 litfloat K31 = cIn[3] * R01 + cIn[8] * R11 + cIn[17] * R12;
111 litfloat K32 = cIn[3] * R02 + cIn[8] * R12 + cIn[17] * R22;
112 litfloat K40 = cIn[4] * R00 + cIn[9] * R01 + cIn[19] * R02;
113 litfloat K41 = cIn[4] * R01 + cIn[9] * R11 + cIn[19] * R12;
114 litfloat K42 = cIn[4] * R02 + cIn[9] * R12 + cIn[19] * R22;
115 litfloat K50 = cIn[5] * R00 + cIn[10] * R01 + cIn[20] * R02;
116 litfloat K51 = cIn[5] * R01 + cIn[10] * R11 + cIn[20] * R12;
117 litfloat K52 = cIn[5] * R02 + cIn[10] * R12 + cIn[20] * R22;
121 xOut[0] += K00 * dx + K01 * dy + K02 * dt;
122 xOut[1] += K10 * dx + K11 * dy + K12 * dt;
123 xOut[2] += K20 * dx + K21 * dy + K22 * dt;
124 xOut[3] += K30 * dx + K31 * dy + K32 * dt;
125 xOut[4] += K40 * dx + K41 * dy + K42 * dt;
126 xOut[5] += K50 * dx + K51 * dy + K52 * dt;
129 std::vector<litfloat> cOut = cIn;
131 cOut[0] -= K00 * cIn[0] + K01 * cIn[1] + K02 * cIn[5];
132 cOut[1] -= K00 * cIn[1] + K01 * cIn[6] + K02 * cIn[10];
133 cOut[2] -= K00 * cIn[2] + K01 * cIn[7] + K02 * cIn[14];
134 cOut[3] -= K00 * cIn[3] + K01 * cIn[8] + K02 * cIn[17];
135 cOut[4] -= K00 * cIn[4] + K01 * cIn[9] + K02 * cIn[19];
136 cOut[5] -= K00 * cIn[5] + K01 * cIn[10] + K02 * cIn[20];
138 cOut[6] -= K10 * cIn[1] + K11 * cIn[6] + K12 * cIn[10];
139 cOut[7] -= K10 * cIn[2] + K11 * cIn[7] + K12 * cIn[14];
140 cOut[8] -= K10 * cIn[3] + K11 * cIn[8] + K12 * cIn[17];
141 cOut[9] -= K10 * cIn[4] + K11 * cIn[9] + K12 * cIn[19];
142 cOut[10] -= K10 * cIn[5] + K11 * cIn[10] + K12 * cIn[20];
144 cOut[11] -= K20 * cIn[2] + K21 * cIn[7] + K22 * cIn[14];
145 cOut[12] -= K20 * cIn[3] + K21 * cIn[8] + K22 * cIn[17];
146 cOut[13] -= K20 * cIn[4] + K21 * cIn[9] + K22 * cIn[19];
147 cOut[14] -= K20 * cIn[5] + K21 * cIn[10] + K22 * cIn[20];
149 cOut[15] -= K30 * cIn[3] + K31 * cIn[8] + K32 * cIn[17];
150 cOut[16] -= K30 * cIn[4] + K31 * cIn[9] + K32 * cIn[19];
151 cOut[17] -= K30 * cIn[5] + K31 * cIn[10] + K32 * cIn[20];
153 cOut[18] -= K40 * cIn[4] + K41 * cIn[9] + K42 * cIn[19];
154 cOut[19] -= K40 * cIn[5] + K41 * cIn[10] + K42 * cIn[20];
156 cOut[20] -= K50 * cIn[5] + K51 * cIn[10] + K52 * cIn[20];
181 litfloat norm = (dxx - cOut[0]) * ((dyy - cOut[6]) * (dtt - cOut[20]) - cOut[10] * cOut[10])
182 + (dxy - cOut[1]) * (cOut[5] * cOut[10] - (dxy - cOut[1]) * (dtt - cOut[20]))
183 + cOut[5] * ((dxy - cOut[1]) * cOut[10] - (dyy - cOut[6]) * cOut[5]);
190 litfloat M00 = ((dyy - cOut[6]) * (dtt - cOut[20]) - cOut[10] * cOut[10]) / norm;
191 litfloat M01 = ((dxy - cOut[1]) * (dtt - cOut[20]) - cOut[5] * cOut[10]) / norm;
192 litfloat M02 = ((dxy - cOut[1]) * cOut[10] - (dyy - cOut[6]) * cOut[5]) / norm;
193 litfloat M11 = ((dxx - cOut[0]) * (dtt - cOut[20]) - cOut[5] * cOut[5]) / norm;
194 litfloat M12 = ((dxx - cOut[0]) * cOut[10] - (dxy - cOut[1]) * cOut[5]) / norm;
195 litfloat M22 = ((dxx - cOut[0]) * (dyy - cOut[6]) - (dxy - cOut[1]) * (dxy - cOut[1])) / norm;
215 chiSq = xmx * (xmx * M00 + ymy * M01 + tmt * M02) + ymy * (xmx * M01 + ymy * M11 + tmt * M12)
216 + tmt * (xmx * M02 + ymy * M12 + tmt * M22);
235 std::vector<litfloat> C1 = cInInv;
236 litfloat det = dxx * dyy - dxy * dxy;
243 std::vector<litfloat> t(5);
244 t[0] = cInInv[0] * par->
GetX() + cInInv[1] * par->
GetY() + cInInv[2] * par->
GetTx() + cInInv[3] * par->
GetTy()
245 + cInInv[4] * par->
GetQp() + (dyy * hit->
GetX() - dxy * hit->
GetY()) / det;
246 t[1] = cInInv[1] * par->
GetX() + cInInv[5] * par->
GetY() + cInInv[6] * par->
GetTx() + cInInv[7] * par->
GetTy()
247 + cInInv[8] * par->
GetQp() + (-dxy * hit->
GetX() + dxx * hit->
GetY()) / det;
248 t[2] = cInInv[2] * par->
GetX() + cInInv[6] * par->
GetY() + cInInv[9] * par->
GetTx() + cInInv[10] * par->
GetTy()
249 + cInInv[11] * par->
GetQp();
250 t[3] = cInInv[3] * par->
GetX() + cInInv[7] * par->
GetY() + cInInv[10] * par->
GetTx() + cInInv[12] * par->
GetTy()
251 + cInInv[13] * par->
GetQp();
252 t[4] = cInInv[4] * par->
GetX() + cInInv[8] * par->
GetY() + cInInv[11] * par->
GetTx() + cInInv[13] * par->
GetTy()
253 + cInInv[14] * par->
GetQp();
255 std::vector<litfloat> xOut(5);
274 chiSq = ((xmx * dyy - ymy * dxy) * xmx + (-xmx * dxy + ymy * dxx) * ymy) / det
275 + (dx0 * cInInv[0] + dx1 * cInInv[1] + dx2 * cInInv[2] + dx3 * cInInv[3] + dx4 * cInInv[4]) * dx0
276 + (dx0 * cInInv[1] + dx1 * cInInv[5] + dx2 * cInInv[6] + dx3 * cInInv[7] + dx4 * cInInv[8]) * dx1
277 + (dx0 * cInInv[2] + dx1 * cInInv[6] + dx2 * cInInv[9] + dx3 * cInInv[10] + dx4 * cInInv[11]) * dx2
278 + (dx0 * cInInv[3] + dx1 * cInInv[7] + dx2 * cInInv[10] + dx3 * cInInv[12] + dx4 * cInInv[13]) * dx3
279 + (dx0 * cInInv[4] + dx1 * cInInv[8] + dx2 * cInInv[11] + dx3 * cInInv[13] + dx4 * cInInv[14]) * dx4;
293 litfloat phiCosSq = phiCos * phiCos;
294 litfloat phiSinSq = phiSin * phiSin;
295 litfloat phi2SinCos = 2 * phiCos * phiSin;
298 litfloat R = 1. / (duu + cIn[0] * phiCosSq + phi2SinCos * cIn[1] + cIn[5] * phiSinSq);
301 litfloat K0 = cIn[0] * phiCos + cIn[1] * phiSin;
302 litfloat K1 = cIn[1] * phiCos + cIn[5] * phiSin;
303 litfloat K2 = cIn[2] * phiCos + cIn[6] * phiSin;
304 litfloat K3 = cIn[3] * phiCos + cIn[7] * phiSin;
305 litfloat K4 = cIn[4] * phiCos + cIn[8] * phiSin;
314 litfloat r = u - xIn[0] * phiCos - xIn[1] * phiSin;
317 std::vector<litfloat> xOut(5);
318 xOut[0] = xIn[0] + KR0 * r;
319 xOut[1] = xIn[1] + KR1 * r;
320 xOut[2] = xIn[2] + KR2 * r;
321 xOut[3] = xIn[3] + KR3 * r;
322 xOut[4] = xIn[4] + KR4 * r;
325 std::vector<litfloat> cOut(15);
326 cOut[0] = cIn[0] - KR0 * K0;
327 cOut[1] = cIn[1] - KR0 * K1;
328 cOut[2] = cIn[2] - KR0 * K2;
329 cOut[3] = cIn[3] - KR0 * K3;
330 cOut[4] = cIn[4] - KR0 * K4;
332 cOut[5] = cIn[5] - KR1 * K1;
333 cOut[6] = cIn[6] - KR1 * K2;
334 cOut[7] = cIn[7] - KR1 * K3;
335 cOut[8] = cIn[8] - KR1 * K4;
337 cOut[9] = cIn[9] - KR2 * K2;
338 cOut[10] = cIn[10] - KR2 * K3;
339 cOut[11] = cIn[11] - KR2 * K4;
341 cOut[12] = cIn[12] - KR3 * K3;
342 cOut[13] = cIn[13] - KR3 * K4;
344 cOut[14] = cIn[14] - KR4 * K4;
355 litfloat ru = u - xOut[0] * phiCos - xOut[1] * phiSin;
358 chiSq = (ru * ru) / (duu - phiCosSq * cOut[0] - phi2SinCos * cOut[1] - phiSinSq * cOut[5]);
377 std::vector<litfloat> C1 = cInInv;
378 C1[0] += phiCos * phiCos / duu;
379 C1[1] += phiCos * phiSin / duu;
380 C1[5] += phiSin * phiSin / duu;
384 std::vector<litfloat> t(5);
385 t[0] = cInInv[0] * par->
GetX() + cInInv[1] * par->
GetY() + cInInv[2] * par->
GetTx() + cInInv[3] * par->
GetTy()
386 + cInInv[4] * par->
GetQp() + phiCos * hit->
GetU() / duu;
387 t[1] = cInInv[1] * par->
GetX() + cInInv[5] * par->
GetY() + cInInv[6] * par->
GetTx() + cInInv[7] * par->
GetTy()
388 + cInInv[8] * par->
GetQp() + phiSin * hit->
GetU() / duu;
389 t[2] = cInInv[2] * par->
GetX() + cInInv[6] * par->
GetY() + cInInv[9] * par->
GetTx() + cInInv[10] * par->
GetTy()
390 + cInInv[11] * par->
GetQp();
391 t[3] = cInInv[3] * par->
GetX() + cInInv[7] * par->
GetY() + cInInv[10] * par->
GetTx() + cInInv[12] * par->
GetTy()
392 + cInInv[13] * par->
GetQp();
393 t[4] = cInInv[4] * par->
GetX() + cInInv[8] * par->
GetY() + cInInv[11] * par->
GetTx() + cInInv[13] * par->
GetTy()
394 + cInInv[14] * par->
GetQp();
396 std::vector<litfloat> xOut(5);
408 litfloat zeta = hit->
GetU() - phiCos * xOut[0] - phiSin * xOut[1];
414 chiSq = zeta * zeta / duu
415 + (dx0 * cInInv[0] + dx1 * cInInv[1] + dx2 * cInInv[2] + dx3 * cInInv[3] + dx4 * cInInv[4]) * dx0
416 + (dx0 * cInInv[1] + dx1 * cInInv[5] + dx2 * cInInv[6] + dx3 * cInInv[7] + dx4 * cInInv[8]) * dx1
417 + (dx0 * cInInv[2] + dx1 * cInInv[6] + dx2 * cInInv[9] + dx3 * cInInv[10] + dx4 * cInInv[11]) * dx2
418 + (dx0 * cInInv[3] + dx1 * cInInv[7] + dx2 * cInInv[10] + dx3 * cInInv[12] + dx4 * cInInv[13]) * dx3
419 + (dx0 * cInInv[4] + dx1 * cInInv[8] + dx2 * cInInv[11] + dx3 * cInInv[13] + dx4 * cInInv[14]) * dx4;