--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/08/31 14:56:51 1.40 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2009/02/03 10:14:27 1.52 @@ -60,12 +60,20 @@ ypu[ip] = 0; }; - - TrkParams::SetTrackingMode(); - TrkParams::SetPrecisionFactor(); - TrkParams::SetStepMin(); + +// 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]; @@ -184,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; }; @@ -228,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; }; @@ -297,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) */ @@ -371,6 +400,23 @@ return (last_plane-first_plane+1); } /** + * Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between + * the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6). + */ +Int_t TrkTrack::GetLeverArmXY(){ + int first_plane = -1; + int last_plane = -1; + for(Int_t ip=0; ip<6; ip++){ + if( XGood(ip)*YGood(ip) && first_plane == -1 )first_plane = ip; + if( XGood(ip)*YGood(ip) && first_plane != -1 )last_plane = ip; + } + if( first_plane == -1 || last_plane == -1){ + cout<< "Int_t TrkTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<10) index=10; @@ -621,12 +667,16 @@ // path_.error = 0; // readb_(); - TrkParams::SetTrackingMode(); - TrkParams::SetPrecisionFactor(); - TrkParams::SetStepMin(); +// 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 "<XMAGNLOW && xmagntopYMAGNLOW && ymagntopXMAGNLOW && xmagnbottomYMAGNLOW && ymagnbottom0 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. @@ -911,7 +1061,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) */ @@ -934,30 +1084,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(); @@ -1017,11 +1431,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 *** @@ -1279,6 +1711,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); //----------------------------------------------------- @@ -1292,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); //----------------------------------------------------- new(sy[i]) TrkSinglet(*t_singlet); t_singlet->Clear(); }; + + delete t_track; delete t_singlet; @@ -1410,7 +1848,8 @@ if(!Track)return 0; - TRefArray *sorted = new TRefArray(); + // TRefArray *sorted = new TRefArray(); + TRefArray *sorted = NULL; TClonesArray &t = *Track; // TClonesArray &ts = *PhysicalTrack; @@ -1448,6 +1887,7 @@ // cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<Add( (TrkTrack*)t[indi] ); m[indi] = 0; @@ -1473,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){ @@ -1495,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; @@ -1515,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; @@ -1536,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; } @@ -1574,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; } @@ -1584,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; @@ -1611,12 +2051,16 @@ // path_.error = 0; // readb_(); - TrkParams::SetTrackingMode(); - TrkParams::SetPrecisionFactor(); - TrkParams::SetStepMin(); +// 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"<