--- DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp 2006/11/09 17:05:44 1.7 +++ DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp 2006/11/14 14:08:50 1.8 @@ -85,12 +85,15 @@ CaloLevel2::CaloLevel2() { // CaloTrk = new TClonesArray("CaloTrkVar",1); - estrip = TArrayF(0,NULL); + estrip = TArrayI(0,NULL); // this->Clear(); // }; +/** + * Clear the CaloLevel2 object + **/ void CaloLevel2::Clear() { // CaloTrk->Clear(); @@ -189,52 +192,84 @@ } /** - * Gives the detected energy for the given strip once loaded the event + * Returns the detected energy for the given strip once loaded the event **/ -Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ - Int_t splane = 0; - Int_t sstrip = 0; +Float_t CaloLevel2::GetEstrip(Int_t sview, Int_t splane, Int_t sstrip){ + Int_t view = -1; + Int_t plane = -1; + Int_t strip = -1; + Float_t mip = 0.; // if ( nstrip == 0 ) return(0.); // for (Int_t i = 0; i 0. ){ - splane = (Int_t)trunc(estrip.At(i)/1000000.); - sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); - if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); - }; - } else { - if ( estrip.At(i) < 0. ){ - splane = (Int_t)trunc(-estrip.At(i)/1000000.); - sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); - if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); - }; - }; + // + mip = DecodeEstrip(i,view,plane,strip); + // + if ( view == sview && splane == plane && sstrip == strip ) return(mip); + // + // entry are ordered by strip, plane and view number. Go out if you pass the input strip + // + if ( view == sview && plane == splane && strip > sstrip ) return(0.); + if ( view == sview && plane > splane ) return(0.); + if ( view > sview ) return(0.); + // }; return(0.); }; /** - * Given estrip entry returns energy and strip + * Given estrip entry returns energy plus view, plane and strip numbers **/ Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ + // if ( entry>nstrip ) return(0.); // + // printf(" num lim %f \n",std::numeric_limits::max()); + // printf(" estrip.At(%i) = %i \n",entry,estrip.At(entry)); + // + Int_t eval = 0; if ( estrip.At(entry) > 0. ){ view = 0; - plane = (Int_t)trunc(estrip.At(entry)/1000000.); - strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); - return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); - }; - if ( estrip.At(entry) < 0. ){ + eval = estrip.At(entry); + } else { view = 1; - plane = (Int_t)trunc(-estrip.At(entry)/1000000.); - strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); - return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); - }; + eval = -estrip.At(entry); + }; + // + Int_t fbi = 0; + fbi = (Int_t)truncf((Float_t)(eval/1000000000)); + // + Int_t plom = 0; + plom = (Int_t)truncf((Float_t)((eval-fbi*1000000000)/10000000)); + // + Float_t tim = 100000.; + plane = plom; + if ( fbi == 1 ) tim = 10000.; + if ( plom > 21 ){ + plane = plom - 22; + if ( fbi == 1 ){ + tim = 1000.; + } else { + tim = 100.; + }; + }; + if ( plom > 43 ){ + plane = plom - 44; + tim = 10.; + }; + if ( plom > 65 ){ + plane = plom - 66; + tim = 1.; + }; // - printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); + strip = (Int_t)truncf((Float_t)((eval - fbi*1000000000 -plom*10000000)/100000)); + // + Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim; + // + if ( mip > 0. && mip < 99999. ) return(mip); + // + printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry); // view = -1; plane = -1; @@ -242,6 +277,10 @@ return(0.); } +/** + * 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;