00074 {
00075
00076 double xc,yc;
00077 double rho;
00078 double xx[2],yy[2];
00079 double tofx,tofy;
00080 double nx,ny;
00081 double cosx,sinx;
00082 double aa,ca,cb,cc,detm;
00083
00084
00085 int Id_cdfztrk = id; R_tof = rtof;
00086
00087 if( Id_cdfztrk<0 ) {
00088 if (_debug) std::cout << " TofFz_helix *** wrong id_cdfztrk ="
00089 << Id_cdfztrk << std::endl;
00090 return(-1);
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 const HepPoint3D pivot1(0.,0.,0.);
00114 HepVector a(5,0);
00115 a[0] = fzisan[0];
00116 a[1] = fzisan[1];
00117 a[2] = fzisan[2];
00118 a[3] = fzisan[3];
00119 a[4] = fzisan[4];
00120
00121
00122
00123 if (abs(a[3])>50.0 || abs(a[4])>500.0) return (-5);
00124
00125
00126
00127 Helix helix1(pivot1,a);
00128 Dr = helix1.a()[0];
00129 Phi0 = helix1.a()[1];
00130 Kappa = helix1.a()[2];
00131 Dz = helix1.a()[3];
00132 Tanl = helix1.a()[4];
00133
00134
00135
00136
00137
00138
00139
00140
00141 rho = helix1.radius();
00142
00143 HepPoint3D xyz = helix1.center();
00144 xc = xyz(0);
00145 yc = xyz(1);
00146
00147
00148 Hep3Vector vxyz = helix1.direction();
00149 nx = vxyz(0);
00150 ny = vxyz(1);
00151
00152
00153 if(fabs(rho)>R_tof/2){
00154
00155
00156
00157 if( xc==0.0 && yc==0.0 ) return(-3);
00158
00159 ca = xc*xc + yc*yc ;
00160 aa = 0.5 * ( ca - rho*rho + R_tof*R_tof );
00161
00162 if ( xc != 0.0 ) {
00163 cb = aa * yc;
00164 cc = aa*aa - R_tof*R_tof*xc*xc;
00165
00166 detm = cb*cb - ca*cc;
00167 if ( detm > 0.0 ) {
00168 yy[0] = ( cb + sqrt(detm) )/ ca;
00169 xx[0] = ( aa - yy[0]*yc )/xc;
00170 yy[1] = ( cb - sqrt(detm) )/ ca;
00171 xx[1] = ( aa - yy[1]*yc )/xc;
00172 } else return(-1);
00173 }
00174 else{
00175 cb = aa * xc;
00176 cc = aa*aa - R_tof*R_tof*yc*yc;
00177
00178 detm = cb*cb - ca*cc;
00179 if ( detm > 0.0 ) {
00180 xx[0] = ( cb + sqrt(detm) )/ca;
00181 yy[0] = ( aa - xx[0]*xc )/yc;
00182 xx[1] = ( cb - sqrt(detm) )/ca;
00183 yy[1] = ( aa - xx[1]*xc )/yc;
00184 } else return(-2);
00185 }
00186
00187
00188
00189 if( xx[0]*nx + yy[0]*ny > 0.0 ) { tofx = xx[0]; tofy = yy[0]; }
00190 else { tofx = xx[1]; tofy = yy[1]; }
00191
00192 double fi = atan2(tofy ,tofx );
00193
00194
00195 if( fi < 0.0 ) fi=pi2+fi;
00196 Fi_tof = fi;
00197
00198 Tofid = (int) ( Fi_tof/piby44 );
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 const HepPoint3D pivot2( tofx, tofy, 0.0);
00210 helix1.pivot(pivot2);
00211
00212
00213 Phi1=helix1.a()[1];
00214 Z_tof=helix1.a()[3];
00215
00216 double dphi = (-xc*(tofx-xc)-yc*(tofy-yc))/sqrt(xc*xc+yc*yc)/fabs(rho);
00217 dphi = acos(dphi);
00218 Pathl = fabs(rho*dphi);
00219 double coscor=sqrt(1.0+Tanl*Tanl);
00220 Pathl=Pathl*coscor;
00221
00222
00223 Hep3Vector vxyz1 = helix1.direction();
00224 nx = vxyz1(0);
00225 ny = vxyz1(1);
00226
00227 double corxy=(nx*tofx+ny*tofy)/R_tof;
00228 Path_tof=4.0*coscor/corxy;
00229
00230 if(abs(Z_tof)<115) return (1);
00231
00232 if(Z_tof>=115){
00233 Z_tof=133;
00234 Pathl=Z_tof/sin(atan(Tanl));
00235 double phi0=-(Z_tof/Tanl)/rho;
00236 double phi=-(Z_tof-Dz)/Tanl/rho;
00237 double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00238 double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00239
00240 double x_endtof=Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00241 double y_endtof=Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00242 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00243
00244 Helix helix1(pivot1,a);
00245
00246 double x1_endtof=helix1.x(phi).x();
00247 double y1_endtof=helix1.x(phi).y();
00248 double z1_endtof=helix1.x(phi).z();
00249
00250 double fi_endtof = atan2(y_endtof,x_endtof );
00251 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00252
00253 Tofid =(int)(fi_endtof/piby24);
00254 if(Tofid>47)Tofid=Tofid-48;
00255
00256
00257 return (0);
00258
00259 }else if (Z_tof<=-115){
00260 Z_tof=-133;
00261 Pathl=Z_tof/sin(atan(Tanl));
00262 double phi0=-(Z_tof/Tanl)/rho;
00263 double phi=-(Z_tof-Dz)/Tanl/rho;
00264 double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00265 double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00266
00267 double x_endtof=Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00268 double y_endtof=Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00269 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00270
00271 Helix helix1(pivot1,a);
00272
00273 double x1_endtof=helix1.x(phi).x();
00274 double y1_endtof=helix1.x(phi).y();
00275 double z1_endtof=helix1.x(phi).z();
00276
00277 double fi_endtof = atan2(y_endtof,x_endtof );
00278 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00279
00280 Tofid =(int)(fi_endtof/piby24);
00281 if(Tofid>47) Tofid=Tofid-48;
00282 return (2);
00283
00284
00285 }
00286
00287 }
00288 else {
00289
00290 if(Tanl>0){
00291 Z_tof=133;
00292
00293 Pathl=Z_tof/sin(atan(Tanl));
00294 double phi0=-(Z_tof/Tanl)/rho;
00295 double phi=-(Z_tof-Dz)/Tanl/rho;
00296 double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00297 double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00298
00299 double x_endtof=Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00300 double y_endtof=Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00301 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00302
00303
00304
00305
00306 double fi_endtof = atan2(y_endtof,x_endtof );
00307 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00308
00309 Tofid =(int)(fi_endtof/piby24);
00310 if(Tofid>47)Tofid=Tofid-48;
00311 return (0);
00312
00313 }
00314 else{
00315 Z_tof=-133;
00316 Pathl=Z_tof/sin(atan(Tanl));
00317 double phi0=-(Z_tof/Tanl)/rho;
00318 double phi=-(Z_tof-Dz)/Tanl/rho;
00319 double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00320 double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00321
00322
00323 double x_endtof=Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00324 double y_endtof=Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00325 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00326
00327
00328
00329
00330 double fi_endtof = atan2(y_endtof,x_endtof );
00331 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00332
00333 Tofid =(int)(fi_endtof/piby24);
00334 if(Tofid>47)Tofid=Tofid-48;
00335 return (2);
00336 }
00337 }
00338
00339 if (abs(Pathl) > _pathl_cut ||
00340 Z_tof < _ztof_cutm || Z_tof > _ztof_cutx) {
00341
00342 if (_debug) {
00343 printf("\n TofFz_helix> Trk=%3d params(dr,phi,kappa,dz,tanl)="
00344 "(%5.1f,%6.3f,%6.4f,%6.1f,%6.3f) R_tof %5.1f\n",
00345 Id_cdfztrk,Dr,Phi0,Kappa,Dz,Tanl,R_tof);
00346
00347 printf(" TofFz_helix> rho=%8.1f, (xc,yc)=(%8.1f,%8.1f)"
00348 " (nx,ny)=(%5.2f,%5.2f)\n",rho,xc,yc,nx,ny);
00349
00350 printf(" TofFz_helix> tof (x,y)=(%5.1f,%5.1f) and (%5.1f,%5.1f)\n",
00351 xx[0],yy[0],xx[1],yy[1]);
00352
00353 printf(" TofFz_helix> tofid=%3d, fitof=%6.3f, w=%5.3f"
00354 " (x,y,z)=(%5.1f,%5.1f,%5.1f) pathl=%5.1f cm path=%5.1f cm\n",
00355 Tofid,Fi_tof,W_tof,tofx,tofy,Z_tof,Pathl,Path_tof);
00356 }
00357 return (-7);
00358 }
00359
00360
00361
00362
00363 }