--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/04/27 10:39:57 1.32 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/05/24 13:29:09 1.34 @@ -12,9 +12,13 @@ extern "C" { void dotrack_(int*, double*, double*, double*, double*, int*); void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); - void mini2_(int*,int*,int*); - void guess_(); - void gufld_(float*, float*); + void mini2_(int*,int*,int*); + void guess_(); + void gufld_(float*, float*); + float risxeta2_(float *); + float risxeta3_(float *); + float risxeta4_(float *); + float risyeta2_(float *); } //-------------------------------------- @@ -56,6 +60,11 @@ // clx = TRefArray(6,0); // cly = TRefArray(6,0); + TrkParams::SetTrackingMode(); + TrkParams::SetPrecisionFactor(); + TrkParams::SetStepMin(); + TrkParams::SetPFA(); + }; //-------------------------------------- // @@ -95,6 +104,11 @@ // clx = TRefArray(t.clx); // cly = TRefArray(t.cly); + TrkParams::SetTrackingMode(); + TrkParams::SetPrecisionFactor(); + TrkParams::SetStepMin(); + TrkParams::SetPFA(); + }; //-------------------------------------- // @@ -372,6 +386,8 @@ 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 << "tailx : "; for(int i=0; i<6; i++)cout << tailx[i] << " "; + cout << endl << "taily : "; for(int i=0; i<6; i++)cout << taily[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]<<" "; @@ -397,10 +413,89 @@ for(int i=0; i<6; i++) resy[i]=*ry++; } /** + * Set the TrkTrack tails position resolution + */ +void TrkTrack::SetTail(double *tx, double *ty, double factor){ + for(int i=0; i<6; i++) tailx[i]=factor*(*tx++); + for(int i=0; i<6; i++) taily[i]=factor*(*ty++); +} +/** + * Set the TrkTrack Student parameter (resx,resy,tailx,taily) + * from previous gausian fit + *@param flag =0 standard, =1 with noise correction + */ +void TrkTrack::SetStudentParam(int flag){ + float sx[11]={0.000128242, + 0.000136942, + 0.000162718, + 0.000202644, + 0.00025597, + 0.000317456, + 0.000349048, + 0.000384638, + 0.000457295, + 0.000512319, + 0.000538573}; + float tx[11]={1.79402, + 2.04876, + 2.88376, + 3.3, + 3.14084, + 4.07686, + 4.44736, + 3.5179, + 3.38697, + 3.45739, + 3.18627}; + float sy[11]={0.000483075, + 0.000466925, + 0.000431658, + 0.000428317, + 0.000433854, + 0.000444044, + 0.000482098, + 0.000537579, + 0.000636279, + 0.000741998, + 0.000864261}; + float ty[11]={0.997032, + 1.11147, + 1.18526, + 1.61404, + 2.21908, + 3.08959, + 4.48833, + 4.42687, + 4.65253, + 4.52043, + 4.29926}; + int index; + float fact; + for(int i=0; i<6; i++) { + index = int((fabs(axv[i])+1.)/2.); + if(index>10) index=10; + tailx[i]=tx[index]; + if(flag==1) { + if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i])); + if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i])); + if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i])); + } else fact = 1.; + resx[i] = sx[index]*fact; + } + for(int i=0; i<6; i++) { + index = int((fabs(ayv[i])+1.)/2.); + if(index>10) index=10; + taily[i]=ty[index]; + if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i])); + else fact = 1.; + resy[i] = sy[index]*fact; + } +} +/** * Set the TrkTrack good measurement */ void TrkTrack::SetGood(int *xg, int *yg){ - // NB! si perdera` l'informazione sul numero del cluster + for(int i=0; i<6; i++) xgood[i]=*xg++; for(int i=0; i<6; i++) ygood[i]=*yg++; } @@ -415,6 +510,10 @@ // path_.error = 0; // readb_(); + TrkParams::SetTrackingMode(); + TrkParams::SetPrecisionFactor(); + TrkParams::SetStepMin(); + TrkParams::Set(path,1); TrkParams::Load(1); @@ -428,8 +527,8 @@ for(int i=0; i<6; i++){ -// track.xgood[i]=xgood[i]; -// track.ygood[i]=ygood[i]; +// cout << i<<" - "<GetTrkLevel0() )return false; + * event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 + * int fail=0; + * event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); + * + * @see EvaluateClusterPositions() + * + * The fitting procedure can be varied by changing the tracking mode, + * the fit-precision factor and the minimum number of step. + * @see SetTrackingMode(int) + * @see SetPrecisionFactor(double) + * @see SetStepMin(int) + */ +void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ float al_ini[] = {0.,0.,0.,0.,0.}; + TrkParams::Load( ); + if( !TrkParams::IsLoaded() )return; + extern cMini2track track_; fail = 0; FillMiniStruct(track_); - + + if(froml1!=0)EvaluateClusterPositions(); + // if fit variables have been reset, evaluate the initial guess if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); @@ -514,11 +695,11 @@ // ------------------------------------------ // call mini routine - TrkParams::Load(1); - if( !TrkParams::IsLoaded(1) ){ - cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"< " << 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){ - if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<>>> fit failed "<