16void cfnewpm(
const double *par,
const double *xyzStart,
const double *xyzEnd,
17 const double ustep,
double *parn,
double *closePoint,
20 double d__1, d__2,dist_left;
21 double vect[7], stmg, vout[7]={0.}, dpar0[5];
22 double perig[3], dstep, xyzst[3],
charge;
23 double posold, poscur, totway, dp;
40 totway = (ustep) * sqrt(1. / (d__1 * d__1) + 1.);
42 if (fabs(ustep) < 10. && fabs(totway) < 20.)
return;
46 vect[0] = sin(par[4]) * par[1] +xyzStart[0];
47 vect[1] = -cos(par[4]) * par[1] +xyzStart[1];
48 vect[2] = par[2] +xyzStart[2];
52 double pt = constB / fabs(par[5]);
53 double px = pt * cos(par[4]);
54 double py = pt * sin(par[4]);
55 double pz = pt / tan(par[3]);
56 double p = sqrt(pt * pt +
pz *
pz);
66 while(fabs(poscur) < fabs(totway)) {
68 d__1 = fabs(poscur) + stmg;
70 poscur = d__1 < d__2 ? d__1 : d__2;
71 poscur =
d_sign(poscur, totway);
72 dstep = poscur - posold;
81 dX = vect[0]-xyzEnd[0];
82 dY = vect[1]-xyzEnd[1];
83 dZ = vect[2]-xyzEnd[2];
84 dist_left = sqrt( dX*dX + dY*dY + dZ*dZ);
85 if(dist_left < stmg)
break;
92 if(std::abs(constB)<0.001)constB=0.001;
96 dpar0[2] = acos(vout[5]);
97 dpar0[3] = atan2(vout[4], vout[3]);
100 px = vect[3] * vect[6];
101 py = vect[4] * vect[6];
104 xyzst[0] = xyzEnd[0] - vout[0];
105 xyzst[1] = xyzEnd[1] - vout[1];
106 xyzst[2] = xyzEnd[2] - vout[2];
108 cfnewp(ich, dpar0, xyzst, &dp, parn, perig);
109 closePoint[0] = perig[0] + vout[0];
110 closePoint[1] = perig[1] + vout[1];
111 closePoint[2] = perig[2] + vout[2];
static void getMagFld(const double, const double, const double, double &, double &, double &, const VKalVrtControlBase *)
void cfnewpm(const double *par, const double *xyzStart, const double *xyzEnd, const double ustep, double *parn, double *closePoint, const VKalVrtControlBase *CONTROL)
void cfnewp(const long int ich, const double *parold, const double *ref, double *s, double *parnew, double *per)