--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2006/10/24 07:28:38 1.12 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2006/11/07 15:55:11 1.15 @@ -4,6 +4,7 @@ */ #include #include +#include using namespace std; //...................................... // F77 routines @@ -12,6 +13,8 @@ void dotrack_(int*, double*, double*, double*, double*, int*); void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); int readb_(const char*); + void mini2_(int*,int*,int*); + void guess_(); } //-------------------------------------- // @@ -21,10 +24,10 @@ seqno = -1; image = -1; chi2 = 0; - nstep = 0; - for(int it1=0;it1<5;it1++){ - al[it1] = 0; - for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; + nstep = 0; + for(int it1=0;it1<5;it1++){ + al[it1] = 0; + for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; }; for(int ip=0;ip<6;ip++){ xgood[ip] = 0; @@ -55,10 +58,10 @@ seqno = t.seqno; image = t.image; chi2 = t.chi2; - nstep = t.nstep; - for(int it1=0;it1<5;it1++){ - al[it1] = t.al[it1]; - for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; + nstep = t.nstep; + for(int it1=0;it1<5;it1++){ + al[it1] = t.al[it1]; + for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; }; for(int ip=0;ip<6;ip++){ xgood[ip] = t.xgood[ip]; @@ -196,19 +199,182 @@ //-------------------------------------- void TrkTrack::Dump(){ cout << endl << "========== Track " ; - cout << endl << "seq. n. : "<< seqno; - cout << endl << "image n. : "<< image; - cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; + cout << endl << "seq. n. : "<< seqno; + cout << endl << "image n. : "<< image; + cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; cout << endl << "chi^2 : "<< chi2; - cout << endl << "n.step : "<< nstep; - cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; + cout << endl << "n.step : "<< nstep; + cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; + cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; + cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; + cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; + cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; + cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; + cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; + cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; + cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; + cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; + cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; + cout << endl; +} +/** + * Set the TrkTrack position measurements + */ +void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ + for(int i=0; i<6; i++) xm[i]=*xmeas++; + for(int i=0; i<6; i++) ym[i]=*ymeas++; + for(int i=0; i<6; i++) zm[i]=*zmeas++; +} +/** + * Set the TrkTrack position resolution + */ +void TrkTrack::SetResolution(double *rx, double *ry){ + for(int i=0; i<6; i++) resx[i]=*rx++; + for(int i=0; i<6; i++) resy[i]=*ry++; } +/** + * Set the TrkTrack good measurement + */ +void TrkTrack::SetGood(int *xg, int *yg){ + for(int i=0; i<6; i++) xgood[i]=*xg++; + for(int i=0; i<6; i++) ygood[i]=*yg++; +} + +/** + * Load the magnetic field + */ +void TrkTrack::LoadField(TString s){ + readb_(s.Data()); +}; +/** + * 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; + + cout << "fitting routine "< " << track_.al[4] << endl; + + for(int i=0; i<5; i++) al[i]=track_.al[i]; + chi2=track_.chi2; + nstep=track_.nstep; + for(int i=0; i<6; i++) xv[i]=track_.xv[i]; + for(int i=0; i<6; i++) yv[i]=track_.yv[i]; + for(int i=0; i<6; i++) zv[i]=track_.zv[i]; + for(int i=0; i<6; i++) axv[i]=track_.axv[i]; + for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; + 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"<