16 void vpderiv(
bool UseTrackErr,
long int Charge,
const double *pari0,
double *covi,
double *vrtref,
double *covvrtref,
17 double *drdpar,
double *dwgt,
double *rv0,
VKalVrtControl * FitCONTROL)
21 double dshft[6] = { 1.e-4, 1.e-4, 1.e-4, 1.e-4, 1.e-4, 1.e-4};
23 double DrvCoef[4] = {-2., -1., 1.,2.};
26 double pari[6], covd[15], dcov[3], rvec[50];
28 int j, ij,
ip, ipp,
id=0;
29 double dwgt0[3]={0.,0.,0.};
31 double cs, pp, sn,
pt,
rho;
32 double covdtr[15], ctg,
par[5], cnv[36];
34 #define rvec_ref(a_1,a_2) rvec[(a_2)*2 + (a_1) - 1]
35 #define drdpar_ref(a_1,a_2) drdpar[(a_2)*2 + (a_1)]
36 #define cnv_ref(a_1,a_2) cnv[(a_2)*6 + (a_1) - 7]
64 for (
ip = 0;
ip <= 4*6; ++
ip) {
73 ipp =
ip;
while(ipp>6)ipp-=6;
74 if(
ip>=1 &&
ip<=6 )
id=0;
75 if(
ip>=7 &&
ip<=12)
id=1;
76 if(
ip>=13 &&
ip<=18)
id=2;
77 if(
ip>=19 &&
ip<=24)
id=3;
78 if (
ip != 0) pari[ipp - 1] *= (dshft[ipp-1]*DrvCoef[
id] + 1.);
80 pt = sqrt(pari[3]*pari[3] + pari[4]*pari[4]);
81 pp =
pt*
pt + pari[5]*pari[5];
85 rho = Charge * constB /
pt;
89 par[2] = acos(pari[5] / sqrt(pp));
92 par[3] = atan2(pari[4], pari[3]);
94 if (Charge == 0)
par[4] = constB /
pt;
113 cnv_ref(4, 3) = pari[5] * pari[3] / pp /
pt;
114 cnv_ref(5, 3) = pari[5] * pari[4] / pp /
pt;
131 if ( Charge == 0) {
cnv_ref(4, 5) = -pari[3] * constB / (
pt*
pt*
pt);}
132 if ( Charge == 0) {
cnv_ref(5, 5) = -pari[4] * constB / (
pt*
pt*
pt);}
137 tdasatVK(cnv, &covi[0], covd, 5, 6);
158 for (
int i = 1;
i <= 3; ++
i) {
159 for (j = 1; j <= 3; ++j) {
161 ij = ij * (ij - 1) / 2 + (
i < j ?
i : j );
169 dcov[0] += covdtr[0];
170 dcov[1] += covdtr[1];
171 dcov[2] += covdtr[2];
176 int jerr=
cfdinv(dcov, &dwgt[0], -2);
if(jerr){jerr=
cfdinv(dcov, &dwgt[0], 2);
if(jerr){dwgt[0]=dwgt[2]=1.e6; dwgt[1]=0.;}};
189 for (
int i = 1;
i <= 6; ++
i) {