/** * \file TrkLevel1.cpp * \author Elena Vannuccini */ #include #include using namespace std; //-------------------------------------- // // //-------------------------------------- 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 scut) s += clsignal[is]; }; return s; }; /** * Evaluate the cluster signal-to-noise, as defined by Turchetta. * @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 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 "<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). */ void TrkLevel1::GetLevel1Struct(cTrkLevel1 *l1) const { // ********* completare ********* // // ********* completare ********* // // ********* completare ********* // // ********* completare ********* // // ********* completare ********* // // ********* completare ********* // // general variables // l1->good1 = good1; for(Int_t i=0; i<12 ; i++){ // l1->crc[i] = crc[i]; for(Int_t j=0; j<24 ; j++){ l1->cnev[j][i] = cnev[j][i]; l1->cnnev[j][i] = cnnev[j][i]; }; // l1->fshower[i] = fshower[i]; }; // *** CLUSTERS *** l1->nclstr1 = Cluster->GetEntries(); for(Int_t i=0;inclstr1;i++){ l1->view[i] = ((TrkCluster *)Cluster->At(i))->view; // l1->ladder[i] = ((TrkCluster *)Cluster->At(i))->ladder; l1->maxs[i] = ((TrkCluster *)Cluster->At(i))->maxs; // l1->mult[i] = ((TrkCluster *)Cluster->At(i))->mult; // l1->dedx[i] = ((TrkCluster *)Cluster->At(i))->sgnl; } // ********* completare ********* // } //-------------------------------------- // // //-------------------------------------- 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(); } //-------------------------------------- // // //-------------------------------------- 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; } ClassImp(TrkLevel1); ClassImp(TrkCluster);