--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/08/22 07:03:45 1.39 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2014/02/27 11:24:43 1.56 @@ -12,6 +12,7 @@ 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*); @@ -52,19 +53,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??? -// clx = TRefArray(6,0); -// cly = TRefArray(6,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::DoTrack(Trajectory* t) instead + * */ -int TrkTrack::DoTrack(Trajectory* t){ - - double *dxout = new double[t->npoint]; - double *dyout = new double[t->npoint]; - double *dzin = new double[t->npoint]; - double dal[5]; - - int ifail = 0; - - for (int i=0; i<5; i++) dal[i] = (double)al[i]; - for (int i=0; inpoint; i++) dzin[i] = (double)t->z[i]; +int TrkTrack::DoTrack2(Trajectory* t){ - TrkParams::Load(1); - if( !TrkParams::IsLoaded(1) ){ - cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<npoint),dzin,dxout,dyout,dal,&ifail); - - for (int i=0; inpoint; i++){ - t->x[i] = (float)*dxout++; - t->y[i] = (float)*dyout++; - } + cout << endl; + cout << " int TrkTrack::DoTrack2(Trajectory* t) --->> NB NB !! this method is going to be eliminated !!! "<>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<npoint]; double *dyout = new double[t->npoint]; @@ -217,22 +221,25 @@ TrkParams::Load(1); if( !TrkParams::IsLoaded(1) ){ - cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<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; }; @@ -292,7 +299,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) */ @@ -366,6 +374,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; @@ -607,12 +641,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 "<zm[i]; axv[i] = track->axv[i]; ayv[i] = track->ayv[i]; + resx[i] = track->resx[i]; //Elena 10th + resy[i] = track->resy[i]; } } @@ -710,15 +793,28 @@ */ Bool_t TrkTrack::EvaluateClusterPositions(){ -// cout << "void TrkTrack::GetClusterPositions() "<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) + * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume) + */ +// 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; + +// } +Bool_t TrkTrack::IsInsideAcceptance(float toll){ + + + int ngf = TrkParams::nGF; + for(int i=0; i= 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 one of the surfaces which define the + * geometrical acceptance. + * @param surf tag of the surface (possible values are: S11 S12 S21 S22 T1 + * CUF T2 T3 T4 T5 CLF T6 S31 S32). + * @param toll Tolerance around the nominal surface (toll>0 define an inner + * fiducial surface) +*/ +Bool_t TrkTrack::IsInsideGFSurface(const char* surf, float toll){ + + + int ngf = TrkParams::nGF; + bool SURFOK = false; + for(int i=0; i TrkParams::xGF_min[i] + toll && + xGF[i] < TrkParams::xGF_max[i] - toll && + yGF[i] > TrkParams::yGF_min[i] + toll && + yGF[i] < TrkParams::yGF_max[i] - toll && + true)return true; + } + } + if( !SURFOK )cout << " Bool_t TrkTrack::IsInsideGFSurface(char* surf, float toll) --> suface "<5||clid<1||il<-1||il>2||is<-1||is>1) + cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<5||clid<1||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(); @@ -1002,11 +1498,13 @@ //-------------------------------------- TrkSinglet::TrkSinglet(){ // cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<ntrk() ; - cout << endl << "nclsx() : " << this->nclsx(); - cout << endl << "nclsy() : " << this->nclsy(); + 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 @@ -1152,7 +1655,7 @@ * 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) + * @param ivk Viking-chip number (0-23) */ Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); @@ -1237,15 +1740,33 @@ 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->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]; //----------------------------------------------------- //----------------------------------------------------- //----------------------------------------------------- //----------------------------------------------------- }; + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // evaluated coordinates (to define GF) + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + int ngf = TrkParams::nGF; + float *zgf = TrkParams::zGF; + Trajectory tgf = Trajectory(ngf,zgf); + tgf.DoTrack(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 *** @@ -1257,6 +1778,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); //----------------------------------------------------- @@ -1270,12 +1793,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; @@ -1388,7 +1915,8 @@ if(!Track)return 0; - TRefArray *sorted = new TRefArray(); + // TRefArray *sorted = new TRefArray(); + TRefArray *sorted = NULL; TClonesArray &t = *Track; // TClonesArray &ts = *PhysicalTrack; @@ -1426,6 +1954,7 @@ // cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<Add( (TrkTrack*)t[indi] ); m[indi] = 0; @@ -1451,8 +1980,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){ @@ -1473,8 +2002,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; @@ -1493,8 +2022,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; @@ -1514,8 +2043,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; } @@ -1552,8 +2081,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; } @@ -1562,7 +2091,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; @@ -1589,12 +2118,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"<>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead + * + */ +int Trajectory::DoTrack2(float* al, float zini){ + + cout << endl; + cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<