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 (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) {
780 msRad.At(
n, 0, 0) =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
806 for (
int i = 0;
i < 6; ++
i) {
807 printf(
"%8f ", psPar.constAt(0, 0,
i));
812 for (
int i = 0;
i < 6; ++
i) {
813 for (
int j = 0;
j < 6; ++
j)
814 printf(
"%8f ", psErr.constAt(0,
i,
j));
819 for (
int i = 0;
i < 3; ++
i) {
820 printf(
"%8f ", msPar.constAt(0, 0,
i));
825 for (
int i = 0;
i < 3; ++
i) {
826 for (
int j = 0;
j < 3; ++
j)
827 printf(
"%8f ", msErr.constAt(0,
i,
j));
845 for (
int n = 0;
n <
NN; ++
n) {
846 const float r =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
847 rotT00.At(
n, 0, 0) = -(msPar.constAt(
n, 1, 0) + psPar.constAt(
n, 1, 0)) / (2 * r);
848 rotT01.At(
n, 0, 0) = (msPar.constAt(
n, 0, 0) + psPar.constAt(
n, 0, 0)) / (2 * r);
852 SubtractFirst3(msPar, psPar, res_glo);
855 AddIntoUpperLeft3x3(psErr, msErr, resErr_glo);
858 RotateResidualsOnTangentPlane(rotT00, rotT01, res_glo, res_loc);
861 ProjectResErr(rotT00, rotT01, resErr_glo, tempHH);
862 ProjectResErrTransp(rotT00, rotT01, tempHH, resErr_loc);
867 printf(
"res_glo:\n");
868 for (
int i = 0;
i < 3; ++
i) {
869 printf(
"%8f ", res_glo.At(0,
i, 0));
872 printf(
"resErr_glo:\n");
873 for (
int i = 0;
i < 3; ++
i) {
874 for (
int j = 0;
j < 3; ++
j)
875 printf(
"%8f ", resErr_glo.At(0,
i,
j));
879 printf(
"res_loc:\n");
880 for (
int i = 0;
i < 2; ++
i) {
881 printf(
"%8f ", res_loc.At(0,
i, 0));
885 for (
int i = 0;
i < 3; ++
i) {
886 for (
int j = 0;
j < 3; ++
j)
887 printf(
"%8f ", tempHH.At(0,
i,
j));
891 printf(
"resErr_loc:\n");
892 for (
int i = 0;
i < 2; ++
i) {
893 for (
int j = 0;
j < 2; ++
j)
894 printf(
"%8f ", resErr_loc.At(0,
i,
j));
905 Chi2Similarity(res_loc, resErr_loc, outChi2);
910 printf(
"resErr_loc (Inv):\n");
911 for (
int i = 0;
i < 2; ++
i) {
912 for (
int j = 0;
j < 2; ++
j)
913 printf(
"%8f ", resErr_loc.At(0,
i,
j));
917 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
925 CovXYconstrain(rotT00, rotT01, psErr, psErrLoc);
928 KalmanHTG(rotT00, rotT01, resErr_loc, tempHH);
929 KalmanGain(psErrLoc, tempHH, K);
931 MultResidualsAdd(K, psPar, res_loc, outPar);
936 KHMult(K, rotT00, rotT01, tempLL);
937 KHC(tempLL, psErrLoc, outErr);
938 outErr.subtract(psErrLoc, outErr);
944 printf(
"psErrLoc:\n");
945 for (
int i = 0;
i < 6; ++
i) {
946 for (
int j = 0;
j < 6; ++
j)
947 printf(
"% 8e ", psErrLoc.At(0,
i,
j));
952 printf(
"resErr_loc (Inv):\n");
953 for (
int i = 0;
i < 2; ++
i) {
954 for (
int j = 0;
j < 2; ++
j)
955 printf(
"%8f ", resErr_loc.At(0,
i,
j));
960 for (
int i = 0;
i < 3; ++
i) {
961 for (
int j = 0;
j < 3; ++
j)
962 printf(
"%8f ", tempHH.At(0,
i,
j));
967 for (
int i = 0;
i < 6; ++
i) {
968 for (
int j = 0;
j < 3; ++
j)
969 printf(
"%8f ", K.At(0,
i,
j));
974 for (
int i = 0;
i < 6; ++
i) {
975 for (
int j = 0;
j < 6; ++
j)
976 printf(
"%8f ", tempLL.At(0,
i,
j));
981 for (
int i = 0;
i < 6; ++
i) {
982 printf(
"%8f ", outPar.At(0,
i, 0));
986 for (
int i = 0;
i < 6; ++
i) {
987 for (
int j = 0;
j < 6; ++
j)
988 printf(
"%8f ", outErr.At(0,
i,
j));
1011 KFO_Update_Params |
KFO_Local_Cov, psErr, psPar, msErr, msPar, plNrm, plDir, outErr, outPar, dummy_chi2, N_proc);
1026 const bool propToHit) {
1056 for (
int n = 0;
n <
NN; ++
n) {
1057 if (outPar.At(
n, 3, 0) < 0) {
1058 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
1059 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
1076 KFO_Calculate_Chi2, psErr, psPar, msErr, msPar, plNrm, plDir, dummy_err, dummy_par, outChi2, N_proc);
1091 const bool propToHit) {
1098 KFO_Calculate_Chi2, propErr, propPar, msErr, msPar, plNrm, plDir, dummy_err, dummy_par, outChi2, N_proc);
1101 KFO_Calculate_Chi2, psErr, psPar, msErr, msPar, plNrm, plDir, dummy_err, dummy_par, outChi2, N_proc);
1122 for (
int i = 0;
i < 6; ++
i) {
1123 printf(
"%8f ", psPar.constAt(0, 0,
i));
1128 for (
int i = 0;
i < 6; ++
i) {
1129 for (
int j = 0;
j < 6; ++
j)
1130 printf(
"%8f ", psErr.constAt(0,
i,
j));
1135 for (
int i = 0;
i < 3; ++
i) {
1136 printf(
"%8f ", msPar.constAt(0, 0,
i));
1141 for (
int i = 0;
i < 3; ++
i) {
1142 for (
int j = 0;
j < 3; ++
j)
1143 printf(
"%8f ", msErr.constAt(0,
i,
j));
1160 for (
int n = 0;
n <
NN; ++
n) {
1161 prj(
n, 0, 0) = plDir(
n, 0, 0);
1162 prj(
n, 0, 1) = plDir(
n, 1, 0);
1163 prj(
n, 0, 2) = plDir(
n, 2, 0);
1164 prj(
n, 1, 0) = plNrm(
n, 1, 0) * plDir(
n, 2, 0) - plNrm(
n, 2, 0) * plDir(
n, 1, 0);
1165 prj(
n, 1, 1) = plNrm(
n, 2, 0) * plDir(
n, 0, 0) - plNrm(
n, 0, 0) * plDir(
n, 2, 0);
1166 prj(
n, 1, 2) = plNrm(
n, 0, 0) * plDir(
n, 1, 0) - plNrm(
n, 1, 0) * plDir(
n, 0, 0);
1170 SubtractFirst3(msPar, psPar, res_glo);
1173 AddIntoUpperLeft3x3(psErr, msErr, resErr_glo);
1176 RotateResidualsOnPlane(prj, res_glo, res_loc);
1179 ProjectResErr(prj, resErr_glo, temp2H);
1180 ProjectResErrTransp(prj, temp2H, resErr_loc);
1186 for (
int i = 0;
i < 2; ++
i) {
1187 for (
int j = 0;
j < 3; ++
j)
1188 printf(
"%8f ", prj.At(0,
i,
j));
1192 printf(
"res_glo:\n");
1193 for (
int i = 0;
i < 3; ++
i) {
1194 printf(
"%8f ", res_glo.At(0,
i, 0));
1197 printf(
"resErr_glo:\n");
1198 for (
int i = 0;
i < 3; ++
i) {
1199 for (
int j = 0;
j < 3; ++
j)
1200 printf(
"%8f ", resErr_glo.At(0,
i,
j));
1204 printf(
"res_loc:\n");
1205 for (
int i = 0;
i < 2; ++
i) {
1206 printf(
"%8f ", res_loc.At(0,
i, 0));
1209 printf(
"temp2H:\n");
1210 for (
int i = 0;
i < 2; ++
i) {
1211 for (
int j = 0;
j < 3; ++
j)
1212 printf(
"%8f ", temp2H.At(0,
i,
j));
1216 printf(
"resErr_loc:\n");
1217 for (
int i = 0;
i < 2; ++
i) {
1218 for (
int j = 0;
j < 2; ++
j)
1219 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1230 Chi2Similarity(res_loc, resErr_loc, outChi2);
1235 printf(
"resErr_loc (Inv):\n");
1236 for (
int i = 0;
i < 2; ++
i) {
1237 for (
int j = 0;
j < 2; ++
j)
1238 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1242 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
1252 KalmanHTG(prj, resErr_loc, tempH2);
1253 KalmanGain(psErrLoc, tempH2, K);
1255 MultResidualsAdd(K, psPar, res_loc, outPar);
1260 KHMult(K, prj, tempLL);
1261 KHC(tempLL, psErrLoc, outErr);
1262 outErr.subtract(psErrLoc, outErr);
1268 printf(
"psErrLoc:\n");
1269 for (
int i = 0;
i < 6; ++
i) {
1270 for (
int j = 0;
j < 6; ++
j)
1271 printf(
"% 8e ", psErrLoc.At(0,
i,
j));
1276 printf(
"resErr_loc (Inv):\n");
1277 for (
int i = 0;
i < 2; ++
i) {
1278 for (
int j = 0;
j < 2; ++
j)
1279 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1283 printf(
"tempH2:\n");
1284 for (
int i = 0;
i < 3; ++
i) {
1285 for (
int j = 0;
j < 2; ++
j)
1286 printf(
"%8f ", tempH2.At(0,
i,
j));
1291 for (
int i = 0;
i < 6; ++
i) {
1292 for (
int j = 0;
j < 2; ++
j)
1293 printf(
"%8f ", K.At(0,
i,
j));
1297 printf(
"tempLL:\n");
1298 for (
int i = 0;
i < 6; ++
i) {
1299 for (
int j = 0;
j < 6; ++
j)
1300 printf(
"%8f ", tempLL.At(0,
i,
j));
1304 printf(
"outPar:\n");
1305 for (
int i = 0;
i < 6; ++
i) {
1306 printf(
"%8f ", outPar.At(0,
i, 0));
1309 printf(
"outErr:\n");
1310 for (
int i = 0;
i < 6; ++
i) {
1311 for (
int j = 0;
j < 6; ++
j)
1312 printf(
"%8f ", outErr.At(0,
i,
j));
1345 const bool propToHit) {
1351 for (
int n = 0;
n <
NN; ++
n) {
1352 msZ.At(
n, 0, 0) = msPar.constAt(
n, 2, 0);
1361 for (
int n = 0;
n <
NN; ++
n) {
1362 if (outPar.At(
n, 3, 0) < 0) {
1363 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
1364 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
1391 const bool propToHit) {
1397 for (
int n = 0;
n <
NN; ++
n) {
1398 msZ.At(
n, 0, 0) = msPar.constAt(
n, 2, 0);
1423 printf(
"updateParametersEndcapMPlex\n");
1425 for (
int i = 0;
i < 6; ++
i) {
1426 printf(
"%8f ", psPar.constAt(0, 0,
i));
1431 for (
int i = 0;
i < 3; ++
i) {
1432 printf(
"%8f ", msPar.constAt(0, 0,
i));
1437 for (
int i = 0;
i < 6; ++
i) {
1438 for (
int j = 0;
j < 6; ++
j)
1439 printf(
"%8f ", psErr.constAt(0,
i,
j));
1444 for (
int i = 0;
i < 3; ++
i) {
1445 for (
int j = 0;
j < 3; ++
j)
1446 printf(
"%8f ", msErr.constAt(0,
i,
j));
1454 SubtractFirst2(msPar, psPar,
res);
1457 AddIntoUpperLeft2x2(psErr, msErr, resErr);
1462 printf(
"resErr:\n");
1463 for (
int i = 0;
i < 2; ++
i) {
1464 for (
int j = 0;
j < 2; ++
j)
1465 printf(
"%8f ", resErr.At(0,
i,
j));
1476 Chi2Similarity(
res, resErr, outChi2);
1481 printf(
"resErr_loc (Inv):\n");
1482 for (
int i = 0;
i < 2; ++
i) {
1483 for (
int j = 0;
j < 2; ++
j)
1484 printf(
"%8f ", resErr.At(0,
i,
j));
1488 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
1495 KalmanGain(psErr, resErr, K);
1497 MultResidualsAdd(K, psPar,
res, outPar);
1501 KHC(K, psErr, outErr);
1506 printf(
"outErr before subtract:\n");
1507 for (
int i = 0;
i < 6; ++
i) {
1508 for (
int j = 0;
j < 6; ++
j)
1509 printf(
"%8f ", outErr.At(0,
i,
j));
1516 outErr.subtract(psErr, outErr);
1522 for (
int i = 0;
i < 2; ++
i) {
1523 printf(
"%8f ",
res.At(0,
i, 0));
1526 printf(
"resErr (Inv):\n");
1527 for (
int i = 0;
i < 2; ++
i) {
1528 for (
int j = 0;
j < 2; ++
j)
1529 printf(
"%8f ", resErr.At(0,
i,
j));
1534 for (
int i = 0;
i < 6; ++
i) {
1535 for (
int j = 0;
j < 2; ++
j)
1536 printf(
"%8f ", K.At(0,
i,
j));
1540 printf(
"outPar:\n");
1541 for (
int i = 0;
i < 6; ++
i) {
1542 printf(
"%8f ", outPar.At(0,
i, 0));
1545 printf(
"outErr:\n");
1546 for (
int i = 0;
i < 6; ++
i) {
1547 for (
int j = 0;
j < 6; ++
j)
1548 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)