19 double veca[3],
double vecb[3],
20 double &d,
double xyz_a[3],
double xyz_b[3],
int fgZcal){
26 double seca[3], secb[3];
30 for(i=0; i<3; i++) vst[i] = sta[i] - stb[i];
37 m2 = vp[0]*vp[0] + vp[1]*vp[1] + vp[2]*vp[2];
40 for(i=0; i<3; i++) vp[i] /= modvp;
43 for(i=0; i<3; i++) d += vst[i] * vp[i];
46 if( 0 == fgZcal )
return 1;
48 double veca00 = veca[0]*veca[0];
49 double veca11 = veca[1]*veca[1];
50 double veca22 = veca[2]*veca[2];
52 double veca01 = veca[0]*veca[1];
53 double veca02 = veca[0]*veca[2];
54 double veca12 = veca[1]*veca[2];
56 double vecb00 = vecb[0]*vecb[0];
57 double vecb11 = vecb[1]*vecb[1];
58 double vecb22 = vecb[2]*vecb[2];
59 double vecb01 = vecb[0]*vecb[1];
60 double vecb02 = vecb[0]*vecb[2];
61 double vecb12 = vecb[1]*vecb[2];
63 seca[0] = veca[1]*vecb01 + veca[2]*vecb02 - veca[0]*(vecb11 + vecb22);
64 seca[1] = veca[0]*vecb01 + veca[2]*vecb12 - veca[1]*(vecb00 + vecb22);
65 seca[2] = veca[0]*vecb02 + veca[1]*vecb12 - veca[2]*(vecb00 + vecb11);
67 secb[0] = vecb[1]*veca01 + vecb[2]*veca02 - vecb[0]*(veca11 + veca22);
68 secb[1] = vecb[0]*veca01 + vecb[2]*veca12 - vecb[1]*(veca00 + veca22);
69 secb[2] = vecb[0]*veca02 + vecb[1]*veca12 - vecb[2]*(veca00 + veca11);
72 tpa += seca[i] * (sta[i] - stb[i]);
73 twb += secb[i] * (stb[i] - sta[i]);
80 xyz_a[i] = veca[i] * tpa + sta[i];
81 xyz_b[i] = vecb[i] * twb + stb[i];
92 for(
int i=0; i<5; i++) a(i+1)=trkpar[i];
94 double x0 = trkpar[0] *
cos(trkpar[1]);
95 double y0 = trkpar[0] *
sin(trkpar[1]);
96 double z0 = trkpar[3];
97 double phi0 = trkpar[1] +
HFPI;
98 if(phi0 >
PI2) phi0 -=
PI2;
99 double g = 1e13 / (
CC * BFIELD * trkpar[2]);
100 double tanl = trkpar[4];
131 if(dphi >
PI) dphi -=
PI2;
132 if(dphi < -
PI) dphi +=
PI2;
134 trkst[0] = x0 + g * (
sin(phi) -
sin(phi0));
135 trkst[1] = y0 + g * (-
cos(phi) +
cos(phi0));
137 trkst[2] = z0 + g * tanl * dphi;
145 dist2Line(trkst, wirest, trkv, wirev, doca, xyz_trk, xyz_wire);
151 HepPoint3D newPivot(xyz_trk[0],xyz_trk[1],xyz_trk[2]);
152 aHelix.
pivot(newPivot);
156 double delPhi = phiNew - phi;
157 while(delPhi>
M_PI) delPhi-=
M_PI*2.0;
158 while(delPhi<-
M_PI) delPhi+=
M_PI*2.0;
159 if(fabs(delPhi) < 1.0E-8)
break;
181 double whitPos[],
double zini){
187 double ten = wpos[6];
188 double a = 9.47e-05 / (2 * ten);
189 double dx = wpos[0] - wpos[3];
190 double dy = wpos[1] - wpos[4];
191 double dz = wpos[2] - wpos[5];
192 double length = sqrt(dx*dx + dz*dz);
196 if(whitPos[2] < 0.5*
length) ztan = whitPos[2];
202 double sinalf = dx / sqrt(dx*dx + dz*dz);
203 double cosalf = dz / sqrt(dx*dx + dz*dz);
204 double tanalf = dx / dz;
216 for(
int i=0; i<5; i++) par(i+1)=trkpar[i];
218 double tmp = (ztan-wpos[5])/dz;
219 pivot.setX(tmp*dx+wpos[3]);
220 pivot.setY(tmp*dy+wpos[4]);
221 pivot.setZ(tmp*dz+wpos[5]);
227 std::cout <<
"ERROR: wire position error in getdocaLine() !!!"
229 std::cout<<
"dz = "<<dz<<std::endl;
240 xyz[0] = (zc - wpos[5]) * tanalf + wpos[3];
241 xyz[1] = a*zp*zp + (wpos[1] - wpos[4])*zp/
length
246 dxyz[1] = 2.0 * a * zp + (wpos[1] - wpos[4]) /
length;
251 doca = docaHelixWire(trkpar, xyz, dxyz, ztan, phiIni);
254 if( fabs(zc-ztan) < 0.5 )
break;
264 whitPos[1] = a*zp*zp + (wpos[1] - wpos[4])*zp/
length
266 whitPos[0] = (ztan - wpos[5]) * tanalf + wpos[3];
314 double xxLC[gNsamLC];
315 double yyLC[gNsamLC];
316 double aPointOnWire[3]={0,0,0};
318 for(i=0; i<
NTRKPAR; i++) sampar[i] = helix[i];
319 double startpar = helix[ipar] - 0.5*gStepLC[ipar]*(double)gNsamLC;
321 for(i=0; i<gNsamLC; i++){
322 sampar[ipar] = startpar + (double)i * gStepLC[ipar];
323 xxLC[i] = sampar[ipar];
326 getDoca(sampar, wpos, doca, aPointOnWire, zini);
335 double par = helix[ipar];
337 TSpline3* pSpline3 =
new TSpline3(
"deri", xxLC, yyLC, gNsamLC);
338 deri = pSpline3->Derivative(par);
bool getDoca(double trkpar[], double wpos[], double &doca, double whitPos[], double zini)
doca: distance of closest approach.
int dist2Line(double sta[3], double stb[3], double veca[3], double vecb[3], double &d, double xyz_a[3], double xyz_b[3], int fgZcal=1)