13 val[0] = veca[1]*vecb[2] - veca[2]*vecb[1];
14 val[1] = veca[2]*vecb[0] - veca[0]*vecb[2];
15 val[2] = veca[0]*vecb[1] - veca[1]*vecb[0];
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;
170 double whitPos[],
double zini){
176 double ten = wpos[6];
177 double a = 9.47e-05 / (2 * ten);
178 double dx = wpos[0] - wpos[3];
179 double dy = wpos[1] - wpos[4];
180 double dz = wpos[2] - wpos[5];
181 double length = sqrt(dx*dx + dz*dz);
185 if(whitPos[2] < 0.5*
length) ztan = whitPos[2];
191 double sinalf = dx / sqrt(dx*dx + dz*dz);
192 double cosalf = dz / sqrt(dx*dx + dz*dz);
193 double tanalf = dx / dz;
205 for(
int i=0; i<5; i++) par(i+1)=trkpar[i];
207 double tmp = (ztan-wpos[5])/dz;
208 pivot.setX(tmp*dx+wpos[3]);
209 pivot.setY(tmp*dy+wpos[4]);
210 pivot.setZ(tmp*dz+wpos[5]);
216 std::cout <<
"ERROR: wire position error in getdocaLine() !!!"
218 std::cout<<
"dz = "<<dz<<std::endl;
229 xyz[0] = (zc - wpos[5]) * tanalf + wpos[3];
230 xyz[1] = a*zp*zp + (wpos[1] - wpos[4])*zp/
length
235 dxyz[1] = 2.0 * a * zp + (wpos[1] - wpos[4]) /
length;
240 doca = docaHelixWire(trkpar, xyz, dxyz, ztan, phiIni);
243 if( fabs(zc-ztan) < 0.5 )
break;
253 whitPos[1] = a*zp*zp + (wpos[1] - wpos[4])*zp/
length
255 whitPos[0] = (ztan - wpos[5]) * tanalf + wpos[3];
261 double dr = trkpar[0];
262 double fi0 = trkpar[1];
263 double kap = trkpar[2];
266 double phi0 = fi0 +
HFPI;
267 if(phi0 >
PI2) phi0 -=
PI2;
268 double g = 1.0e13 / (
CC * BFIELD * kap);
270 double aa = rw*rw - (dr-g)*(dr-g) - g*g;
271 double bb = 2*g*(dr - g);
279 if(kap > 0) phi = phi0 + dd;
280 else phi = phi0 - dd;
284 if(phi < 0) phi +=
PI2;
286 double x0 = dr *
cos(fi0);
287 double y0 = dr *
sin(fi0);
288 pos[0] = x0 + g * (
sin(phi) -
sin(phi0));
289 pos[1] = y0 + g * (-
cos(phi) +
cos(phi0));
291 if(kap > 0) pos[2] = trkpar[3] + g * trkpar[4] * dd;
292 else pos[2] = trkpar[3] - g * trkpar[4] * dd;
303 double xxLC[gNsamLC];
304 double yyLC[gNsamLC];
305 double aPointOnWire[3]={0,0,0};
307 for(i=0; i<
NTRKPAR; i++) sampar[i] = helix[i];
308 double startpar = helix[ipar] - 0.5*gStepLC[ipar]*(double)gNsamLC;
310 for(i=0; i<gNsamLC; i++){
311 sampar[ipar] = startpar + (double)i * gStepLC[ipar];
312 xxLC[i] = sampar[ipar];
315 getDoca(sampar, wpos, doca, aPointOnWire, zini);
324 double par = helix[ipar];
326 TSpline3* pSpline3 =
new TSpline3(
"deri", xxLC, yyLC, gNsamLC);
327 deri = pSpline3->Derivative(par);
double sin(const BesAngle a)
double cos(const BesAngle a)
const HepPoint3D & pivot(void) const
returns pivot position.
double getPhiIni(double trkpar[], double rLayer, double pos[])
bool getDeriLoc(int ipar, double helix[], double &deri, double wpos[], double zini)
void expd(double veca[3], double vecb[3], double val[3])
bool getDoca(double trkpar[], double wpos[], double &doca, double whitPos[], double zini)
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)
double docaHelixWire(double trkpar[], double wirest[], double wirev[], double &zwire, double zini)