7 #include "KalmanUtilsMPlex.icc" 12 using namespace mkfit;
22 MultResidualsAdd_imp(
A,
B,
C,
D, 0,
NN);
35 const T*
a =
A.fArray;
37 const T*
b =
B.fArray;
39 const T*
c =
C.fArray;
47 d[0 *
N +
n] =
b[0 *
N +
n] +
a[0 *
N +
n] *
c[0 *
N +
n] +
a[1 *
N +
n] *
c[1 *
N +
n];
48 d[1 *
N +
n] =
b[1 *
N +
n] +
a[2 *
N +
n] *
c[0 *
N +
n] +
a[3 *
N +
n] *
c[1 *
N +
n];
49 d[2 *
N +
n] =
b[2 *
N +
n] +
a[4 *
N +
n] *
c[0 *
N +
n] +
a[5 *
N +
n] *
c[1 *
N +
n];
50 d[3 *
N +
n] =
b[3 *
N +
n] +
a[6 *
N +
n] *
c[0 *
N +
n] +
a[7 *
N +
n] *
c[1 *
N +
n];
51 d[4 *
N +
n] =
b[4 *
N +
n] +
a[8 *
N +
n] *
c[0 *
N +
n] +
a[9 *
N +
n] *
c[1 *
N +
n];
52 d[5 *
N +
n] =
b[5 *
N +
n] +
a[10 *
N +
n] *
c[0 *
N +
n] +
a[11 *
N +
n] *
c[1 *
N +
n];
58 inline void Chi2Similarity(
const MPlex2V&
A,
68 const T*
a =
A.fArray;
70 const T*
c =
C.fArray;
78 d[0 *
N +
n] =
c[0 *
N +
n] *
a[0 *
N +
n] *
a[0 *
N +
n] +
c[2 *
N +
n] *
a[1 *
N +
n] *
a[1 *
N +
n] +
79 2 * (
c[1 *
N +
n] *
a[1 *
N +
n] *
a[0 *
N +
n]);
91 const T*
a =
A.fArray;
93 const T*
b =
B.fArray;
100 c[0 *
N +
n] =
a[0 *
N +
n] +
b[0 *
N +
n];
101 c[1 *
N +
n] =
a[1 *
N +
n] +
b[1 *
N +
n];
102 c[2 *
N +
n] =
a[2 *
N +
n] +
b[2 *
N +
n];
103 c[3 *
N +
n] =
a[3 *
N +
n] +
b[3 *
N +
n];
104 c[4 *
N +
n] =
a[4 *
N +
n] +
b[4 *
N +
n];
105 c[5 *
N +
n] =
a[5 *
N +
n] +
b[5 *
N +
n];
115 const T*
a =
A.fArray;
117 const T*
b =
B.fArray;
124 c[0 *
N +
n] =
a[0 *
N +
n] +
b[0 *
N +
n];
125 c[1 *
N +
n] =
a[1 *
N +
n] +
b[1 *
N +
n];
126 c[2 *
N +
n] =
a[2 *
N +
n] +
b[2 *
N +
n];
138 const T*
a =
A.fArray;
140 const T*
b =
B.fArray;
147 c[0 *
N +
n] =
a[0 *
N +
n] -
b[0 *
N +
n];
148 c[1 *
N +
n] =
a[1 *
N +
n] -
b[1 *
N +
n];
149 c[2 *
N +
n] =
a[2 *
N +
n] -
b[2 *
N +
n];
159 const T*
a =
A.fArray;
161 const T*
b =
B.fArray;
168 c[0 *
N +
n] =
a[0 *
N +
n] -
b[0 *
N +
n];
169 c[1 *
N +
n] =
a[1 *
N +
n] -
b[1 *
N +
n];
183 const T* a00 = A00.fArray;
185 const T* a01 = A01.fArray;
187 const T*
b =
B.fArray;
193 for (
int n = 0;
n <
N; ++
n) {
194 c[0 *
N +
n] = a00[
n] *
b[0 *
N +
n] + a01[
n] *
b[1 *
N +
n];
195 c[1 *
N +
n] = a00[
n] *
b[1 *
N +
n] + a01[
n] *
b[2 *
N +
n];
196 c[2 *
N +
n] = a00[
n] *
b[3 *
N +
n] + a01[
n] *
b[4 *
N +
n];
197 c[3 *
N +
n] =
b[3 *
N +
n];
198 c[4 *
N +
n] =
b[4 *
N +
n];
199 c[5 *
N +
n] =
b[5 *
N +
n];
200 c[6 *
N +
n] = a01[
n] *
b[0 *
N +
n] - a00[
n] *
b[1 *
N +
n];
201 c[7 *
N +
n] = a01[
n] *
b[1 *
N +
n] - a00[
n] *
b[2 *
N +
n];
202 c[8 *
N +
n] = a01[
n] *
b[3 *
N +
n] - a00[
n] *
b[4 *
N +
n];
214 const T* a00 = A00.fArray;
216 const T* a01 = A01.fArray;
218 const T*
b =
B.fArray;
224 for (
int n = 0;
n <
N; ++
n) {
225 c[0 *
N +
n] =
b[0 *
N +
n] * a00[
n] +
b[1 *
N +
n] * a01[
n];
226 c[1 *
N +
n] =
b[3 *
N +
n] * a00[
n] +
b[4 *
N +
n] * a01[
n];
227 c[2 *
N +
n] =
b[5 *
N +
n];
231 inline void RotateResidualsOnTangentPlane(
const MPlexQF& R00,
236 RotateResidualsOnTangentPlane_impl(R00, R01,
A,
B, 0,
NN);
255 const T*
a =
A.fArray;
257 const T*
b =
B.fArray;
263 for (
int n = 0;
n <
N; ++
n) {
264 c[0 *
N +
n] =
a[0 *
N +
n] *
b[0 *
N +
n] +
a[1 *
N +
n] *
b[1 *
N +
n] +
a[2 *
N +
n] *
b[3 *
N +
n];
265 c[1 *
N +
n] =
a[0 *
N +
n] *
b[1 *
N +
n] +
a[1 *
N +
n] *
b[2 *
N +
n] +
a[2 *
N +
n] *
b[4 *
N +
n];
266 c[2 *
N +
n] =
a[0 *
N +
n] *
b[3 *
N +
n] +
a[1 *
N +
n] *
b[4 *
N +
n] +
a[2 *
N +
n] *
b[5 *
N +
n];
267 c[3 *
N +
n] =
a[3 *
N +
n] *
b[0 *
N +
n] +
a[4 *
N +
n] *
b[1 *
N +
n] +
a[5 *
N +
n] *
b[3 *
N +
n];
268 c[4 *
N +
n] =
a[3 *
N +
n] *
b[1 *
N +
n] +
a[4 *
N +
n] *
b[2 *
N +
n] +
a[5 *
N +
n] *
b[4 *
N +
n];
269 c[5 *
N +
n] =
a[3 *
N +
n] *
b[3 *
N +
n] +
a[4 *
N +
n] *
b[4 *
N +
n] +
a[5 *
N +
n] *
b[5 *
N +
n];
287 const T*
a =
A.fArray;
289 const T*
b =
B.fArray;
295 for (
int n = 0;
n <
N; ++
n) {
296 c[0 *
N +
n] =
b[0 *
N +
n] *
a[0 *
N +
n] +
b[1 *
N +
n] *
a[1 *
N +
n] +
b[2 *
N +
n] *
a[2 *
N +
n];
297 c[1 *
N +
n] =
b[0 *
N +
n] *
a[3 *
N +
n] +
b[1 *
N +
n] *
a[4 *
N +
n] +
b[2 *
N +
n] *
a[5 *
N +
n];
298 c[2 *
N +
n] =
b[3 *
N +
n] *
a[3 *
N +
n] +
b[4 *
N +
n] *
a[4 *
N +
n] +
b[5 *
N +
n] *
a[5 *
N +
n];
302 inline void RotateResidualsOnPlane(
const MPlex2H&
R,
317 for (
int n = 0;
n <
NN; ++
n) {
318 B(
n, 0, 0) =
R(
n, 0, 0) *
A(
n, 0, 0) +
R(
n, 0, 1) *
A(
n, 1, 0) +
R(
n, 0, 2) *
A(
n, 2, 0);
319 B(
n, 1, 0) =
R(
n, 1, 0) *
A(
n, 0, 0) +
R(
n, 1, 1) *
A(
n, 1, 0) +
R(
n, 1, 2) *
A(
n, 2, 0);
332 const T* a00 = A00.fArray;
334 const T* a01 = A01.fArray;
336 const T*
b =
B.fArray;
342 for (
int n = 0;
n <
N; ++
n) {
343 c[0 *
N +
n] = a00[
n] *
b[0 *
N +
n];
344 c[1 *
N +
n] = a00[
n] *
b[1 *
N +
n];
346 c[3 *
N +
n] = a01[
n] *
b[0 *
N +
n];
347 c[4 *
N +
n] = a01[
n] *
b[1 *
N +
n];
349 c[6 *
N +
n] =
b[1 *
N +
n];
350 c[7 *
N +
n] =
b[2 *
N +
n];
361 const T*
a =
A.fArray;
363 const T*
b =
B.fArray;
369 for (
int n = 0;
n <
N; ++
n) {
370 c[0 *
N +
n] =
a[0 *
N +
n] *
b[0 *
N +
n] +
a[1 *
N +
n] *
b[3 *
N +
n] +
a[3 *
N +
n] *
b[6 *
N +
n];
371 c[1 *
N +
n] =
a[0 *
N +
n] *
b[1 *
N +
n] +
a[1 *
N +
n] *
b[4 *
N +
n] +
a[3 *
N +
n] *
b[7 *
N +
n];
373 c[3 *
N +
n] =
a[1 *
N +
n] *
b[0 *
N +
n] +
a[2 *
N +
n] *
b[3 *
N +
n] +
a[4 *
N +
n] *
b[6 *
N +
n];
374 c[4 *
N +
n] =
a[1 *
N +
n] *
b[1 *
N +
n] +
a[2 *
N +
n] *
b[4 *
N +
n] +
a[4 *
N +
n] *
b[7 *
N +
n];
376 c[6 *
N +
n] =
a[3 *
N +
n] *
b[0 *
N +
n] +
a[4 *
N +
n] *
b[3 *
N +
n] +
a[5 *
N +
n] *
b[6 *
N +
n];
377 c[7 *
N +
n] =
a[3 *
N +
n] *
b[1 *
N +
n] +
a[4 *
N +
n] *
b[4 *
N +
n] +
a[5 *
N +
n] *
b[7 *
N +
n];
379 c[9 *
N +
n] =
a[6 *
N +
n] *
b[0 *
N +
n] +
a[7 *
N +
n] *
b[3 *
N +
n] +
a[8 *
N +
n] *
b[6 *
N +
n];
380 c[10 *
N +
n] =
a[6 *
N +
n] *
b[1 *
N +
n] +
a[7 *
N +
n] *
b[4 *
N +
n] +
a[8 *
N +
n] *
b[7 *
N +
n];
382 c[12 *
N +
n] =
a[10 *
N +
n] *
b[0 *
N +
n] +
a[11 *
N +
n] *
b[3 *
N +
n] +
a[12 *
N +
n] *
b[6 *
N +
n];
383 c[13 *
N +
n] =
a[10 *
N +
n] *
b[1 *
N +
n] +
a[11 *
N +
n] *
b[4 *
N +
n] +
a[12 *
N +
n] *
b[7 *
N +
n];
385 c[15 *
N +
n] =
a[15 *
N +
n] *
b[0 *
N +
n] +
a[16 *
N +
n] *
b[3 *
N +
n] +
a[17 *
N +
n] *
b[6 *
N +
n];
386 c[16 *
N +
n] =
a[15 *
N +
n] *
b[1 *
N +
n] +
a[16 *
N +
n] *
b[4 *
N +
n] +
a[17 *
N +
n] *
b[7 *
N +
n];
409 const T*
a =
A.fArray;
411 const T*
b =
B.fArray;
417 for (
int n = 0;
n <
N; ++
n) {
418 c[0 *
N +
n] =
a[0 *
N +
n] *
b[0 *
N +
n] +
a[3 *
N +
n] *
b[1 *
N +
n];
419 c[1 *
N +
n] =
a[0 *
N +
n] *
b[1 *
N +
n] +
a[3 *
N +
n] *
b[2 *
N +
n];
420 c[2 *
N +
n] =
a[1 *
N +
n] *
b[0 *
N +
n] +
a[4 *
N +
n] *
b[1 *
N +
n];
421 c[3 *
N +
n] =
a[1 *
N +
n] *
b[1 *
N +
n] +
a[4 *
N +
n] *
b[2 *
N +
n];
422 c[4 *
N +
n] =
a[2 *
N +
n] *
b[0 *
N +
n] +
a[5 *
N +
n] *
b[1 *
N +
n];
423 c[5 *
N +
n] =
a[2 *
N +
n] *
b[1 *
N +
n] +
a[5 *
N +
n] *
b[2 *
N +
n];
454 const T*
a =
A.fArray;
456 const T*
b =
B.fArray;
462 for (
int n = 0;
n <
N; ++
n) {
463 c[0 *
N +
n] =
a[0 *
N +
n] *
b[0 *
N +
n] +
a[1 *
N +
n] *
b[2 *
N +
n] +
a[3 *
N +
n] *
b[4 *
N +
n];
464 c[1 *
N +
n] =
a[0 *
N +
n] *
b[1 *
N +
n] +
a[1 *
N +
n] *
b[3 *
N +
n] +
a[3 *
N +
n] *
b[5 *
N +
n];
465 c[2 *
N +
n] =
a[1 *
N +
n] *
b[0 *
N +
n] +
a[2 *
N +
n] *
b[2 *
N +
n] +
a[4 *
N +
n] *
b[4 *
N +
n];
466 c[3 *
N +
n] =
a[1 *
N +
n] *
b[1 *
N +
n] +
a[2 *
N +
n] *
b[3 *
N +
n] +
a[4 *
N +
n] *
b[5 *
N +
n];
467 c[4 *
N +
n] =
a[3 *
N +
n] *
b[0 *
N +
n] +
a[4 *
N +
n] *
b[2 *
N +
n] +
a[5 *
N +
n] *
b[4 *
N +
n];
468 c[5 *
N +
n] =
a[3 *
N +
n] *
b[1 *
N +
n] +
a[4 *
N +
n] *
b[3 *
N +
n] +
a[5 *
N +
n] *
b[5 *
N +
n];
469 c[6 *
N +
n] =
a[6 *
N +
n] *
b[0 *
N +
n] +
a[7 *
N +
n] *
b[2 *
N +
n] +
a[8 *
N +
n] *
b[4 *
N +
n];
470 c[7 *
N +
n] =
a[6 *
N +
n] *
b[1 *
N +
n] +
a[7 *
N +
n] *
b[3 *
N +
n] +
a[8 *
N +
n] *
b[5 *
N +
n];
471 c[8 *
N +
n] =
a[10 *
N +
n] *
b[0 *
N +
n] +
a[11 *
N +
n] *
b[2 *
N +
n] +
a[12 *
N +
n] *
b[4 *
N +
n];
472 c[9 *
N +
n] =
a[10 *
N +
n] *
b[1 *
N +
n] +
a[11 *
N +
n] *
b[3 *
N +
n] +
a[12 *
N +
n] *
b[5 *
N +
n];
473 c[10 *
N +
n] =
a[15 *
N +
n] *
b[0 *
N +
n] +
a[16 *
N +
n] *
b[2 *
N +
n] +
a[17 *
N +
n] *
b[4 *
N +
n];
474 c[11 *
N +
n] =
a[15 *
N +
n] *
b[1 *
N +
n] +
a[16 *
N +
n] *
b[3 *
N +
n] +
a[17 *
N +
n] *
b[5 *
N +
n];
484 const T* r00 =
R00.fArray;
486 const T* r01 = R01.fArray;
488 const T* ci = Ci.fArray;
494 for (
int n = 0;
n <
N; ++
n) {
497 r00[
n] * r00[
n] * ci[0 *
N +
n] + 2 * r00[
n] * r01[
n] * ci[1 *
N +
n] + r01[
n] * r01[
n] * ci[2 *
N +
n];
498 co[1 *
N +
n] = r00[
n] * r01[
n] *
co[0 *
N +
n];
499 co[2 *
N +
n] = r01[
n] * r01[
n] *
co[0 *
N +
n];
500 co[0 *
N +
n] = r00[
n] * r00[
n] *
co[0 *
N +
n];
502 co[3 *
N +
n] = r00[
n] * ci[3 *
N +
n] + r01[
n] * ci[4 *
N +
n];
506 co[6 *
N +
n] = r00[
n] * ci[6 *
N +
n] + r01[
n] * ci[7 *
N +
n];
510 co[10 *
N +
n] = r00[
n] * ci[10 *
N +
n] + r01[
n] * ci[11 *
N +
n];
511 co[11 *
N +
n] = r01[
n] *
co[10 *
N +
n];
512 co[10 *
N +
n] = r00[
n] *
co[10 *
N +
n];
514 co[15 *
N +
n] = r00[
n] * ci[15 *
N +
n] + r01[
n] * ci[16 *
N +
n];
515 co[16 *
N +
n] = r01[
n] *
co[15 *
N +
n];
516 co[15 *
N +
n] = r00[
n] *
co[15 *
N +
n];
526 const T*
a =
A.fArray;
528 const T*
b =
B.fArray;
533 #include "KalmanGain62.ah" 538 KHMult_imp(
A, B00, B01,
C, 0,
NN);
572 for (
int n = 0;
n <
NN; ++
n) {
573 C(
n, 0, 0) =
A(
n, 0, 0) *
B(
n, 0, 0) +
A(
n, 0, 1) *
B(
n, 1, 0);
574 C(
n, 0, 1) =
A(
n, 0, 0) *
B(
n, 0, 1) +
A(
n, 0, 1) *
B(
n, 1, 1);
575 C(
n, 0, 2) =
A(
n, 0, 0) *
B(
n, 0, 2) +
A(
n, 0, 1) *
B(
n, 1, 2);
579 C(
n, 0, 6) =
A(
n, 1, 0) *
B(
n, 0, 0) +
A(
n, 1, 1) *
B(
n, 1, 0);
580 C(
n, 0, 7) =
A(
n, 1, 0) *
B(
n, 0, 1) +
A(
n, 1, 1) *
B(
n, 1, 1);
581 C(
n, 0, 8) =
A(
n, 1, 0) *
B(
n, 0, 2) +
A(
n, 1, 1) *
B(
n, 1, 2);
585 C(
n, 0, 12) =
A(
n, 2, 0) *
B(
n, 0, 0) +
A(
n, 2, 1) *
B(
n, 1, 0);
586 C(
n, 0, 13) =
A(
n, 2, 0) *
B(
n, 0, 1) +
A(
n, 2, 1) *
B(
n, 1, 1);
587 C(
n, 0, 14) =
A(
n, 2, 0) *
B(
n, 0, 2) +
A(
n, 2, 1) *
B(
n, 1, 2);
591 C(
n, 0, 18) =
A(
n, 3, 0) *
B(
n, 0, 0) +
A(
n, 3, 1) *
B(
n, 1, 0);
592 C(
n, 0, 19) =
A(
n, 3, 0) *
B(
n, 0, 1) +
A(
n, 3, 1) *
B(
n, 1, 1);
593 C(
n, 0, 20) =
A(
n, 3, 0) *
B(
n, 0, 2) +
A(
n, 3, 1) *
B(
n, 1, 2);
597 C(
n, 0, 24) =
A(
n, 4, 0) *
B(
n, 0, 0) +
A(
n, 4, 1) *
B(
n, 1, 0);
598 C(
n, 0, 25) =
A(
n, 4, 0) *
B(
n, 0, 1) +
A(
n, 4, 1) *
B(
n, 1, 1);
599 C(
n, 0, 26) =
A(
n, 4, 0) *
B(
n, 0, 2) +
A(
n, 4, 1) *
B(
n, 1, 2);
603 C(
n, 0, 30) =
A(
n, 5, 0) *
B(
n, 0, 0) +
A(
n, 5, 1) *
B(
n, 1, 0);
604 C(
n, 0, 31) =
A(
n, 5, 0) *
B(
n, 0, 1) +
A(
n, 5, 1) *
B(
n, 1, 1);
605 C(
n, 0, 32) =
A(
n, 5, 0) *
B(
n, 0, 2) +
A(
n, 5, 1) *
B(
n, 1, 2);
618 const T*
a =
A.fArray;
620 const T*
b =
B.fArray;
634 const T*
a =
A.fArray;
636 const T*
b =
B.fArray;
645 template <
typename T1,
typename T2,
typename T3>
646 void MultFull(
const T1&
A,
int nia,
int nja,
const T2&
B,
int nib,
int njb, T3&
C,
int nic,
int njc) {
652 for (
int n = 0;
n <
NN; ++
n) {
653 for (
int i = 0;
i < nia; ++
i) {
654 for (
int j = 0;
j < njb; ++
j) {
656 for (
int k = 0;
k < nja; ++
k)
665 template <
typename T1,
typename T2,
typename T3>
666 void MultTranspFull(
const T1&
A,
int nia,
int nja,
const T2&
B,
int nib,
int njb, T3&
C,
int nic,
int njc) {
672 for (
int n = 0;
n <
NN; ++
n) {
673 for (
int i = 0;
i < nia; ++
i) {
674 for (
int j = 0;
j < nib; ++
j) {
676 for (
int k = 0;
k < nja; ++
k)
725 const bool propToHit) {
731 for (
int n = 0;
n <
NN; ++
n) {
732 msRad.At(
n, 0, 0) =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
743 for (
int n = 0;
n <
NN; ++
n) {
744 if (
n < N_proc && outPar.At(
n, 3, 0) < 0) {
745 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
746 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
773 const bool propToHit) {
779 for (
int n = 0;
n <
NN; ++
n) {
781 msRad.At(
n, 0, 0) =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
783 msRad.At(
n, 0, 0) = 0.0f;
810 for (
int i = 0;
i < 6; ++
i) {
811 printf(
"%8f ", psPar.constAt(0, 0,
i));
816 for (
int i = 0;
i < 6; ++
i) {
817 for (
int j = 0;
j < 6; ++
j)
818 printf(
"%8f ", psErr.constAt(0,
i,
j));
823 for (
int i = 0;
i < 3; ++
i) {
824 printf(
"%8f ", msPar.constAt(0, 0,
i));
829 for (
int i = 0;
i < 3; ++
i) {
830 for (
int j = 0;
j < 3; ++
j)
831 printf(
"%8f ", msErr.constAt(0,
i,
j));
849 for (
int n = 0;
n <
NN; ++
n) {
851 const float r =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
852 rotT00.At(
n, 0, 0) = -(msPar.constAt(
n, 1, 0) + psPar.constAt(
n, 1, 0)) / (2 * r);
853 rotT01.At(
n, 0, 0) = (msPar.constAt(
n, 0, 0) + psPar.constAt(
n, 0, 0)) / (2 * r);
855 rotT00.At(
n, 0, 0) = 0.0f;
856 rotT01.At(
n, 0, 0) = 0.0f;
861 SubtractFirst3(msPar, psPar, res_glo);
864 AddIntoUpperLeft3x3(psErr, msErr, resErr_glo);
867 RotateResidualsOnTangentPlane(rotT00, rotT01, res_glo, res_loc);
870 ProjectResErr(rotT00, rotT01, resErr_glo, tempHH);
871 ProjectResErrTransp(rotT00, rotT01, tempHH, resErr_loc);
876 printf(
"res_glo:\n");
877 for (
int i = 0;
i < 3; ++
i) {
878 printf(
"%8f ", res_glo.At(0,
i, 0));
881 printf(
"resErr_glo:\n");
882 for (
int i = 0;
i < 3; ++
i) {
883 for (
int j = 0;
j < 3; ++
j)
884 printf(
"%8f ", resErr_glo.At(0,
i,
j));
888 printf(
"res_loc:\n");
889 for (
int i = 0;
i < 2; ++
i) {
890 printf(
"%8f ", res_loc.At(0,
i, 0));
894 for (
int i = 0;
i < 3; ++
i) {
895 for (
int j = 0;
j < 3; ++
j)
896 printf(
"%8f ", tempHH.At(0,
i,
j));
900 printf(
"resErr_loc:\n");
901 for (
int i = 0;
i < 2; ++
i) {
902 for (
int j = 0;
j < 2; ++
j)
903 printf(
"%8f ", resErr_loc.At(0,
i,
j));
914 Chi2Similarity(res_loc, resErr_loc, outChi2);
919 printf(
"resErr_loc (Inv):\n");
920 for (
int i = 0;
i < 2; ++
i) {
921 for (
int j = 0;
j < 2; ++
j)
922 printf(
"%8f ", resErr_loc.At(0,
i,
j));
926 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
934 CovXYconstrain(rotT00, rotT01, psErr, psErrLoc);
937 KalmanHTG(rotT00, rotT01, resErr_loc, tempHH);
938 KalmanGain(psErrLoc, tempHH, K);
940 MultResidualsAdd(K, psPar, res_loc, outPar);
945 KHMult(K, rotT00, rotT01, tempLL);
946 KHC(tempLL, psErrLoc, outErr);
947 outErr.subtract(psErrLoc, outErr);
953 printf(
"psErrLoc:\n");
954 for (
int i = 0;
i < 6; ++
i) {
955 for (
int j = 0;
j < 6; ++
j)
956 printf(
"% 8e ", psErrLoc.At(0,
i,
j));
961 printf(
"resErr_loc (Inv):\n");
962 for (
int i = 0;
i < 2; ++
i) {
963 for (
int j = 0;
j < 2; ++
j)
964 printf(
"%8f ", resErr_loc.At(0,
i,
j));
969 for (
int i = 0;
i < 3; ++
i) {
970 for (
int j = 0;
j < 3; ++
j)
971 printf(
"%8f ", tempHH.At(0,
i,
j));
976 for (
int i = 0;
i < 6; ++
i) {
977 for (
int j = 0;
j < 3; ++
j)
978 printf(
"%8f ", K.At(0,
i,
j));
983 for (
int i = 0;
i < 6; ++
i) {
984 for (
int j = 0;
j < 6; ++
j)
985 printf(
"%8f ", tempLL.At(0,
i,
j));
990 for (
int i = 0;
i < 6; ++
i) {
991 printf(
"%8f ", outPar.At(0,
i, 0));
995 for (
int i = 0;
i < 6; ++
i) {
996 for (
int j = 0;
j < 6; ++
j)
997 printf(
"%8f ", outErr.At(0,
i,
j));
1020 KFO_Update_Params |
KFO_Local_Cov, psErr, psPar, msErr, msPar, plNrm, plDir, outErr, outPar, dummy_chi2, N_proc);
1035 const bool propToHit) {
1065 for (
int n = 0;
n <
NN; ++
n) {
1066 if (outPar.At(
n, 3, 0) < 0) {
1067 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
1068 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
1085 KFO_Calculate_Chi2, psErr, psPar, msErr, msPar, plNrm, plDir, dummy_err, dummy_par, outChi2, N_proc);
1100 const bool propToHit) {
1107 KFO_Calculate_Chi2, propErr, propPar, msErr, msPar, plNrm, plDir, dummy_err, dummy_par, outChi2, N_proc);
1110 KFO_Calculate_Chi2, psErr, psPar, msErr, msPar, plNrm, plDir, dummy_err, dummy_par, outChi2, N_proc);
1131 for (
int i = 0;
i < 6; ++
i) {
1132 printf(
"%8f ", psPar.constAt(0, 0,
i));
1137 for (
int i = 0;
i < 6; ++
i) {
1138 for (
int j = 0;
j < 6; ++
j)
1139 printf(
"%8f ", psErr.constAt(0,
i,
j));
1144 for (
int i = 0;
i < 3; ++
i) {
1145 printf(
"%8f ", msPar.constAt(0, 0,
i));
1150 for (
int i = 0;
i < 3; ++
i) {
1151 for (
int j = 0;
j < 3; ++
j)
1152 printf(
"%8f ", msErr.constAt(0,
i,
j));
1169 for (
int n = 0;
n <
NN; ++
n) {
1170 prj(
n, 0, 0) = plDir(
n, 0, 0);
1171 prj(
n, 0, 1) = plDir(
n, 1, 0);
1172 prj(
n, 0, 2) = plDir(
n, 2, 0);
1173 prj(
n, 1, 0) = plNrm(
n, 1, 0) * plDir(
n, 2, 0) - plNrm(
n, 2, 0) * plDir(
n, 1, 0);
1174 prj(
n, 1, 1) = plNrm(
n, 2, 0) * plDir(
n, 0, 0) - plNrm(
n, 0, 0) * plDir(
n, 2, 0);
1175 prj(
n, 1, 2) = plNrm(
n, 0, 0) * plDir(
n, 1, 0) - plNrm(
n, 1, 0) * plDir(
n, 0, 0);
1179 SubtractFirst3(msPar, psPar, res_glo);
1182 AddIntoUpperLeft3x3(psErr, msErr, resErr_glo);
1185 RotateResidualsOnPlane(prj, res_glo, res_loc);
1188 ProjectResErr(prj, resErr_glo, temp2H);
1189 ProjectResErrTransp(prj, temp2H, resErr_loc);
1195 for (
int i = 0;
i < 2; ++
i) {
1196 for (
int j = 0;
j < 3; ++
j)
1197 printf(
"%8f ", prj.At(0,
i,
j));
1201 printf(
"res_glo:\n");
1202 for (
int i = 0;
i < 3; ++
i) {
1203 printf(
"%8f ", res_glo.At(0,
i, 0));
1206 printf(
"resErr_glo:\n");
1207 for (
int i = 0;
i < 3; ++
i) {
1208 for (
int j = 0;
j < 3; ++
j)
1209 printf(
"%8f ", resErr_glo.At(0,
i,
j));
1213 printf(
"res_loc:\n");
1214 for (
int i = 0;
i < 2; ++
i) {
1215 printf(
"%8f ", res_loc.At(0,
i, 0));
1218 printf(
"temp2H:\n");
1219 for (
int i = 0;
i < 2; ++
i) {
1220 for (
int j = 0;
j < 3; ++
j)
1221 printf(
"%8f ", temp2H.At(0,
i,
j));
1225 printf(
"resErr_loc:\n");
1226 for (
int i = 0;
i < 2; ++
i) {
1227 for (
int j = 0;
j < 2; ++
j)
1228 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1239 Chi2Similarity(res_loc, resErr_loc, outChi2);
1244 printf(
"resErr_loc (Inv):\n");
1245 for (
int i = 0;
i < 2; ++
i) {
1246 for (
int j = 0;
j < 2; ++
j)
1247 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1251 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
1261 KalmanHTG(prj, resErr_loc, tempH2);
1262 KalmanGain(psErrLoc, tempH2, K);
1264 MultResidualsAdd(K, psPar, res_loc, outPar);
1269 KHMult(K, prj, tempLL);
1270 KHC(tempLL, psErrLoc, outErr);
1271 outErr.subtract(psErrLoc, outErr);
1277 printf(
"psErrLoc:\n");
1278 for (
int i = 0;
i < 6; ++
i) {
1279 for (
int j = 0;
j < 6; ++
j)
1280 printf(
"% 8e ", psErrLoc.At(0,
i,
j));
1285 printf(
"resErr_loc (Inv):\n");
1286 for (
int i = 0;
i < 2; ++
i) {
1287 for (
int j = 0;
j < 2; ++
j)
1288 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1292 printf(
"tempH2:\n");
1293 for (
int i = 0;
i < 3; ++
i) {
1294 for (
int j = 0;
j < 2; ++
j)
1295 printf(
"%8f ", tempH2.At(0,
i,
j));
1300 for (
int i = 0;
i < 6; ++
i) {
1301 for (
int j = 0;
j < 2; ++
j)
1302 printf(
"%8f ", K.At(0,
i,
j));
1306 printf(
"tempLL:\n");
1307 for (
int i = 0;
i < 6; ++
i) {
1308 for (
int j = 0;
j < 6; ++
j)
1309 printf(
"%8f ", tempLL.At(0,
i,
j));
1313 printf(
"outPar:\n");
1314 for (
int i = 0;
i < 6; ++
i) {
1315 printf(
"%8f ", outPar.At(0,
i, 0));
1318 printf(
"outErr:\n");
1319 for (
int i = 0;
i < 6; ++
i) {
1320 for (
int j = 0;
j < 6; ++
j)
1321 printf(
"%8f ", outErr.At(0,
i,
j));
1354 const bool propToHit) {
1360 for (
int n = 0;
n <
NN; ++
n) {
1361 msZ.At(
n, 0, 0) = msPar.constAt(
n, 2, 0);
1370 for (
int n = 0;
n <
NN; ++
n) {
1371 if (
n < N_proc && outPar.At(
n, 3, 0) < 0) {
1372 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
1373 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
1400 const bool propToHit) {
1406 for (
int n = 0;
n <
NN; ++
n) {
1407 msZ.At(
n, 0, 0) = msPar.constAt(
n, 2, 0);
1432 printf(
"updateParametersEndcapMPlex\n");
1434 for (
int i = 0;
i < 6; ++
i) {
1435 printf(
"%8f ", psPar.constAt(0, 0,
i));
1440 for (
int i = 0;
i < 3; ++
i) {
1441 printf(
"%8f ", msPar.constAt(0, 0,
i));
1446 for (
int i = 0;
i < 6; ++
i) {
1447 for (
int j = 0;
j < 6; ++
j)
1448 printf(
"%8f ", psErr.constAt(0,
i,
j));
1453 for (
int i = 0;
i < 3; ++
i) {
1454 for (
int j = 0;
j < 3; ++
j)
1455 printf(
"%8f ", msErr.constAt(0,
i,
j));
1463 SubtractFirst2(msPar, psPar,
res);
1466 AddIntoUpperLeft2x2(psErr, msErr, resErr);
1471 printf(
"resErr:\n");
1472 for (
int i = 0;
i < 2; ++
i) {
1473 for (
int j = 0;
j < 2; ++
j)
1474 printf(
"%8f ", resErr.At(0,
i,
j));
1485 Chi2Similarity(
res, resErr, outChi2);
1490 printf(
"resErr_loc (Inv):\n");
1491 for (
int i = 0;
i < 2; ++
i) {
1492 for (
int j = 0;
j < 2; ++
j)
1493 printf(
"%8f ", resErr.At(0,
i,
j));
1497 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
1504 KalmanGain(psErr, resErr, K);
1506 MultResidualsAdd(K, psPar,
res, outPar);
1510 KHC(K, psErr, outErr);
1515 printf(
"outErr before subtract:\n");
1516 for (
int i = 0;
i < 6; ++
i) {
1517 for (
int j = 0;
j < 6; ++
j)
1518 printf(
"%8f ", outErr.At(0,
i,
j));
1525 outErr.subtract(psErr, outErr);
1531 for (
int i = 0;
i < 2; ++
i) {
1532 printf(
"%8f ",
res.At(0,
i, 0));
1535 printf(
"resErr (Inv):\n");
1536 for (
int i = 0;
i < 2; ++
i) {
1537 for (
int j = 0;
j < 2; ++
j)
1538 printf(
"%8f ", resErr.At(0,
i,
j));
1543 for (
int i = 0;
i < 6; ++
i) {
1544 for (
int j = 0;
j < 2; ++
j)
1545 printf(
"%8f ", K.At(0,
i,
j));
1549 printf(
"outPar:\n");
1550 for (
int i = 0;
i < 6; ++
i) {
1551 printf(
"%8f ", outPar.At(0,
i, 0));
1554 printf(
"outErr:\n");
1555 for (
int i = 0;
i < 6; ++
i) {
1556 for (
int j = 0;
j < 6; ++
j)
1557 printf(
"%8f ", outErr.At(0,
i,
j));
void propagateHelixToPlaneMPlex(const MPlexLS &inErr, const MPlexLV &inPar, const MPlexQI &inChg, const MPlexHV &plPnt, const MPlexHV &plNrm, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &pflags, const MPlexQI *noMatEffPtr)
Matriplex::Matriplex< float, HH, HH, NN > MPlexHH
Matriplex::Matriplex< float, LL, LL, NN > MPlexLL
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
void propagateHelixToRMPlex(const MPlexLS &inErr, const MPlexLV &inPar, const MPlexQI &inChg, const MPlexQF &msRad, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &pflags, const MPlexQI *noMatEffPtr)
void kalmanOperationEndcap(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
Matriplex::Matriplex< float, HH, 1, NN > MPlexHV
void kalmanUpdate(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, const int N_proc)
void kalmanOperationPlane(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
Matriplex::Matriplex< float, LL, 2, NN > MPlexL2
Matriplex::Matriplex< float, LL, 1, NN > MPlexLV
void kalmanPropagateAndUpdate(const MPlexLS &psErr, const MPlexLV &psPar, MPlexQI &Chg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
__host__ __device__ VT * co
void squashPhiMPlex(MPlexLV &par, const int N_proc)
void kalmanOperation(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void invertCramerSym(MPlexSym< T, D, N > &A, double *determ=nullptr)
void kalmanUpdateEndcap(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, const int N_proc)
void kalmanComputeChi2Endcap(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexQF &outChi2, const int N_proc)
constexpr Matriplex::idx_t NN
void kalmanUpdatePlane(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, MPlexLS &outErr, MPlexLV &outPar, const int N_proc)
void kalmanPropagateAndUpdatePlane(const MPlexLS &psErr, const MPlexLV &psPar, MPlexQI &Chg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
void kalmanPropagateAndUpdateEndcap(const MPlexLS &psErr, const MPlexLV &psPar, MPlexQI &Chg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
void kalmanPropagateAndComputeChi2(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexQF &outChi2, MPlexLV &propPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
Matriplex::Matriplex< float, HH, 2, NN > MPlexH2
void kalmanPropagateAndComputeChi2Plane(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, MPlexQF &outChi2, MPlexLV &propPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
Matriplex::Matriplex< int, 1, 1, NN > MPlexQI
void kalmanPropagateAndComputeChi2Endcap(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexQF &outChi2, MPlexLV &propPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
Matriplex::Matriplex< float, 2, HH, NN > MPlex2H
void kalmanComputeChi2Plane(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, MPlexQF &outChi2, const int N_proc)
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
DecomposeProduct< arg, typename Div::arg > D
Matriplex::MatriplexSym< float, 2, NN > MPlex2S
Matriplex::MatriplexSym< float, HH, NN > MPlexHS
Matriplex::Matriplex< float, LL, HH, NN > MPlexLH
Matriplex::Matriplex< float, 2, 1, NN > MPlex2V
void propagateHelixToZMPlex(const MPlexLS &inErr, const MPlexLV &inPar, const MPlexQI &inChg, const MPlexQF &msZ, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &pflags, const MPlexQI *noMatEffPtr)
Matriplex::MatriplexSym< float, LL, NN > MPlexLS
void kalmanComputeChi2(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexQF &outChi2, const int N_proc)
#define ASSUME_ALIGNED(a, b)