/[PAMELA software]/DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp
ViewVC logotype

Diff of /DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mocchiut, Tue Nov 14 14:08:50 2006 UTC revision 1.9 by mocchiut, Wed Nov 22 08:31:11 2006 UTC
# Line 5  Line 5 
5  **/  **/
6  #include <TObject.h>  #include <TObject.h>
7  #include <CaloLevel2.h>  #include <CaloLevel2.h>
8    
9    //
10  ClassImp(CaloTrkVar);  ClassImp(CaloTrkVar);
11  ClassImp(CaloLevel2);  ClassImp(CaloLevel2);
12    
# Line 85  CaloTrkVar::CaloTrkVar(const CaloTrkVar Line 87  CaloTrkVar::CaloTrkVar(const CaloTrkVar
87  CaloLevel2::CaloLevel2() {      CaloLevel2::CaloLevel2() {    
88    //    //
89    CaloTrk = new TClonesArray("CaloTrkVar",1);    CaloTrk = new TClonesArray("CaloTrkVar",1);
   estrip = TArrayI(0,NULL);  
90    //    //
91    this->Clear();    this->Clear();
92    //    //
# Line 120  void CaloLevel2::Clear() {     Line 121  void CaloLevel2::Clear() {    
121    memset(cbar, 0, 2*22*sizeof(Float_t));    memset(cbar, 0, 2*22*sizeof(Float_t));
122    good = 0;    good = 0;
123    selftrigger = 0;    selftrigger = 0;
124    estrip.Reset();    //
125  };  };
126    
127    
# Line 192  void CaloLevel2::GetLevel2Struct(cCaloLe Line 193  void CaloLevel2::GetLevel2Struct(cCaloLe
193  }  }
194    
195  /**  /**
  * Returns the detected energy for the given strip once loaded the event  
 **/  
 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<nstrip; i++ ){  
     //  
     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 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<Float_t>::max());  
   //  printf(" estrip.At(%i) = %i \n",entry,estrip.At(entry));  
   //  
   Int_t eval = 0;  
   if ( estrip.At(entry) > 0. ){  
     view = 0;  
     eval = estrip.At(entry);  
   } else {  
     view = 1;  
     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.;  
   };  
   //  
   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;  
   strip = -1;  
   return(0.);    
 }  
   
 /**  
196   * Should return the energy in GeV if the particle would be an electron   * Should return the energy in GeV if the particle would be an electron
197   * using a parametrization taken from Monte Carlo simulation   * using a parametrization taken from Monte Carlo simulation
198  **/  **/

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.23