7 #include "KalmanUtilsMPlex.icc" 12 using namespace mkfit;
22 MultResidualsAdd_imp(
A,
B,
C,
D, 0,
NN);
34 const T*
a =
A.fArray;
36 const T*
b =
B.fArray;
38 const T*
c =
C.fArray;
46 d[0 *
N +
n] =
b[0 *
N +
n] +
a[0 *
N +
n] *
c[0 *
N +
n] +
a[1 *
N +
n] *
c[1 *
N +
n];
47 d[1 *
N +
n] =
b[1 *
N +
n] +
a[2 *
N +
n] *
c[0 *
N +
n] +
a[3 *
N +
n] *
c[1 *
N +
n];
48 d[2 *
N +
n] =
b[2 *
N +
n] +
a[4 *
N +
n] *
c[0 *
N +
n] +
a[5 *
N +
n] *
c[1 *
N +
n];
49 d[3 *
N +
n] =
b[3 *
N +
n] +
a[6 *
N +
n] *
c[0 *
N +
n] +
a[7 *
N +
n] *
c[1 *
N +
n];
50 d[4 *
N +
n] =
b[4 *
N +
n] +
a[8 *
N +
n] *
c[0 *
N +
n] +
a[9 *
N +
n] *
c[1 *
N +
n];
51 d[5 *
N +
n] =
b[5 *
N +
n] +
a[10 *
N +
n] *
c[0 *
N +
n] +
a[11 *
N +
n] *
c[1 *
N +
n];
64 const T*
a =
A.fArray;
66 const T*
b =
B.fArray;
68 const T*
c =
C.fArray;
76 d[0 *
N +
n] =
b[0 *
N +
n] +
a[0 *
N +
n] *
c[0 *
N +
n] +
a[1 *
N +
n] *
c[1 *
N +
n];
77 d[1 *
N +
n] =
b[1 *
N +
n] +
a[2 *
N +
n] *
c[0 *
N +
n] +
a[3 *
N +
n] *
c[1 *
N +
n];
78 d[2 *
N +
n] =
b[2 *
N +
n] +
a[4 *
N +
n] *
c[0 *
N +
n] +
a[5 *
N +
n] *
c[1 *
N +
n];
79 d[3 *
N +
n] =
b[3 *
N +
n] +
a[6 *
N +
n] *
c[0 *
N +
n] +
a[7 *
N +
n] *
c[1 *
N +
n];
80 d[4 *
N +
n] =
b[4 *
N +
n] +
a[8 *
N +
n] *
c[0 *
N +
n] +
a[9 *
N +
n] *
c[1 *
N +
n];
86 inline void Chi2Similarity(
const MPlex2V&
A,
96 const T*
a =
A.fArray;
98 const T*
c =
C.fArray;
106 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] +
107 2 * (
c[1 *
N +
n] *
a[1 *
N +
n] *
a[0 *
N +
n]);
119 const T*
a =
A.fArray;
121 const T*
b =
B.fArray;
128 c[0 *
N +
n] =
a[0 *
N +
n] +
b[0 *
N +
n];
129 c[1 *
N +
n] =
a[1 *
N +
n] +
b[1 *
N +
n];
130 c[2 *
N +
n] =
a[2 *
N +
n] +
b[2 *
N +
n];
131 c[3 *
N +
n] =
a[3 *
N +
n] +
b[3 *
N +
n];
132 c[4 *
N +
n] =
a[4 *
N +
n] +
b[4 *
N +
n];
133 c[5 *
N +
n] =
a[5 *
N +
n] +
b[5 *
N +
n];
143 const T*
a =
A.fArray;
145 const T*
b =
B.fArray;
152 c[0 *
N +
n] =
a[0 *
N +
n] +
b[0 *
N +
n];
153 c[1 *
N +
n] =
a[1 *
N +
n] +
b[1 *
N +
n];
154 c[2 *
N +
n] =
a[2 *
N +
n] +
b[2 *
N +
n];
166 const T*
a =
A.fArray;
168 const T*
b =
B.fArray;
175 c[0 *
N +
n] =
a[0 *
N +
n] -
b[0 *
N +
n];
176 c[1 *
N +
n] =
a[1 *
N +
n] -
b[1 *
N +
n];
177 c[2 *
N +
n] =
a[2 *
N +
n] -
b[2 *
N +
n];
187 const T*
a =
A.fArray;
189 const T*
b =
B.fArray;
196 c[0 *
N +
n] =
a[0 *
N +
n] -
b[0 *
N +
n];
197 c[1 *
N +
n] =
a[1 *
N +
n] -
b[1 *
N +
n];
211 const T* a00 = A00.fArray;
213 const T* a01 = A01.fArray;
215 const T*
b =
B.fArray;
221 for (
int n = 0;
n <
N; ++
n) {
222 c[0 *
N +
n] = a00[
n] *
b[0 *
N +
n] + a01[
n] *
b[1 *
N +
n];
223 c[1 *
N +
n] = a00[
n] *
b[1 *
N +
n] + a01[
n] *
b[2 *
N +
n];
224 c[2 *
N +
n] = a00[
n] *
b[3 *
N +
n] + a01[
n] *
b[4 *
N +
n];
225 c[3 *
N +
n] =
b[3 *
N +
n];
226 c[4 *
N +
n] =
b[4 *
N +
n];
227 c[5 *
N +
n] =
b[5 *
N +
n];
228 c[6 *
N +
n] = a01[
n] *
b[0 *
N +
n] - a00[
n] *
b[1 *
N +
n];
229 c[7 *
N +
n] = a01[
n] *
b[1 *
N +
n] - a00[
n] *
b[2 *
N +
n];
230 c[8 *
N +
n] = a01[
n] *
b[3 *
N +
n] - a00[
n] *
b[4 *
N +
n];
242 const T* a00 = A00.fArray;
244 const T* a01 = A01.fArray;
246 const T*
b =
B.fArray;
252 for (
int n = 0;
n <
N; ++
n) {
253 c[0 *
N +
n] =
b[0 *
N +
n] * a00[
n] +
b[1 *
N +
n] * a01[
n];
254 c[1 *
N +
n] =
b[3 *
N +
n] * a00[
n] +
b[4 *
N +
n] * a01[
n];
255 c[2 *
N +
n] =
b[5 *
N +
n];
259 inline void RotateResidualsOnTangentPlane(
const MPlexQF& R00,
264 RotateResidualsOnTangentPlane_impl(R00, R01,
A,
B, 0,
NN);
304 template <
class T1,
class T2>
305 inline void ProjectResErr(
const T1&
A,
const T2&
B,
MPlex2H&
C) {
319 const T*
a =
A.fArray;
321 const T*
b =
B.fArray;
327 for (
int n = 0;
n <
N; ++
n) {
328 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];
329 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];
330 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];
331 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];
332 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];
333 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];
353 const T*
a =
A.fArray;
355 const T*
b =
B.fArray;
361 for (
int n = 0;
n <
N; ++
n) {
362 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];
363 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];
364 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];
380 for (
int n = 0;
n <
NN; ++
n) {
381 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);
382 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);
383 B(
n, 2, 0) =
R(
n, 2, 0) *
A(
n, 0, 0) +
R(
n, 2, 1) *
A(
n, 1, 0) +
R(
n, 2, 2) *
A(
n, 2, 0);
399 for (
int n = 0;
n <
NN; ++
n) {
400 B(
n, 0, 0) =
R(
n, 0, 0) *
A(
n, 0, 0) +
R(
n, 1, 0) *
A(
n, 1, 0) +
R(
n, 2, 0) *
A(
n, 2, 0);
401 B(
n, 1, 0) =
R(
n, 0, 1) *
A(
n, 0, 0) +
R(
n, 1, 1) *
A(
n, 1, 0) +
R(
n, 2, 1) *
A(
n, 2, 0);
402 B(
n, 2, 0) =
R(
n, 0, 2) *
A(
n, 0, 0) +
R(
n, 1, 2) *
A(
n, 1, 0) +
R(
n, 2, 2) *
A(
n, 2, 0);
406 template <
typename T1,
typename T2>
407 void RotateResidualsOnPlane(
const T1&
R,
412 for (
int n = 0;
n <
NN; ++
n) {
413 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);
414 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);
427 const T* a00 = A00.fArray;
429 const T* a01 = A01.fArray;
431 const T*
b =
B.fArray;
437 for (
int n = 0;
n <
N; ++
n) {
438 c[0 *
N +
n] = a00[
n] *
b[0 *
N +
n];
439 c[1 *
N +
n] = a00[
n] *
b[1 *
N +
n];
441 c[3 *
N +
n] = a01[
n] *
b[0 *
N +
n];
442 c[4 *
N +
n] = a01[
n] *
b[1 *
N +
n];
444 c[6 *
N +
n] =
b[1 *
N +
n];
445 c[7 *
N +
n] =
b[2 *
N +
n];
456 const T*
a =
A.fArray;
458 const T*
b =
B.fArray;
464 for (
int n = 0;
n <
N; ++
n) {
465 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];
466 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];
468 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];
469 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];
471 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];
472 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];
474 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];
475 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];
477 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];
478 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];
480 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];
481 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];
504 const T*
a =
A.fArray;
506 const T*
b =
B.fArray;
512 for (
int n = 0;
n <
N; ++
n) {
513 c[0 *
N +
n] =
a[0 *
N +
n] *
b[0 *
N +
n] +
a[3 *
N +
n] *
b[1 *
N +
n];
514 c[1 *
N +
n] =
a[0 *
N +
n] *
b[1 *
N +
n] +
a[3 *
N +
n] *
b[2 *
N +
n];
515 c[2 *
N +
n] =
a[1 *
N +
n] *
b[0 *
N +
n] +
a[4 *
N +
n] *
b[1 *
N +
n];
516 c[3 *
N +
n] =
a[1 *
N +
n] *
b[1 *
N +
n] +
a[4 *
N +
n] *
b[2 *
N +
n];
517 c[4 *
N +
n] =
a[2 *
N +
n] *
b[0 *
N +
n] +
a[5 *
N +
n] *
b[1 *
N +
n];
518 c[5 *
N +
n] =
a[2 *
N +
n] *
b[1 *
N +
n] +
a[5 *
N +
n] *
b[2 *
N +
n];
549 const T*
a =
A.fArray;
551 const T*
b =
B.fArray;
557 for (
int n = 0;
n <
N; ++
n) {
558 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];
559 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];
560 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];
561 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];
562 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];
563 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];
564 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];
565 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];
566 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];
567 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];
568 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];
569 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];
579 const T* r00 =
R00.fArray;
581 const T* r01 = R01.fArray;
583 const T* ci = Ci.fArray;
589 for (
int n = 0;
n <
N; ++
n) {
592 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];
593 co[1 *
N +
n] = r00[
n] * r01[
n] *
co[0 *
N +
n];
594 co[2 *
N +
n] = r01[
n] * r01[
n] *
co[0 *
N +
n];
595 co[0 *
N +
n] = r00[
n] * r00[
n] *
co[0 *
N +
n];
597 co[3 *
N +
n] = r00[
n] * ci[3 *
N +
n] + r01[
n] * ci[4 *
N +
n];
601 co[6 *
N +
n] = r00[
n] * ci[6 *
N +
n] + r01[
n] * ci[7 *
N +
n];
605 co[10 *
N +
n] = r00[
n] * ci[10 *
N +
n] + r01[
n] * ci[11 *
N +
n];
606 co[11 *
N +
n] = r01[
n] *
co[10 *
N +
n];
607 co[10 *
N +
n] = r00[
n] *
co[10 *
N +
n];
609 co[15 *
N +
n] = r00[
n] * ci[15 *
N +
n] + r01[
n] * ci[16 *
N +
n];
610 co[16 *
N +
n] = r01[
n] *
co[15 *
N +
n];
611 co[15 *
N +
n] = r00[
n] *
co[15 *
N +
n];
621 const T*
a =
A.fArray;
623 const T*
b =
B.fArray;
628 #include "KalmanGain62.ah" 633 KHMult_imp(
A, B00, B01,
C, 0,
NN);
667 for (
int n = 0;
n <
NN; ++
n) {
668 C(
n, 0, 0) =
A(
n, 0, 0) *
B(
n, 0, 0) +
A(
n, 0, 1) *
B(
n, 1, 0);
669 C(
n, 0, 1) =
A(
n, 0, 0) *
B(
n, 0, 1) +
A(
n, 0, 1) *
B(
n, 1, 1);
670 C(
n, 0, 2) =
A(
n, 0, 0) *
B(
n, 0, 2) +
A(
n, 0, 1) *
B(
n, 1, 2);
674 C(
n, 0, 6) =
A(
n, 1, 0) *
B(
n, 0, 0) +
A(
n, 1, 1) *
B(
n, 1, 0);
675 C(
n, 0, 7) =
A(
n, 1, 0) *
B(
n, 0, 1) +
A(
n, 1, 1) *
B(
n, 1, 1);
676 C(
n, 0, 8) =
A(
n, 1, 0) *
B(
n, 0, 2) +
A(
n, 1, 1) *
B(
n, 1, 2);
680 C(
n, 0, 12) =
A(
n, 2, 0) *
B(
n, 0, 0) +
A(
n, 2, 1) *
B(
n, 1, 0);
681 C(
n, 0, 13) =
A(
n, 2, 0) *
B(
n, 0, 1) +
A(
n, 2, 1) *
B(
n, 1, 1);
682 C(
n, 0, 14) =
A(
n, 2, 0) *
B(
n, 0, 2) +
A(
n, 2, 1) *
B(
n, 1, 2);
686 C(
n, 0, 18) =
A(
n, 3, 0) *
B(
n, 0, 0) +
A(
n, 3, 1) *
B(
n, 1, 0);
687 C(
n, 0, 19) =
A(
n, 3, 0) *
B(
n, 0, 1) +
A(
n, 3, 1) *
B(
n, 1, 1);
688 C(
n, 0, 20) =
A(
n, 3, 0) *
B(
n, 0, 2) +
A(
n, 3, 1) *
B(
n, 1, 2);
692 C(
n, 0, 24) =
A(
n, 4, 0) *
B(
n, 0, 0) +
A(
n, 4, 1) *
B(
n, 1, 0);
693 C(
n, 0, 25) =
A(
n, 4, 0) *
B(
n, 0, 1) +
A(
n, 4, 1) *
B(
n, 1, 1);
694 C(
n, 0, 26) =
A(
n, 4, 0) *
B(
n, 0, 2) +
A(
n, 4, 1) *
B(
n, 1, 2);
698 C(
n, 0, 30) =
A(
n, 5, 0) *
B(
n, 0, 0) +
A(
n, 5, 1) *
B(
n, 1, 0);
699 C(
n, 0, 31) =
A(
n, 5, 0) *
B(
n, 0, 1) +
A(
n, 5, 1) *
B(
n, 1, 1);
700 C(
n, 0, 32) =
A(
n, 5, 0) *
B(
n, 0, 2) +
A(
n, 5, 1) *
B(
n, 1, 2);
713 const T*
a =
A.fArray;
715 const T*
b =
B.fArray;
729 const T*
a =
A.fArray;
731 const T*
b =
B.fArray;
743 const T*
a =
A.fArray;
745 const T*
b =
B.fArray;
750 #include "JacCCS2Loc.ah" 759 const T*
a =
A.fArray;
761 const T*
b =
B.fArray;
766 #include "PsErrLoc.ah" 775 const T*
a =
A.fArray;
777 const T*
b =
B.fArray;
782 #include "PsErrLocTransp.ah" 791 const T*
a =
A.fArray;
793 const T*
b =
B.fArray;
798 #include "PsErrLocUpd.ah" 807 const T*
a =
A.fArray;
809 const T*
b =
B.fArray;
814 #include "JacLoc2CCS.ah" 823 const T*
a =
A.fArray;
825 const T*
b =
B.fArray;
830 #include "OutErrCCS.ah" 839 const T*
a =
A.fArray;
841 const T*
b =
B.fArray;
846 #include "OutErrCCSTransp.ah" 850 template <
typename T1,
typename T2,
typename T3>
851 void MultFull(
const T1&
A,
int nia,
int nja,
const T2&
B,
int nib,
int njb, T3&
C,
int nic,
int njc) {
857 for (
int n = 0;
n <
NN; ++
n) {
858 for (
int i = 0;
i < nia; ++
i) {
859 for (
int j = 0;
j < njb; ++
j) {
861 for (
int k = 0;
k < nja; ++
k)
870 template <
typename T1,
typename T2,
typename T3>
871 void MultTranspFull(
const T1&
A,
int nia,
int nja,
const T2&
B,
int nib,
int njb, T3&
C,
int nic,
int njc) {
877 for (
int n = 0;
n <
NN; ++
n) {
878 for (
int i = 0;
i < nia; ++
i) {
879 for (
int j = 0;
j < nib; ++
j) {
881 for (
int k = 0;
k < nja; ++
k)
930 const bool propToHit) {
936 for (
int n = 0;
n <
NN; ++
n) {
937 msRad.At(
n, 0, 0) =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
948 for (
int n = 0;
n <
NN; ++
n) {
949 if (
n < N_proc && outPar.At(
n, 3, 0) < 0) {
950 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
951 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
978 const bool propToHit) {
984 for (
int n = 0;
n <
NN; ++
n) {
986 msRad.At(
n, 0, 0) =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
988 msRad.At(
n, 0, 0) = 0.0f;
1015 for (
int i = 0;
i < 6; ++
i) {
1016 printf(
"%8f ", psPar.constAt(0, 0,
i));
1021 for (
int i = 0;
i < 6; ++
i) {
1022 for (
int j = 0;
j < 6; ++
j)
1023 printf(
"%8f ", psErr.constAt(0,
i,
j));
1028 for (
int i = 0;
i < 3; ++
i) {
1029 printf(
"%8f ", msPar.constAt(0, 0,
i));
1034 for (
int i = 0;
i < 3; ++
i) {
1035 for (
int j = 0;
j < 3; ++
j)
1036 printf(
"%8f ", msErr.constAt(0,
i,
j));
1054 for (
int n = 0;
n <
NN; ++
n) {
1056 const float r =
std::hypot(msPar.constAt(
n, 0, 0), msPar.constAt(
n, 1, 0));
1057 rotT00.At(
n, 0, 0) = -(msPar.constAt(
n, 1, 0) + psPar.constAt(
n, 1, 0)) / (2 * r);
1058 rotT01.At(
n, 0, 0) = (msPar.constAt(
n, 0, 0) + psPar.constAt(
n, 0, 0)) / (2 * r);
1060 rotT00.At(
n, 0, 0) = 0.0f;
1061 rotT01.At(
n, 0, 0) = 0.0f;
1066 SubtractFirst3(msPar, psPar, res_glo);
1069 AddIntoUpperLeft3x3(psErr, msErr, resErr_glo);
1072 RotateResidualsOnTangentPlane(rotT00, rotT01, res_glo, res_loc);
1075 ProjectResErr(rotT00, rotT01, resErr_glo, tempHH);
1076 ProjectResErrTransp(rotT00, rotT01, tempHH, resErr_loc);
1081 printf(
"res_glo:\n");
1082 for (
int i = 0;
i < 3; ++
i) {
1083 printf(
"%8f ", res_glo.At(0,
i, 0));
1086 printf(
"resErr_glo:\n");
1087 for (
int i = 0;
i < 3; ++
i) {
1088 for (
int j = 0;
j < 3; ++
j)
1089 printf(
"%8f ", resErr_glo.At(0,
i,
j));
1093 printf(
"res_loc:\n");
1094 for (
int i = 0;
i < 2; ++
i) {
1095 printf(
"%8f ", res_loc.At(0,
i, 0));
1098 printf(
"tempHH:\n");
1099 for (
int i = 0;
i < 3; ++
i) {
1100 for (
int j = 0;
j < 3; ++
j)
1101 printf(
"%8f ", tempHH.At(0,
i,
j));
1105 printf(
"resErr_loc:\n");
1106 for (
int i = 0;
i < 2; ++
i) {
1107 for (
int j = 0;
j < 2; ++
j)
1108 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1119 Chi2Similarity(res_loc, resErr_loc, outChi2);
1124 printf(
"resErr_loc (Inv):\n");
1125 for (
int i = 0;
i < 2; ++
i) {
1126 for (
int j = 0;
j < 2; ++
j)
1127 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1131 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
1139 CovXYconstrain(rotT00, rotT01, psErr, psErrLoc);
1142 KalmanHTG(rotT00, rotT01, resErr_loc, tempHH);
1143 KalmanGain(psErrLoc, tempHH, K);
1145 MultResidualsAdd(K, psPar, res_loc, outPar);
1150 KHMult(K, rotT00, rotT01, tempLL);
1151 KHC(tempLL, psErrLoc, outErr);
1152 outErr.subtract(psErrLoc, outErr);
1158 printf(
"psErrLoc:\n");
1159 for (
int i = 0;
i < 6; ++
i) {
1160 for (
int j = 0;
j < 6; ++
j)
1161 printf(
"% 8e ", psErrLoc.At(0,
i,
j));
1166 printf(
"resErr_loc (Inv):\n");
1167 for (
int i = 0;
i < 2; ++
i) {
1168 for (
int j = 0;
j < 2; ++
j)
1169 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1173 printf(
"tempHH:\n");
1174 for (
int i = 0;
i < 3; ++
i) {
1175 for (
int j = 0;
j < 3; ++
j)
1176 printf(
"%8f ", tempHH.At(0,
i,
j));
1181 for (
int i = 0;
i < 6; ++
i) {
1182 for (
int j = 0;
j < 3; ++
j)
1183 printf(
"%8f ", K.At(0,
i,
j));
1187 printf(
"tempLL:\n");
1188 for (
int i = 0;
i < 6; ++
i) {
1189 for (
int j = 0;
j < 6; ++
j)
1190 printf(
"%8f ", tempLL.At(0,
i,
j));
1194 printf(
"outPar:\n");
1195 for (
int i = 0;
i < 6; ++
i) {
1196 printf(
"%8f ", outPar.At(0,
i, 0));
1199 printf(
"outErr:\n");
1200 for (
int i = 0;
i < 6; ++
i) {
1201 for (
int j = 0;
j < 6; ++
j)
1202 printf(
"%8f ", outErr.At(0,
i,
j));
1254 const bool propToHit) {
1288 for (
int n = 0;
n <
NN; ++
n) {
1289 if (outPar.At(
n, 3, 0) < 0) {
1290 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
1291 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
1336 const bool propToHit) {
1391 for (
int i = 0;
i < 6; ++
i) {
1392 printf(
"%8f ", psPar.constAt(0, 0,
i));
1397 for (
int i = 0;
i < 6; ++
i) {
1398 for (
int j = 0;
j < 6; ++
j)
1399 printf(
"%8f ", psErr.constAt(0,
i,
j));
1404 for (
int i = 0;
i < 3; ++
i) {
1405 printf(
"%8f ", msPar.constAt(0, 0,
i));
1410 for (
int i = 0;
i < 3; ++
i) {
1411 for (
int j = 0;
j < 3; ++
j)
1412 printf(
"%8f ", msErr.constAt(0,
i,
j));
1421 for (
int n = 0;
n <
NN; ++
n) {
1422 rot(
n, 0, 0) = plDir(
n, 0, 0);
1423 rot(
n, 0, 1) = plDir(
n, 1, 0);
1424 rot(
n, 0, 2) = plDir(
n, 2, 0);
1425 rot(
n, 1, 0) = plNrm(
n, 1, 0) * plDir(
n, 2, 0) - plNrm(
n, 2, 0) * plDir(
n, 1, 0);
1426 rot(
n, 1, 1) = plNrm(
n, 2, 0) * plDir(
n, 0, 0) - plNrm(
n, 0, 0) * plDir(
n, 2, 0);
1427 rot(
n, 1, 2) = plNrm(
n, 0, 0) * plDir(
n, 1, 0) - plNrm(
n, 1, 0) * plDir(
n, 0, 0);
1428 rot(
n, 2, 0) = plNrm(
n, 0, 0);
1429 rot(
n, 2, 1) = plNrm(
n, 1, 0);
1430 rot(
n, 2, 2) = plNrm(
n, 2, 0);
1436 for (
int n = 0;
n <
NN; ++
n) {
1437 xd(
n, 0, 0) = psPar(
n, 0, 0) - plPnt(
n, 0, 0);
1438 xd(
n, 0, 1) = psPar(
n, 0, 1) - plPnt(
n, 0, 1);
1439 xd(
n, 0, 2) = psPar(
n, 0, 2) - plPnt(
n, 0, 2);
1442 RotateResidualsOnPlane(
rot, xd, xlo);
1446 for (
int n = 0;
n <
NN; ++
n) {
1447 pt(
n, 0, 0) = 1.f / psPar(
n, 3, 0);
1456 for (
int n = 0;
n <
NN; ++
n) {
1457 pgl(
n, 0, 0) = cosP(
n, 0, 0) *
pt(
n, 0, 0);
1458 pgl(
n, 0, 1) = sinP(
n, 0, 0) *
pt(
n, 0, 0);
1459 pgl(
n, 0, 2) = cosT(
n, 0, 0) *
pt(
n, 0, 0) / sinT(
n, 0, 0);
1463 RotateVectorOnPlane(
rot, pgl, plo);
1466 for (
int n = 0;
n <
NN; ++
n) {
1467 lp(
n, 0, 0) = inChg(
n, 0, 0) * psPar(
n, 3, 0) * sinT(
n, 0, 0);
1468 lp(
n, 0, 1) = plo(
n, 0, 0) / plo(
n, 0, 2);
1469 lp(
n, 0, 2) = plo(
n, 0, 1) / plo(
n, 0, 2);
1470 lp(
n, 0, 3) = xlo(
n, 0, 0);
1471 lp(
n, 0, 4) = xlo(
n, 0, 1);
1475 for (
int n = 0;
n <
NN; ++
n) {
1476 pzSign(
n, 0, 0) = plo(
n, 0, 2) > 0.f ? 1 : -1;
1518 for (
int n = 0;
n <
NN; ++
n) {
1519 jacCCS2Curv(
n, 0, 3) = inChg(
n, 0, 0) * sinT(
n, 0, 0);
1520 jacCCS2Curv(
n, 0, 5) = inChg(
n, 0, 0) * cosT(
n, 0, 0) * psPar(
n, 3, 0);
1521 jacCCS2Curv(
n, 1, 5) = -1.f;
1522 jacCCS2Curv(
n, 2, 4) = 1.f;
1523 jacCCS2Curv(
n, 3, 0) = -sinP(
n, 0, 0);
1524 jacCCS2Curv(
n, 3, 1) = cosP(
n, 0, 0);
1525 jacCCS2Curv(
n, 4, 0) = -cosP(
n, 0, 0) * cosT(
n, 0, 0);
1526 jacCCS2Curv(
n, 4, 1) = -sinP(
n, 0, 0) * cosT(
n, 0, 0);
1527 jacCCS2Curv(
n, 4, 2) = sinT(
n, 0, 0);
1535 for (
int n = 0;
n <
NN; ++
n) {
1536 const float abslp00 =
std::abs(lp(
n, 0, 0));
1538 un(
n, 0, 0) = -pgl(
n, 0, 1) * abslp00 / vn(
n, 0, 2);
1539 un(
n, 0, 1) = pgl(
n, 0, 0) * abslp00 / vn(
n, 0, 2);
1541 vn(
n, 0, 0) = -pgl(
n, 0, 2) * abslp00 * un(
n, 0, 1);
1542 vn(
n, 0, 1) = pgl(
n, 0, 2) * abslp00 * un(
n, 0, 0);
1545 RotateVectorOnPlane(
rot, un, u);
1547 RotateVectorOnPlane(
rot, vn,
v);
1550 for (
int n = 0;
n <
NN; ++
n) {
1553 const float qh2 = bF * lp(
n, 0, 0);
1554 const float t1r =
std::sqrt(1.
f + lp(
n, 0, 1) * lp(
n, 0, 1) + lp(
n, 0, 2) * lp(
n, 0, 2)) * pzSign(
n, 0, 0);
1555 const float t2r = t1r * t1r;
1556 const float t3r = t1r * t2r;
1557 jacCurv2Loc(
n, 0, 0) = 1.f;
1558 jacCurv2Loc(
n, 1, 1) = -u(
n, 0, 1) * t2r;
1559 jacCurv2Loc(
n, 1, 2) =
v(
n, 0, 1) * vn(
n, 0, 2) * t2r;
1560 jacCurv2Loc(
n, 2, 1) = u(
n, 0, 0) * t2r;
1561 jacCurv2Loc(
n, 2, 2) = -
v(
n, 0, 0) * vn(
n, 0, 2) * t2r;
1562 jacCurv2Loc(
n, 3, 3) =
v(
n, 0, 1) * t1r;
1563 jacCurv2Loc(
n, 3, 4) = -u(
n, 0, 1) * t1r;
1564 jacCurv2Loc(
n, 4, 3) = -
v(
n, 0, 0) * t1r;
1565 jacCurv2Loc(
n, 4, 4) = u(
n, 0, 0) * t1r;
1566 const float cosz = -vn(
n, 0, 2) * qh2;
1567 const float ui = u(
n, 0, 2) * t3r;
1568 const float vi =
v(
n, 0, 2) * t3r;
1569 jacCurv2Loc(
n, 1, 3) = -
ui *
v(
n, 0, 1) * cosz;
1570 jacCurv2Loc(
n, 1, 4) = -vi *
v(
n, 0, 1) * cosz;
1571 jacCurv2Loc(
n, 2, 3) =
ui *
v(
n, 0, 0) * cosz;
1572 jacCurv2Loc(
n, 2, 4) = vi *
v(
n, 0, 0) * cosz;
1578 JacCCS2Loc(jacCurv2Loc, jacCCS2Curv, jacCCS2Loc);
1583 PsErrLoc(jacCCS2Loc, psErr, temp56);
1584 PsErrLocTransp(temp56, jacCCS2Loc, psErrLoc);
1588 for (
int n = 0;
n <
NN; ++
n) {
1589 md(
n, 0, 0) = msPar(
n, 0, 0) - plPnt(
n, 0, 0);
1590 md(
n, 0, 1) = msPar(
n, 0, 1) - plPnt(
n, 0, 1);
1591 md(
n, 0, 2) = msPar(
n, 0, 2) - plPnt(
n, 0, 2);
1594 RotateResidualsOnPlane(
rot, md, mslo);
1598 for (
int n = 0;
n <
NN; ++
n) {
1599 res_loc(
n, 0, 0) = mslo(
n, 0, 0) - xlo(
n, 0, 0);
1600 res_loc(
n, 0, 1) = mslo(
n, 0, 1) - xlo(
n, 0, 1);
1605 ProjectResErr(
rot, msErr, temp2Hmsl);
1606 ProjectResErrTransp(
rot, temp2Hmsl, msErr_loc);
1610 for (
int n = 0;
n <
NN; ++
n) {
1611 resErr_loc(
n, 0, 0) = psErrLoc(
n, 3, 3) + msErr_loc(
n, 0, 0);
1612 resErr_loc(
n, 0, 1) = psErrLoc(
n, 3, 4) + msErr_loc(
n, 0, 1);
1613 resErr_loc(
n, 1, 1) = psErrLoc(
n, 4, 4) + msErr_loc(
n, 1, 1);
1678 Chi2Similarity(res_loc, resErr_loc, outChi2);
1683 printf(
"resErr_loc (Inv):\n");
1684 for (
int i = 0;
i < 2; ++
i) {
1685 for (
int j = 0;
j < 2; ++
j)
1686 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1690 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
1698 for (
int n = 0;
n <
NN; ++
n) {
1699 #pragma GCC unroll 5 1700 for (
int j = 0;
j < 5; ++
j) {
1701 K(
n,
j, 0) = resErr_loc(
n, 0, 0) * psErrLoc(
n,
j, 3) + resErr_loc(
n, 0, 1) * psErrLoc(
n,
j, 4);
1702 K(
n,
j, 1) = resErr_loc(
n, 0, 1) * psErrLoc(
n,
j, 3) + resErr_loc(
n, 1, 1) * psErrLoc(
n,
j, 4);
1707 MultResidualsAdd(K, lp, res_loc, lp_upd);
1711 for (
int n = 0;
n <
NN; ++
n) {
1712 #pragma GCC unroll 5 1713 for (
int j = 0;
j < 5; ++
j) {
1714 ImKH(
n,
j,
j) = 1.f;
1715 ImKH(
n,
j, 3) -= K(
n,
j, 0);
1716 ImKH(
n,
j, 4) -= K(
n,
j, 1);
1720 PsErrLocUpd(ImKH, psErrLoc, psErrLoc_upd);
1726 for (
int n = 0;
n <
NN; ++
n) {
1727 lxu(
n, 0, 0) = lp_upd(
n, 0, 3);
1728 lxu(
n, 0, 1) = lp_upd(
n, 0, 4);
1732 std::sqrt(1.
f + lp_upd(
n, 0, 1) * lp_upd(
n, 0, 1) + lp_upd(
n, 0, 2) * lp_upd(
n, 0, 2)));
1733 lpu(
n, 0, 0) = lpu(
n, 0, 2) * lp_upd(
n, 0, 1);
1734 lpu(
n, 0, 1) = lpu(
n, 0, 2) * lp_upd(
n, 0, 2);
1737 RotateVectorOnPlaneTransp(
rot, lxu, gxu);
1739 for (
int n = 0;
n <
NN; ++
n) {
1740 gxu(
n, 0, 0) += plPnt(
n, 0, 0);
1741 gxu(
n, 0, 1) += plPnt(
n, 0, 1);
1742 gxu(
n, 0, 2) += plPnt(
n, 0, 2);
1745 RotateVectorOnPlaneTransp(
rot, lpu,
gpu);
1749 for (
int n = 0;
n <
NN; ++
n) {
1750 pt(
n, 0, 0) =
std::sqrt(
gpu.At(
n, 0, 0) *
gpu.At(
n, 0, 0) +
gpu.At(
n, 0, 1) *
gpu.At(
n, 0, 1));
1751 p(
n, 0, 0) =
std::sqrt(
pt.At(
n, 0, 0) *
pt.At(
n, 0, 0) +
gpu.At(
n, 0, 2) *
gpu.At(
n, 0, 2));
1752 sinP(
n, 0, 0) =
gpu.At(
n, 0, 1) /
pt(
n, 0, 0);
1753 cosP(
n, 0, 0) =
gpu.At(
n, 0, 0) /
pt(
n, 0, 0);
1754 sinT(
n, 0, 0) =
pt(
n, 0, 0) /
p(
n, 0, 0);
1755 cosT(
n, 0, 0) =
gpu.At(
n, 0, 2) /
p(
n, 0, 0);
1759 for (
int n = 0;
n <
NN; ++
n) {
1760 outPar(
n, 0, 0) = gxu.At(
n, 0, 0);
1761 outPar(
n, 0, 1) = gxu.At(
n, 0, 1);
1762 outPar(
n, 0, 2) = gxu.At(
n, 0, 2);
1763 outPar(
n, 0, 3) = 1.f /
pt(
n, 0, 0);
1772 for (
int n = 0;
n <
NN; ++
n) {
1773 jacCurv2CCS(
n, 0, 3) = -sinP(
n, 0, 0);
1774 jacCurv2CCS(
n, 0, 4) = -cosT(
n, 0, 0) * cosP(
n, 0, 0);
1775 jacCurv2CCS(
n, 1, 3) = cosP(
n, 0, 0);
1776 jacCurv2CCS(
n, 1, 4) = -cosT(
n, 0, 0) * sinP(
n, 0, 0);
1777 jacCurv2CCS(
n, 2, 4) = sinT(
n, 0, 0);
1778 jacCurv2CCS(
n, 3, 0) = inChg(
n, 0, 0) / sinT(
n, 0, 0);
1779 jacCurv2CCS(
n, 3, 1) = outPar(
n, 3, 0) * cosT(
n, 0, 0) / sinT(
n, 0, 0);
1780 jacCurv2CCS(
n, 4, 2) = 1.f;
1781 jacCurv2CCS(
n, 5, 1) = -1.f;
1788 for (
int n = 0;
n <
NN; ++
n) {
1790 tnl(
n, 0, 0) = lpu(
n, 0, 0) * abslpupd00;
1791 tnl(
n, 0, 1) = lpu(
n, 0, 1) * abslpupd00;
1792 tnl(
n, 0, 2) = lpu(
n, 0, 2) * abslpupd00;
1795 RotateVectorOnPlaneTransp(
rot, tnl, tn);
1797 for (
int n = 0;
n <
NN; ++
n) {
1798 vn(
n, 0, 2) =
std::max(1.
e-30
f,
std::sqrt(tn(
n, 0, 0) * tn(
n, 0, 0) + tn(
n, 0, 1) * tn(
n, 0, 1)));
1799 un(
n, 0, 0) = -tn(
n, 0, 1) / vn(
n, 0, 2);
1800 un(
n, 0, 1) = tn(
n, 0, 0) / vn(
n, 0, 2);
1802 vn(
n, 0, 0) = -tn(
n, 0, 2) * un(
n, 0, 1);
1803 vn(
n, 0, 1) = tn(
n, 0, 2) * un(
n, 0, 0);
1807 for (
int n = 0;
n <
NN; ++
n) {
1810 const float qh2 = bF * lp_upd(
n, 0, 0);
1811 const float cosl1 = 1.f / vn(
n, 0, 2);
1812 const float uj = un(
n, 0, 0) *
rot(
n, 0, 0) + un(
n, 0, 1) *
rot(
n, 0, 1);
1813 const float uk = un(
n, 0, 0) *
rot(
n, 1, 0) + un(
n, 0, 1) *
rot(
n, 1, 1);
1814 const float vj = vn(
n, 0, 0) *
rot(
n, 0, 0) + vn(
n, 0, 1) *
rot(
n, 0, 1) + vn(
n, 0, 2) *
rot(
n, 0, 2);
1815 const float vk = vn(
n, 0, 0) *
rot(
n, 1, 0) + vn(
n, 0, 1) *
rot(
n, 1, 1) + vn(
n, 0, 2) *
rot(
n, 1, 2);
1816 const float cosz = vn(
n, 0, 2) * qh2;
1817 jacLoc2Curv(
n, 0, 0) = 1.f;
1818 jacLoc2Curv(
n, 1, 1) = tnl(
n, 0, 2) * vj;
1819 jacLoc2Curv(
n, 1, 2) = tnl(
n, 0, 2) * vk;
1820 jacLoc2Curv(
n, 2, 1) = tnl(
n, 0, 2) * uj * cosl1;
1821 jacLoc2Curv(
n, 2, 2) = tnl(
n, 0, 2) * uk * cosl1;
1822 jacLoc2Curv(
n, 3, 3) = uj;
1823 jacLoc2Curv(
n, 3, 4) = uk;
1824 jacLoc2Curv(
n, 4, 3) = vj;
1825 jacLoc2Curv(
n, 4, 4) = vk;
1826 jacLoc2Curv(
n, 2, 3) = tnl(
n, 0, 0) * (cosz * cosl1);
1827 jacLoc2Curv(
n, 2, 4) = tnl(
n, 0, 1) * (cosz * cosl1);
1832 JacLoc2CCS(jacCurv2CCS, jacLoc2Curv, jacLoc2CCS);
1836 OutErrCCS(jacLoc2CCS, psErrLoc_upd, temp65);
1837 OutErrCCSTransp(temp65, jacLoc2CCS, outErr);
1918 printf(
"psErrLoc_upd:\n");
1919 for (
int i = 0;
i < 5; ++
i) {
1920 for (
int j = 0;
j < 5; ++
j)
1921 printf(
"% 8e ", psErrLoc_upd.At(0,
i,
j));
1926 printf(
"resErr_loc (Inv):\n");
1927 for (
int i = 0;
i < 2; ++
i) {
1928 for (
int j = 0;
j < 2; ++
j)
1929 printf(
"%8f ", resErr_loc.At(0,
i,
j));
1934 for (
int i = 0;
i < 6; ++
i) {
1935 for (
int j = 0;
j < 2; ++
j)
1936 printf(
"%8f ", K.At(0,
i,
j));
1940 printf(
"outPar:\n");
1941 for (
int i = 0;
i < 6; ++
i) {
1942 printf(
"%8f ", outPar.At(0,
i, 0));
1945 printf(
"outErr:\n");
1946 for (
int i = 0;
i < 6; ++
i) {
1947 for (
int j = 0;
j < 6; ++
j)
1948 printf(
"%8f ", outErr.At(0,
i,
j));
1978 for (
int i = 0;
i < 6; ++
i) {
1979 printf(
"%8f ", psPar.constAt(0, 0,
i));
1984 for (
int i = 0;
i < 6; ++
i) {
1985 for (
int j = 0;
j < 6; ++
j)
1986 printf(
"%8f ", psErr.constAt(0,
i,
j));
1991 for (
int i = 0;
i < 3; ++
i) {
1992 printf(
"%8f ", msPar.constAt(0, 0,
i));
1997 for (
int i = 0;
i < 3; ++
i) {
1998 for (
int j = 0;
j < 3; ++
j)
1999 printf(
"%8f ", msErr.constAt(0,
i,
j));
2015 for (
int n = 0;
n <
NN; ++
n) {
2016 prj(
n, 0, 0) = plDir(
n, 0, 0);
2017 prj(
n, 0, 1) = plDir(
n, 1, 0);
2018 prj(
n, 0, 2) = plDir(
n, 2, 0);
2019 prj(
n, 1, 0) = plNrm(
n, 1, 0) * plDir(
n, 2, 0) - plNrm(
n, 2, 0) * plDir(
n, 1, 0);
2020 prj(
n, 1, 1) = plNrm(
n, 2, 0) * plDir(
n, 0, 0) - plNrm(
n, 0, 0) * plDir(
n, 2, 0);
2021 prj(
n, 1, 2) = plNrm(
n, 0, 0) * plDir(
n, 1, 0) - plNrm(
n, 1, 0) * plDir(
n, 0, 0);
2025 SubtractFirst3(msPar, psPar, res_glo);
2028 AddIntoUpperLeft3x3(psErr, msErr, resErr_glo);
2031 RotateResidualsOnPlane(prj, res_glo, res_loc);
2034 ProjectResErr(prj, resErr_glo, temp2H);
2035 ProjectResErrTransp(prj, temp2H, resErr_loc);
2041 for (
int i = 0;
i < 2; ++
i) {
2042 for (
int j = 0;
j < 3; ++
j)
2043 printf(
"%8f ", prj.At(0,
i,
j));
2047 printf(
"res_glo:\n");
2048 for (
int i = 0;
i < 3; ++
i) {
2049 printf(
"%8f ", res_glo.At(0,
i, 0));
2052 printf(
"resErr_glo:\n");
2053 for (
int i = 0;
i < 3; ++
i) {
2054 for (
int j = 0;
j < 3; ++
j)
2055 printf(
"%8f ", resErr_glo.At(0,
i,
j));
2059 printf(
"res_loc:\n");
2060 for (
int i = 0;
i < 2; ++
i) {
2061 printf(
"%8f ", res_loc.At(0,
i, 0));
2064 printf(
"temp2H:\n");
2065 for (
int i = 0;
i < 2; ++
i) {
2066 for (
int j = 0;
j < 3; ++
j)
2067 printf(
"%8f ", temp2H.At(0,
i,
j));
2071 printf(
"resErr_loc:\n");
2072 for (
int i = 0;
i < 2; ++
i) {
2073 for (
int j = 0;
j < 2; ++
j)
2074 printf(
"%8f ", resErr_loc.At(0,
i,
j));
2085 Chi2Similarity(res_loc, resErr_loc, outChi2);
2090 printf(
"resErr_loc (Inv):\n");
2091 for (
int i = 0;
i < 2; ++
i) {
2092 for (
int j = 0;
j < 2; ++
j)
2093 printf(
"%8f ", resErr_loc.At(0,
i,
j));
2097 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
2107 KalmanHTG(prj, resErr_loc, tempH2);
2108 KalmanGain(psErrLoc, tempH2, K);
2110 MultResidualsAdd(K, psPar, res_loc, outPar);
2115 KHMult(K, prj, tempLL);
2116 KHC(tempLL, psErrLoc, outErr);
2117 outErr.subtract(psErrLoc, outErr);
2123 printf(
"psErrLoc:\n");
2124 for (
int i = 0;
i < 6; ++
i) {
2125 for (
int j = 0;
j < 6; ++
j)
2126 printf(
"% 8e ", psErrLoc.At(0,
i,
j));
2131 printf(
"resErr_loc (Inv):\n");
2132 for (
int i = 0;
i < 2; ++
i) {
2133 for (
int j = 0;
j < 2; ++
j)
2134 printf(
"%8f ", resErr_loc.At(0,
i,
j));
2138 printf(
"tempH2:\n");
2139 for (
int i = 0;
i < 3; ++
i) {
2140 for (
int j = 0;
j < 2; ++
j)
2141 printf(
"%8f ", tempH2.At(0,
i,
j));
2146 for (
int i = 0;
i < 6; ++
i) {
2147 for (
int j = 0;
j < 2; ++
j)
2148 printf(
"%8f ", K.At(0,
i,
j));
2152 printf(
"tempLL:\n");
2153 for (
int i = 0;
i < 6; ++
i) {
2154 for (
int j = 0;
j < 6; ++
j)
2155 printf(
"%8f ", tempLL.At(0,
i,
j));
2159 printf(
"outPar:\n");
2160 for (
int i = 0;
i < 6; ++
i) {
2161 printf(
"%8f ", outPar.At(0,
i, 0));
2164 printf(
"outErr:\n");
2165 for (
int i = 0;
i < 6; ++
i) {
2166 for (
int j = 0;
j < 6; ++
j)
2167 printf(
"%8f ", outErr.At(0,
i,
j));
2200 const bool propToHit) {
2206 for (
int n = 0;
n <
NN; ++
n) {
2207 msZ.At(
n, 0, 0) = msPar.constAt(
n, 2, 0);
2216 for (
int n = 0;
n <
NN; ++
n) {
2217 if (
n < N_proc && outPar.At(
n, 3, 0) < 0) {
2218 Chg.At(
n, 0, 0) = -Chg.At(
n, 0, 0);
2219 outPar.At(
n, 3, 0) = -outPar.At(
n, 3, 0);
2246 const bool propToHit) {
2252 for (
int n = 0;
n <
NN; ++
n) {
2253 msZ.At(
n, 0, 0) = msPar.constAt(
n, 2, 0);
2278 printf(
"updateParametersEndcapMPlex\n");
2280 for (
int i = 0;
i < 6; ++
i) {
2281 printf(
"%8f ", psPar.constAt(0, 0,
i));
2286 for (
int i = 0;
i < 3; ++
i) {
2287 printf(
"%8f ", msPar.constAt(0, 0,
i));
2292 for (
int i = 0;
i < 6; ++
i) {
2293 for (
int j = 0;
j < 6; ++
j)
2294 printf(
"%8f ", psErr.constAt(0,
i,
j));
2299 for (
int i = 0;
i < 3; ++
i) {
2300 for (
int j = 0;
j < 3; ++
j)
2301 printf(
"%8f ", msErr.constAt(0,
i,
j));
2309 SubtractFirst2(msPar, psPar,
res);
2312 AddIntoUpperLeft2x2(psErr, msErr, resErr);
2317 printf(
"resErr:\n");
2318 for (
int i = 0;
i < 2; ++
i) {
2319 for (
int j = 0;
j < 2; ++
j)
2320 printf(
"%8f ", resErr.At(0,
i,
j));
2331 Chi2Similarity(
res, resErr, outChi2);
2336 printf(
"resErr_loc (Inv):\n");
2337 for (
int i = 0;
i < 2; ++
i) {
2338 for (
int j = 0;
j < 2; ++
j)
2339 printf(
"%8f ", resErr.At(0,
i,
j));
2343 printf(
"chi2: %8f\n", outChi2.At(0, 0, 0));
2350 KalmanGain(psErr, resErr, K);
2352 MultResidualsAdd(K, psPar,
res, outPar);
2356 KHC(K, psErr, outErr);
2361 printf(
"outErr before subtract:\n");
2362 for (
int i = 0;
i < 6; ++
i) {
2363 for (
int j = 0;
j < 6; ++
j)
2364 printf(
"%8f ", outErr.At(0,
i,
j));
2371 outErr.subtract(psErr, outErr);
2377 for (
int i = 0;
i < 2; ++
i) {
2378 printf(
"%8f ",
res.At(0,
i, 0));
2381 printf(
"resErr (Inv):\n");
2382 for (
int i = 0;
i < 2; ++
i) {
2383 for (
int j = 0;
j < 2; ++
j)
2384 printf(
"%8f ", resErr.At(0,
i,
j));
2389 for (
int i = 0;
i < 6; ++
i) {
2390 for (
int j = 0;
j < 2; ++
j)
2391 printf(
"%8f ", K.At(0,
i,
j));
2395 printf(
"outPar:\n");
2396 for (
int i = 0;
i < 6; ++
i) {
2397 printf(
"%8f ", outPar.At(0,
i, 0));
2400 printf(
"outErr:\n");
2401 for (
int i = 0;
i < 6; ++
i) {
2402 for (
int j = 0;
j < 6; ++
j)
2403 printf(
"%8f ", outErr.At(0,
i,
j));
Matriplex::Matriplex< float, HH, HH, NN > MPlexHH
Matriplex::MatriplexSym< float, 5, NN > MPlex5S
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)
Sin< T >::type sin(const T &t)
void kalmanComputeChi2Plane(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, const MPlexHV &plPnt, MPlexQF &outChi2, const int N_proc)
Matriplex::Matriplex< float, LL, 2, NN > MPlexL2
float getTheta(float r, float z)
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
Matriplex::Matriplex< float, 5, 5, NN > MPlex55
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 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=nullptr)
void kalmanComputeChi2Endcap(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, MPlexQF &outChi2, const int N_proc)
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=nullptr)
constexpr Matriplex::idx_t NN
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
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)
void kalmanOperationPlaneLocal(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, const MPlexHV &plPnt, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
Matriplex::Matriplex< float, HH, 2, NN > MPlexH2
Matriplex::Matriplex< int, 1, 1, NN > MPlexQI
Matriplex::Matriplex< float, 5, 6, NN > MPlex56
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
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
DecomposeProduct< arg, typename Div::arg > D
Matriplex::MatriplexSym< float, 2, NN > MPlex2S
Matriplex::Matriplex< float, 5, 2, NN > MPlex52
float getPhi(float x, float y)
Matriplex::MatriplexSym< float, HH, NN > MPlexHS
Matriplex::Matriplex< float, LL, HH, NN > MPlexLH
void kalmanOperationPlane(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, const MPlexHV &plPnt, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
Matriplex::Matriplex< float, 2, 1, NN > MPlex2V
void kalmanUpdatePlane(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &Chg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, const MPlexHV &plPnt, MPlexLS &outErr, MPlexLV &outPar, const int N_proc)
void kalmanPropagateAndComputeChi2Plane(const MPlexLS &psErr, const MPlexLV &psPar, const MPlexQI &inChg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, const MPlexHV &plPnt, MPlexQF &outChi2, MPlexLV &propPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)
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)
Matriplex::Matriplex< float, 5, 1, NN > MPlex5V
#define ASSUME_ALIGNED(a, b)
Matriplex::Matriplex< float, 6, 5, NN > MPlex65
void kalmanPropagateAndUpdatePlane(const MPlexLS &psErr, const MPlexLV &psPar, MPlexQI &Chg, const MPlexHS &msErr, const MPlexHV &msPar, const MPlexHV &plNrm, const MPlexHV &plDir, const MPlexHV &plPnt, MPlexLS &outErr, MPlexLV &outPar, MPlexQI &outFailFlag, const int N_proc, const PropagationFlags &propFlags, const bool propToHit)