/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/EsTimeAlg/EsTimeAlg-00-02-60/src/Toffz_helix.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 #include "GaudiKernel/MsgStream.h"
00029 #include "GaudiKernel/AlgFactory.h"
00030 #include "GaudiKernel/ISvcLocator.h"
00031 #include "GaudiKernel/SmartDataPtr.h"
00032 #include "GaudiKernel/IDataProviderSvc.h"
00033 #include "GaudiKernel/PropertyMgr.h"
00034 #include "EventModel/Event.h"
00035 #include "MdcRawEvent/MdcDigi.h"
00036 #include "TofRawEvent/TofDigi.h"
00037 #include "McTruth/McParticle.h"
00038 
00039 #include "MdcGeomSvc/IMdcGeomSvc.h"
00040 #include "MdcGeomSvc/MdcGeoWire.h"
00041 #include "MdcGeomSvc/MdcGeoLayer.h"
00042 #include <vector>
00043 #include <iostream>
00044 #include <cstdio>
00045 #include <math.h>
00046 
00047 #include "EsTimeAlg/Toffz_helix.h"
00048 #include "CLHEP/Vector/ThreeVector.h"   
00049 #include "MdcFastTrkAlg/FTFinder.h"
00050 #include "TrackUtil/Helix.h"
00051 #include "CLHEP/Geometry/Point3D.h"
00052  
00053 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00054   typedef HepGeom::Point3D<double> HepPoint3D;
00055 #endif
00056 
00057 using CLHEP::HepVector; 
00058 using CLHEP::Hep3Vector;
00059 
00060 
00061 TofFz_helix::TofFz_helix(void) {
00062    piby1=3.141593;
00063    pi2=2.0*piby1;
00064    piby44=piby1/44.0;
00065    piby24=piby1/24.0;
00066    piby18=piby1/18.0;
00067    _debug=1;
00068    _pathl_cut= 500.0;
00069    _ztof_cutm=-140.0;
00070    _ztof_cutx= 140.0;
00071 
00072  
00073 }
00074 
00075 
00076 int TofFz_helix::TofFz_Get(double rtof, int id, double fzisan[]) {
00077    // crossing points of the helix on the tof cylinder
00078    double xc,yc;            // center of the circle
00079    double rho;              // radius of tof cyclinder
00080    double  xx[2],yy[2];      // coordinates of hits
00081    double  tofx,tofy;        // (x,y) on the radius of R_tof
00082    double  nx,ny;            // direction cosines of mom vector at vertex
00083    double  cosx,sinx;
00084    double aa,ca,cb,cc,detm;
00085   
00086    // fzisan track ID and TOF radius
00087    int Id_cdfztrk = id; R_tof = rtof;
00088 
00089     if( Id_cdfztrk<0 ) {
00090      if (_debug) std::cout << " TofFz_helix *** wrong id_cdfztrk ="
00091                            << Id_cdfztrk << std::endl;
00092                                                   return(-1);
00093    }
00094    
00095    const HepPoint3D pivot1(0.,0.,0.);
00096    HepVector  a(5,0);
00097    a[0] = fzisan[0];
00098    a[1] = fzisan[1];
00099    a[2] = fzisan[2];
00100    a[3] = fzisan[3];
00101    a[4] = fzisan[4];
00102 
00103 
00104    // Ill-fitted track in fzisan (dz=tanl=-9999.)
00105    if (abs(a[3])>50.0 || abs(a[4])>500.0)          return (-5);
00106   // if (abs(a[3])>10.0 || abs(a[4])>500.0)          return (-5);
00107 
00108    // D e f i n e   h e l i x
00109    Helix helix1(pivot1,a);
00110    Dr    = helix1.a()[0];   
00111    Phi0  = helix1.a()[1];   
00112    Kappa = helix1.a()[2];    
00113    Dz    = helix1.a()[3];   
00114    Tanl  = helix1.a()[4];
00115 
00116    // check cdfztrk hit on tof cyclinder
00117    rho  = helix1.radius(); 
00118    // cout<<" Toffz_helix:: rho  ="<<rho<<endl;  // radius of the circle in cm
00119    HepPoint3D    xyz    = helix1.center();
00120    xc   = xyz(0);
00121    yc   = xyz(1);
00122    // cout<<"Toffz_helix::helix center:xc="<<xc<<",yc= "<<yc<<endl;
00123 
00124    Hep3Vector vxyz   = helix1.direction();
00125    nx   = vxyz(0);              // direction of track at the vertex
00126    ny   = vxyz(1); 
00127    // cout<<"Toffz_helix::direction: nx= "<<nx<<", ny="<<ny<<endl;
00128   
00129    if(fabs(rho)>R_tof/2){
00130    
00131    // get hit on tof cylinder at radius R_tof;
00132 
00133    if( xc==0.0 && yc==0.0 ) return(-3); 
00134    // coefficients of quadratic equation
00135    ca = xc*xc + yc*yc ;
00136    aa = 0.5 * ( ca - rho*rho + R_tof*R_tof );
00137    
00138    if ( xc != 0.0 ) {
00139       cb = aa * yc;
00140       cc = aa*aa - R_tof*R_tof*xc*xc; 
00141       // determinant
00142       detm = cb*cb - ca*cc;
00143       if ( detm > 0.0 ) {
00144          yy[0] = ( cb + sqrt(detm) )/ ca;
00145          xx[0] = ( aa - yy[0]*yc )/xc;
00146          yy[1] = ( cb - sqrt(detm) )/ ca;
00147          xx[1] = ( aa - yy[1]*yc )/xc;
00148       } else  return(-1);
00149    }
00150    else{
00151       cb = aa * xc;
00152       cc = aa*aa - R_tof*R_tof*yc*yc;
00153       // determinant
00154       detm = cb*cb - ca*cc;
00155       if ( detm > 0.0 ) {
00156          xx[0] = ( cb + sqrt(detm) )/ca;
00157          yy[0] = ( aa - xx[0]*xc )/yc;
00158          xx[1] = ( cb - sqrt(detm) )/ca;
00159          yy[1] = ( aa - xx[1]*xc )/yc;
00160       } else return(-2);
00161    }
00162  
00163    // choose one of hits according to track direction at the vertex.
00164   
00165    if( xx[0]*nx + yy[0]*ny > 0.0 ) { tofx = xx[0]; tofy = yy[0]; }
00166    else                            { tofx = xx[1]; tofy = yy[1]; }
00167   
00168    double fi = atan2(tofy ,tofx );    // atna2 from -pi to pi
00169 
00170    
00171    if( fi < 0.0 ) fi=pi2+fi;
00172    Fi_tof = fi;         
00173    //  Tofid = (int) ( Fi_tof/piby44 + 1.0 );
00174    Tofid = (int) ( Fi_tof/piby44  );
00175    
00176    // get phi and z on the tof counter
00177    const HepPoint3D pivot2( tofx, tofy, 0.0);
00178    helix1.pivot(pivot2);
00179    
00180    // corrected by Ozaki san to avoid negative path length on Aug.10,99   
00181    Phi1=helix1.a()[1];
00182    Z_tof=helix1.a()[3];
00183    
00184    double dphi = (-xc*(tofx-xc)-yc*(tofy-yc))/sqrt(xc*xc+yc*yc)/fabs(rho);
00185    dphi = acos(dphi);
00186    Pathl = fabs(rho*dphi);
00187    double coscor=sqrt(1.0+Tanl*Tanl);
00188    Pathl=Pathl*coscor;
00189 
00190    // path length in tof scintillator
00191    Hep3Vector vxyz1   = helix1.direction();
00192    nx   = vxyz1(0);            // direction of track at the vertex
00193    ny   = vxyz1(1); 
00194    //   cout<<" Toffz_helix::track direction: nx="<<nx<<",ny="<<ny<<endl;
00195    double corxy=(nx*tofx+ny*tofy)/R_tof;
00196    Path_tof=4.0*coscor/corxy;
00197    // cout<<" Toffz_helix::Path_tof="<< Path_tof<<endl;
00198    if(abs(Z_tof)<115)  return (1);
00199    //  if(Z_tof>116.5){
00200 
00201 
00202    //std::cout << "   helix1.a()[3]    " << helix1.a()[3] <<std::endl;
00203 
00204    if(Z_tof>=115){
00205      // Scintillator East Endcap TOF
00206      Z_tof = 133;
00207      Pathl = Z_tof/sin(atan(Tanl));
00208      double phi0 = -(Z_tof/Tanl)/rho;
00209      double phi  = -(Z_tof-Dz)/Tanl/rho;
00210      double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00211      double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00212      
00213      double x_endtof = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00214      double y_endtof = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00215      r_endtof = sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00216      
00217      Helix helix1(pivot1,a); 
00218      
00219      double x1_endtof=helix1.x(phi).x();
00220      double y1_endtof=helix1.x(phi).y();
00221      double z1_endtof=helix1.x(phi).z(); 
00222      
00223      double fi_endtof = atan2(y_endtof,x_endtof );    // atna2 from -pi to pi
00224      if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00225      
00226      Tofid =(int)(fi_endtof/piby24);
00227      if(Tofid>47)Tofid=Tofid-48;
00228    
00229      // MRPC East Endcap TOF
00230      // using hardware provide number: 1330+1+1+4.73 / mingming 133.7
00231      double Z_etf_1 = 133.673;
00232      double Pathl_1 = Z_etf_1/sin(atan(Tanl));
00233      double phi0_1 = -(Z_etf_1/Tanl)/rho;
00234      double phi_1  = -(Z_etf_1-Dz)/Tanl/rho;
00235      double phi1_1 = (Z_etf_1*Kappa*0.003)/Tanl;
00236      double phi2_1 = (Z_etf_1-Dz)*Kappa*0.003/Tanl;
00237      
00238      double x1_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_1));
00239      double y1_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_1));
00240      double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
00241      
00242      double x_etf_1 = helix1.x(phi_1).x();
00243      double y_etf_1 = helix1.x(phi_1).y();
00244      double z_etf_1 = helix1.x(phi_1).z(); 
00245      
00246      // the sysmetric axis of east endcap has a degree shift
00247      double fi_etf_1 = atan2( y1_etf, x1_etf ) + 1.25*piby1/180.0;
00248      if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
00249 
00250      int Etfid_1 = (int)(fi_etf_1/piby18);
00251      if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
00252      
00253      // Inner Layer
00254      if( Etfid_1%2 == 1 ) {
00255        Etfid = Etfid_1;
00256        r_etf = r_etf_1;
00257        Z_etf = Z_etf_1;
00258        Path_etf = Pathl_1;
00259      }
00260      // Outer Layer
00261      else {
00262        // using hardware provide number 1357.5+1+2.5+4.73 / mingming 136.4
00263        double Z_etf_2 = 136.573;
00264        double Pathl_2 = Z_etf_2/sin(atan(Tanl));
00265        double phi0_2 = -(Z_etf_2/Tanl)/rho;
00266        double phi_2  = -(Z_etf_2-Dz)/Tanl/rho;
00267        double phi1_2 = (Z_etf_2*Kappa*0.003)/Tanl;
00268        double phi2_2 = (Z_etf_2-Dz)*Kappa*0.003/Tanl;
00269        
00270        double x2_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_2));
00271        double y2_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_2));
00272        double r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
00273        
00274        double x_etf_2 = helix1.x(phi_2).x();
00275        double y_etf_2 = helix1.x(phi_2).y();
00276        double z_etf_2 = helix1.x(phi_2).z(); 
00277        
00278        // the sysmetric axis of east endcap has a 3.75 degree shift
00279        double fi_etf_2 = atan2( y2_etf, x2_etf ) + 1.25*piby1/180.0 ;
00280        if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
00281        
00282        int Etfid_2 = (int)(fi_etf_2/piby18);
00283        if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
00284        
00285        if( Etfid_2%2 == 1 ) {
00286          int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
00287          int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
00288          if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
00289          else { Etfid_2 = tmp1; }
00290        }
00291        
00292        Etfid = Etfid_2;
00293        r_etf = r_etf_2;
00294        Z_etf = Z_etf_2;
00295        Path_etf = Pathl_2;
00296      }
00297 
00298      return (0);
00299 
00300    }
00301    else if (Z_tof<=-115){
00302      // Scintillator West Endcap TOF
00303      Z_tof = -133;
00304      Pathl = Z_tof/sin(atan(Tanl));
00305      double phi0 = -(Z_tof/Tanl)/rho;
00306      double phi  = -(Z_tof-Dz)/Tanl/rho;
00307      double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00308      double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00309      
00310      double x_endtof = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00311      double y_endtof = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00312      r_endtof = sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00313      
00314      Helix helix1(pivot1,a);   
00315      
00316      double x1_endtof=helix1.x(phi).x();
00317      double y1_endtof=helix1.x(phi).y();
00318      double z1_endtof=helix1.x(phi).z(); 
00319      
00320      double fi_endtof = atan2(y_endtof,x_endtof );    // atna2 from -pi to pi
00321      if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00322      
00323      Tofid =(int)(fi_endtof/piby24);
00324      if(Tofid>47) Tofid=Tofid-48;
00325 
00326      // MRPC West Endcap TOF
00327      double Z_etf_1 = -133.673;
00328      double Pathl_1 = Z_etf_1/sin(atan(Tanl));
00329      double phi0_1 = -(Z_etf_1/Tanl)/rho;
00330      double phi_1  = -(Z_etf_1-Dz)/Tanl/rho;
00331      double phi1_1 = (Z_etf_1*Kappa*0.003)/Tanl;
00332      double phi2_1 = (Z_etf_1-Dz)*Kappa*0.003/Tanl;
00333      
00334      double x1_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_1));
00335      double y1_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_1));
00336      double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
00337      
00338      double x_etf_1 = helix1.x(phi_1).x();
00339      double y_etf_1 = helix1.x(phi_1).y();
00340      double z_etf_1 = helix1.x(phi_1).z(); 
00341      
00342      // the sysmetric axis of west endcap has a 16.25 degree shift
00343      double fi_etf_1 = atan2( y1_etf, x1_etf ) - 11.25*piby1/180.0;
00344      if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
00345      
00346      int Etfid_1 = (int)(fi_etf_1/piby18);
00347      if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
00348      
00349      // Inner Layer
00350      if( Etfid_1%2 == 1 ) {
00351        Etfid = Etfid_1;
00352        r_etf = r_etf_1;
00353        Z_etf = Z_etf_1;
00354        Path_etf = Pathl_1;
00355      }
00356      // Outer Layer
00357      else {
00358        double Z_etf_2 = -136.573;
00359        double Pathl_2 = Z_etf_2/sin(atan(Tanl));
00360        double phi0_2 = -(Z_etf_2/Tanl)/rho;
00361        double phi_2  = -(Z_etf_2-Dz)/Tanl/rho;
00362        double phi1_2 = (Z_etf_2*Kappa*0.003)/Tanl;
00363        double phi2_2 = (Z_etf_2-Dz)*Kappa*0.003/Tanl;
00364        
00365        double x2_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_2));
00366        double y2_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_2));
00367        double r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
00368        
00369        double x_etf_2 = helix1.x(phi_2).x();
00370        double y_etf_2 = helix1.x(phi_2).y();
00371        double z_etf_2 = helix1.x(phi_2).z(); 
00372        
00373        // the sysmetric axis of west endcap has a 16.25 degree shift
00374        double fi_etf_2 = atan2( y2_etf, x2_etf ) - 11.25*piby1/180.0;
00375        if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
00376        
00377        int Etfid_2 = (int)(fi_etf_2/piby18);
00378        if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
00379        
00380        if( Etfid_2%2 == 1 ) {
00381          int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
00382          int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
00383          if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
00384          else { Etfid_2 = tmp1; }
00385        }
00386        
00387        Etfid = Etfid_2;
00388        r_etf = r_etf_2;
00389        Z_etf = Z_etf_2;
00390        Path_etf = Pathl_2;
00391      }
00392 
00393      return (2);
00394 
00395    }
00396 
00397    }
00398    else {
00399      if(Tanl>0){
00400        // Scintillator East Endcap TOF
00401        Z_tof = 133;
00402        Pathl = Z_tof/sin(atan(Tanl));
00403        double phi0 = -(Z_tof/Tanl)/rho;
00404        double phi  = -(Z_tof-Dz)/Tanl/rho;
00405        double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00406        double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00407        
00408        double x_endtof=Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00409        double y_endtof=Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00410        r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00411        
00412        double fi_endtof = atan2(y_endtof,x_endtof );    // atna2 from -pi to pi
00413        if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00414        Tofid =(int)(fi_endtof/piby24);
00415        if(Tofid>47)Tofid=Tofid-48;
00416      
00417        // MRPC East Endcap TOF
00418        double Z_etf_1 = 133.673;
00419        double Pathl_1 = Z_etf_1/sin(atan(Tanl));
00420        double phi0_1 = -(Z_etf_1/Tanl)/rho;
00421        double phi_1  = -(Z_etf_1-Dz)/Tanl/rho;
00422        double phi1_1 = (Z_etf_1*Kappa*0.003)/Tanl;
00423        double phi2_1 = (Z_etf_1-Dz)*Kappa*0.003/Tanl;
00424      
00425        double x1_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_1));
00426        double y1_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_1));
00427        double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
00428 
00429        double x_etf_1 = helix1.x(phi_1).x();
00430        double y_etf_1 = helix1.x(phi_1).y();
00431        double z_etf_1 = helix1.x(phi_1).z(); 
00432        
00433        // the sysmetric axis of east endcap has a 3.75 degree shift
00434        double fi_etf_1 = atan2( y1_etf, x1_etf ) + 1.25*piby1/180.0;
00435        if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
00436        
00437        int Etfid_1 = (int)(fi_etf_1/piby18);
00438        if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
00439        
00440        // Inner Layer
00441        if( Etfid_1%2 == 1 ) {
00442          Etfid = Etfid_1;
00443          r_etf = r_etf_1;
00444          Z_etf = Z_etf_1;
00445          Path_etf = Pathl_1;
00446        }
00447        // Outer Layer
00448        else {
00449          double Z_etf_2 = 136.573;
00450          double Pathl_2 = Z_etf_2/sin(atan(Tanl));
00451          double phi0_2 = -(Z_etf_2/Tanl)/rho;
00452          double phi_2  = -(Z_etf_2-Dz)/Tanl/rho;
00453          double phi1_2 = (Z_etf_2*Kappa*0.003)/Tanl;
00454          double phi2_2 = (Z_etf_2-Dz)*Kappa*0.003/Tanl;
00455          
00456          double x2_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_2));
00457          double y2_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_2));
00458          double r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
00459          
00460          double x_etf_2 = helix1.x(phi_2).x();
00461          double y_etf_2 = helix1.x(phi_2).y();
00462          double z_etf_2 = helix1.x(phi_2).z(); 
00463          
00464          // the sysmetric axis of east endcap has a 3.75 degree shift
00465          double fi_etf_2 = atan2( y2_etf, x2_etf ) + 1.25*piby1/180.0;
00466          if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
00467          
00468          int Etfid_2 = (int)(fi_etf_2/piby18);
00469          if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
00470          
00471          if( Etfid_2%2 == 1 ) {
00472            int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
00473            int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
00474            if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
00475            else { Etfid_2 = tmp1; }
00476          }
00477          Etfid = Etfid_2;
00478          r_etf = r_etf_2;
00479          Z_etf = Z_etf_2;
00480          Path_etf = Pathl_2;
00481        }
00482 
00483        return (0);
00484      }
00485      else{
00486        // Scintillator West Endcap TOF
00487        Z_tof = -133;
00488        Pathl = Z_tof/sin(atan(Tanl));
00489        double phi0 = -(Z_tof/Tanl)/rho;
00490        double phi  = -(Z_tof-Dz)/Tanl/rho;
00491        double phi1 = (Z_tof*Kappa*0.003)/Tanl;
00492        double phi2 = (Z_tof-Dz)*Kappa*0.003/Tanl;
00493        
00494        double x_endtof=Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi));
00495        double y_endtof=Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi));
00496        r_endtof=sqrt(x_endtof * x_endtof + y_endtof * y_endtof);
00497        
00498        double fi_endtof = atan2(y_endtof,x_endtof );    // atna2 from -pi to pi
00499        if (fi_endtof<0) fi_endtof=pi2+fi_endtof;
00500        Tofid =(int)(fi_endtof/piby24);
00501        if(Tofid>47)Tofid=Tofid-48;
00502      
00503        // MRPC West Endcap TOF
00504        double Z_etf_1 = -133.673;
00505        double Pathl_1 = Z_etf_1/sin(atan(Tanl));
00506        double phi0_1 = -(Z_etf_1/Tanl)/rho;
00507        double phi_1  = -(Z_etf_1-Dz)/Tanl/rho;
00508        double phi1_1 = (Z_etf_1*Kappa*0.003)/Tanl;
00509        double phi2_1 = (Z_etf_1-Dz)*Kappa*0.003/Tanl;
00510        
00511        double x1_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_1));
00512        double y1_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_1));
00513        double r_etf_1 = sqrt( x1_etf*x1_etf + y1_etf*y1_etf );
00514        
00515        double x_etf_1 = helix1.x(phi_1).x();
00516        double y_etf_1 = helix1.x(phi_1).y();
00517        double z_etf_1 = helix1.x(phi_1).z(); 
00518        
00519        // the sysmetric axis of west endcap has a 16.25 degree shift
00520        double fi_etf_1 = atan2( y1_etf, x1_etf ) - 11.25*piby1/180.0;
00521        if( fi_etf_1<0 ) { fi_etf_1 = pi2 + fi_etf_1; }
00522        
00523        int Etfid_1 = (int)(fi_etf_1/piby18);
00524        if( Etfid_1>35 ) { Etfid_1 = Etfid_1 - 36; }
00525        
00526        if( Etfid_1%2 == 1 ) {
00527          Etfid = Etfid_1;
00528          r_etf = r_etf_1;
00529          Z_etf = Z_etf_1;
00530          Path_etf = Pathl_1;
00531        }
00532        else {
00533          double Z_etf_2 = -136.573;
00534          double Pathl_2 = Z_etf_2/sin(atan(Tanl));
00535          double phi0_2 = -(Z_etf_2/Tanl)/rho;
00536          double phi_2  = -(Z_etf_2-Dz)/Tanl/rho;
00537          double phi1_2 = (Z_etf_2*Kappa*0.003)/Tanl;
00538          double phi2_2 = (Z_etf_2-Dz)*Kappa*0.003/Tanl;
00539          
00540          double x2_etf = Dr*cos(Phi0)+(1/(Kappa*0.003))*(cos(Phi0)-cos(Phi0+phi_2));
00541          double y2_etf = Dr*sin(Phi0)+(1/(Kappa*0.003))*(sin(Phi0)-sin(Phi0+phi_2));
00542          int r_etf_2 = sqrt( x2_etf*x2_etf + y2_etf*y2_etf );
00543          
00544          double x_etf_2 = helix1.x(phi_2).x();
00545          double y_etf_2 = helix1.x(phi_2).y();
00546          double z_etf_2 = helix1.x(phi_2).z(); 
00547          
00548          // the sysmetric axis of west endcap has a 16.25 degree shift
00549          double fi_etf_2 = atan2( y2_etf, x2_etf ) - 11.25*piby1/180.0;
00550          if( fi_etf_2<0 ) { fi_etf_2 = pi2 + fi_etf_2; }
00551          
00552          int Etfid_2 = (int)(fi_etf_2/piby18);
00553          if( Etfid_2>35 ) { Etfid_2 = Etfid_2 - 36; }
00554          
00555          if( Etfid_2%2 == 1 ) {
00556            int tmp1 = (int)((fi_etf_2+0.5*piby18)/piby18);
00557            int tmp2 = (int)((fi_etf_2-0.5*piby18)/piby18);
00558            if( tmp1 == Etfid_2 ) { Etfid_2 = tmp2; }
00559            else { Etfid_2 = tmp1; }
00560          }
00561          
00562          Etfid = Etfid_2;
00563          r_etf = r_etf_2;
00564          Z_etf = Z_etf_2;
00565          Path_etf = Pathl_2;
00566        }
00567 
00568        return (2);
00569      }
00570    }
00571 
00572    if (abs(Pathl) > _pathl_cut || 
00573        Z_tof < _ztof_cutm || Z_tof > _ztof_cutx) {
00574      // Bad path length or Z_tof
00575      if (_debug) {
00576        printf("\n TofFz_helix> Trk=%3d  params(dr,phi,kappa,dz,tanl)="
00577               "(%5.1f,%6.3f,%6.4f,%6.1f,%6.3f) R_tof %5.1f\n",
00578               Id_cdfztrk,Dr,Phi0,Kappa,Dz,Tanl,R_tof);
00579        
00580        printf(" TofFz_helix> rho=%8.1f, (xc,yc)=(%8.1f,%8.1f)"
00581               " (nx,ny)=(%5.2f,%5.2f)\n",rho,xc,yc,nx,ny);
00582       
00583        printf(" TofFz_helix> tof (x,y)=(%5.1f,%5.1f) and (%5.1f,%5.1f)\n",
00584               xx[0],yy[0],xx[1],yy[1]);
00585      
00586        printf(" TofFz_helix> tofid=%3d, fitof=%6.3f, w=%5.3f"
00587               " (x,y,z)=(%5.1f,%5.1f,%5.1f)  pathl=%5.1f cm  path=%5.1f cm\n",
00588               Tofid,Fi_tof,W_tof,tofx,tofy,Z_tof,Pathl,Path_tof);
00589      }
00590      return (-7);
00591    }
00592           
00593 }

Generated on Tue Nov 29 23:13:21 2016 for BOSS_7.0.2 by  doxygen 1.4.7