78 double aa, ca, cb, cc, detm;
87 std::cout <<
" TofFz_helix *** wrong id_cdfztrk =" << Id_cdfztrk << std::endl;
100 if (
abs( a[3] ) > 50.0 ||
abs( a[4] ) > 500.0 )
return ( -5 );
104 Helix helix1( pivot1, a );
106 Phi0 = helix1.
a()[1];
109 Tanl = helix1.
a()[4];
124 if ( fabs( rho ) >
R_tof / 2 )
129 if ( xc == 0.0 && yc == 0.0 )
return ( -3 );
131 ca = xc * xc + yc * yc;
132 aa = 0.5 * ( ca - rho * rho +
R_tof *
R_tof );
139 detm = cb * cb - ca * cc;
142 yy[0] = ( cb + sqrt( detm ) ) / ca;
143 xx[0] = ( aa - yy[0] * yc ) / xc;
144 yy[1] = ( cb - sqrt( detm ) ) / ca;
145 xx[1] = ( aa - yy[1] * yc ) / xc;
154 detm = cb * cb - ca * cc;
157 xx[0] = ( cb + sqrt( detm ) ) / ca;
158 yy[0] = ( aa - xx[0] * xc ) / yc;
159 xx[1] = ( cb - sqrt( detm ) ) / ca;
160 yy[1] = ( aa - xx[1] * xc ) / yc;
167 if ( xx[0] * nx + yy[0] * ny > 0.0 )
178 double fi = atan2( tofy, tofx );
180 if ( fi < 0.0 ) fi = pi2 + fi;
187 helix1.
pivot( pivot2 );
190 Phi1 = helix1.
a()[1];
194 ( -xc * ( tofx - xc ) - yc * ( tofy - yc ) ) / sqrt( xc * xc + yc * yc ) / fabs( rho );
196 Pathl = fabs( rho * dphi );
197 double coscor = sqrt( 1.0 +
Tanl *
Tanl );
205 double corxy = ( nx * tofx + ny * tofy ) /
R_tof;
208 if (
abs(
Z_tof ) < 115 )
return ( 1 );
227 r_endtof = sqrt( x_endtof * x_endtof + y_endtof * y_endtof );
229 Helix helix1( pivot1, a );
231 double x1_endtof = helix1.
x( phi ).x();
232 double y1_endtof = helix1.
x( phi ).y();
233 double z1_endtof = helix1.
x( phi ).z();
235 double fi_endtof = atan2( y_endtof, x_endtof );
236 if ( fi_endtof < 0 ) fi_endtof = pi2 + fi_endtof;
238 Tofid = (int)( fi_endtof / piby24 );
243 double Z_etf_1 = 133.673;
244 double Pathl_1 = Z_etf_1 /
sin( atan(
Tanl ) );
245 double phi0_1 = -( Z_etf_1 /
Tanl ) / rho;
246 double phi_1 = -( Z_etf_1 -
Dz ) /
Tanl / rho;
247 double phi1_1 = ( Z_etf_1 *
Kappa * 0.003 ) /
Tanl;
248 double phi2_1 = ( Z_etf_1 -
Dz ) *
Kappa * 0.003 /
Tanl;
254 double r_etf_1 = sqrt( x1_etf * x1_etf + y1_etf * y1_etf );
256 double x_etf_1 = helix1.
x( phi_1 ).x();
257 double y_etf_1 = helix1.
x( phi_1 ).y();
258 double z_etf_1 = helix1.
x( phi_1 ).z();
261 double fi_etf_1 = atan2( y1_etf, x1_etf ) + 1.25 * piby1 / 180.0;
262 if ( fi_etf_1 < 0 ) { fi_etf_1 = pi2 + fi_etf_1; }
264 int Etfid_1 = (int)( fi_etf_1 / piby18 );
265 if ( Etfid_1 > 35 ) { Etfid_1 = Etfid_1 - 36; }
268 if ( Etfid_1 % 2 == 1 )
279 double Z_etf_2 = 136.573;
280 double Pathl_2 = Z_etf_2 /
sin( atan(
Tanl ) );
281 double phi0_2 = -( Z_etf_2 /
Tanl ) / rho;
282 double phi_2 = -( Z_etf_2 -
Dz ) /
Tanl / rho;
283 double phi1_2 = ( Z_etf_2 *
Kappa * 0.003 ) /
Tanl;
284 double phi2_2 = ( Z_etf_2 -
Dz ) *
Kappa * 0.003 /
Tanl;
290 double r_etf_2 = sqrt( x2_etf * x2_etf + y2_etf * y2_etf );
292 double x_etf_2 = helix1.
x( phi_2 ).x();
293 double y_etf_2 = helix1.
x( phi_2 ).y();
294 double z_etf_2 = helix1.
x( phi_2 ).z();
297 double fi_etf_2 = atan2( y2_etf, x2_etf ) + 1.25 * piby1 / 180.0;
298 if ( fi_etf_2 < 0 ) { fi_etf_2 = pi2 + fi_etf_2; }
300 int Etfid_2 = (int)( fi_etf_2 / piby18 );
301 if ( Etfid_2 > 35 ) { Etfid_2 = Etfid_2 - 36; }
303 if ( Etfid_2 % 2 == 1 )
305 int tmp1 = (int)( ( fi_etf_2 + 0.5 * piby18 ) / piby18 );
306 int tmp2 = (int)( ( fi_etf_2 - 0.5 * piby18 ) / piby18 );
307 if ( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
308 else { Etfid_2 = tmp1; }
319 else if (
Z_tof <= -115 )
333 r_endtof = sqrt( x_endtof * x_endtof + y_endtof * y_endtof );
335 Helix helix1( pivot1, a );
337 double x1_endtof = helix1.
x( phi ).x();
338 double y1_endtof = helix1.
x( phi ).y();
339 double z1_endtof = helix1.
x( phi ).z();
341 double fi_endtof = atan2( y_endtof, x_endtof );
342 if ( fi_endtof < 0 ) fi_endtof = pi2 + fi_endtof;
344 Tofid = (int)( fi_endtof / piby24 );
348 double Z_etf_1 = -133.673;
349 double Pathl_1 = Z_etf_1 /
sin( atan(
Tanl ) );
350 double phi0_1 = -( Z_etf_1 /
Tanl ) / rho;
351 double phi_1 = -( Z_etf_1 -
Dz ) /
Tanl / rho;
352 double phi1_1 = ( Z_etf_1 *
Kappa * 0.003 ) /
Tanl;
353 double phi2_1 = ( Z_etf_1 -
Dz ) *
Kappa * 0.003 /
Tanl;
359 double r_etf_1 = sqrt( x1_etf * x1_etf + y1_etf * y1_etf );
361 double x_etf_1 = helix1.
x( phi_1 ).x();
362 double y_etf_1 = helix1.
x( phi_1 ).y();
363 double z_etf_1 = helix1.
x( phi_1 ).z();
366 double fi_etf_1 = atan2( y1_etf, x1_etf ) - 11.25 * piby1 / 180.0;
367 if ( fi_etf_1 < 0 ) { fi_etf_1 = pi2 + fi_etf_1; }
369 int Etfid_1 = (int)( fi_etf_1 / piby18 );
370 if ( Etfid_1 > 35 ) { Etfid_1 = Etfid_1 - 36; }
373 if ( Etfid_1 % 2 == 1 )
383 double Z_etf_2 = -136.573;
384 double Pathl_2 = Z_etf_2 /
sin( atan(
Tanl ) );
385 double phi0_2 = -( Z_etf_2 /
Tanl ) / rho;
386 double phi_2 = -( Z_etf_2 -
Dz ) /
Tanl / rho;
387 double phi1_2 = ( Z_etf_2 *
Kappa * 0.003 ) /
Tanl;
388 double phi2_2 = ( Z_etf_2 -
Dz ) *
Kappa * 0.003 /
Tanl;
394 double r_etf_2 = sqrt( x2_etf * x2_etf + y2_etf * y2_etf );
396 double x_etf_2 = helix1.
x( phi_2 ).x();
397 double y_etf_2 = helix1.
x( phi_2 ).y();
398 double z_etf_2 = helix1.
x( phi_2 ).z();
401 double fi_etf_2 = atan2( y2_etf, x2_etf ) - 11.25 * piby1 / 180.0;
402 if ( fi_etf_2 < 0 ) { fi_etf_2 = pi2 + fi_etf_2; }
404 int Etfid_2 = (int)( fi_etf_2 / piby18 );
405 if ( Etfid_2 > 35 ) { Etfid_2 = Etfid_2 - 36; }
407 if ( Etfid_2 % 2 == 1 )
409 int tmp1 = (int)( ( fi_etf_2 + 0.5 * piby18 ) / piby18 );
410 int tmp2 = (int)( ( fi_etf_2 - 0.5 * piby18 ) / piby18 );
411 if ( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
412 else { Etfid_2 = tmp1; }
440 r_endtof = sqrt( x_endtof * x_endtof + y_endtof * y_endtof );
442 double fi_endtof = atan2( y_endtof, x_endtof );
443 if ( fi_endtof < 0 ) fi_endtof = pi2 + fi_endtof;
444 Tofid = (int)( fi_endtof / piby24 );
448 double Z_etf_1 = 133.673;
449 double Pathl_1 = Z_etf_1 /
sin( atan(
Tanl ) );
450 double phi0_1 = -( Z_etf_1 /
Tanl ) / rho;
451 double phi_1 = -( Z_etf_1 -
Dz ) /
Tanl / rho;
452 double phi1_1 = ( Z_etf_1 *
Kappa * 0.003 ) /
Tanl;
453 double phi2_1 = ( Z_etf_1 -
Dz ) *
Kappa * 0.003 /
Tanl;
459 double r_etf_1 = sqrt( x1_etf * x1_etf + y1_etf * y1_etf );
461 double x_etf_1 = helix1.
x( phi_1 ).x();
462 double y_etf_1 = helix1.
x( phi_1 ).y();
463 double z_etf_1 = helix1.
x( phi_1 ).z();
466 double fi_etf_1 = atan2( y1_etf, x1_etf ) + 1.25 * piby1 / 180.0;
467 if ( fi_etf_1 < 0 ) { fi_etf_1 = pi2 + fi_etf_1; }
469 int Etfid_1 = (int)( fi_etf_1 / piby18 );
470 if ( Etfid_1 > 35 ) { Etfid_1 = Etfid_1 - 36; }
473 if ( Etfid_1 % 2 == 1 )
483 double Z_etf_2 = 136.573;
484 double Pathl_2 = Z_etf_2 /
sin( atan(
Tanl ) );
485 double phi0_2 = -( Z_etf_2 /
Tanl ) / rho;
486 double phi_2 = -( Z_etf_2 -
Dz ) /
Tanl / rho;
487 double phi1_2 = ( Z_etf_2 *
Kappa * 0.003 ) /
Tanl;
488 double phi2_2 = ( Z_etf_2 -
Dz ) *
Kappa * 0.003 /
Tanl;
494 double r_etf_2 = sqrt( x2_etf * x2_etf + y2_etf * y2_etf );
496 double x_etf_2 = helix1.
x( phi_2 ).x();
497 double y_etf_2 = helix1.
x( phi_2 ).y();
498 double z_etf_2 = helix1.
x( phi_2 ).z();
501 double fi_etf_2 = atan2( y2_etf, x2_etf ) + 1.25 * piby1 / 180.0;
502 if ( fi_etf_2 < 0 ) { fi_etf_2 = pi2 + fi_etf_2; }
504 int Etfid_2 = (int)( fi_etf_2 / piby18 );
505 if ( Etfid_2 > 35 ) { Etfid_2 = Etfid_2 - 36; }
507 if ( Etfid_2 % 2 == 1 )
509 int tmp1 = (int)( ( fi_etf_2 + 0.5 * piby18 ) / piby18 );
510 int tmp2 = (int)( ( fi_etf_2 - 0.5 * piby18 ) / piby18 );
511 if ( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
512 else { Etfid_2 = tmp1; }
536 r_endtof = sqrt( x_endtof * x_endtof + y_endtof * y_endtof );
538 double fi_endtof = atan2( y_endtof, x_endtof );
539 if ( fi_endtof < 0 ) fi_endtof = pi2 + fi_endtof;
540 Tofid = (int)( fi_endtof / piby24 );
544 double Z_etf_1 = -133.673;
545 double Pathl_1 = Z_etf_1 /
sin( atan(
Tanl ) );
546 double phi0_1 = -( Z_etf_1 /
Tanl ) / rho;
547 double phi_1 = -( Z_etf_1 -
Dz ) /
Tanl / rho;
548 double phi1_1 = ( Z_etf_1 *
Kappa * 0.003 ) /
Tanl;
549 double phi2_1 = ( Z_etf_1 -
Dz ) *
Kappa * 0.003 /
Tanl;
555 double r_etf_1 = sqrt( x1_etf * x1_etf + y1_etf * y1_etf );
557 double x_etf_1 = helix1.
x( phi_1 ).x();
558 double y_etf_1 = helix1.
x( phi_1 ).y();
559 double z_etf_1 = helix1.
x( phi_1 ).z();
562 double fi_etf_1 = atan2( y1_etf, x1_etf ) - 11.25 * piby1 / 180.0;
563 if ( fi_etf_1 < 0 ) { fi_etf_1 = pi2 + fi_etf_1; }
565 int Etfid_1 = (int)( fi_etf_1 / piby18 );
566 if ( Etfid_1 > 35 ) { Etfid_1 = Etfid_1 - 36; }
568 if ( Etfid_1 % 2 == 1 )
577 double Z_etf_2 = -136.573;
578 double Pathl_2 = Z_etf_2 /
sin( atan(
Tanl ) );
579 double phi0_2 = -( Z_etf_2 /
Tanl ) / rho;
580 double phi_2 = -( Z_etf_2 -
Dz ) /
Tanl / rho;
581 double phi1_2 = ( Z_etf_2 *
Kappa * 0.003 ) /
Tanl;
582 double phi2_2 = ( Z_etf_2 -
Dz ) *
Kappa * 0.003 /
Tanl;
588 int r_etf_2 = sqrt( x2_etf * x2_etf + y2_etf * y2_etf );
590 double x_etf_2 = helix1.
x( phi_2 ).x();
591 double y_etf_2 = helix1.
x( phi_2 ).y();
592 double z_etf_2 = helix1.
x( phi_2 ).z();
595 double fi_etf_2 = atan2( y2_etf, x2_etf ) - 11.25 * piby1 / 180.0;
596 if ( fi_etf_2 < 0 ) { fi_etf_2 = pi2 + fi_etf_2; }
598 int Etfid_2 = (int)( fi_etf_2 / piby18 );
599 if ( Etfid_2 > 35 ) { Etfid_2 = Etfid_2 - 36; }
601 if ( Etfid_2 % 2 == 1 )
603 int tmp1 = (int)( ( fi_etf_2 + 0.5 * piby18 ) / piby18 );
604 int tmp2 = (int)( ( fi_etf_2 - 0.5 * piby18 ) / piby18 );
605 if ( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
606 else { Etfid_2 = tmp1; }
624 printf(
"\n TofFz_helix> Trk=%3d params(dr,phi,kappa,dz,tanl)="
625 "(%5.1f,%6.3f,%6.4f,%6.1f,%6.3f) R_tof %5.1f\n",
628 printf(
" TofFz_helix> rho=%8.1f, (xc,yc)=(%8.1f,%8.1f)"
629 " (nx,ny)=(%5.2f,%5.2f)\n",
630 rho, xc, yc, nx, ny );
632 printf(
" TofFz_helix> tof (x,y)=(%5.1f,%5.1f) and (%5.1f,%5.1f)\n", xx[0], yy[0], xx[1],
635 printf(
" TofFz_helix> tofid=%3d, fitof=%6.3f, w=%5.3f"
636 " (x,y,z)=(%5.1f,%5.1f,%5.1f) pathl=%5.1f cm path=%5.1f cm\n",
642 std::cerr <<
"TofFz_helix> Error: should not reach here" << std::endl;