76 {
77
78 double xc,yc;
79 double rho;
80 double xx[2],yy[2];
81 double tofx,tofy;
82 double nx,ny;
83 double cosx,sinx;
84 double aa,ca,cb,cc,detm;
85
86
87 int Id_cdfztrk = id;
R_tof = rtof;
88
89 if( Id_cdfztrk<0 ) {
90 if (_debug) std::cout << " TofFz_helix *** wrong id_cdfztrk ="
91 << Id_cdfztrk << std::endl;
92 return(-1);
93 }
94
96 HepVector a(5,0);
97 a[0] = fzisan[0];
98 a[1] = fzisan[1];
99 a[2] = fzisan[2];
100 a[3] = fzisan[3];
101 a[4] = fzisan[4];
102
103
104
105 if (
abs(a[3])>50.0 ||
abs(a[4])>500.0)
return (-5);
106
107
108
109 Helix helix1(pivot1,a);
111 Phi0 = helix1.a()[1];
112 Kappa = helix1.a()[2];
114 Tanl = helix1.a()[4];
115
116
117 rho = helix1.radius();
118
120 xc = xyz(0);
121 yc = xyz(1);
122
123
124 Hep3Vector vxyz = helix1.direction();
125 nx = vxyz(0);
126 ny = vxyz(1);
127
128
129 if(fabs(rho)>
R_tof/2){
130
131
132
133 if( xc==0.0 && yc==0.0 ) return(-3);
134
135 ca = xc*xc + yc*yc ;
137
138 if ( xc != 0.0 ) {
139 cb = aa * yc;
141
142 detm = cb*cb - ca*cc;
143 if ( detm > 0.0 ) {
144 yy[0] = ( cb + sqrt(detm) )/ ca;
145 xx[0] = ( aa - yy[0]*yc )/xc;
146 yy[1] = ( cb - sqrt(detm) )/ ca;
147 xx[1] = ( aa - yy[1]*yc )/xc;
148 } else return(-1);
149 }
150 else{
151 cb = aa * xc;
153
154 detm = cb*cb - ca*cc;
155 if ( detm > 0.0 ) {
156 xx[0] = ( cb + sqrt(detm) )/ca;
157 yy[0] = ( aa - xx[0]*xc )/yc;
158 xx[1] = ( cb - sqrt(detm) )/ca;
159 yy[1] = ( aa - xx[1]*xc )/yc;
160 } else return(-2);
161 }
162
163
164
165 if( xx[0]*nx + yy[0]*ny > 0.0 ) { tofx = xx[0]; tofy = yy[0]; }
166 else { tofx = xx[1]; tofy = yy[1]; }
167
168 double fi = atan2(tofy ,tofx );
169
170
171 if( fi < 0.0 ) fi=pi2+fi;
173
175
176
178 helix1.pivot(pivot2);
179
180
183
184 double dphi = (-xc*(tofx-xc)-yc*(tofy-yc))/sqrt(xc*xc+yc*yc)/fabs(rho);
185 dphi = acos(dphi);
186 Pathl = fabs(rho*dphi);
189
190
191 Hep3Vector vxyz1 = helix1.direction();
192 nx = vxyz1(0);
193 ny = vxyz1(1);
194
195 double corxy=(nx*tofx+ny*tofy)/
R_tof;
197
199
200
201
202
203
205
212
215 r_endtof = sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
216
217 Helix helix1(pivot1,a);
218
219 double x1_endtof=helix1.x(phi).x();
220 double y1_endtof=helix1.x(phi).y();
221 double z1_endtof=helix1.x(phi).z();
222
223 double fi_endtof = atan2(y_endtof,x_endtof );
224 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
225
226 Tofid =(int)(fi_endtof/piby24);
228
229
230
231 double Z_etf_1 = 133.673;
232 double Pathl_1 = Z_etf_1/
sin(atan(
Tanl));
233 double phi0_1 = -(Z_etf_1/
Tanl)/rho;
234 double phi_1 = -(Z_etf_1-
Dz)/
Tanl/rho;
235 double phi1_1 = (Z_etf_1*
Kappa*0.003)/
Tanl;
237
240 double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
241
242 double x_etf_1 = helix1.x(phi_1).x();
243 double y_etf_1 = helix1.x(phi_1).y();
244 double z_etf_1 = helix1.x(phi_1).z();
245
246
247 double fi_etf_1 = atan2( y1_etf, x1_etf ) + 1.25*piby1/180.0;
248 if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
249
250 int Etfid_1 = (int)(fi_etf_1/piby18);
251 if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
252
253
254 if( Etfid_1%2 == 1 ) {
259 }
260
261 else {
262
263 double Z_etf_2 = 136.573;
264 double Pathl_2 = Z_etf_2/
sin(atan(
Tanl));
265 double phi0_2 = -(Z_etf_2/
Tanl)/rho;
266 double phi_2 = -(Z_etf_2-
Dz)/
Tanl/rho;
267 double phi1_2 = (Z_etf_2*
Kappa*0.003)/
Tanl;
269
272 double r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
273
274 double x_etf_2 = helix1.x(phi_2).x();
275 double y_etf_2 = helix1.x(phi_2).y();
276 double z_etf_2 = helix1.x(phi_2).z();
277
278
279 double fi_etf_2 = atan2( y2_etf, x2_etf ) + 1.25*piby1/180.0 ;
280 if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
281
282 int Etfid_2 = (int)(fi_etf_2/piby18);
283 if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
284
285 if( Etfid_2%2 == 1 ) {
286 int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
287 int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
288 if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
289 else { Etfid_2 = tmp1; }
290 }
291
296 }
297
298 return (0);
299
300 }
301 else if (
Z_tof<=-115){
302
309
312 r_endtof = sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
313
314 Helix helix1(pivot1,a);
315
316 double x1_endtof=helix1.x(phi).x();
317 double y1_endtof=helix1.x(phi).y();
318 double z1_endtof=helix1.x(phi).z();
319
320 double fi_endtof = atan2(y_endtof,x_endtof );
321 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
322
323 Tofid =(int)(fi_endtof/piby24);
325
326
327 double Z_etf_1 = -133.673;
328 double Pathl_1 = Z_etf_1/
sin(atan(
Tanl));
329 double phi0_1 = -(Z_etf_1/
Tanl)/rho;
330 double phi_1 = -(Z_etf_1-
Dz)/
Tanl/rho;
331 double phi1_1 = (Z_etf_1*
Kappa*0.003)/
Tanl;
333
336 double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
337
338 double x_etf_1 = helix1.x(phi_1).x();
339 double y_etf_1 = helix1.x(phi_1).y();
340 double z_etf_1 = helix1.x(phi_1).z();
341
342
343 double fi_etf_1 = atan2( y1_etf, x1_etf ) - 11.25*piby1/180.0;
344 if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
345
346 int Etfid_1 = (int)(fi_etf_1/piby18);
347 if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
348
349
350 if( Etfid_1%2 == 1 ) {
355 }
356
357 else {
358 double Z_etf_2 = -136.573;
359 double Pathl_2 = Z_etf_2/
sin(atan(
Tanl));
360 double phi0_2 = -(Z_etf_2/
Tanl)/rho;
361 double phi_2 = -(Z_etf_2-
Dz)/
Tanl/rho;
362 double phi1_2 = (Z_etf_2*
Kappa*0.003)/
Tanl;
364
367 double r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
368
369 double x_etf_2 = helix1.x(phi_2).x();
370 double y_etf_2 = helix1.x(phi_2).y();
371 double z_etf_2 = helix1.x(phi_2).z();
372
373
374 double fi_etf_2 = atan2( y2_etf, x2_etf ) - 11.25*piby1/180.0;
375 if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
376
377 int Etfid_2 = (int)(fi_etf_2/piby18);
378 if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
379
380 if( Etfid_2%2 == 1 ) {
381 int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
382 int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
383 if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
384 else { Etfid_2 = tmp1; }
385 }
386
391 }
392
393 return (2);
394
395 }
396
397 }
398 else {
400
407
410 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
411
412 double fi_endtof = atan2(y_endtof,x_endtof );
413 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
414 Tofid =(int)(fi_endtof/piby24);
416
417
418 double Z_etf_1 = 133.673;
419 double Pathl_1 = Z_etf_1/
sin(atan(
Tanl));
420 double phi0_1 = -(Z_etf_1/
Tanl)/rho;
421 double phi_1 = -(Z_etf_1-
Dz)/
Tanl/rho;
422 double phi1_1 = (Z_etf_1*
Kappa*0.003)/
Tanl;
424
427 double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
428
429 double x_etf_1 = helix1.x(phi_1).x();
430 double y_etf_1 = helix1.x(phi_1).y();
431 double z_etf_1 = helix1.x(phi_1).z();
432
433
434 double fi_etf_1 = atan2( y1_etf, x1_etf ) + 1.25*piby1/180.0;
435 if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
436
437 int Etfid_1 = (int)(fi_etf_1/piby18);
438 if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
439
440
441 if( Etfid_1%2 == 1 ) {
446 }
447
448 else {
449 double Z_etf_2 = 136.573;
450 double Pathl_2 = Z_etf_2/
sin(atan(
Tanl));
451 double phi0_2 = -(Z_etf_2/
Tanl)/rho;
452 double phi_2 = -(Z_etf_2-
Dz)/
Tanl/rho;
453 double phi1_2 = (Z_etf_2*
Kappa*0.003)/
Tanl;
455
458 double r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
459
460 double x_etf_2 = helix1.x(phi_2).x();
461 double y_etf_2 = helix1.x(phi_2).y();
462 double z_etf_2 = helix1.x(phi_2).z();
463
464
465 double fi_etf_2 = atan2( y2_etf, x2_etf ) + 1.25*piby1/180.0;
466 if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
467
468 int Etfid_2 = (int)(fi_etf_2/piby18);
469 if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
470
471 if( Etfid_2%2 == 1 ) {
472 int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
473 int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
474 if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
475 else { Etfid_2 = tmp1; }
476 }
481 }
482
483 return (0);
484 }
485 else{
486
493
496 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
497
498 double fi_endtof = atan2(y_endtof,x_endtof );
499 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
500 Tofid =(int)(fi_endtof/piby24);
502
503
504 double Z_etf_1 = -133.673;
505 double Pathl_1 = Z_etf_1/
sin(atan(
Tanl));
506 double phi0_1 = -(Z_etf_1/
Tanl)/rho;
507 double phi_1 = -(Z_etf_1-
Dz)/
Tanl/rho;
508 double phi1_1 = (Z_etf_1*
Kappa*0.003)/
Tanl;
510
513 double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
514
515 double x_etf_1 = helix1.x(phi_1).x();
516 double y_etf_1 = helix1.x(phi_1).y();
517 double z_etf_1 = helix1.x(phi_1).z();
518
519
520 double fi_etf_1 = atan2( y1_etf, x1_etf ) - 11.25*piby1/180.0;
521 if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
522
523 int Etfid_1 = (int)(fi_etf_1/piby18);
524 if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
525
526 if( Etfid_1%2 == 1 ) {
531 }
532 else {
533 double Z_etf_2 = -136.573;
534 double Pathl_2 = Z_etf_2/
sin(atan(
Tanl));
535 double phi0_2 = -(Z_etf_2/
Tanl)/rho;
536 double phi_2 = -(Z_etf_2-
Dz)/
Tanl/rho;
537 double phi1_2 = (Z_etf_2*
Kappa*0.003)/
Tanl;
539
542 int r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
543
544 double x_etf_2 = helix1.x(phi_2).x();
545 double y_etf_2 = helix1.x(phi_2).y();
546 double z_etf_2 = helix1.x(phi_2).z();
547
548
549 double fi_etf_2 = atan2( y2_etf, x2_etf ) - 11.25*piby1/180.0;
550 if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
551
552 int Etfid_2 = (int)(fi_etf_2/piby18);
553 if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
554
555 if( Etfid_2%2 == 1 ) {
556 int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
557 int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
558 if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
559 else { Etfid_2 = tmp1; }
560 }
561
566 }
567
568 return (2);
569 }
570 }
571
574
575 if (_debug) {
576 printf("\n TofFz_helix> Trk=%3d params(dr,phi,kappa,dz,tanl)="
577 "(%5.1f,%6.3f,%6.4f,%6.1f,%6.3f) R_tof %5.1f\n",
579
580 printf(" TofFz_helix> rho=%8.1f, (xc,yc)=(%8.1f,%8.1f)"
581 " (nx,ny)=(%5.2f,%5.2f)\n",rho,xc,yc,nx,ny);
582
583 printf(" TofFz_helix> tof (x,y)=(%5.1f,%5.1f) and (%5.1f,%5.1f)\n",
584 xx[0],yy[0],xx[1],yy[1]);
585
586 printf(" TofFz_helix> tofid=%3d, fitof=%6.3f, w=%5.3f"
587 " (x,y,z)=(%5.1f,%5.1f,%5.1f) pathl=%5.1f cm path=%5.1f cm\n",
589 }
590 return (-7);
591 }
592
593}
double sin(const BesAngle a)
double cos(const BesAngle a)