]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliCaloRawAnalyzerPeakFinder.cxx
added protection against floating point exception (Alexander)
[u/mrichter/AliRoot.git] / EMCAL / AliCaloRawAnalyzerPeakFinder.cxx
index 556a7ba3d2265c9e9f54965418a05711fa39b142..8d627019efc5175099ecc3748af58128123e644a 100644 (file)
 #include "TFile.h"
 #include "AliCaloPeakFinderVectors.h"
 #include <iostream>
-//#include "AliEMCALRawUtils.h"
 
 using namespace std;
 
 
+
 ClassImp( AliCaloRawAnalyzerPeakFinder )
 
 
 AliCaloRawAnalyzerPeakFinder::AliCaloRawAnalyzerPeakFinder() :AliCaloRawAnalyzer("Peak-Finder", "PF"),  
-//    fAmp(0),
                                                              fPeakFinderVectors(0),
                                                              fRunOnAlien(false),
                                                              fIsInitialized(false)
@@ -63,9 +62,6 @@ void
 AliCaloRawAnalyzerPeakFinder::InitOCDB(bool alien) const
 {
   // Setting the default OCDB pathe depending on wether we work locally or on the GRID.
-  
-
-  //  if( AliCDBManager::Instance()->HasStorage("alien://$ALICE_ROOT/OCDB")  == false  &&  AliCDBManager::Instance()->HasStorage("local://$ALICE_ROOT/OCDB") == false )
   if( !AliCDBManager::Instance()->IsDefaultStorageSet ())
     {
       AliCDBManager::Instance()->SetDefaultStorage(  alien == true ? "alien://$ALICE_ROOT/OCDB" : "local://$ALICE_ROOT/OCDB" );
@@ -124,6 +120,7 @@ AliCaloRawAnalyzerPeakFinder::ScanCoarse(const Double_t *const array, const int
 AliCaloFitResults 
 AliCaloRawAnalyzerPeakFinder::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1,  const UInt_t altrocfg2 )
 {
+  // Evaluation of amplitude and TOF
   if( fIsInitialized == false )
     {
       cout << __FILE__ << ":" << __LINE__ << "ERROR, peakfinder vectors not loaded" << endl;
@@ -163,11 +160,8 @@ AliCaloRawAnalyzerPeakFinder::Evaluate( const vector<AliCaloBunchInfo> &bunchvec
              int n = last - first;  
              int pfindex = n - fNsampleCut; 
              pfindex = pfindex > PF::SAMPLERANGE ? PF::SAMPLERANGE : pfindex;
-
              int dt =  maxampindex - startbin -2; 
              int tmpindex = 0;
-
-
              Float_t tmptof = ScanCoarse( &fReversed[dt] , n );
              
              if( tmptof < -1 )
@@ -185,28 +179,24 @@ AliCaloRawAnalyzerPeakFinder::Evaluate( const vector<AliCaloBunchInfo> &bunchvec
                  }
 
              double tof = 0;
-           
              for(int k=0; k < PF::SAMPLERANGE; k++   )
                {
                  tof +=  fPFTofVectors[0][pfindex][k]*fReversed[ dt  +k + tmpindex -1 ];   
                }
-           
              for( int i=0; i < PF::SAMPLERANGE; i++ )
                {
                  {
+                   
                    fAmp += fPFAmpVectors[0][pfindex][i]*fReversed[ dt  +i  +tmpindex -1 ];
                  }
                }
+
              if( TMath::Abs(  (maxf - fAmp  )/maxf )  >   0.1 )
                {
-                 //      cout << __FILE__ << ":" << __LINE__ << "WARNING: amp was" << fAmp <<", but was changed to "<< maxf << endl;
                  fAmp = maxf;
                }
              
-             //      tof = timebinOffset - 0.01*tof/fAmp; // clock ticks
              tof = timebinOffset - 0.01*tof/fAmp - fL1Phase/TIMEBINWITH; // clock
-
-             // use local-array time for chi2 estimate
              Float_t chi2 = CalculateChi2(fAmp, tof-timebinOffset+maxrev, first, last);
              Int_t ndf = last - first - 1; // nsamples - 2
              return AliCaloFitResults( maxamp, ped , Ret::kFitPar, fAmp, tof, 
@@ -236,9 +226,8 @@ AliCaloRawAnalyzerPeakFinder::CopyVectors( const AliCaloPeakFinderVectors *const
        {
          for( int j=0; j < PF::SAMPLERANGE; j++)  
            {
-             // cout << __FILE__ << ":" << __LINE__ << ": TPX !!; i= "<< i << "  j = "<< j << endl;
-             // pfv->GetVector( i, j, fPFAmpVectors[i][j] ,  fPFTofVectors[i][j],    
-             //                      fPFAmpVectorsCoarse[i][j] , fPFTofVectorsCoarse[i][j]  ); 
+             pfv->GetVector( i, j, fPFAmpVectors[i][j] ,  fPFTofVectors[i][j],    
+                             fPFAmpVectorsCoarse[i][j] , fPFTofVectorsCoarse[i][j]  ); 
 
              fPeakFinderVectors->SetVector( i, j, fPFAmpVectors[i][j], fPFTofVectors[i][j],    
                                             fPFAmpVectorsCoarse[i][j], fPFTofVectorsCoarse[i][j] );   
@@ -261,31 +250,20 @@ AliCaloRawAnalyzerPeakFinder::LoadVectorsOCDB()
   
   if( entry != 0 )
   {
-    
-    cout << __FILE__ << ":" << __LINE__ << ": Printing metadata !! " << endl;
-    entry->PrintMetaData();
-    
-    cout << __FILE__ << ":" << __LINE__ << ": Finnsihed Printing metadata !! " << endl;
-
+    //cout << __FILE__ << ":" << __LINE__ << ": Printing metadata !! " << endl;
+    //entry->PrintMetaData();
     AliCaloPeakFinderVectors  *pfv = (AliCaloPeakFinderVectors *)entry->GetObject(); 
-    cout << __FILE__ << ":" << __LINE__ << ": got pfv !! " << endl;
-
     if( pfv == 0 )
     {
       cout << __FILE__ << ":" << __LINE__ << "_ ERRROR " << endl;
     }
-    
-    cout << __FILE__ << ":" << __LINE__ << ": TP0 !! " << endl;
     CopyVectors( pfv );
-   
-    cout << __FILE__ << ":" << __LINE__ << ": TP1 !! " << endl;
-
+    
     if( pfv != 0 )
     {
       fIsInitialized = true;
     }
   }
-  
 }