]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliCaloRawAnalyzerFastFit.cxx
Coverity fixes
[u/mrichter/AliRoot.git] / EMCAL / AliCaloRawAnalyzerFastFit.cxx
index 4a7d1d8e2da75be3671455a625b285befec0fab4..0a103ffe05f293f0086431c39a4018d86a4d9749 100644 (file)
@@ -1,3 +1,4 @@
+// -*- mode: c++ -*-
 /**************************************************************************
  * This file is property of and copyright by the Experimental Nuclear     *
  * Physics Group, Dep. of Physics                                         *
 /**************************************************************************
  * This file is property of and copyright by the Experimental Nuclear     *
  * Physics Group, Dep. of Physics                                         *
 #include <iostream>
 
 using namespace std;
 #include <iostream>
 
 using namespace std;
+#include "AliCaloConstants.h"
 
 ClassImp( AliCaloRawAnalyzerFastFit )
 
 
 ClassImp( AliCaloRawAnalyzerFastFit )
 
-AliCaloRawAnalyzerFastFit::AliCaloRawAnalyzerFastFit() : AliCaloRawAnalyzer("Fast Fit (Alexei)", "FF")
+
+AliCaloRawAnalyzerFastFit::AliCaloRawAnalyzerFastFit() : AliCaloRawAnalyzerFitter("Fast Fit (Alexei)", "FF")
 {
   // Comment
 {
   // Comment
-
-  for(int i=0; i <  1008; i++)
-    {
-      fXAxis[i] = i;
-    }
-
+  fAlgo= Algo::kFastFit;
 }
 
 }
 
+
 AliCaloRawAnalyzerFastFit::~AliCaloRawAnalyzerFastFit()
 {
 
 AliCaloRawAnalyzerFastFit::~AliCaloRawAnalyzerFastFit()
 {
 
@@ -64,14 +63,21 @@ AliCaloRawAnalyzerFastFit::Evaluate( const vector<AliCaloBunchInfo> &bunchvector
   if( index >= 0)
     {
       Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index))  ,  altrocfg1, altrocfg2, fReversed  );
   if( index >= 0)
     {
       Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index))  ,  altrocfg1, altrocfg2, fReversed  );
-      int first = 0;
-      int last = 0;
       Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(),  fReversed );
       Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(),  fReversed );
-      int maxrev =  maxampindex -  bunchvector.at(index).GetStartBin();
       short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
       short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
-      if ( maxf >= fAmpCut )
+
+      if(  maxf < fAmpCut  ||  ( maxamp - ped) > fOverflowCut  ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
+       {
+         return  AliCaloFitResults( maxamp, ped, Algo::kCrude, maxf, timebinOffset);
+       }
+      else if ( maxf >= fAmpCut ) // no if statement needed really; keep for readability
        {
        {
-         SelectSubarray( fReversed,  bunchvector.at(index).GetLength(), maxrev , &first, &last);
+         int first = 0;
+         int last = 0;
+         int maxrev =  maxampindex -  bunchvector.at(index).GetStartBin();
+
+         SelectSubarray( fReversed,  bunchvector.at(index).GetLength(), maxrev , &first, &last, fFitArrayCut);
+
          int nsamples =  last - first + 1;
 
          if( ( nsamples  )  >= fNsampleCut )  
          int nsamples =  last - first + 1;
 
          if( ( nsamples  )  >= fNsampleCut )  
@@ -91,24 +97,23 @@ AliCaloRawAnalyzerFastFit::Evaluate( const vector<AliCaloBunchInfo> &bunchvector
              Double_t chi2 = 0;
              Double_t dTau = 2.35; // time-bin units
              
              Double_t chi2 = 0;
              Double_t dTau = 2.35; // time-bin units
              
-             AliCaloFastAltroFitv0::FastFit(fXAxis, ordered , nsamples,
+             AliCaloFastAltroFitv0::FastFit(fXaxis, ordered , nsamples,
                                             eSignal, dTau, dAmp, eAmp, dTime0, eTime, chi2);
           
              Double_t dTimeMax = dTime0 + timebinOffset - (maxrev - first) // abs. t0
                + dTau; // +tau, makes sum tmax
                                             eSignal, dTau, dAmp, eAmp, dTime0, eTime, chi2);
           
              Double_t dTimeMax = dTime0 + timebinOffset - (maxrev - first) // abs. t0
                + dTau; // +tau, makes sum tmax
-             return AliCaloFitResults(maxamp, ped, AliCaloFitResults::kFitPar,  dAmp, dTimeMax, timebinOffset, chi2,  AliCaloFitResults::kDummy,
-                                      AliCaloFitResults::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
+             return AliCaloFitResults(maxamp, ped, Ret::kFitPar,  dAmp, dTimeMax, timebinOffset, chi2,  Ret::kDummy,
+                                      Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
            } // samplecut
          else 
            {
            } // samplecut
          else 
            {
-             return AliCaloFitResults( maxamp, ped, AliCaloFitResults::kCrude, maxf, timebinOffset); 
+             Float_t chi2 = CalculateChi2(maxf, maxrev, first, last);
+             Int_t ndf = last - first - 1; // nsamples - 2
+             return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset,
+                                       timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); 
            }
        } // ampcut
            }
        } // ampcut
-      else 
-       {
-         return AliCaloFitResults( maxamp , ped, AliCaloFitResults::kCrude, maxf, timebinOffset);
-       }
     } // bunch index    
 
     } // bunch index    
 
-  return AliCaloFitResults(AliCaloFitResults::kInvalid , AliCaloFitResults::kInvalid);
+  return AliCaloFitResults( Ret::kInvalid , Ret::kInvalid );
 }
 }