--- DarthVader/TrackerLevel2/src/ExtTrack.cpp 2014/02/27 11:24:43 1.1 +++ DarthVader/TrackerLevel2/src/ExtTrack.cpp 2016/02/26 12:03:36 1.9 @@ -6,200 +6,618 @@ #include #include using namespace std; -//...................................... -// F77 routines -//...................................... -extern "C" { -// void dotrack_(int*, double*, double*, double*, double*, int*); -// void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); -// void dotrack3_(int*, double*, double*, double*, double*,double*, double*, double*,double*,int*); -// void mini2_(int*,int*,int*); -// void guess_(); -// void gufld_(float*, float*); -// float risxeta2_(float *); -// float risxeta3_(float *); -// float risxeta4_(float *); -// float risyeta2_(float *); -} +ExtTrack::ExtTrack(int dim){ + + //cout << " ExtTrack::ExtTrack("< 1 || ip < 0 || ippp > 5 || il < 0 || il > 2) && + true){ + cout << " void ExtTrack::FillMiniStruct(TrkTrack&) --- WARNING ---trk sensor not defined, cannot read alignment parameters "<=nplanes){ + cout << " ExtTrack::SetZ("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::ResetXY("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::SetXY("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::SetX("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::SetX("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::SetXGood("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::SetYGood("< exceed vector dimension = "<0. ? 1./sqrt(coval[4][4]) : 0. ) ; cout << endl << "dedx_x : "; for(int i=0; i>>> fit failed "<al[i]); + for(int j=0; j<5; j++) coval[i][j] = (float) (track->cov[i][j]); + } + chi2 = (float) (track->chi2); + nstep = (float) (track->nstep); for(int i=0; ixv[i]); + yv[i] = (float) (track->yv[i]); + zv[i] = (float) (track->zv[i]); + xm[i] = (float) (track->xm[i]); + ym[i] = (float) (track->ym[i]); + zm[i] = (float) (track->zm[i]); + xma[i] = (float) (track->xm_a[i]); + yma[i] = (float) (track->ym_a[i]); + zma[i] = (float) (track->zm_a[i]); + xmb[i] = (float) (track->xm_b[i]); + ymb[i] = (float) (track->ym_b[i]); + zmb[i] = (float) (track->zm_b[i]); + axv[i] = (float) (track->axv[i]); + ayv[i] = (float) (track->ayv[i]); + } + zini = (float) (track->zini); +} +/** + * Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. + * If no cluster is associated, ID=-1. + * + */ +int ExtTrack::GetClusterX_ID(int ip){ + if(ip<0 || ip>=nplanes)return -1; + return ((int)fabs(xgood[ip]))%10000000-1; +}; +/** + * Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. + * + */ +int ExtTrack::GetClusterY_ID(int ip){ + if(ip<0 || ip>=nplanes)return -1; + return ((int)fabs(ygood[ip]))%10000000-1; +}; - track.xgood[i]=XGood(i); - track.ygood[i]=YGood(i); - - track.xm[i]=xm[i]; - track.ym[i]=ym[i]; - track.zm[i]=zm[i]; - - float segment = 100.; //temporaneo - track.xm_a[i]=xm[i]; - track.xm_b[i]=xm[i]; - track.ym_a[i]=ym[i]; - track.ym_b[i]=ym[i]; - if( XGood(i) && !YGood(i) ){ - track.ym_a[i] = track.ym_a[i]+segment; - track.ym_b[i] = track.ym_b[i]-segment; - }else if( !XGood(i) && YGood(i)){ - track.xm_a[i] = track.xm_a[i]+segment; - track.xm_b[i] = track.xm_b[i]-segment; - } +/** + * Method to retrieve the dE/dx measured on a tracker view. + * @param ip plane (0-5) + * @param iv view (0=x 1=y) + */ +Float_t ExtTrack::GetDEDX(int ip, int iv){ + if(iv==0 && ip>=0 && ip=0 && ip0)return dedx/np; + return -1; +}; +/** + * Method to evaluate the dE/dx averaged over all Y views. + */ +Float_t ExtTrack::GetDEDXY(bool cutSat){ + Float_t dedx=0; + Int_t np=0; + for(Int_t ip=0; ip0)return dedx/np; + return -1; +}; + +/** + * Returns 1 if the cluster on a tracker view includes bad strips + * (at least one bad strip among the four strip used by p.f.a.) + * @param ip plane (0-5) + * @param iv view (0=x 1=y) + */ +Bool_t ExtTrack::IsBad(int ip,int iv){ + if(ip>=6&&ip<8)return false; + if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; + else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; + else { + cout << "ExtTrack::IsBad(int ip, int iv) -- wrong input parameters "<=nplanes){ + cout << " ExtTrack::GetClusterX_Multiplicity("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::GetClusterY_Multiplicity("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::GetClusterX_MaxStrip("< exceed vector dimension = "<=nplanes){ + cout << " ExtTrack::GetClusterY_MaxStrip("< exceed vector dimension = "<0)rig=1./al[4]; + if(rig<0) rig=-rig; + return rig; +}; +// +Float_t ExtTrack::GetDeflection(){ + Float_t def=0; + if(chi2>0)def=al[4]; + return def; +}; - track.zini = 55.; -// track.zini = 23.5; -// ZINI = 23.5 !!! it should be the same parameter in all codes +// +// all that follows: EM porting from TrkLevel2 +// +Bool_t ExtTrack::IsInsideAcceptance(float toll){ + int ngf = TrkParams::nGF; + float* zgf = TrkParams::zGF; + //this is a patch, to assign correctly xGF and yGF cordinates. + + Trajectory tj = Trajectory(ngf,zgf); + tj.DoTrack(al,zini); + + //NB the folowing assignment is NOT permanent!!! + for(int i=0; i<14; i++){ + xGF[i] = tj.x[i]; + yGF[i] = tj.y[i]; + } + + for(int i=0; i= TrkParams::xGF_max[i] - toll || +// yGF[i] <= TrkParams::yGF_min[i] + toll || +// yGF[i] >= TrkParams::yGF_max[i] - toll || + tj.x[i] <= TrkParams::xGF_min[i] + toll || + tj.x[i] >= TrkParams::xGF_max[i] - toll || + tj.y[i] <= TrkParams::yGF_min[i] + toll || + tj.y[i] >= TrkParams::yGF_max[i] - toll || + false){ + + return false; + } + } + return true; } + /** - * Method to set values from minimization-routine common + * Returns the reduced chi-square of track x-projection + */ +Float_t ExtTrack::GetChi2X(){ + float chiq=0; + for(int ip=0; ip3)chiq=chiq/(GetNX()-3); + else chiq=0; + // if(chiq==0)cout << " Float_t ExtTrack::GetChi2X() -- WARNING -- value not defined "<2)chiq=chiq/(GetNY()-2); + else chiq=0; + // if(chiq==0)cout << " Float_t ExtTrack::GetChi2Y() -- WARNING -- value not defined "<al[i]; - for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; +/** + * Returns the track "lever-arm" on the x view, defined as the distance (in planes) between + * the upper and lower x measurements (the maximum value of lever-arm is 6). + */ +Int_t ExtTrack::GetLeverArmX(){ + int first_plane = -1; + int last_plane = -1; + for(Int_t ip=0; ipchi2; - nstep = track->nstep; - for(int i=0; i<6; i++){ - xv[i] = track->xv[i]; - yv[i] = track->yv[i]; - zv[i] = track->zv[i]; - xm[i] = track->xm[i]; - ym[i] = track->ym[i]; - zm[i] = track->zm[i]; - axv[i] = track->axv[i]; - ayv[i] = track->ayv[i]; + if( first_plane == -1 || last_plane == -1){ + cout<< "Int_t ExtTrack::GetLeverArmX() -- XGood(ip) always false ??? "<=6 && ip<8)return false; + if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; + else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; + else { + cout << "ExtTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<