4 #define cnst const fvec
7 fvec wi, zeta, zetawi, HCH;
8 fvec F0, F1, F2, F3, F4, F5;
9 fvec K1, K2, K3, K4, K5;
26 wi = w/( (mask & info.
sigma2) +HCH );
28 chi2 += mask & (zeta * zetawi);
30 wi = w / (info.
sigma2 + HCH);
32 chi2 += zeta * zetawi;
73 fvec wi, zeta, zetawi, HCH;
74 fvec F0, F1, F2, F3, F4, F5;
75 fvec K1, K2, K3, K4, K5;
92 wi = w/( (mask & info.
sigma2) +HCH );
94 chi2 += mask & (zeta * zetawi);
96 wi = w / (info.
sigma2 + HCH);
98 chi2 += zeta * zetawi;
139 fvec wi, zeta, zetawi, HCH;
140 fvec F0, F1, F2, F3, F4, F5;
141 fvec K1, K2, K3, K4, K5;
157 const fvec mask = (HCH < info.sigma2 * 16.);
158 wi = w/( (mask & info.sigma2) +HCH );
160 chi2 += mask & (zeta * zetawi);
162 wi = w / (dt0 * dt0 + HCH);
164 chi2 += zeta * zetawi;
213 initialised =
fvec(zero < *w);
217 initialised =
fvec(zero < one);
222 fx += (
ftx * dz & initialised);
223 fy += (
fty * dz & initialised);
224 fz += (dz & initialised);
230 const fvec dzC32_in = dz *
C32;
232 C21 += (dzC32_in & initialised);
237 C20 += ((dz *
C22) & initialised);
238 C00 += (dz * (
C20 + C20_in) & initialised);
242 C31 += ((dz *
C33) & initialised);
243 C11 += ((dz * (
C31 + C31_in)) & initialised);
244 C30 += dzC32_in & initialised;
246 C40 += (dz *
C42 & initialised);
247 C41 += (dz *
C43 & initialised);
257 C55 = ((k1 * (
C52 + c52) + k2 * (
C53 + c53)) & initialised) +
C55;
269 initialised =
fvec(zero < *w);
273 initialised =
fvec(zero < one);
279 fx += (
ftx * dz & initialised);
280 fy += (
fty * dz & initialised);
281 fz += (dz & initialised);
291 const fvec dzC32_in = dz *
C32;
293 C21 += (dzC32_in & initialised);
298 C20 += ((dz *
C22) & initialised);
299 C00 += (dz * (
C20 + C20_in) & initialised);
303 C31 += ((dz *
C33) & initialised);
304 C11 += ((dz * (
C31 + C31_in)) & initialised);
305 C30 += dzC32_in & initialised;
307 C40 += (dz *
C42 & initialised);
308 C41 += (dz *
C43 & initialised);
318 C55 = ((k1 * (
C52 + c52) + k2 * (
C53 + c53)) & initialised) +
C55;
358 const fvec a[4] = {0.0f, 0.5f, 0.5f, 1.0f};
359 const fvec c[4] = {1.0f / 6.0f, 1.0f / 3.0f, 1.0f / 3.0f, 1.0f / 6.0f};
360 const fvec b[4] = {0.0f, 0.5f, 0.5f, 1.0f};
363 fvec k[20], x0[5],
x[5], k1[20];
364 fvec Ax[4], Ay[4], Ax_tx[4], Ay_tx[4], Ax_ty[4], Ay_ty[4], At[4], At_tx[4],
370 const fvec z_in = fz;
371 const fvec h = (z_out - fz);
391 for (step = 0; step < 4; ++step) {
392 F.Get(z_in + a[step] *
h, B[step]);
395 for (step = 0; step < 4; ++step) {
396 for (
i = 0;
i < 5; ++
i) {
400 x[
i] = x0[
i] + b[step] * k[step * 5 - 5 +
i];
409 fvec tx2ty21 = 1.f + tx2 + ty2;
411 fvec I_tx2ty21 = 1.f / tx2ty21 * qp0;
415 fvec tx2ty2qp = tx2ty2 * qp0;
419 (txty * B[step][0] + ty * B[step][2] - (1.f + tx2) * B[step][1]) * tx2ty2;
420 Ay[step] = (-txty * B[step][1] - tx * B[step][2] + (1.f + ty2) * B[step][0])
423 Ax_tx[step] = Ax[step] * tx * I_tx2ty21
424 + (ty * B[step][0] - 2.f * tx * B[step][1]) * tx2ty2qp;
426 Ax[step] * ty * I_tx2ty21 + (tx * B[step][0] + B[step][2]) * tx2ty2qp;
428 Ay[step] * tx * I_tx2ty21 + (-ty * B[step][1] - B[step][2]) * tx2ty2qp;
429 Ay_ty[step] = Ay[step] * ty * I_tx2ty21
430 + (-tx * B[step][1] + 2.f * ty * B[step][0]) * tx2ty2qp;
432 fvec p2 = 1.f / (qp0 * qp0);
433 fvec m2 = 0.1395679f * 0.1395679f;
434 fvec v = 29.9792458f *
sqrt(p2 / (m2 + p2));
435 At[step] =
sqrt(1.
f + tx * tx + ty * ty) /
v;
436 At_tx[step] = tx /
sqrt(1.
f + tx * tx + ty * ty) /
v;
437 At_ty[step] = ty /
sqrt(1.
f + tx * tx + ty * ty) /
v;
443 k[step4 + 1] = ty *
h;
444 k[step4 + 2] = Ax[step] * qp0;
445 k[step4 + 3] = Ay[step] * qp0;
446 k[step4 + 4] = At[step] *
h;
453 initialised =
fvec(zero < *w);
457 initialised =
fvec(zero < one);
469 fx = ((x0[0] + c[0] * k[0] + c[1] * k[5 + 0] + c[2] * k[10 + 0]
472 + ((!initialised) & fx);
473 fy = ((x0[1] + c[0] * k[1] + c[1] * k[5 + 1] + c[2] * k[10 + 1]
476 + ((!initialised) & fy);
477 ftx = ((x0[2] + c[0] * k[2] + c[1] * k[5 + 2] + c[2] * k[10 + 2]
480 + ((!initialised) & ftx);
481 fty = ((x0[3] + c[0] * k[3] + c[1] * k[5 + 3] + c[2] * k[10 + 3]
484 + ((!initialised) & fty);
485 ft = ((x0[4] + c[0] * k[4] + c[1] * k[5 + 4] + c[2] * k[10 + 4]
488 + ((!initialised) & ft);
489 fz = (z_out & initialised) + ((!initialised) & fz);
508 for (step = 0; step < 4; ++step) {
509 for (
i = 0;
i < 5; ++
i) {
513 x[
i] = x0[
i] + b[step] * k1[step * 5 - 5 +
i];
517 k1[step4] =
x[2] *
h;
518 k1[step4 + 1] =
x[3] *
h;
519 k1[step4 + 2] = Ax[step] + Ax_tx[step] *
x[2] + Ax_ty[step] *
x[3];
520 k1[step4 + 3] = Ay[step] + Ay_tx[step] *
x[2] + Ay_ty[step] *
x[3];
521 k1[step4 + 4] = At[step] + At_tx[step] *
x[2] + At_ty[step] *
x[3];
527 for (
i = 0;
i < 4; ++
i) {
528 J[24 +
i] = x0[
i] + c[0] * k1[
i] + c[1] * k1[5 +
i] + c[2] * k1[10 +
i]
532 J[29] = x0[4] + c[0] * k1[4] + c[1] * k1[5 + 4] + c[2] * k1[10 + 4]
551 for (step = 0; step < 4; ++step) {
552 for (
i = 0;
i < 5; ++
i) {
556 x[
i] = x0[
i] + b[step] * k1[step * 5 - 5 +
i];
560 k1[step4] =
x[2] *
h;
561 k1[step4 + 1] =
x[3] *
h;
563 k1[step4 + 3] = Ay_tx[step] *
x[2] + Ay_ty[step] *
x[3];
564 k1[step4 + 4] = At_tx[step] *
x[2] + At_ty[step] *
x[3];
567 for (
i = 0;
i < 4; ++
i) {
569 J[12 +
i] = x0[
i] + c[0] * k1[
i] + c[1] * k1[5 +
i] + c[2] * k1[10 +
i]
576 J[17] = x0[4] + c[0] * k1[4] + c[1] * k1[5 + 4] + c[2] * k1[10 + 4]
592 for (step = 0; step < 4; ++step) {
593 for (
i = 0;
i < 5; ++
i) {
597 x[
i] = x0[
i] + b[step] * k1[step * 5 - 5 +
i];
601 k1[step4] =
x[2] *
h;
602 k1[step4 + 1] =
x[3] *
h;
603 k1[step4 + 2] = Ax_tx[step] *
x[2] + Ax_ty[step] *
x[3];
605 k1[step4 + 4] = At_tx[step] *
x[2] + At_ty[step] *
x[3];
608 for (
i = 0;
i < 3; ++
i) {
609 J[18 +
i] = x0[
i] + c[0] * k1[
i] + c[1] * k1[5 +
i] + c[2] * k1[10 +
i]
615 J[23] = x0[4] + c[0] * k1[4] + c[1] * k1[5 + 4] + c[2] * k1[10 + 4]
620 for (
i = 0;
i < 12; ++
i)
624 for (
i = 30;
i < 35;
i++)
628 fvec dqp = qp_in - qp0;
631 fx += ((J[6 * 4 + 0] * dqp) & initialised);
632 fy += ((J[6 * 4 + 1] * dqp) & initialised);
633 ftx += ((J[6 * 4 + 2] * dqp) & initialised);
634 fty += ((J[6 * 4 + 3] * dqp) & initialised);
635 ft += ((J[6 * 4 + 5] * dqp) & initialised);
658 const fvec c42 = C42, c43 = C43;
661 C00 + C20 * J[6 * 2 + 0] + C30 * J[6 * 3 + 0] + C40 * J[6 * 4 + 0];
663 C10 + C21 * J[6 * 2 + 0] + C31 * J[6 * 3 + 0] + C41 * J[6 * 4 + 0];
665 C20 + C22 * J[6 * 2 + 0] + C32 * J[6 * 3 + 0] + c42 * J[6 * 4 + 0];
667 C30 + C32 * J[6 * 2 + 0] + C33 * J[6 * 3 + 0] + c43 * J[6 * 4 + 0];
669 C40 + C42 * J[6 * 2 + 0] + C43 * J[6 * 3 + 0] + C44 * J[6 * 4 + 0];
671 C50 + C52 * J[6 * 2 + 0] + C53 * J[6 * 3 + 0] + C54 * J[6 * 4 + 0];
675 C11 + C21 * J[6 * 2 + 1] + C31 * J[6 * 3 + 1] + C41 * J[6 * 4 + 1];
677 C21 + C22 * J[6 * 2 + 1] + C32 * J[6 * 3 + 1] + c42 * J[6 * 4 + 1];
679 C31 + C32 * J[6 * 2 + 1] + C33 * J[6 * 3 + 1] + c43 * J[6 * 4 + 1];
681 C41 + C42 * J[6 * 2 + 1] + C43 * J[6 * 3 + 1] + C44 * J[6 * 4 + 1];
683 C51 + C52 * J[6 * 2 + 1] + C53 * J[6 * 3 + 1] + C54 * J[6 * 4 + 1];
688 C22 * J[6 * 2 + 2] + C32 * J[6 * 3 + 2] + c42 * J[6 * 4 + 2];
690 C32 * J[6 * 2 + 2] + C33 * J[6 * 3 + 2] + c43 * J[6 * 4 + 2];
692 C42 * J[6 * 2 + 2] + C43 * J[6 * 3 + 2] + C44 * J[6 * 4 + 2];
694 C52 * J[6 * 2 + 2] + C53 * J[6 * 3 + 2] + C54 * J[6 * 4 + 2];
699 C22 * J[6 * 2 + 3] + C32 * J[6 * 3 + 3] + c42 * J[6 * 4 + 3];
701 C32 * J[6 * 2 + 3] + C33 * J[6 * 3 + 3] + c43 * J[6 * 4 + 3];
703 C42 * J[6 * 2 + 3] + C43 * J[6 * 3 + 3] + C44 * J[6 * 4 + 3];
705 C52 * J[6 * 2 + 3] + C53 * J[6 * 3 + 3] + C54 * J[6 * 4 + 3];
707 const fvec cj24 = C42;
708 const fvec cj34 = C43;
709 const fvec cj44 = C44;
710 const fvec cj54 = C54;
714 const fvec cj25 = C52 + C22 * J[17] + C32 * J[23] + C42 * J[29];
715 const fvec cj35 = C53 + C32 * J[17] + C33 * J[23] + C43 * J[29];
716 const fvec cj45 = C54 + C42 * J[17] + C43 * J[23] + C44 * J[29];
717 const fvec cj55 = C55 + C52 * J[17] + C53 * J[23] + C54 * J[29];
720 C00 = ((cj00 + cj20 * J[12] + cj30 * J[18] + cj40 * J[24]) & initialised)
721 + ((!initialised) & C00);
723 C10 = ((cj10 + cj20 * J[13] + cj30 * J[19] + cj40 * J[25]) & initialised)
724 + ((!initialised) & C10);
725 C11 = ((cj11 + cj21 * J[13] + cj31 * J[19] + cj41 * J[25]) & initialised)
726 + ((!initialised) & C11);
728 C20 = ((cj20 + cj30 * J[20] + cj40 * J[26]) & initialised)
729 + ((!initialised) & C20);
730 C21 = ((cj21 + cj31 * J[20] + cj41 * J[26]) & initialised)
731 + ((!initialised) & C21);
732 C22 = ((cj22 + cj32 * J[20] + cj42 * J[26]) & initialised)
733 + ((!initialised) & C22);
735 C30 = ((cj30 + cj20 * J[15] + cj40 * J[27]) & initialised)
736 + ((!initialised) & C30);
737 C31 = ((cj31 + cj21 * J[15] + cj41 * J[27]) & initialised)
738 + ((!initialised) & C31);
739 C32 = ((cj32 + cj22 * J[15] + cj42 * J[27]) & initialised)
740 + ((!initialised) & C32);
741 C33 = ((cj33 + cj23 * J[15] + cj43 * J[27]) & initialised)
742 + ((!initialised) & C33);
744 C40 = ((cj40) &initialised) + ((!initialised) & C40);
745 C41 = ((cj41) &initialised) + ((!initialised) & C41);
746 C42 = ((cj42) &initialised) + ((!initialised) & C42);
747 C43 = ((cj43) &initialised) + ((!initialised) & C43);
748 C44 = ((cj44) &initialised) + ((!initialised) & C44);
750 C50 = ((cj50 + cj20 * J[17] + cj30 * J[23] + cj40 * J[29]) & initialised)
751 + ((!initialised) & C50);
752 C51 = ((cj51 + cj21 * J[17] + cj31 * J[23] + cj41 * J[29]) & initialised)
753 + ((!initialised) & C51);
754 C52 = ((cj52 + cj22 * J[17] + cj32 * J[23] + cj42 * J[29]) & initialised)
755 + ((!initialised) & C52);
756 C53 = ((cj53 + cj23 * J[17] + cj33 * J[23] + cj43 * J[29]) & initialised)
757 + ((!initialised) & C53);
758 C54 = ((cj54 + cj24 * J[17] + cj34 * J[23] + cj44 * J[29]) & initialised)
759 + ((!initialised) & C54);
760 C55 = ((cj55 + cj25 * J[17] + cj35 * J[23] + cj45 * J[29]) & initialised)
761 + ((!initialised) & C55);
777 fvec h = txtx + tyty;
782 cnst c1 = 0.0136f, c2 = c1 * 0.038f, c3 = c2 * 0.5f, c4 = -c3 / 2.0f,
783 c5 = c3 / 3.0f, c6 = -c3 / 4.0f;
785 (c1 + c2 *
fvec(logRadThick) + c3 *
h + h2 * (c4 + c5 *
h + c6 * h2))
790 C22 += w * txtx1 * a;
791 C32 += w * tx * ty * a;
792 C33 += w * (
ONE + tyty) * a;
804 fvec h = txtx + tyty;
809 cnst c1 = 0.0136f, c2 = c1 * 0.038f, c3 = c2 * 0.5f, c4 = -c3 / 2.0f,
810 c5 = c3 / 3.0f, c6 = -c3 / 4.0f;
813 (c1 + c2 *
log(radThick) + c3 *
h + h2 * (c4 + c5 *
h + c6 * h2)) * qp0t;
815 fvec a = ((t + mass2 * qp0 * qp0t) * radThick * s0 * s0);
817 C22 += w * txtx1 * a;
818 C32 += w * tx * ty * a;
819 C33 += w * (
ONE + tyty) * a;
835 fvec h = txtx + tyty;
840 cnst c1 = 0.0136f, c2 = c1 * 0.038f, c3 = c2 * 0.5f, c4 = -c3 / 2.0f,
841 c5 = c3 / 3.0f, c6 = -c3 / 4.0f;
844 (c1 + c2 *
log(radThick) + c3 *
h + h2 * (c4 + c5 *
h + c6 * h2)) * qp0t;
846 fvec a = ((t + mass2 * qp0 * qp0t) * radThick * s0 * s0);
848 fvec D = (fDownstream) ? 1. : -1.;
849 fvec T23 = (thickness * thickness) / 3.0;
850 fvec T2 = thickness / 2.0;
852 C00 += w * txtx1 * a * T23;
853 C10 += w * tx * ty * a * T23;
854 C20 += w * txtx1 * a * D * T2;
855 C30 += w * tx * ty * a * D * T2;
857 C11 += w * (
ONE + tyty) * a * T23;
858 C21 += w * tx * ty * a * D * T2;
859 C31 += w * (
ONE + tyty) * a * D * T2;
861 C22 += w * txtx1 * a;
862 C32 += w * tx * ty * a;
863 C33 += w * (
ONE + tyty) * a;
879 fvec h = txtx + tyty;
884 cnst c1 = 0.0136f, c2 = c1 * 0.038f, c3 = c2 * 0.5f, c4 = -c3 / 2.0f,
885 c5 = c3 / 3.0f, c6 = -c3 / 4.0f;
888 (c1 + c2 * info.
logRadThick + c3 *
h + h2 * (c4 + c5 *
h + c6 * h2)) * qp0t;
890 fvec a = ((t + mass2 * qp0 * qp0t) * info.
RadThick * s0 * s0);
892 C22 += w * txtx1 * a;
893 C32 += w * tx * ty * a;
894 C33 += w * (
ONE + tyty) * a;
899 const fvec& radThick,
904 const fvec& E2 = mass2 + p2;
910 const fvec& dE = bethe * radThick * tr * 2.33f * 9.34961f;
912 const fvec& E2Corrected =
913 (
sqrt(E2) + direction * dE) * (
sqrt(E2) + direction * dE);
914 fvec corr =
sqrt(p2 / (E2Corrected - mass2));
929 const fvec& radThick,
933 const fvec& p2 = 1.f / (qp0 * qp0);
934 const fvec& E2 = mass2 + p2;
937 float atomicA = 55.845f;
939 float radLen = 1.758f;
943 i = (12. * atomicZ + 7.) * 1.e-9;
945 i = (9.76 * atomicZ + 58.8 * std::pow(atomicZ, -0.19)) * 1.e-9;
953 fvec dE = bethe * radThick * tr * radLen * rho;
955 const fvec& E2Corrected =
956 (
sqrt(E2) + direction * dE) * (
sqrt(E2) + direction * dE);
957 fvec corr =
sqrt(p2 / (E2Corrected - mass2));
964 float P =
fabs(1. / qp0[0]);
970 fvec STEP = radThick * tr * radLen;
971 fvec EMASS = 0.511 * 1e-3;
977 fvec XI = (153.5 * Z * STEP * RHO) / (A * BETA * BETA);
980 fvec ETA = BETA * GAMMA;
981 fvec ETASQ = ETA * ETA;
983 fvec F1 = 2. * EMASS * ETASQ;
984 fvec F2 = 1. + 2. * RATIO * GAMMA + RATIO * RATIO;
985 fvec EMAX = 1e6 * F1 / F2;
987 fvec DEDX2 = XI * EMAX * (1. - (BETA * BETA / 2.)) * 1e-12;
989 fvec SDEDX = ((E2) *DEDX2) / std::pow(P, 6);
1000 const fvec& radThick,
1004 const fvec& p2 = 1.f / (qp0 * qp0);
1005 const fvec& E2 = mass2 + p2;
1008 float atomicA = 12.011f;
1010 float radLen = 18.76f;
1014 i = (12. * atomicZ + 7.) * 1.e-9;
1016 i = (9.76 * atomicZ + 58.8 * std::pow(atomicZ, -0.19)) * 1.e-9;
1024 fvec dE = bethe * radThick * tr * radLen * rho;
1026 const fvec& E2Corrected =
1027 (
sqrt(E2) + direction * dE) * (
sqrt(E2) + direction * dE);
1028 fvec corr =
sqrt(p2 / (E2Corrected - mass2));
1035 float P =
fabs(1. / qp0[0]);
1041 fvec STEP = radThick * tr * radLen;
1042 fvec EMASS = 0.511 * 1e-3;
1048 fvec XI = (153.5 * Z * STEP * RHO) / (A * BETA * BETA);
1051 fvec ETA = BETA * GAMMA;
1052 fvec ETASQ = ETA * ETA;
1054 fvec F1 = 2. * EMASS * ETASQ;
1055 fvec F2 = 1. + 2. * RATIO * GAMMA + RATIO * RATIO;
1056 fvec EMAX = 1e6 * F1 / F2;
1058 fvec DEDX2 = XI * EMAX * (1. - (BETA * BETA / 2.)) * 1e-12;
1060 fvec SDEDX = ((E2) *DEDX2) / std::pow(P, 6);
1071 const fvec& radThick,
1075 const fvec& p2 = 1.f / (qp0 * qp0);
1076 const fvec& E2 = mass2 + p2;
1079 float atomicA = 26.981f;
1081 float radLen = 2.265f;
1085 i = (12. * atomicZ + 7.) * 1.e-9;
1087 i = (9.76 * atomicZ + 58.8 * std::pow(atomicZ, -0.19)) * 1.e-9;
1095 fvec dE = bethe * radThick * tr * radLen * rho;
1097 const fvec& E2Corrected =
1098 (
sqrt(E2) + direction * dE) * (
sqrt(E2) + direction * dE);
1099 fvec corr =
sqrt(p2 / (E2Corrected - mass2));
1106 float P =
fabs(1. / qp0[0]);
1112 fvec STEP = radThick * tr * radLen;
1113 fvec EMASS = 0.511 * 1e-3;
1119 fvec XI = (153.5 * Z * STEP * RHO) / (A * BETA * BETA);
1122 fvec ETA = BETA * GAMMA;
1123 fvec ETASQ = ETA * ETA;
1125 fvec F1 = 2. * EMASS * ETASQ;
1126 fvec F2 = 1. + 2. * RATIO * GAMMA + RATIO * RATIO;
1127 fvec EMAX = 1e6 * F1 / F2;
1129 fvec DEDX2 = XI * EMAX * (1. - (BETA * BETA / 2.)) * 1e-12;
1131 fvec SDEDX = ((E2) *DEDX2) / std::pow(P, 6);