28#include "GaudiKernel/MsgStream.h"
29#include "GaudiKernel/AlgFactory.h"
30#include "GaudiKernel/ISvcLocator.h"
31#include "GaudiKernel/SmartDataPtr.h"
32#include "GaudiKernel/IDataProviderSvc.h"
33#include "GaudiKernel/PropertyMgr.h"
48#include "CLHEP/Vector/ThreeVector.h"
51#include "CLHEP/Geometry/Point3D.h"
53#ifndef ENABLE_BACKWARDS_COMPATIBILITY
57using CLHEP::HepVector;
58using CLHEP::Hep3Vector;
84 double aa,ca,cb,cc,detm;
87 int Id_cdfztrk = id;
R_tof = rtof;
90 if (_debug) std::cout <<
" TofFz_helix *** wrong id_cdfztrk ="
91 << Id_cdfztrk << std::endl;
125 if (
abs(a[3])>50.0 ||
abs(a[4])>500.0)
return (-5);
129 Helix helix1(pivot1,a);
131 Phi0 = helix1.
a()[1];
134 Tanl = helix1.
a()[4];
155 if(fabs(rho)>
R_tof/2){
159 if( xc==0.0 && yc==0.0 )
return(-3);
168 detm = cb*cb - ca*cc;
170 yy[0] = ( cb + sqrt(detm) )/ ca;
171 xx[0] = ( aa - yy[0]*yc )/xc;
172 yy[1] = ( cb - sqrt(detm) )/ ca;
173 xx[1] = ( aa - yy[1]*yc )/xc;
180 detm = cb*cb - ca*cc;
182 xx[0] = ( cb + sqrt(detm) )/ca;
183 yy[0] = ( aa - xx[0]*xc )/yc;
184 xx[1] = ( cb - sqrt(detm) )/ca;
185 yy[1] = ( aa - xx[1]*xc )/yc;
191 if( xx[0]*nx + yy[0]*ny > 0.0 ) { tofx = xx[0]; tofy = yy[0]; }
192 else { tofx = xx[1]; tofy = yy[1]; }
194 double fi = atan2(tofy ,tofx );
197 if( fi < 0.0 ) fi=pi2+fi;
212 helix1.
pivot(pivot2);
218 double dphi = (-xc*(tofx-xc)-yc*(tofy-yc))/sqrt(xc*xc+yc*yc)/fabs(rho);
220 Pathl = fabs(rho*dphi);
229 double corxy=(nx*tofx+ny*tofy)/
R_tof;
248 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
250 Helix helix1(pivot1,a);
252 double x1_endtof=helix1.
x(phi).x();
253 double y1_endtof=helix1.
x(phi).y();
254 double z1_endtof=helix1.
x(phi).z();
256 double fi_endtof = atan2(y_endtof,x_endtof );
257 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
259 Tofid =(int)(fi_endtof/piby24);
263 double fi_endtof_mrpc = atan2(y_endtof,x_endtof)-3.141592654/2.;
264 if(fi_endtof_mrpc<0) fi_endtof_mrpc += 2*3.141592654;
266 int mrpc_moduleId = ((int)(fi_endtof_mrpc/(3.141593/18)))+1;
267 if(mrpc_moduleId%2==0){mrpc_moduleId=mrpc_moduleId/2;}
268 else {mrpc_moduleId=(mrpc_moduleId+1)/2;}
269 if(helix1.
a()[3]>0) {(mrpc_moduleId -= 19); mrpc_moduleId=mrpc_moduleId*(-1); }
277 }
else if (
Z_tof<=-115){
287 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
289 Helix helix1(pivot1,a);
291 double x1_endtof=helix1.
x(phi).x();
292 double y1_endtof=helix1.
x(phi).y();
293 double z1_endtof=helix1.
x(phi).z();
295 double fi_endtof = atan2(y_endtof,x_endtof );
296 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
298 Tofid =(int)(fi_endtof/piby24);
301 double fi_endtof_mrpc = atan2(y_endtof,x_endtof)-3.141592654/2.;
302 if(fi_endtof_mrpc<0) fi_endtof_mrpc += 2*3.141592654;
304 int mrpc_moduleId = ((int)(fi_endtof_mrpc/(3.141593/18)))+1;
305 if(mrpc_moduleId%2==0){mrpc_moduleId=mrpc_moduleId/2;}
306 else {mrpc_moduleId=(mrpc_moduleId+1)/2;}
307 if(helix1.
a()[3]>0) {(mrpc_moduleId -= 19); mrpc_moduleId=mrpc_moduleId*(-1); }
330 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
335 double fi_endtof = atan2(y_endtof,x_endtof );
336 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
338 Tofid =(int)(fi_endtof/piby24);
342 double fi_endtof_mrpc = atan2(y_endtof,x_endtof)-3.141592654/2.;
343 if(fi_endtof_mrpc<0) fi_endtof_mrpc += 2*3.141592654;
345 int mrpc_moduleId = ((int)(fi_endtof_mrpc/(3.141593/18)))+1;
346 if(mrpc_moduleId%2==0){mrpc_moduleId=mrpc_moduleId/2;}
347 else {mrpc_moduleId=(mrpc_moduleId+1)/2;}
348 if(helix1.
a()[3]>0) {(mrpc_moduleId -= 19); mrpc_moduleId=mrpc_moduleId*(-1); }
369 r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
374 double fi_endtof = atan2(y_endtof,x_endtof );
375 if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
377 Tofid =(int)(fi_endtof/piby24);
381 double fi_endtof_mrpc = atan2(y_endtof,x_endtof)-3.141592654/2.;
382 if(fi_endtof_mrpc<0) fi_endtof_mrpc += 2*3.141592654;
384 int mrpc_moduleId = ((int)(fi_endtof_mrpc/(3.141593/18)))+1;
385 if(mrpc_moduleId%2==0){mrpc_moduleId=mrpc_moduleId/2;}
386 else {mrpc_moduleId=(mrpc_moduleId+1)/2;}
387 if(helix1.
a()[3]>0) {(mrpc_moduleId -= 19); mrpc_moduleId=mrpc_moduleId*(-1); }
400 Z_tof < _ztof_cutm || Z_tof > _ztof_cutx) {
403 printf(
"\n TofFz_helix> Trk=%3d params(dr,phi,kappa,dz,tanl)="
404 "(%5.1f,%6.3f,%6.4f,%6.1f,%6.3f) R_tof %5.1f\n",
407 printf(
" TofFz_helix> rho=%8.1f, (xc,yc)=(%8.1f,%8.1f)"
408 " (nx,ny)=(%5.2f,%5.2f)\n",rho,xc,yc,nx,ny);
410 printf(
" TofFz_helix> tof (x,y)=(%5.1f,%5.1f) and (%5.1f,%5.1f)\n",
411 xx[0],yy[0],xx[1],yy[1]);
413 printf(
" TofFz_helix> tofid=%3d, fitof=%6.3f, w=%5.3f"
414 " (x,y,z)=(%5.1f,%5.1f,%5.1f) pathl=%5.1f cm path=%5.1f cm\n",
double sin(const BesAngle a)
double cos(const BesAngle a)
double abs(const EvtComplex &c)
HepGeom::Point3D< double > HepPoint3D
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double radius(void) const
returns radious of helix.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
Hep3Vector direction(double dPhi=0.) const
returns direction vector after rotating angle dPhi in phi direction.
int TofFz_Get(double, int, double[])