/[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.7 by mocchiut, Thu Nov 9 17:05:44 2006 UTC revision 1.8 by mocchiut, Tue Nov 14 14:08:50 2006 UTC
# Line 85  CaloTrkVar::CaloTrkVar(const CaloTrkVar Line 85  CaloTrkVar::CaloTrkVar(const CaloTrkVar
85  CaloLevel2::CaloLevel2() {      CaloLevel2::CaloLevel2() {    
86    //    //
87    CaloTrk = new TClonesArray("CaloTrkVar",1);    CaloTrk = new TClonesArray("CaloTrkVar",1);
88    estrip = TArrayF(0,NULL);    estrip = TArrayI(0,NULL);
89    //    //
90    this->Clear();    this->Clear();
91    //    //
92  };  };
93    
94    /**
95     * Clear the CaloLevel2 object
96     **/
97  void CaloLevel2::Clear() {      void CaloLevel2::Clear() {    
98    //    //
99    CaloTrk->Clear();    CaloTrk->Clear();
# Line 189  void CaloLevel2::GetLevel2Struct(cCaloLe Line 192  void CaloLevel2::GetLevel2Struct(cCaloLe
192  }  }
193    
194  /**  /**
195   * Gives the detected energy for the given strip once loaded the event   * Returns the detected energy for the given strip once loaded the event
196  **/  **/
197  Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){  Float_t CaloLevel2::GetEstrip(Int_t sview, Int_t splane, Int_t sstrip){
198    Int_t splane = 0;    Int_t view = -1;
199    Int_t sstrip = 0;    Int_t plane = -1;
200      Int_t strip = -1;
201      Float_t mip = 0.;
202    //    //
203    if ( nstrip == 0 ) return(0.);    if ( nstrip == 0 ) return(0.);
204    //    //
205    for (Int_t i = 0; i<nstrip; i++ ){    for (Int_t i = 0; i<nstrip; i++ ){
206      if ( view == 0 ){      //
207        if ( estrip.At(i) > 0. ){      mip = DecodeEstrip(i,view,plane,strip);
208          splane = (Int_t)trunc(estrip.At(i)/1000000.);      //
209          sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.);      if ( view == sview && splane == plane && sstrip == strip ) return(mip);
210          if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.);      //
211        };              // entry are ordered by strip, plane and view number. Go out if you pass the input strip
212      } else {      //
213        if ( estrip.At(i) < 0. ){      if ( view == sview && plane == splane && strip > sstrip ) return(0.);
214          splane = (Int_t)trunc(-estrip.At(i)/1000000.);      if ( view == sview && plane > splane ) return(0.);
215          sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.);      if ( view > sview ) return(0.);
216          if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.);              //
       };          
     };  
217    };    };
218    return(0.);    return(0.);
219  };  };
220    
221  /**  /**
222   * Given estrip entry returns energy and strip   * Given estrip entry returns energy plus view, plane and strip numbers
223  **/  **/
224  Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){  Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){
225      //
226    if ( entry>nstrip ) return(0.);    if ( entry>nstrip ) return(0.);
227    //    //
228      //  printf(" num lim %f \n",std::numeric_limits<Float_t>::max());
229      //  printf(" estrip.At(%i) = %i \n",entry,estrip.At(entry));
230      //
231      Int_t eval = 0;
232    if ( estrip.At(entry) > 0. ){    if ( estrip.At(entry) > 0. ){
233      view = 0;      view = 0;
234      plane = (Int_t)trunc(estrip.At(entry)/1000000.);      eval = estrip.At(entry);
235      strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.);    } else {
     return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.);  
   };  
   if ( estrip.At(entry) < 0. ){  
236      view = 1;      view = 1;
237      plane = (Int_t)trunc(-estrip.At(entry)/1000000.);      eval = -estrip.At(entry);
238      strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.);    };
239      return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.);        //
240    };        Int_t fbi = 0;
241      fbi = (Int_t)truncf((Float_t)(eval/1000000000));
242      //
243      Int_t plom = 0;
244      plom = (Int_t)truncf((Float_t)((eval-fbi*1000000000)/10000000));
245      //
246      Float_t tim = 100000.;
247      plane = plom;
248      if ( fbi == 1 ) tim = 10000.;
249      if ( plom > 21 ){
250        plane = plom - 22;
251        if ( fbi == 1 ){
252          tim = 1000.;
253        } else {
254          tim = 100.;
255        };
256      };
257      if ( plom > 43 ){
258        plane = plom - 44;
259        tim = 10.;
260      };
261      if ( plom > 65 ){
262        plane = plom - 66;
263        tim = 1.;
264      };
265    //    //
266    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));
267      //
268      Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim;
269      //
270      if ( mip > 0. && mip < 99999. ) return(mip);
271      //
272      printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry);
273    //    //
274    view = -1;    view = -1;
275    plane = -1;    plane = -1;
# Line 242  Float_t CaloLevel2::DecodeEstrip(Int_t e Line 277  Float_t CaloLevel2::DecodeEstrip(Int_t e
277    return(0.);      return(0.);  
278  }  }
279    
280    /**
281     * Should return the energy in GeV if the particle would be an electron
282     * using a parametrization taken from Monte Carlo simulation
283    **/
284  void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){  void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){
285    if ( nstrip == 0 ) return;    if ( nstrip == 0 ) return;
286    energy = qtot * 40.82 * 0.000106;    energy = qtot * 40.82 * 0.000106;

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

  ViewVC Help
Powered by ViewVC 1.1.23