--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2006/10/27 16:59:20 1.14 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2006/11/14 16:21:08 1.17 @@ -12,13 +12,51 @@ extern "C" { void dotrack_(int*, double*, double*, double*, double*, int*); void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); - int readb_(const char*); +// int readb_(const char*); + int readb_(); void mini2_(int*,int*,int*); + void guess_(); } //-------------------------------------- // // //-------------------------------------- +/** + * Evaluates the trajectory in the apparatus associated to the track. + * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. + * @param t pointer to an object of the class Trajectory, + * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). + * @return error flag. + */ +int Trajectory::DoTrack2(float* al){ + + double *dxout = new double[t->npoint]; + double *dyout = new double[t->npoint]; + double *dthxout = new double[t->npoint]; + double *dthyout = new double[t->npoint]; + double *dtlout = new double[t->npoint]; + double *dzin = new double[t->npoint]; + double dal[5]; + + int ifail = 0; + + for (int i=0; i<5; i++) dal[i] = (double)al[i]; + for (int i=0; inpoint; i++) dzin[i] = (double)z[i]; + + dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); + + for (int i=0; inpoint; i++){ + x[i] = (float)*dxout++; + y[i] = (float)*dyout++; + thx[i] = (float)*dthxout++; + thy[i] = (float)*dthyout++; + tl[i] = (float)*dtlout++; + } + + return ifail; +}; +//--------------------------------------------- +//--------------------------------------------- TrkTrack::TrkTrack(){ seqno = -1; image = -1; @@ -248,18 +286,24 @@ /** * Load the magnetic field */ -void TrkTrack::LoadField(TString s){ - readb_(s.Data()); +void TrkTrack::LoadField(TString path){ + + strcpy(path_.path,path.Data()); + path_.pathlen = path.Length(); + path_.error = 0; + readb_(); + }; /** * Tracking method. It calls F77 mini routine. */ void TrkTrack::Fit(double pfixed, int& fail, int iprint){ + + float al_ini[] = {0.,0.,0.,0.,0.}; + extern cMini2track track_; fail = 0; -// extern cMini2fitinfo fit_info_; -// extern void mini_2_(int*,int*); -// track_.xm[0]=1.0; + for(int i=0; i<6; i++) track_.xm[i]=xm[i]; for(int i=0; i<6; i++) track_.ym[i]=ym[i]; for(int i=0; i<6; i++) track_.zm[i]=zm[i]; @@ -267,45 +311,59 @@ for(int i=0; i<6; i++) track_.resy[i]=resy[i]; for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; + // initial guess of "al" with linear fit - if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ - double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; - double det, ax, ay, bx, by; - for(int i=0; i " << track_.al[4] << endl; @@ -328,9 +387,15 @@ for(int i=0; i<5; i++) { for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; } + + if(fail){ + cout << " >>>> fit failed >>>> drawing initial par"<