14 void cfClstPnt(
double *
par,
const double *Vrt,
double *ClstPnt) noexcept {
19 double e2 = 1. +
e[2] *
e[2];
26 double u = (Vrt[0] - Per[0]) *
e[0] + (Vrt[1] - Per[1]) *
e[1] +
27 (Vrt[2] - Per[2]) *
e[2];
30 ClstPnt[0] = Per[0] +
u *
e[0];
31 ClstPnt[1] = Per[1] +
u *
e[1];
32 ClstPnt[2] = Per[2] +
u *
e[2];
40 #define min(a,b) ((a) <= (b) ? (a) : (b))
41 #define max(a,b) ((a) >= (b) ? (a) : (b))
43 void cfimp(
long int TrkID,
long int ich,
int IFL,
double *
par,
44 const double *
err,
double *vrt,
double *vcov,
double *rimp,
47 double dcov[3], errd[15], paro[5];
48 double dwgt[3], errn[15];
78 for (
int ii = 0; ii < 15; ++ii) {errd[ii] =
err[ii];}
81 double Ref0[3]={0.,0.,0.};
93 double sn =
sin(paro[3]);
94 double cs =
cos(paro[3]);
99 cnv[1] = sn /
tan(paro[2]);
100 cnv[3] = cs /
tan(paro[2]);
105 for (i__ = 1; i__ <= 3; ++i__) {
106 for (j = 1; j <= 3; ++j) {
108 ij = ij * (ij - 1) / 2 +
min(i__, j);
109 dcov[0] += cnv[(i__ << 1) - 2] * cnv[(j << 1) - 2] * vcov[ij];
110 dcov[2] += cnv[(i__ << 1) - 1] * cnv[(j << 1) - 1] * vcov[ij];
111 dcov[1] += cnv[(i__ << 1) - 2] * cnv[(j << 1) - 1] * vcov[ij];
116 rcov[0] = errn[0] + dcov[0];
117 rcov[1] = errn[1] + dcov[1];
118 rcov[2] = errn[2] + dcov[2];
119 }
else if (IFL == -1) {
120 rcov[0] = errn[0] - dcov[0];
121 rcov[1] = errn[1] - dcov[1];
122 rcov[2] = errn[2] - dcov[2];
128 int jerr =
cfdinv(rcov, dwgt, -2);
129 if (jerr) {jerr=
cfdinv(rcov, dwgt, 2);
if(jerr){dwgt[0]=dwgt[2]=1.e6; dwgt[1]=0.;}}
130 (*sign) = sqrt(std::abs(dwgt[0] * rimp[0] * rimp[0] + dwgt[1] * 2. * rimp[0] * rimp[1] +
131 dwgt[2] * rimp[1] * rimp[1]));
135 void cfimpc(
long int TrkID,
long int ich,
int IFL,
double *
par,
136 const double *
err,
double *vrt,
double *vcov,
double *rimp,
139 double dcov[3], errd[15], paro[5];
140 double dwgt[3], errn[15], cnv[6];
151 for (
int ii = 0; ii < 15; ++ii) {errd[ii] =
err[ii];}
153 double Ref0[3]={0.,0.,0.};
156 double tmpVrt[3]={0.,0.,0.};
double ClosestPnt[3];
157 cfClstPnt( paro, tmpVrt, ClosestPnt);
158 paro[0]=sqrt(ClosestPnt[0]*ClosestPnt[0] + ClosestPnt[1]*ClosestPnt[1]);
159 paro[1]=ClosestPnt[2];
172 cnv[1] = sn /
tan(paro[2]);
173 cnv[3] = cs /
tan(paro[2]);
178 for (i__ = 1; i__ <= 3; ++i__) {
179 for (j = 1; j <= 3; ++j) {
181 ij = ij * (ij - 1) / 2 +
min(i__, j);
182 dcov[0] += cnv[(i__ << 1) - 2] * cnv[(j << 1) - 2] * vcov[ij];
183 dcov[2] += cnv[(i__ << 1) - 1] * cnv[(j << 1) - 1] * vcov[ij];
184 dcov[1] += cnv[(i__ << 1) - 2] * cnv[(j << 1) - 1] * vcov[ij];
189 rcov[0] = errn[0] + dcov[0];
190 rcov[1] = errn[1] + dcov[1];
191 rcov[2] = errn[2] + dcov[2];
192 }
else if (IFL == -1) {
193 rcov[0] = errn[0] - dcov[0];
194 rcov[1] = errn[1] - dcov[1];
195 rcov[2] = errn[2] - dcov[2];
201 int jerr =
cfdinv(rcov, dwgt, -2);
203 jerr =
cfdinv(rcov, dwgt, 2);
205 dwgt[0] = dwgt[2] = 1.e6;
209 (*sign) = sqrt(std::abs(dwgt[0] * rimp[0] * rimp[0] +
210 dwgt[1] * 2. * rimp[0] * rimp[1] +
211 dwgt[2] * rimp[1] * rimp[1]));