--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2006/09/28 14:04:39 1.10 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2006/10/27 16:59:20 1.14 @@ -4,6 +4,7 @@ */ #include #include +#include using namespace std; //...................................... // F77 routines @@ -11,7 +12,8 @@ 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*); + void mini2_(int*,int*,int*); } //-------------------------------------- // @@ -21,10 +23,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 +57,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 +198,154 @@ //-------------------------------------- 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){ + 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]; + for(int i=0; i<6; i++) track_.resx[i]=resx[i]; + 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; + + 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]; + } +}; +/* + * Reset the parameters fit + */ +void TrkTrack::FitReset(){ + for(int i=0; i<5; i++) al[i]=-9999.; + chi2=0.; + nstep=0; + for(int i=0; i<6; i++) xv[i]=0.; + for(int i=0; i<6; i++) yv[i]=0.; + for(int i=0; i<6; i++) zv[i]=0.; + for(int i=0; i<6; i++) axv[i]=0.; + for(int i=0; i<6; i++) ayv[i]=0.; + for(int i=0; i<5; i++) { + for(int j=0; j<5; j++) coval[i][j]=0.; + } +} + //-------------------------------------- // // @@ -247,6 +384,15 @@ // // //-------------------------------------- +void TrkTrack::Delete(){ + Clear(); + clx->Delete(); + cly->Delete(); +}; + //-------------------------------------- +// +// +//-------------------------------------- //-------------------------------------- // @@ -569,6 +715,17 @@ // // //-------------------------------------- +void TrkLevel2::Delete(){ + + Clear(); + Track->Delete(); + SingletX->Delete(); + SingletY->Delete(); +} +//-------------------------------------- +// +// +//-------------------------------------- /** * Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). * This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. @@ -712,7 +869,7 @@ Float_t ntot=0; TClonesArray &t = *Track; - for(int i=0; iGetImageSeqNo() == -1 ) ntot+=1.; else ntot+=0.5; }