22 double setLimitedFitVrt(
VKVertex* vk,
double alf,
double bet,
double dCoefNorm,
26 for (
int ii = 0; ii < 3; ++ii) {
27 newVrt[ii] = vk->
iniV[ii] + (alf + bet) * (vk->
fitV[ii] - vk->
iniV[ii]) +
28 bet * dCoefNorm * vk->
dxyz0[ii];
31 for (
int ii = 0; ii < NTRK;
37 trk->
iniP[0] + (alf + bet) * (trk->
fitP[0] - trk->
iniP[0]) +
38 bet * dCoefNorm * t_trk->
parf0[0];
40 trk->
iniP[1] + (alf + bet) * (trk->
fitP[1] - trk->
iniP[1]) +
41 bet * dCoefNorm * t_trk->
parf0[1];
43 trk->
iniP[2] + (alf + bet) * (trk->
fitP[2] - trk->
iniP[2]) +
44 bet * dCoefNorm * t_trk->
parf0[2];
46 if (bet != 0. && std::abs(t_trk->
part[2]) < 1.e-7)
48 trk->
iniP[2] + (alf + bet) * (trk->
fitP[2] - trk->
iniP[2]);
57 double calcChi2Addition(
VKVertex* vk,
const double wgtvrtd[6],
58 const double xyzf[3]) {
60 double Chi2t = 0., signif;
66 wgtvrtd[0] *
d1 *
d1 + wgtvrtd[2] *
d2 *
d2 + wgtvrtd[5] * d3 * d3 +
67 2. * (
d2 *
d1 * wgtvrtd[1] + d3 * (
d1 * wgtvrtd[3] +
d2 * wgtvrtd[4]));
71 Chi2t += signif * signif;
77 void makeNoPostFit(
VKVertex* vk,
double wgtvrtd[],
double& dCoefNorm) {
78 double xyzt[3] = {0.};
79 vk->
Chi2 = setLimitedFitVrt(
80 vk, 1., 0., dCoefNorm,
xyzt);
82 vk->
Chi2 += calcChi2Addition(vk, wgtvrtd,
xyzt);
86 for (
int i = 0;
i < NTRK; ++
i) {
88 for (
int j = 0; j < 3; j++) {
96 bool makePostFit(
VKVertex* vk,
double wgtvrtd[],
double& dCoefNorm) {
99 double dScale = 1.e8, dScaleMax = 1.e10;
100 double alfLowLim = 0.1;
101 double alfUppLim = 1.1;
103 double xyzt[3], chi2t[10] = {0.};
104 double alf = 1., bet = 0.;
106 double ContribC[10] = {0.};
109 int PostFitIteration = 4;
111 PostFitIteration = 4;
115 for (j = 1; j <= PostFitIteration; ++j) {
129 setLimitedFitVrt(vk, alf, bet, dCoefNorm,
133 calcChi2Addition(vk, wgtvrtd,
xyzt);
140 dScale =
std::max(chi2t[0], 5. * NTRK) / (dCnstContrib + 1 / dScaleMax);
141 if (dScale > dScaleMax)
146 ContribC[jm1] = dCnstContrib * dScale;
147 if (j != PostFitIteration) {
148 chi2t[jm1] += 5. * ContribC[jm1];
153 alf =
finter(chi2t[0], chi2t[1], chi2t[2], 0., 0.5, 1.);
154 if (chi2t[0] == chi2t[1] && chi2t[1] == chi2t[2])
158 if (alf < alfLowLim) {
191 if (j == 4 && alf != alfLowLim) {
192 ValForChk = chi2t[3];
193 if ((PostFitIteration == 4) && NCNST)
194 ValForChk += ContribC[3];
195 int notImproved =
false;
196 if (ValForChk > chi2t[0] * 1.0001) {
198 ValForChk = chi2t[0];
201 if (ValForChk > chi2t[1] * 1.0001) {
203 ValForChk = chi2t[1];
206 if (ValForChk > chi2t[2] * 1.0001) {
208 ValForChk = chi2t[2];
215 setLimitedFitVrt(vk, alf, bet, dCoefNorm,
219 calcChi2Addition(vk, wgtvrtd,
xyzt);
223 if (j != PostFitIteration) {
224 chi2t[jm1] += ContribC[jm1];
233 for (ii = 0; ii < NTRK; ++ii) {
236 vk->
Chi2 = chi2t[PostFitIteration - 1];
240 for (ii = 0; ii < NTRK; ++ii) {
242 for (j = 0; j < 3; j++) {
249 if (alf == alfLowLim)
295 double dxyz[3],
xyzt[3], eigv[8];
301 double wa[6], stv[3], wgtvrtd[6], tv[3];
303 int ic, jj,
it, jt, ii,
kt;
306 #define ader_ref(a_1,a_2) vk->ader[(a_2)*(vkalNTrkM*3+3) + (a_1) - (vkalNTrkM*3+4)]
307 #define cvder_ref(a_1,a_2) vk->FVC.cvder[(a_2)*2 + (a_1) - 3]
308 #define dcv_ref(a_1,a_2) vk->FVC.dcv[(a_2)*6 + (a_1) - 7]
360 std::unique_ptr<double[]> dphi = std::unique_ptr<double[]>(
new double[NTRK]);
361 std::unique_ptr<double[]> deps = std::unique_ptr<double[]>(
new double[NTRK]);
362 std::unique_ptr<double[]> drho = std::unique_ptr<double[]>(
new double[NTRK]);
363 std::unique_ptr<double[]> dtet = std::unique_ptr<double[]>(
new double[NTRK]);
364 std::unique_ptr<double[]> dzp = std::unique_ptr<double[]>(
new double[NTRK]);
366 for (
int i=0;
i<3; ++
i) { tv[
i] = 0.; stv[
i] = 0.;}
367 for (
int i=0;
i<6; ++
i) { vk->
wa[
i] = 0.; wa[
i] = 0.;}
368 for (
k=0;
k<2;
k++) {
for(j=0; j<3; j++) drdvy[
k][j] = drdpy[
k][j] = 0.;};
369 for (
k=0;
k<3;
k++) {
for(j=0; j<3; j++) pyv[
k][j] = vyv[
k][j] = 0.;};
382 for (ii = 1; ii <= 3; ++ii) {
383 for (jj = 1; jj <= 3; ++jj) {
389 for (
kt = 0;
kt < NTRK; ++
kt) {
391 double theta_ini =trk->
iniP[0];
392 double phi_ini =trk->
iniP[1];
393 double invR_ini =trk->
iniP[2];
396 double cotth = 1. /
tan( theta_ini );
397 double cosf =
cos(phi_ini);
398 double sinf =
sin(phi_ini);
399 double uu =
xyz[0]*cosf +
xyz[1]*sinf;
400 double vv =
xyz[1]*cosf -
xyz[0]*sinf;
403 eps = -
vv - uu*uu * invR_ini / 2.;
404 zp = -uu * (1. -
vv * invR_ini) * cotth;
405 phip = -uu * invR_ini;
414 deps[
kt] = trk->
a0() - eps;
415 dzp[
kt] = trk->
z() -
xyz[2];
417 dtet[
kt] = trk->
theta() - theta_ini;
418 dphi[
kt] = trk->
phi() - phi_ini;
420 drho[
kt] = trk->
invR() - invR_ini;
426 double d11 = sinf - ( uu*cosf *invR_ini);
427 double d12 = -cosf - ( uu*sinf *invR_ini);
428 double d21 = -cosf * cotth + ( (
vv*cosf-uu*sinf)*cotth *invR_ini);
429 double d22 = -sinf * cotth + ( (
vv*sinf+uu*cosf)*cotth *invR_ini);
431 double d41 = -cosf * invR_ini;
432 double d42 = -sinf * invR_ini;
443 double dw11 = d11 * trk->
WgtM[0] + d21 * trk->
WgtM[1] + d41 * trk->
WgtM[6];
444 double dw12 = d11 * trk->
WgtM[1] + d21 * trk->
WgtM[2] + d41 * trk->
WgtM[7];
445 double dw13 = d11 * trk->
WgtM[3] + d21 * trk->
WgtM[4] + d41 * trk->
WgtM[8];
446 double dw14 = d11 * trk->
WgtM[6] + d21 * trk->
WgtM[7] + d41 * trk->
WgtM[9];
447 double dw15 = d11 * trk->
WgtM[10]+ d21 * trk->
WgtM[11]+ d41 * trk->
WgtM[13];
450 double dw21 = d12 * trk->
WgtM[0] + d22 * trk->
WgtM[1] + d42 * trk->
WgtM[6];
451 double dw22 = d12 * trk->
WgtM[1] + d22 * trk->
WgtM[2] + d42 * trk->
WgtM[7];
452 double dw23 = d12 * trk->
WgtM[3] + d22 * trk->
WgtM[4] + d42 * trk->
WgtM[8];
453 double dw24 = d12 * trk->
WgtM[6] + d22 * trk->
WgtM[7] + d42 * trk->
WgtM[9];
454 double dw25 = d12 * trk->
WgtM[10]+ d22 * trk->
WgtM[11]+ d42 * trk->
WgtM[13];
455 double dw31 = trk->
WgtM[1];
456 double dw32 = trk->
WgtM[2];
457 double dw33 = trk->
WgtM[4];
458 double dw34 = trk->
WgtM[7];
459 double dw35 = trk->
WgtM[11];
462 tv[0] += dw11 * deps[
kt] + dw12 * dzp[
kt];
463 tv[1] += dw21 * deps[
kt] + dw22 * dzp[
kt];
464 tv[2] += dw31 * deps[
kt] + dw32 * dzp[
kt];
465 tv[0] += dw13 * dtet[
kt] + dw14 * dphi[
kt] + dw15 * drho[
kt];
466 tv[1] += dw23 * dtet[
kt] + dw24 * dphi[
kt] + dw25 * drho[
kt];
467 tv[2] += dw33 * dtet[
kt] + dw34 * dphi[
kt] + dw35 * drho[
kt];
469 stv[0] += dw11 * deps[
kt] + dw12 * dzp[
kt];
470 stv[1] += dw21 * deps[
kt] + dw22 * dzp[
kt];
471 stv[2] += dw31 * deps[
kt] + dw32 * dzp[
kt];
472 stv[0] += dw13 * dtet[
kt] + dw14 * dphi[
kt] + dw15*drho[
kt];
473 stv[1] += dw23 * dtet[
kt] + dw24 * dphi[
kt] + dw25*drho[
kt];
474 stv[2] += dw33 * dtet[
kt] + dw34 * dphi[
kt] + dw35*drho[
kt];
477 double e12 = uu - invR_ini *
vv * uu;
478 double e13 = -uu*uu / 2.;
479 double e21 = uu *(1. -
vv*invR_ini) * (cotth*cotth + 1.);
480 double e22 = -
vv*cotth + (
vv*
vv-uu*uu)*invR_ini*cotth;
481 double e23 = uu*
vv*cotth;
482 double e43 = -uu + 2.*uu*
vv*invR_ini;
488 e21 = uu * (cotth*cotth + 1.);
495 double ew11 = e21 * trk->
WgtM[1] + trk->
WgtM[3];
496 double ew12 = e21 * trk->
WgtM[2] + trk->
WgtM[4];
497 double ew13 = e21 * trk->
WgtM[4] + trk->
WgtM[5];
498 double ew14 = e21 * trk->
WgtM[7] + trk->
WgtM[8];
499 double ew15 = e21 * trk->
WgtM[11]+ trk->
WgtM[12];
500 double ew21 = e12 * trk->
WgtM[0] + e22 * trk->
WgtM[1] + trk->
WgtM[6];
501 double ew22 = e12 * trk->
WgtM[1] + e22 * trk->
WgtM[2] + trk->
WgtM[7];
502 double ew23 = e12 * trk->
WgtM[3] + e22 * trk->
WgtM[4] + trk->
WgtM[8];
503 double ew24 = e12 * trk->
WgtM[6] + e22 * trk->
WgtM[7] + trk->
WgtM[9];
504 double ew25 = e12 * trk->
WgtM[10]+ e22 * trk->
WgtM[11]+ trk->
WgtM[13];
505 double ew31 = e13 * trk->
WgtM[0] + e23 * trk->
WgtM[1] + e43 * trk->
WgtM[6] + trk->
WgtM[10];
506 double ew32 = e13 * trk->
WgtM[1] + e23 * trk->
WgtM[2] + e43 * trk->
WgtM[7] + trk->
WgtM[11];
507 double ew33 = e13 * trk->
WgtM[3] + e23 * trk->
WgtM[4] + e43 * trk->
WgtM[8] + trk->
WgtM[12];
508 double ew34 = e13 * trk->
WgtM[6] + e23 * trk->
WgtM[7] + e43 * trk->
WgtM[9] + trk->
WgtM[13];
509 double ew35 = e13 * trk->
WgtM[10]+ e23 * trk->
WgtM[11]+ e43 * trk->
WgtM[13]+ trk->
WgtM[14];
513 t_trk->
tt[0] = ew11*deps[
kt] + ew12*dzp[
kt];
514 t_trk->
tt[1] = ew21*deps[
kt] + ew22*dzp[
kt];
515 t_trk->
tt[2] = ew31*deps[
kt] + ew32*dzp[
kt];
516 t_trk->
tt[0] += ew13*dtet[
kt] + ew14*dphi[
kt] + ew15*drho[
kt];
517 t_trk->
tt[1] += ew23*dtet[
kt] + ew24*dphi[
kt] + ew25*drho[
kt];
518 t_trk->
tt[2] += ew33*dtet[
kt] + ew34*dphi[
kt] + ew35*drho[
kt];
520 for (j = 1; j <= 2; ++j) {
536 t_trk->
tt[0] -= drdpy[0][0]*vk->
FVC.
rv0[0] + drdpy[1][0]*vk->
FVC.
rv0[1];
537 t_trk->
tt[1] -= drdpy[0][1]*vk->
FVC.
rv0[0] + drdpy[1][1]*vk->
FVC.
rv0[1];
538 t_trk->
tt[2] -= drdpy[0][2]*vk->
FVC.
rv0[0] + drdpy[1][2]*vk->
FVC.
rv0[1];
539 for (ii = 1; ii <= 3; ++ii) {
540 for (jj = 1; jj <= 3; ++jj) {
541 pyv[jj-1][ii-1] = drdpy[0][ii-1] *
cvder_ref(1, jj) + drdpy[1][ii-1] *
cvder_ref(2, jj);
547 wa[0] += dw11 * d11 + dw12 * d21 + dw14 * d41;
548 wa[1] += dw11 * d12 + dw12 * d22 + dw14 * d42;
549 wa[2] += dw21 * d12 + dw22 * d22 + dw24 * d42;
553 vk->
wa[0] = vk->
wa[0] + dw11 * d11 + dw12 * d21 + dw14 * d41;
554 vk->
wa[1] = vk->
wa[1] + dw11 * d12 + dw12 * d22 + dw14 * d42;
555 vk->
wa[2] = vk->
wa[2] + dw21 * d12 + dw22 * d22 + dw24 * d42;
561 twb[0] = dw12 * e21 + dw13;
562 twb[1] = dw22 * e21 + dw23;
563 twb[2] = dw32 * e21 + dw33;
564 twb[3] = dw11 * e12 + dw12 * e22 + dw14;
565 twb[4] = dw21 * e12 + dw22 * e22 + dw24;
566 twb[5] = dw31 * e12 + dw32 * e22 + dw34;
567 twb[6] = dw11 * e13 + dw12 * e23 + dw14 * e43 + dw15;
568 twb[7] = dw21 * e13 + dw22 * e23 + dw24 * e43 + dw25;
569 twb[8] = dw31 * e13 + dw32 * e23 + dw34 * e43 + dw35;
583 vk->
tmpArr[
kt]->wc[0] = ew12 * e21 + ew13;
584 vk->
tmpArr[
kt]->wc[1] = ew22 * e21 + ew23;
585 vk->
tmpArr[
kt]->wc[3] = ew32 * e21 + ew33;
586 vk->
tmpArr[
kt]->wc[2] = ew21 * e12 + ew22 * e22 + ew24;
587 vk->
tmpArr[
kt]->wc[4] = ew31 * e12 + ew32 * e22 + ew34;
588 vk->
tmpArr[
kt]->wc[5] = ew31 * e13 + ew32 * e23 + ew34 * e43 + ew35;
593 if (IERR)
return IERR;
596 twbci[0] = twb[0]*twci[0] + twb[3]*twci[1] + twb[6]*twci[3];
597 twbci[1] = twb[1]*twci[0] + twb[4]*twci[1] + twb[7]*twci[3];
598 twbci[2] = twb[2]*twci[0] + twb[5]*twci[1] + twb[8]*twci[3];
599 twbci[3] = twb[0]*twci[1] + twb[3]*twci[2] + twb[6]*twci[4];
600 twbci[4] = twb[1]*twci[1] + twb[4]*twci[2] + twb[7]*twci[4];
601 twbci[5] = twb[2]*twci[1] + twb[5]*twci[2] + twb[8]*twci[4];
602 twbci[6] = twb[0]*twci[3] + twb[3]*twci[4] + twb[6]*twci[5];
603 twbci[7] = twb[1]*twci[3] + twb[4]*twci[4] + twb[7]*twci[5];
604 twbci[8] = twb[2]*twci[3] + twb[5]*twci[4] + twb[8]*twci[5];
607 wa[0] = wa[0] - twbci[0]*twb[0] - twbci[3]*twb[3] - twbci[6]*twb[6];
608 wa[1] = wa[1] - twbci[0]*twb[1] - twbci[3]*twb[4] - twbci[6]*twb[7];
609 wa[2] = wa[2] - twbci[1]*twb[1] - twbci[4]*twb[4] - twbci[7]*twb[7];
610 wa[3] = wa[3] - twbci[0]*twb[2] - twbci[3]*twb[5] - twbci[6]*twb[8];
611 wa[4] = wa[4] - twbci[1]*twb[2] - twbci[4]*twb[5] - twbci[7]*twb[8];
612 wa[5] = wa[5] - twbci[2]*twb[2] - twbci[5]*twb[5] - twbci[8]*twb[8];
615 tv[0] = tv[0] - twbci[0] * vk->
tmpArr[
kt]->tt[0] - twbci[3] * vk->
tmpArr[
kt]->tt[1] - twbci[6] * vk->
tmpArr[
kt]->tt[2];
616 tv[1] = tv[1] - twbci[1] * vk->
tmpArr[
kt]->tt[0] - twbci[4] * vk->
tmpArr[
kt]->tt[1] - twbci[7] * vk->
tmpArr[
kt]->tt[2];
617 tv[2] = tv[2] - twbci[2] * vk->
tmpArr[
kt]->tt[0] - twbci[5] * vk->
tmpArr[
kt]->tt[1] - twbci[8] * vk->
tmpArr[
kt]->tt[2];
619 for(
int tpn=0; tpn<9; tpn++){
621 if(tpn<6)vk->
tmpArr[
kt]->wci[tpn] = twci[tpn];
622 vk->
tmpArr[
kt]->wbci[tpn] = twbci[tpn];
634 vk->
wa[0] += wgtvrtd[0];
635 vk->
wa[1] += wgtvrtd[1];
636 vk->
wa[2] += wgtvrtd[2];
637 vk->
wa[3] += wgtvrtd[3];
638 vk->
wa[4] += wgtvrtd[4];
639 vk->
wa[5] += wgtvrtd[5];
640 tv[0] = tv[0] +
xyzt[0] * wgtvrtd[0] +
xyzt[1] * wgtvrtd[1] +
xyzt[2] * wgtvrtd[3];
641 tv[1] = tv[1] +
xyzt[0] * wgtvrtd[1] +
xyzt[1] * wgtvrtd[2] +
xyzt[2] * wgtvrtd[4];
642 tv[2] = tv[2] +
xyzt[0] * wgtvrtd[3] +
xyzt[1] * wgtvrtd[4] +
xyzt[2] * wgtvrtd[5];
643 stv[0] = stv[0] +
xyzt[0] * wgtvrtd[0] +
xyzt[1] * wgtvrtd[1] +
xyzt[2] * wgtvrtd[3];
644 stv[1] = stv[1] +
xyzt[0] * wgtvrtd[1] +
xyzt[1] * wgtvrtd[2] +
xyzt[2] * wgtvrtd[4];
645 stv[2] = stv[2] +
xyzt[0] * wgtvrtd[3] +
xyzt[1] * wgtvrtd[4] +
xyzt[2] * wgtvrtd[5];
648 vk->
T[0]=stv[0]; vk->
T[1]=stv[1]; vk->
T[2]=stv[2];
656 double EigThreshold = 1.e-9;
658 if (eigv[0] < eigv[2] * EigThreshold) {
659 wa[0] += (eigv[2] * EigThreshold - eigv[0]);
660 wa[2] += (eigv[2] * EigThreshold - eigv[0]);
661 wa[5] += (eigv[2] * EigThreshold - eigv[0]);
665 wa[0] += eigv[2] * 1.e-12;
666 wa[2] += eigv[2] * 1.e-12;
667 wa[5] += eigv[2] * 1.e-12;
668 vk->
wa[0] += eigv[2] * 1.e-12;
669 vk->
wa[2] += eigv[2] * 1.e-12;
670 vk->
wa[5] += eigv[2] * 1.e-12;
675 for(ii=0; ii<6; ii++) {
if(std::isnan(wa[ii]))
return -2;}
676 if(wa[0]<0 || wa[2]<0 || wa[5]<0)
return -2;
686 for (j = 0; j < 3; ++j) {
687 vk->
dxyz0[j] = dxyz[j];
688 vk->
fitV[j] = xyzf[j] = vk->
iniV[j] + dxyz[j];
700 for (
kt = 0;
kt < NTRK; ++
kt) {
701 for(
int tpn=0; tpn<9; tpn++){
702 if(tpn<6)twci[tpn] = vk->
tmpArr[
kt]->wci[tpn];
703 twbci[tpn] = vk->
tmpArr[
kt]->wbci[tpn];
708 vk->
tmpArr[
kt]->parf0[0] = twci[0]*tt1 + twci[1]*tt2 + twci[3]*tt3 - twbci[0]*dxyz[0] - twbci[1]*dxyz[1] - twbci[2]*dxyz[2];
709 if( !std::isfinite(vk->
tmpArr[
kt]->parf0[0]) )
return -19;
710 vk->
tmpArr[
kt]->parf0[1] = twci[1]*tt1 + twci[2]*tt2 + twci[4]*tt3 - twbci[3]*dxyz[0] - twbci[4]*dxyz[1] - twbci[5]*dxyz[2];
711 if( !std::isfinite(vk->
tmpArr[
kt]->parf0[1]) )
return -19;
712 vk->
tmpArr[
kt]->parf0[2] = twci[3]*tt1 + twci[4]*tt2 + twci[5]*tt3 - twbci[6]*dxyz[0] - twbci[7]*dxyz[1] - twbci[8]*dxyz[2];
713 if( !std::isfinite(vk->
tmpArr[
kt]->parf0[2]) )
return -19;
727 stv[0] = stv[0] - drdvy[0][0] * vk->
FVC.
rv0[0] - drdvy[1][0] * vk->
FVC.
rv0[1];
728 stv[1] = stv[1] - drdvy[0][1] * vk->
FVC.
rv0[0] - drdvy[1][1] * vk->
FVC.
rv0[1];
729 stv[2] = stv[2] - drdvy[0][2] * vk->
FVC.
rv0[0] - drdvy[1][2] * vk->
FVC.
rv0[1];
731 vk->
T[0]=stv[0];vk->
T[1]=stv[1];vk->
T[2]=stv[2];
733 vk->
wa[0] += vyv[0][0];
734 vk->
wa[1] += vyv[1][0];
735 vk->
wa[2] += vyv[1][1];
736 vk->
wa[3] += vyv[2][0];
737 vk->
wa[4] += vyv[2][1];
738 vk->
wa[5] += vyv[2][2];
741 for (
it = 1;
it <= NTRK; ++
it) {
748 for (jt = 1; jt <= NTRK; ++jt) {
749 for (
k = 0;
k < 3; ++
k) {
750 for (
l = 0;
l < 3; ++
l) {
752 for (j = 0; j < 2; ++j) {
753 dpipj[
k][
l] += vk->
tmpArr[jt-1]->drdp[j][
k] * drdpy[j][
l];
757 for (
k = 1;
k <= 3; ++
k) {
758 for (
l = 1;
l <= 3; ++
l) {
766 double ArrTmp[9];
int ktmp=0;
767 for (
k=1;
k<=3; ++
k) {
771 if( eigv[0]<0 ){EigAddon=eigv[0];}
772 for (
k = 1;
k <=3; ++
k) {
776 long int NParam = NTRK*3 + 3;
778 if ( IERR)
return IERR;
779 double *fortst =
new double[
vkalNTrkM*3+3];
780 for (j = 0; j < 3; ++j) {
782 for (ii=0; ii<NTRK; ++ii) { fortst[ii*3 +3 +j] = vk->
tmpArr[ii]->tt[j];}
784 for (j=0; j<3; ++j) {
786 for (ii=0; ii<NParam; ++ii) {dxyz[j] +=
ader_ref(j+1, ii+1) * fortst[ii];}
787 vk->
dxyz0[j] = dxyz [j];
788 vk->
fitV[j] = vk->
iniV[j] + dxyz[j];
790 double tparf0[3]={0.};
791 for (
it = 1;
it <= NTRK; ++
it) {
793 for (j=0; j<3; ++j) {
795 for (ii = 1; ii <= NParam; ++ii) { tparf0[j] +=
ader_ref(
it*3+j+1, ii)*fortst[ii-1];}
797 for (j=0; j<3; ++j) { t_trk->
parf0[j] = tparf0[j];
819 double dCoefNorm = 0;
822 if (IERR != 0)
return IERR;
828 double* tmpB=
new double[3+3*NTRK];
double* tmpA=
new double[3+3*NTRK];
829 for (ii=0; ii<3; ++ii) {
830 tmpA[ii] = vk->
fitV[ii] - vk->
iniV[ii];
831 tmpB[ii] = vk->
dxyz0[ii];
833 for (
it=0;
it<NTRK; ++
it) {
841 double scalAA=0., scalAB=0.;
842 for (ii=0; ii<3+3*NTRK; ii++) scalAA += tmpA[ii]*tmpA[ii];
843 for (ii=0; ii<3+3*NTRK; ii++) scalAB += tmpA[ii]*tmpB[ii];
844 if(scalAB != 0.) dCoefNorm = -scalAA/scalAB;
847 delete[] tmpA;
delete[] tmpB;
861 for (
it = 0;
it < NTRK; ++
it) {
863 double Ratio=vk->
TrackList[
it]->fitP[2]/vk->
TrackList[
it]->Perig[4];
if(std::abs(Ratio)<1.)Ratio=1./Ratio;
874 bool improved=makePostFit( vk , wgtvrtd, dCoefNorm);
875 if(!improved)improved=makePostFit( vk , wgtvrtd, dCoefNorm);