--- DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp 2007/01/22 09:16:59 1.12 +++ DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp 2014/10/15 12:06:21 1.20 @@ -15,12 +15,13 @@ **/ CaloTrkVar::CaloTrkVar() { this->Clear(); -}; +} /** * Clear variables **/ -void CaloTrkVar::Clear() { +void CaloTrkVar::Clear(Option_t *t) { + //void CaloTrkVar::Clear() { trkseqno = 0; noint = 0; ncore = 0; @@ -91,23 +92,35 @@ // this->Clear(); // -}; +} /** * Create the TClonesArray **/ void CaloLevel2::Set(){//ELENA if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA }//ELENA +//-------------------------------------- +// +// +//-------------------------------------- +void CaloLevel2::SetTrackArray(TClonesArray *track){//ELENA +// if(track && strcmp(track->GetClass()->GetName(),"CaloTrkVar")==0){ + if(track ){ + if(CaloTrk)CaloTrk->Clear("C"); + CaloTrk = track; + } +} /** * Clear the CaloLevel2 object **/ -void CaloLevel2::Clear() { +void CaloLevel2::Clear(Option_t *t ) { // -// CaloTrk->Clear(); //ELENA + // CaloTrk->Clear(); //ELENA if(CaloTrk)CaloTrk->Delete(); //ELENA // nstrip = 0; + nsatstrip = 0; qtot = 0.; // impx = 0.; // impy = 0.; @@ -126,17 +139,18 @@ memset(tany, 0, 2*sizeof(Int_t)); memset(fitmode, 0, 2*sizeof(Int_t)); memset(planemax, 0, 2*sizeof(Int_t)); + memset(selfdelay, 0, 4*7*sizeof(Int_t)); memset(cibar, 0, 2*22*sizeof(Int_t)); memset(cbar, 0, 2*22*sizeof(Float_t)); good = 0; selftrigger = 0; // -}; +} /** * Delete the CaloLevel2 object **/ -void CaloLevel2::Delete() { //ELENA +void CaloLevel2::Delete(Option_t *t) { //ELENA if(CaloTrk){ //ELENA CaloTrk->Delete(); //ELENA delete CaloTrk; //ELENA @@ -144,6 +158,35 @@ } //ELENA /** + * CaloLevel2 +**/ +Bool_t CaloLevel2::IsGood(Bool_t strict) { + // + if ( strict ){ + if ( !good ) return(false); + if ( perr[0] ) return(false); + if ( perr[1] ) return(false); + if ( perr[2] ) return(false); + if ( perr[3] ) return(false); + if ( swerr[0] ) return(false); + if ( swerr[1] ) return(false); + if ( swerr[2] ) return(false); + if ( swerr[3] ) return(false); + if ( crc[0] ) return(false); + if ( crc[1] ) return(false); + if ( crc[2] ) return(false); + if ( crc[3] ) return(false); + } else { + if ( perr[0] == 129 || perr[0] == 136 || perr[0] == 142 || perr[0] == 143 ) return(false); + if ( perr[1] == 129 || perr[1] == 136 || perr[1] == 142 || perr[1] == 143 ) return(false); + if ( perr[2] == 129 || perr[2] == 136 || perr[2] == 142 || perr[2] == 143 ) return(false); + if ( perr[3] == 129 || perr[3] == 136 || perr[3] == 142 || perr[3] == 143 ) return(false); + }; + // + return(true); +} + +/** * Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). */ void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { @@ -230,7 +273,7 @@ printf(" Cannot find selftrigger block\n"); }; return(-100.); -}; +} /** * Returns the impact position on the top of the calorimeter as determined by the calorimeter itself. @@ -252,18 +295,19 @@ printf(" Cannot find selftrigger block\n"); }; return(-100.); -}; +} /** * Should return the energy in GeV if the particle would be an electron * using a parametrization taken from Monte Carlo simulation **/ void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ if ( nstrip == 0 ) return; - energy = qtot * 40.82 * 0.000106; + energy = qtot / 260.; + // energy = qtot * 40.82 * 0.000106; sigma = 0.; if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); return; -}; +} /** * Returns pointer to the set of track-related variables "itrk" @@ -280,3 +324,30 @@ CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; return calotrack; } + +/** + * Retrieves the calorimeter track matching the seqno-th tracker stored track. + * (If seqno = -1 retrieves the self-trigger calorimeter track) + */ +CaloTrkVar *CaloLevel2::GetCaloStoredTrack(int seqno){ + + if( ntrk()==0 ){ + printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i but no Calorimeter tracks are stored\n",seqno); + return NULL; + }; + + CaloTrkVar *c = 0; + Int_t it_calo=0; + + do { + c = GetCaloTrkVar(it_calo); + it_calo++; + } while( c && seqno != c->trkseqno && it_calo < ntrk()); + + if(!c || seqno != c->trkseqno){ + c = 0; + if(seqno!=-1 && seqno !=-2 && seqno!=-3 ) printf("CaloLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo %i does not match Calorimeter stored tracks\n",seqno); + }; + return c; + +}