--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/03/15 12:17:10 1.29 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2009/02/03 10:14:27 1.52 @@ -12,11 +12,13 @@ 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_(); - 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 *); } //-------------------------------------- @@ -41,6 +43,8 @@ zm[ip] = 0; resx[ip] = 0; resy[ip] = 0; + tailx[ip] = 0; + taily[ip] = 0; xv[ip] = 0; yv[ip] = 0; zv[ip] = 0; @@ -48,11 +52,28 @@ ayv[ip] = 0; dedx_x[ip] = 0; dedx_y[ip] = 0; + multmaxx[ip] = 0; + multmaxy[ip] = 0; + seedx[ip] = 0; + seedy[ip] = 0; + xpu[ip] = 0; + ypu[ip] = 0; + }; - clx = 0; - cly = 0; -// clx = new TRefArray(6,0); //forse causa memory leak??? -// cly = new TRefArray(6,0); //forse causa memory leak??? + +// TrkParams::SetTrackingMode(); +// TrkParams::SetPrecisionFactor(); +// TrkParams::SetStepMin(); + TrkParams::SetMiniDefault(); + TrkParams::SetPFA(); + + int ngf = TrkParams::nGF; + for(int i=0; i>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead + * */ int TrkTrack::DoTrack(Trajectory* t){ + cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<npoint]; double *dyout = new double[t->npoint]; double *dzin = new double[t->npoint]; @@ -153,13 +209,13 @@ dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); for (int i=0; inpoint; i++){ - t->x[i] = (float)*dxout++; - t->y[i] = (float)*dyout++; + t->x[i] = (float)*(dxout+i); + t->y[i] = (float)*(dyout+i); } -// delete [] dxout; -// delete [] dyout; -// delete [] dzin; + delete [] dxout; + delete [] dyout; + delete [] dzin; return ifail; }; @@ -197,16 +253,19 @@ dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); for (int i=0; inpoint; i++){ - t->x[i] = (float)*dxout++; - t->y[i] = (float)*dyout++; - t->thx[i] = (float)*dthxout++; - t->thy[i] = (float)*dthyout++; - t->tl[i] = (float)*dtlout++; + t->x[i] = (float)*(dxout+i); + t->y[i] = (float)*(dyout+i); + t->thx[i] = (float)*(dthxout+i); + t->thy[i] = (float)*(dthyout+i); + t->tl[i] = (float)*(dtlout+i); } -// delete [] dxout; -// delete [] dyout; -// delete [] dzin; + delete [] dxout; + delete [] dyout; + delete [] dzin; + delete [] dthxout; + delete [] dthyout; + delete [] dtlout; return ifail; }; @@ -233,11 +292,225 @@ return def; }; // +/** + * 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 TrkTrack::GetDEDX(int ip, int iv){ + if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); + else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); + else { + cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<GetNX()+this->GetNY()); - return dedx; + Float_t dedx=0; + for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); + dedx = dedx/(GetNX()+GetNY()); + return dedx; +}; +/** + * 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 TrkTrack::IsBad(int ip,int iv){ + 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 << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<=0 && ip<6)return (dedx_x[ip]<0) ; + else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; + else { + cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<3)chiq=chiq/(GetNX()-3); + else chiq=0; + if(chiq==0)cout << " Float_t TrkTrack::GetChi2X() -- WARNING -- value not defined "<2)chiq=chiq/(GetNY()-2); + else chiq=0; + if(chiq==0)cout << " Float_t TrkTrack::GetChi2Y() -- WARNING -- value not defined "<3)lnl=lnl/(GetNX()-3); + else lnl=0; + if(lnl==0){ + cout << " Float_t TrkTrack::GetLnLX() -- WARNING -- value not defined "<2)lnl=lnl/(GetNY()-2); + else lnl=0; + if(lnl==0){ + cout << " Float_t TrkTrack::GetLnLY() -- WARNING -- value not defined "<5){ + cout << "Float_t TrkTrack::GetEffectiveAngle(int "< wrong input"< wrong input"<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){ + for(int i=0; i<6; i++) xgood[i]=*xg++; for(int i=0; i<6; i++) ygood[i]=*yg++; } @@ -303,8 +667,16 @@ // path_.error = 0; // readb_(); +// TrkParams::SetTrackingMode(); +// TrkParams::SetPrecisionFactor(); +// TrkParams::SetStepMin(); + TrkParams::SetMiniDefault(); + TrkParams::Set(path,1); TrkParams::Load(1); + if( !TrkParams::IsLoaded(1) ){ + cout << "void TrkTrack::LoadField(TString path) --- ERROR --- m.field not loaded"< 1 || ip < 0 || ip > 5 || il < 0 || il > 2) && + true){ + // se il piano risulta colpito, ladder e sensore devono essere + // assegnati correttamente + cout << " void TrkTrack::FillMiniStruct(cMini2track&) --- WARNING --- sensor not defined, cannot read alignment parameters "<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, the minimum number of step, etc. + * @see SetTrackingMode(int) + * @see SetPrecisionFactor(double) + * @see SetStepMin(int) + * @see SetDeltaB(int,double) + */ +void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ + + bool OK=true; + TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "void TrkTrack::Fit(double,int&,int,int) ---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 "<0 define an inner fiducial volume) + */ +Bool_t TrkTrack::IsInsideCavity(float toll){ +// float xmagntop, ymagntop, xmagnbottom, ymagnbottom; +// xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.); +// ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*ayv[0]/180.); +// xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*axv[5]/180.); +// ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.); +// if( xmagntop>XMAGNLOW && xmagntopYMAGNLOW && ymagntopXMAGNLOW && xmagnbottomYMAGNLOW && ymagnbottom= TrkParams::xGF_max[i] - toll || + yGF[i] <= TrkParams::yGF_min[i] + toll || + yGF[i] >= TrkParams::yGF_max[i] - toll || + false){ + + return false; + } + } + return true; + + +} +/** + * Returns true if the track is inside the nominal acceptance, which is defined + * by the intersection among magnet cavity, silicon-plane sensitive area and + * ToF sensitive area (nominal values from the official document used to + * calculate the geometrical factor) + */ +Bool_t TrkTrack::IsInsideAcceptance(){ + + int ngf = TrkParams::nGF; + for(int i=0; i= TrkParams::xGF_max[i] || + yGF[i] <= TrkParams::yGF_min[i] || + yGF[i] >= TrkParams::yGF_max[i] || + false)return false; + } + return true; + +} +/** + * Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. + * If no cluster is associated, ID=-1. + * @param ip Tracker plane (0-5) + */ +Int_t TrkTrack::GetClusterX_ID(int ip){ + return ((Int_t)fabs(xgood[ip]))%10000000-1; +}; +/** + * Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. + * If no cluster is associated, ID=-1. + * @param ip Tracker plane (0-5) + */ +Int_t TrkTrack::GetClusterY_ID(int ip){ + return ((Int_t)fabs(ygood[ip]))%10000000-1; +}; + +/** + * Method to retrieve the ladder (0-2, increasing x) traversed by the track on this plane. + * If no ladder is traversed (dead area) the metod retuns -1. + * @param ip Tracker plane (0-5) + */ +Int_t TrkTrack::GetLadder(int ip){ + if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; + if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; + return -1; +}; +/** + * Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. + * If no sensor is traversed (dead area) the metod retuns -1. * @param ip Tracker plane (0-5) */ -TrkCluster *TrkTrack::GetClusterX(int ip){ - cout << " TrkCluster *TrkTrack::GetClusterX(int ip) -- momentaneamente fuori servizio --"<< endl; - if(!clx)return NULL; - TrkCluster *pt = (TrkCluster*)(clx->At(ip)); - return pt; +Int_t TrkTrack::GetSensor(int ip){ + if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; + if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; + return -1; }; -/* - * Method to retrieve the Y-view clusters associated to the track. + +/** + * \brief Method to include a x-cluster to the track. * @param ip Tracker plane (0-5) + * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise ) + * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit) + * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit) + * @param bad True if the cluster contains bad strips + * @see Fit(double pfixed, int& fail, int iprint, int froml1) + */ +void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){ +// int il=0; //ladder (temporary) +// bool bad=false; //ladder (temporary) + if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1) + cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<5||clid<0||il<-1||il>2||is<-1||is>1) + cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<, evaluated from the first to the last hit x view. + */ +Float_t TrkTrack::GetXav(){ + + int first_plane = -1; + int last_plane = -1; + for(Int_t ip=0; ip<6; ip++){ + if( XGood(ip) && first_plane == -1 )first_plane = ip; + if( XGood(ip) && first_plane != -1 )last_plane = ip; + } + if( first_plane == -1 || last_plane == -1){ + return -100; + } + if( last_plane-first_plane+1 ==0 )return -100; + + Float_t av = 0; + for(int ip=first_plane; ip<=last_plane; ip++)av+=xv[ip]; + + return (av/(last_plane-first_plane+1)); +} +/** + * \brief Average Y + * Average value of , evaluated from the first to the last hit x view. */ -TrkCluster *TrkTrack::GetClusterY(int ip){ - cout << " TrkCluster *TrkTrack::GetClusterY(int ip) -- momentaneamente fuori servizio --"<< endl; - if(!cly)return NULL; - TrkCluster *pt = (TrkCluster*)(cly->At(ip)); - return pt; +Float_t TrkTrack::GetYav(){ + + int first_plane = -1; + int last_plane = -1; + for(Int_t ip=0; ip<6; ip++){ + if( XGood(ip) && first_plane == -1 )first_plane = ip; + if( XGood(ip) && first_plane != -1 )last_plane = ip; + } + if( first_plane == -1 || last_plane == -1){ + return -100; + } + if( last_plane-first_plane+1 ==0 )return -100; + + Float_t av = 0; + for(int ip=first_plane; ip<=last_plane; ip++)av+=yv[ip]; + + return (av/(last_plane-first_plane+1)); +} +/** + * \brief Average Z + * Average value of , evaluated from the first to the last hit x view. + */ +Float_t TrkTrack::GetZav(){ + + int first_plane = -1; + int last_plane = -1; + for(Int_t ip=0; ip<6; ip++){ + if( XGood(ip) && first_plane == -1 )first_plane = ip; + if( XGood(ip) && first_plane != -1 )last_plane = ip; + } + if( first_plane == -1 || last_plane == -1){ + return -100; + } + if( last_plane-first_plane+1 ==0 )return -100; + + Float_t av = 0; + for(int ip=first_plane; ip<=last_plane; ip++)av+=zv[ip]; + + return (av/(last_plane-first_plane+1)); +} + +/** + * \brief Number of column traversed + */ +Int_t TrkTrack::GetNColumns(){ + int sensors[] = {0,0,0,0,0,0}; + for(int ip=0; ip<6; ip++){ + int sensorid = GetLadder(ip)+3*GetSensor(ip); + if(XGood(ip)||YGood(ip)) + if(sensorid>=0 && sensorid<6)sensors[sensorid]=1; + } + int nsensors=0; + for(int is=0; is<6; is++)nsensors += sensors[is]; + return nsensors; +}; +/** + * \brief Give the maximum energy release + */ +Float_t TrkTrack::GetDEDX_max(int ip, int iv){ + Float_t max=0; + int pfrom = 0; + int pto = 6; + int vfrom = 0; + int vto = 2; + if(ip>=0&&ip<6){ + pfrom = ip; + pto = ip+1; + } + if(iv>=0&&iv<2){ + vfrom = iv; + vto = iv+1; + } + for(int i=pfrom; imax)max=GetDEDX(i,j); + if(j==1 && YGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j); + } + return max; + +}; + +/** + * \brief Give the minimum energy release + */ +Float_t TrkTrack::GetDEDX_min(int ip, int iv){ + Float_t min=100000000; + int pfrom = 0; + int pto = 6; + int vfrom = 0; + int vto = 2; + if(ip>=0&&ip<6){ + pfrom = ip; + pto = ip+1; + } + if(iv>=0&&iv<2){ + vfrom = iv; + vto = iv+1; + } + for(int i=pfrom; i=0&&ip<6){ + pfrom = ip; + pto = ip+1; + } + if(iv>=0&&iv<2){ + vfrom = iv; + vto = iv+1; + } + for(int i=pfrom; ifabs(max))max=xm[i]-xv[i]; + if(j==1 && YGood(i) && fabs(ym[i]-yv[i])>fabs(max))max=ym[i]-yv[i]; + } + } + return max; + +}; +/** + * \brief Give the anerage spatial residual + */ +Float_t TrkTrack::GetResidual_av(int ip, int iv){ + // +//Sum$((xm>-50)*(xm-xv)/resx)/sqrt(TrkTrack.GetNX()*TrkTrack.GetChi2X())<0.3 + + Float_t av = 0.; + int nav = 0; + // + int pfrom = 0; + int pto = 6; + int vfrom = 0; + int vto = 2; + if(ip>=0&&ip<6){ + pfrom = ip; + pto = ip+1; + } + if(iv>=0&&iv<2){ + vfrom = iv; + vto = iv+1; + } + for(int i=pfrom; imax)max=GetClusterX_Multiplicity(ip); + return max; +}; +/** + * \brief Give the minimum multiplicity on the x view + */ +Int_t TrkTrack::GetClusterX_Multiplicity_min(){ + int min=50; + for(int ip=0; ip<6; ip++) + if(GetClusterX_Multiplicity(ip)max)max=GetClusterY_Multiplicity(ip); + return max; +}; +/** + * \brief Give the minimum multiplicity on the x view + */ +Int_t TrkTrack::GetClusterY_Multiplicity_min(){ + int min=50; + for(int ip=0; ip<6; ip++) + if(GetClusterY_Multiplicity(ip)Clear(); - if(cly)cly->Clear(); + int ngf = TrkParams::nGF; + for(int i=0; iClear(); +// if(cly)cly->Clear(); +// clx.Clear(); +// cly.Clear(); }; //-------------------------------------- // @@ -519,9 +1416,9 @@ //-------------------------------------- void TrkTrack::Delete(){ // cout << "TrkTrack::Delete()"<ntrk() ; - cout << endl << "nclsx() : " << this->nclsx(); - cout << endl << "nclsy() : " << this->nclsy(); -// TClonesArray &t = *Track; -// TClonesArray &sx = *SingletX; -// TClonesArray &sy = *SingletY; -// for(int i=0; iDump(); -// for(int i=0; iDump(); -// for(int i=0; iDump(); + cout << endl << "good : "; for(int i=0; i<12; i++) cout << hex <<" 0x"<< good[i]<Dump(); } - if(SingletX){ - TClonesArray &sx = *SingletX; - for(int i=0; iDump(); - } - if(SingletY){ - TClonesArray &sy = *SingletY; - for(int i=0; iDump(); - } +// if(SingletX){ +// TClonesArray &sx = *SingletX; +// for(int i=0; iDump(); +// } +// if(SingletY){ +// TClonesArray &sy = *SingletY; +// for(int i=0; iDump(); +// } + cout << endl; } +/** + * \brief Dump processing status + */ +void TrkLevel2::StatusDump(int view){ + cout << "DSP n. "<= 12)return false; + return !(good[view]&flagmask); + +}; + + //-------------------------------------- // // //-------------------------------------- /** - * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). - */ -// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ - -// // temporary objects: -// TrkSinglet* t_singlet = new TrkSinglet(); -// TrkTrack* t_track = new TrkTrack(); - -// // **** general variables **** -// // good2 = l2->good2; -// for(Int_t i=0; i<12 ; i++){ -// // crc[i] = l2->crc[i]; -// good[i] = l2->good[i]; -// }; -// // *** TRACKS *** -// if(!Track) Track = new TClonesArray("TrkTrack"); -// TClonesArray &t = *Track; -// for(int i=0; intrk; i++){ -// t_track->seqno = i;// NBNBNBNB deve sempre essere = i -// t_track->image = l2->image[i]-1; -// // cout << "track "<seqno << t_track->image<chi2 = l2->chi2_nt[i]; -// t_track->nstep = l2->nstep_nt[i]; -// for(int it1=0;it1<5;it1++){ -// t_track->al[it1] = l2->al_nt[i][it1]; -// for(int it2=0;it2<5;it2++) -// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; -// }; -// for(int ip=0;ip<6;ip++){ -// t_track->xgood[ip] = l2->xgood_nt[i][ip]; -// t_track->ygood[ip] = l2->ygood_nt[i][ip]; -// t_track->xm[ip] = l2->xm_nt[i][ip]; -// t_track->ym[ip] = l2->ym_nt[i][ip]; -// t_track->zm[ip] = l2->zm_nt[i][ip]; -// t_track->resx[ip] = l2->resx_nt[i][ip]; -// t_track->resy[ip] = l2->resy_nt[i][ip]; -// t_track->xv[ip] = l2->xv_nt[i][ip]; -// t_track->yv[ip] = l2->yv_nt[i][ip]; -// t_track->zv[ip] = l2->zv_nt[i][ip]; -// t_track->axv[ip] = l2->axv_nt[i][ip]; -// t_track->ayv[ip] = l2->ayv_nt[i][ip]; -// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; -// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; -// // t_track->clx[ip] = 0; -// // t_track->cly[ip] = 0; -// }; -// new(t[i]) TrkTrack(*t_track); -// t_track->Clear(); -// }; -// // *** SINGLETS *** -// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); -// TClonesArray &sx = *SingletX; -// for(int i=0; inclsx; i++){ -// t_singlet->plane = l2->planex[i]; -// t_singlet->coord[0] = l2->xs[i][0]; -// t_singlet->coord[1] = l2->xs[i][1]; -// t_singlet->sgnl = l2->signlxs[i]; -// // t_singlet->cls = 0; -// new(sx[i]) TrkSinglet(*t_singlet); -// t_singlet->Clear(); -// } -// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); -// TClonesArray &sy = *SingletY; -// for(int i=0; inclsy; i++){ -// t_singlet->plane = l2->planey[i]; -// t_singlet->coord[0] = l2->ys[i][0]; -// t_singlet->coord[1] = l2->ys[i][1]; -// t_singlet->sgnl = l2->signlys[i]; -// // t_singlet->cls = 0; -// new(sy[i]) TrkSinglet(*t_singlet); -// t_singlet->Clear(); -// }; - -// delete t_track; -// delete t_singlet; -// } + * The method returns false if the viking-chip was masked + * either apriori ,on the basis of the mask read from the DB, + * or run-by-run, on the basis of the calibration parameters) + * @param iv Tracker view (0-11) + * @param ivk Viking-chip number (0-23) + */ +Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ + Int_t whichbit = (Int_t)pow(2,ivk); + return (whichbit&VKmask[iv])!=0; +} +/** + * The method returns false if the viking-chip was masked + * for this event due to common-noise computation failure. + * @param iv Tracker view (0-11) + * @param ivk Viking-chip number (0-23) + */ +Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ + Int_t whichbit = (Int_t)pow(2,ivk); + return (whichbit&VKflag[iv])!=0; +} +/** + * The method returns true if the viking-chip was masked, either + * forced (see TrkLevel2::GetVKMask(int,int)) or + * for this event only (TrkLevel2::GetVKFlag(int,int)). + * @param iv Tracker view (0-11) + * @param ivk Viking-chip number (0-23) + */ +Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ + return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); +}; + //-------------------------------------- // // @@ -729,6 +1607,7 @@ // cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<good[i]; + VKmask[i]=0; + VKflag[i]=0; + for(Int_t ii=0; ii<24 ; ii++){ + Int_t setbit = (Int_t)pow(2,ii); + if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; + if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; + }; }; // -------------- // *** TRACKS *** // -------------- if(!Track) Track = new TClonesArray("TrkTrack"); TClonesArray &t = *Track; - //----------------------------------------------------- - if( l1 && !t_track->clx )t_track->clx = new TRefArray(6,0); - if( l1 && !t_track->cly )t_track->cly = new TRefArray(6,0); - //----------------------------------------------------- + for(int i=0; intrk; i++){ -// cout <<" TRACK "<seqno = i;// NBNBNBNB deve sempre essere = i t_track->image = l2->image[i]-1; t_track->chi2 = l2->chi2_nt[i]; @@ -760,13 +1642,30 @@ t_track->coval[it1][it2] = l2->coval[i][it2][it1]; }; for(int ip=0;ip<6;ip++){ - t_track->xgood[ip] = l2->cltrx[i][ip];//l2->xgood_nt[i][ip]; - t_track->ygood[ip] = l2->cltry[i][ip];//l2->ygood_nt[i][ip]; + // --------------------------------- + // new implementation of xgood/ygood + // --------------------------------- + t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID + t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID + t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor + t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor + if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; + if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; +// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ +// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ +// cout << ip << " - "<< l2->cltrx[i][ip] << " "<cltry[i][ip]<<" "<ls[i][ip]<xgood[ip]<<" "<ygood[ip]<GetClusterX_ID(ip)<<" "<GetClusterY_ID(ip)<<" "<GetLadder(ip)<<" "<GetSensor(ip)<BadClusterX(ip)<<" "<BadClusterY(ip)<SaturatedClusterX(ip)<<" "<SaturatedClusterY(ip)<xm[ip] = l2->xm_nt[i][ip]; t_track->ym[ip] = l2->ym_nt[i][ip]; t_track->zm[ip] = l2->zm_nt[i][ip]; t_track->resx[ip] = l2->resx_nt[i][ip]; t_track->resy[ip] = l2->resy_nt[i][ip]; + t_track->tailx[ip] = l2->tailx[i][ip]; + t_track->taily[ip] = l2->taily[i][ip]; t_track->xv[ip] = l2->xv_nt[i][ip]; t_track->yv[ip] = l2->yv_nt[i][ip]; t_track->zv[ip] = l2->zv_nt[i][ip]; @@ -774,38 +1673,34 @@ t_track->ayv[ip] = l2->ayv_nt[i][ip]; t_track->dedx_x[ip] = l2->dedx_x[i][ip]; t_track->dedx_y[ip] = l2->dedx_y[i][ip]; -// cout << " ip "<cltrx[i][ip] "<< l2->cltrx[i][ip]<cltry[i][ip] "<< l2->cltry[i][ip]<multmaxx[ip] = l2->multmaxx[i][ip]; + t_track->multmaxy[ip] = l2->multmaxy[i][ip]; + t_track->seedx[ip] = l2->seedx[i][ip]; + t_track->seedy[ip] = l2->seedy[i][ip]; + t_track->xpu[ip] = l2->xpu[i][ip]; + t_track->ypu[ip] = l2->ypu[i][ip]; //----------------------------------------------------- //----------------------------------------------------- -// if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); -// if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); - if(l2->xgood_nt[i][ip]){ -// cout << " ip "<cltrx[i][ip] "<< l2->cltrx[i][ip]<cltrx[i][ip] "<< l2->cltrx[i][ip]<<" "; -// if( l1->GetCluster(l2->cltrx[i][ip]-1)->TestBit(l1->GetCluster(l2->cltrx[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; - if(l1)t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); -// cout << " --- "<GetCluster(l2->cltrx[i][ip]-1)->GetUniqueID()<xgood[ip] = l2->cltrx[i][ip]; // WORK-AROUND ***** - }else{ - if(l1)t_track->clx->RemoveAt(ip); - } - if(l2->ygood_nt[i][ip]){ -// cout << " ip "<cltry[i][ip] "<< l2->cltry[i][ip]<cltry[i][ip] "<< l2->cltry[i][ip]<<" "; -// if( l1->GetCluster(l2->cltry[i][ip]-1)->TestBit(l1->GetCluster(l2->cltry[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; - if(l1)t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); -// cout << " --- "<GetCluster(l2->cltry[i][ip]-1)->GetUniqueID()<ygood[ip] = l2->cltry[i][ip]; // WORK-AROUND ***** - }else{ - if(l1)t_track->cly->RemoveAt(ip); - } //----------------------------------------------------- //----------------------------------------------------- }; + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // evaluated coordinates (to define GF) + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + int ngf = TrkParams::nGF; + float *zgf = TrkParams::zGF; + Trajectory tgf = Trajectory(ngf,zgf); + tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory + for(int ip=0; ipxGF[ip] = tgf.x[ip]; + t_track->yGF[ip] = tgf.y[ip]; + } + +// if(t_track->IsSaturated())t_track->Dump(); new(t[i]) TrkTrack(*t_track); t_track->Clear(); - }; + };//end loop over track + // ---------------- // *** SINGLETS *** // ---------------- @@ -816,8 +1711,10 @@ t_singlet->coord[0] = l2->xs[i][0]; t_singlet->coord[1] = l2->xs[i][1]; t_singlet->sgnl = l2->signlxs[i]; + t_singlet->multmax = l2->multmaxsx[i]; + if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax; //----------------------------------------------------- - if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); +// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); //----------------------------------------------------- new(sx[i]) TrkSinglet(*t_singlet); t_singlet->Clear(); @@ -829,12 +1726,16 @@ t_singlet->coord[0] = l2->ys[i][0]; t_singlet->coord[1] = l2->ys[i][1]; t_singlet->sgnl = l2->signlys[i]; + t_singlet->multmax = l2->multmaxsy[i]; + if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax; //----------------------------------------------------- - if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); +// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); //----------------------------------------------------- new(sy[i]) TrkSinglet(*t_singlet); t_singlet->Clear(); }; + + delete t_track; delete t_singlet; @@ -865,13 +1766,15 @@ l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; }; for(int ip=0;ip<6;ip++){ - l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; - l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; + l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); + l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; + l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; + l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; @@ -910,6 +1813,8 @@ void TrkLevel2::Clear(){ for(Int_t i=0; i<12 ; i++){ good[i] = -1; + VKflag[i] = 0; + VKmask[i] = 0; }; // if(Track)Track->Clear("C"); // if(SingletX)SingletX->Clear("C"); @@ -943,7 +1848,8 @@ if(!Track)return 0; - TRefArray *sorted = new TRefArray(); + // TRefArray *sorted = new TRefArray(); + TRefArray *sorted = NULL; TClonesArray &t = *Track; // TClonesArray &ts = *PhysicalTrack; @@ -981,6 +1887,7 @@ // cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<Add( (TrkTrack*)t[indi] ); m[indi] = 0; @@ -1006,8 +1913,8 @@ TrkTrack *TrkLevel2::GetStoredTrack(int is){ if(is >= this->ntrk()){ - cout << "** TrkLevel2 ** Track "<< is << "doen not exits! " << endl; - cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; + cout << "TrkTrack *TrkLevel2::GetStoredTrack(int) >> Track "<< is << "doen not exits! " << endl; + cout << "Stored tracks ntrk() = "<< this->ntrk() << endl; return 0; } if(!Track){ @@ -1028,8 +1935,8 @@ TrkSinglet *TrkLevel2::GetSingletX(int is){ if(is >= this->nclsx()){ - cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; - cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; + cout << "TrkSinglet *TrkLevel2::GetSingletX(int) >> Singlet "<< is << "doen not exits! " << endl; + cout << "Stored x-singlets nclsx() = "<< this->nclsx() << endl; return 0; } if(!SingletX)return 0; @@ -1048,8 +1955,8 @@ TrkSinglet *TrkLevel2::GetSingletY(int is){ if(is >= this->nclsy()){ - cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; - cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; + cout << "TrkSinglet *TrkLevel2::GetSingletY(int) >> Singlet "<< is << "doen not exits! " << endl; + cout << "Stored y-singlets nclsx() = "<< this->nclsx() << endl; return 0; } if(!SingletY)return 0; @@ -1069,8 +1976,8 @@ TrkTrack *TrkLevel2::GetTrack(int it){ if(it >= this->GetNTracks()){ - cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; - cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; + cout << "TrkTrack *TrkLevel2::GetTrack(int) >> Track "<< it << "does not exits! " << endl; + cout << "Physical tracks GetNTracks() = "<< this->ntrk() << endl; return 0; } @@ -1107,8 +2014,8 @@ TrkTrack *TrkLevel2::GetTrackImage(int it){ if(it >= this->GetNTracks()){ - cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; - cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; + cout << "TrkTrack *TrkLevel2::GetTrackImage(int) >> Track "<< it << "does not exits! " << endl; + cout << "Physical tracks GetNTracks() = "<< this->ntrk() << endl; return 0; } @@ -1117,7 +2024,7 @@ TrkTrack *track = (TrkTrack*)sorted->At(it); if(!track->HasImage()){ - cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; + cout << "TrkTrack *TrkLevel2::GetTrackImage(int) >> Track "<< it << "does not have image! " << endl; return 0; } if(!Track)return 0; @@ -1144,38 +2051,46 @@ // path_.error = 0; // readb_(); +// TrkParams::SetTrackingMode(); +// TrkParams::SetPrecisionFactor(); +// TrkParams::SetStepMin(); + TrkParams::SetMiniDefault(); + TrkParams::Set(path,1); TrkParams::Load(1); + if( !TrkParams::IsLoaded(1) ){ + cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<