--- DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2007/05/24 16:45:48 1.36 +++ DarthVader/TrackerLevel2/src/TrkLevel2.cpp 2008/11/25 14:41:37 1.49 @@ -52,19 +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??? -// 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::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]; @@ -179,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; }; @@ -223,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; }; @@ -292,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) */ @@ -365,6 +399,103 @@ } return (last_plane-first_plane+1); } +/** + * Returns the reduced chi-square of track x-projection + */ +Float_t TrkTrack::GetChi2X(){ + float chiq=0; + for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.); + if(GetNX()>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"< 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. @@ -798,8 +1042,9 @@ Int_t TrkTrack::GetClusterY_ID(int ip){ return ((Int_t)fabs(ygood[ip]))%10000000-1; }; + /** - * 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) */ @@ -822,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 average 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(); @@ -905,11 +1414,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 @@ -1055,7 +1571,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) ); @@ -1140,15 +1656,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.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 *** @@ -1160,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); //----------------------------------------------------- @@ -1173,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; @@ -1354,8 +1894,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){ @@ -1376,8 +1916,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; @@ -1396,8 +1936,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; @@ -1417,8 +1957,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; } @@ -1455,8 +1995,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; } @@ -1465,7 +2005,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; @@ -1492,12 +2032,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"<