/** * \file TrkLevel1.cpp * \author Elena Vannuccini */ #include #include using namespace std; //...................................... // F77 routines //...................................... extern "C" { // int readetaparam_(); float cog_(int*,int*); float pfaeta_(int*,float*); float pfaeta2_(int*,float*); float pfaeta3_(int*,float*); float pfaeta4_(int*,float*); } //-------------------------------------- // // //-------------------------------------- TrkCluster::TrkCluster(){ view = 0; maxs = 0; indmax = 0; CLlength = 0; clsignal = 0; clsigma = 0; cladc = 0; clbad = 0; }; //-------------------------------------- // // //-------------------------------------- TrkCluster::~TrkCluster(){ delete [] clsignal; delete [] clsigma; delete [] cladc; delete [] clbad; }; //-------------------------------------- // // //-------------------------------------- TrkCluster::TrkCluster(const TrkCluster& t){ view = t.view; maxs = t.maxs; indmax = t.indmax; CLlength = t.CLlength; clsignal = new Float_t[CLlength]; clsigma = new Float_t[CLlength]; cladc = new Int_t[CLlength]; clbad = new Bool_t[CLlength]; for(Int_t i=0; i cut*sigma ). * @param cut Inclusion cut. */ Float_t TrkCluster::GetSignal(Float_t cut){ Float_t s = 0; for(Int_t is = 0; is < CLlength; is++){ Float_t scut = cut*clsigma[is]; if(clsignal[is] > scut) s += clsignal[is]; }; return s; }; /** * Evaluate the cluster signal including a ( maximum ) fixed number of adjacent strips (with s>0) around the maxs. * @param nstrip Number of strips. */ Float_t TrkCluster::GetSignal(Int_t nstrip){ Float_t s = 0; Int_t il = indmax; Int_t ir = indmax; Int_t inc = 0; while ( inc= 0 ) sl = clsignal[il]; if( ir < CLlength ) sr = clsignal[ir]; if( sl == sr && inc == 0 ){ s += clsignal[il]; il--; ir++; }else if ( sl >= sr && sl>0 && inc !=0){ s += sl; il--; }else if ( sl < sr && sr>0 ){ s += sr; ir++; }else break; inc++; } return s; }; /** * Evaluate the cluster signal-to-noise, as defined by Turchetta, including all adjacent strip with a significant signal ( s > cut*sigma ). * @param cut Inclusion cut. */ Float_t TrkCluster::GetSignalToNoise(Float_t cut){ Float_t sn = 0; for(Int_t is = 0; is < CLlength; is++){ Float_t scut = cut*clsigma[is]; if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is]; }; return sn; }; /** * Evaluate the cluster signal-to-noise, as defined by Turchetta, including a ( maximum ) fixed number of adjacent strips (with s>0) around the maxs. * @param nstrip Number of strips. */ Float_t TrkCluster::GetSignalToNoise(Int_t nstrip){ Float_t sn = 0; Int_t il = indmax; Int_t ir = indmax; Int_t inc = 0; while ( inc= 0 ) sl = clsignal[il]; if( ir < CLlength ) sr = clsignal[ir]; if( sl == sr && inc == 0 ){ sn += clsignal[il]/clsigma[il]; il--; ir++; }else if ( sl >= sr && sl>0 && inc !=0){ sn += sl/clsigma[il]; il--; }else if ( sl < sr && sr>0 ){ sn += sr/clsigma[ir]; ir++; }else break; inc++; } return sn; }; /** * Evaluate the cluster multiplicity. * @param cut Inclusion cut. */ Int_t TrkCluster::GetMultiplicity(Float_t cut){ Int_t m = 0; for(Int_t is = 0; is < CLlength; is++){ Float_t scut = cut*clsigma[is]; if(clsignal[is] > scut) m++; }; return m; }; /** * True if the cluster contains bad strips. * @param nbad Number of strips around the maximum. */ Bool_t TrkCluster::IsBad(Int_t nbad){ /* Float_t max = 0; Int_t imax = 0; for(Int_t is = 0; is < CLlength; is++){ if(clsignal[is] > max){ max = clsignal[is]; imax = is; }; }; Int_t il,ir; il = imax; ir = imax;*/ Int_t il,ir; il = indmax; ir = indmax; for(Int_t i=1; i clsignal[ir+1])il--; else ir++; } } Int_t isbad = 0; for(Int_t i=il; i<=ir; i++)isbad += clbad[i]; return ( isbad != nbad ); }; //-------------------------------------- // // //-------------------------------------- void TrkCluster::Dump(){ cout << "----- Cluster" << endl; cout << "View "<nclstr1 = 1; l1->view[0] = view; l1->ladder[0] = GetLadder(); l1->maxs[0] = maxs; l1->mult[0] = GetMultiplicity(); l1->dedx[0] = GetSignal(); l1->indstart[0] = 1; l1->indmax[0] = indmax+1; l1->totCLlength = CLlength; for(Int_t i=0; iclsignal[i] = clsignal[i]; l1->clsigma[i] = clsigma[i]; l1->cladc[i] = cladc[i]; l1->clbad[i] = clbad[i]; }; return l1; }; //-------------------------------------- // // //-------------------------------------- /** * Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs). * @param ncog Number of strips to evaluate COG. * If ncog=0, the COG of the cluster is evaluated according to the cluster multiplicity (defined by the inclusion cut). * If ncog>0, the COG is evaluated using ncog strips, even if they have a negative signal (according to G.Landi) */ Float_t TrkCluster::GetCOG(Int_t ncog){ int ic = 1; level1event_ = *GetLevel1Struct(); return cog_(&ncog,&ic); }; //-------------------------------------- // // //-------------------------------------- /** * Evaluates the cluster position, in strips, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm. * @param neta Number of strips to evaluate ETA. * @param angle Projected angle between particle track and detector plane. * Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle. */ Float_t TrkCluster::GetETA(Int_t neta, float angle){ // LoadPfaParam(); int ic = 1; level1event_ = *GetLevel1Struct(); if(neta == 0) return pfaeta_(&ic,&angle); else if(neta == 2) return pfaeta2_(&ic,&angle); else if(neta == 3) return pfaeta3_(&ic,&angle); else if(neta == 4) return pfaeta4_(&ic,&angle); else cout << "ETA"<nclstr(); i++) ((TrkCluster *)t[i])->Dump(); } //-------------------------------------- // // //-------------------------------------- /** * Fills a TrkLevel1 object with values from a struct cTrkLevel1 (to get data from F77 common). */ void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1){ // *** CLUSTER *** TrkCluster* t_cl = new TrkCluster(); TClonesArray &t = *Cluster; for(int i=0; inclstr1; i++){ t_cl->view = l1->view[i]; t_cl->maxs = l1->maxs[i]; t_cl->indmax = l1->indmax[i] - l1->indstart[i]; Int_t from = l1->indstart[i] -1; Int_t to = l1->totCLlength ; if(i != l1->nclstr1-1)to = l1->indstart[i+1] -1 ; t_cl->CLlength = to - from ; t_cl->clsignal = new Float_t[t_cl->CLlength]; t_cl->clsigma = new Float_t[t_cl->CLlength]; t_cl->cladc = new Int_t[t_cl->CLlength]; t_cl->clbad = new Bool_t[t_cl->CLlength]; Int_t index = 0; for(Int_t is = from; is < to; is++ ){ t_cl->clsignal[index] = (Float_t) l1->clsignal[is]; t_cl->clsigma[index] = (Float_t) l1->clsigma[is]; t_cl->cladc[index] = (Int_t) l1->cladc[is]; t_cl->clbad[index] = (Bool_t) l1->clbad[is]; index++; }; new(t[i]) TrkCluster(*t_cl); }; delete t_cl; // ****general variables**** for(Int_t i=0; i<12 ; i++){ good[i] = -1; for(Int_t j=0; j<24 ; j++){ cnev[j][i] = l1->cnev[j][i]; cnnev[j][i] = l1->cnnev[j][i]; }; }; } /** * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common). */ cTrkLevel1* TrkLevel1::GetLevel1Struct() { cTrkLevel1 *l1=0; // for(Int_t i=0; i<12 ; i++){ l1->good[i] = good[i]; for(Int_t j=0; j<24 ; j++){ l1->cnev[j][i] = cnev[j][i]; l1->cnnev[j][i] = cnnev[j][i]; }; }; // *** CLUSTERS *** l1->nclstr1 = Cluster->GetEntries(); for(Int_t i=0;inclstr1;i++){ l1->view[i] = ((TrkCluster *)Cluster->At(i))->view; l1->maxs[i] = ((TrkCluster *)Cluster->At(i))->maxs; // COMPLETARE // // COMPLETARE // // COMPLETARE // // COMPLETARE // // COMPLETARE // // COMPLETARE // } // COMPLETARE // // COMPLETARE // // COMPLETARE // // COMPLETARE // // COMPLETARE // // COMPLETARE // return l1; } //-------------------------------------- // // //-------------------------------------- void TrkLevel1::Clear(){ for(Int_t i=0; i<12 ; i++){ good[i] = -1; for(Int_t j=0; j<24 ; j++){ cnev[j][i] = 0; cnnev[j][i] = 0; }; }; // Cluster->Clear(); } //-------------------------------------- // // //-------------------------------------- void TrkLevel1::Delete(){ for(Int_t i=0; i<12 ; i++){ good[i] = -1; for(Int_t j=0; j<24 ; j++){ cnev[j][i] = 0; cnnev[j][i] = 0; }; }; // Cluster->Delete(); } //-------------------------------------- // // //-------------------------------------- TrkCluster *TrkLevel1::GetCluster(int is){ if(is >= this->nclstr()){ cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl; cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl; return 0; } TClonesArray &t = *(Cluster); TrkCluster *cluster = (TrkCluster*)t[is]; return cluster; } //-------------------------------------- // // //-------------------------------------- /** * Load Position-Finding-Algorythm parameters (call the F77 routine). * */ int TrkLevel1::LoadPfaParam(TString path){ if( strcmp(path_.path,path.Data()) ){ cout <<"Loading p.f.a. parameters\n"; strcpy(path_.path,path.Data()); path_.pathlen = path.Length(); path_.error = 0; return readetaparam_(); } return 0; } ClassImp(TrkLevel1); ClassImp(TrkCluster);