--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/11/27 15:28:57 1.42 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2008/10/22 15:17:36 1.47 @@ -60,13 +60,20 @@ ypu[ip] = 0; }; - + // 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]; @@ -186,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; }; @@ -230,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; }; @@ -299,7 +325,8 @@ return dedx; }; /** - * Returns 1 if the cluster on a tracker view includes bad strips. + * 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) */ @@ -630,6 +657,9 @@ 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 "<0 define an inner fiducial volume) */ -Bool_t TrkTrack::IsInsideCavity(){ - float xmagntop, ymagntop, xmagnbottom, ymagnbottom; - xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.); - ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.); - xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.); - ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.); - if( xmagntop>XMAGNLOW && xmagntopYMAGNLOW && ymagntopXMAGNLOW && xmagnbottomYMAGNLOW && ymagnbottomXMAGNLOW && 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. @@ -923,7 +1044,7 @@ }; /** - * Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. + * 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) */ @@ -946,30 +1067,289 @@ /** * \brief Method to include a x-cluster to the track. * @param ip Tracker plane (0-5) - * @param clid Cluster ID (0,1,...) - * @param is Sensor (0-1, increasing y) + * @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 is){ - int il=0; //ladder (temporary) - bool bad=false; //ladder (temporary) - xgood[ip]=il*100000000+is*10000000+clid; +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. + */ +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(); // clx.Clear(); @@ -1029,11 +1414,13 @@ //-------------------------------------- TrkSinglet::TrkSinglet(){ // cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<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 *** @@ -1291,6 +1694,8 @@ 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); //----------------------------------------------------- @@ -1304,12 +1709,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); //----------------------------------------------------- new(sy[i]) TrkSinglet(*t_singlet); t_singlet->Clear(); }; + + delete t_track; delete t_singlet; @@ -1630,6 +2039,9 @@ TrkParams::Set(path,1); TrkParams::Load(1); + if( !TrkParams::IsLoaded(1) ){ + cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<