]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRawFitterv0.cxx
Fixed Coverity defect (DIVIDE_BY_ZERO)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawFitterv0.cxx
index c34c78d298ab8cc6ba9e0d4301d3fb860af885eb..e253891aac3055d049af1ecef2c61f61ec0fc46a 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+/* $Id$ */
 
 // This class extracts the signal parameters (energy, time, quality)
 // from ALTRO samples. Energy is in ADC counts, time is in time bin units.
@@ -138,6 +138,7 @@ Bool_t AliPHOSRawFitterv0::Eval(const UShort_t *signal, Int_t sigStart, Int_t si
   // Time is the first time bin
   // Signal overflows is there are at least 3 samples of the same amplitude above 900
 
+  fOverflow= kFALSE ;
   fEnergy  = 0;
   if (fNBunches > 1) {
     fQuality = 1000;
@@ -159,7 +160,7 @@ Bool_t AliPHOSRawFitterv0::Eval(const UShort_t *signal, Int_t sigStart, Int_t si
       pedMean += signal[i];
       pedRMS  += signal[i]*signal[i] ;
     }
-    if(signal[i] >  maxSample) maxSample = signal[i];
+    if(signal[i] >  maxSample){ maxSample = signal[i]; nMax=0;}
     if(signal[i] == maxSample) nMax++;
 
   }
@@ -188,16 +189,14 @@ Bool_t AliPHOSRawFitterv0::Eval(const UShort_t *signal, Int_t sigStart, Int_t si
       pedestal += truePed - altroSettings ;
     }
     else{
-      AliWarning(Form("Can not read data from OCDB")) ;
+      AliDebug(2,Form("Pedestal and offset are not read from OCDB. Use 0 for their values.")) ;
     }
   }
   fEnergy-=pedestal ;
   if (fEnergy < kBaseLine) fEnergy = 0;
 
   //Evaluate time
-  Int_t iStart = sigLength-1;
-  while(iStart>=0 && signal[iStart]-pedestal <kBaseLine) iStart-- ;
-  fTime = sigStart-iStart-2; //2: 1 due to oversubtraction in line above, another 1 due to signal started before amp increased
+  fTime = sigStart-sigLength-3; 
   const Int_t nLine= 6 ;        //Parameters of fitting
   const Float_t eMinTOF = 10. ; //Choosed from beam-test and cosmic analyis
   const Float_t kAmp=0.35 ;     //Result slightly depends on them, so no getters
@@ -241,6 +240,7 @@ Bool_t AliPHOSRawFitterv0::Eval(const UShort_t *signal, Int_t sigStart, Int_t si
     if(idn<sigLength){
       if(signal[idn]<pedestal){
         idn=sigLength-1 ; //do not scan further
+       idn++ ;
         continue ;
       }
       x = sigLength-idn-1;
@@ -261,6 +261,9 @@ Bool_t AliPHOSRawFitterv0::Eval(const UShort_t *signal, Int_t sigStart, Int_t si
   if(det == 0){
     return kTRUE;
   }
+  if(np == 0){
+    return kFALSE;
+  }
   Double_t c1 = (np*sxy - sx*sy)/det;  //slope
   Double_t c0 = (sy-c1*sx)/np; //offset
   if(c1 == 0){