LCOV - code coverage report
Current view: top level - EMCAL/EMCALraw - AliCaloRawAnalyzerFakeALTRO.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 64 7.8 %
Date: 2016-06-14 17:26:59 Functions: 3 7 42.9 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /*
      17             :   Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
      18             : */
      19             : 
      20             : 
      21             : #include "AliCaloRawAnalyzerFakeALTRO.h"
      22             : #include "AliCaloBunchInfo.h"
      23             : #include "AliCaloFitResults.h"
      24             : #include "AliLog.h"
      25             : #include "TMath.h"
      26             : #include <stdexcept>
      27             : #include <iostream>
      28             : #include "TF1.h"
      29             : #include "TGraph.h"
      30             : #include "AliCaloConstants.h"
      31             : 
      32             : using namespace std;
      33             : 
      34          42 : ClassImp( AliCaloRawAnalyzerFakeALTRO )
      35             : 
      36             : 
      37           8 : AliCaloRawAnalyzerFakeALTRO::AliCaloRawAnalyzerFakeALTRO() : AliCaloRawAnalyzerFitter("Chi Square Fit", "FakeAltro")
      38          40 : {
      39             :   // constructor
      40             :   
      41           8 :   fAlgo= Algo::kFakeAltro;
      42          16 : }
      43             : 
      44             : AliCaloRawAnalyzerFakeALTRO::~AliCaloRawAnalyzerFakeALTRO()
      45           0 : {
      46             :   // destructor
      47             :   
      48             :   //delete fTf1;
      49           0 : }
      50             : 
      51             : AliCaloFitResults
      52             : AliCaloRawAnalyzerFakeALTRO::Evaluate( const vector<AliCaloBunchInfo>  &bunchvector,
      53             :                                       UInt_t altrocfg1, UInt_t altrocfg2 )
      54             : {
      55             :   // Extracting signal parameters using fitting
      56             :   
      57           0 :   short maxampindex; //index of maximum amplitude
      58           0 :   short maxamp; //Maximum amplitude
      59           0 :   int index = SelectBunch( bunchvector,  &maxampindex,  &maxamp );
      60             :   
      61           0 :   if( index >= 0)
      62             :   {
      63           0 :     Float_t  ped  = ReverseAndSubtractPed( &(bunchvector.at(index))  ,  altrocfg1, altrocfg2, fReversed  );
      64           0 :     Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(),  fReversed );
      65           0 :     short maxrev = maxampindex  -  bunchvector.at(index).GetStartBin();
      66             :     // timebinOffset is timebin value at maximum (maxrev)
      67           0 :     short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
      68           0 :     Float_t time = (timebinOffset*TIMEBINWITH)-fL1Phase;
      69           0 :     if(  maxf < fAmpCut  ||  maxamp > fOverflowCut  ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
      70             :     {
      71           0 :       return  AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, time, (int)time, 0, 0, Ret::kDummy);
      72             :     }
      73           0 :     else if ( maxf >= fAmpCut )
      74             :     {
      75           0 :       int first = 0;
      76           0 :       int last = 0;
      77           0 :       SelectSubarray( fReversed,  bunchvector.at(index).GetLength(),  maxrev, &first, &last, fFitArrayCut );
      78           0 :       int nsamples =  last - first + 1;
      79             :       
      80           0 :       if( ( nsamples  )  >= fNsampleCut )
      81             :             {
      82           0 :               Float_t tmax = (maxrev - first); // local tmax estimate
      83           0 :               TGraph *graph =  new TGraph(  nsamples, fXaxis,  &fReversed[first] );
      84           0 :               fTf1->SetParameter(0, maxf*fkEulerSquared );
      85           0 :               fTf1->SetParameter(1, tmax - fTau);
      86             :               // set rather loose parameter limits
      87           0 :               fTf1->SetParLimits(0, 0.5*maxf*fkEulerSquared, 2*maxf*fkEulerSquared );
      88           0 :               fTf1->SetParLimits(1, tmax - fTau - 4, tmax - fTau + 4);
      89             :         
      90           0 :               if (fFixTau) {
      91           0 :           fTf1->FixParameter(2, fTau);
      92           0 :               }
      93             :               else {
      94           0 :           fTf1->ReleaseParameter(2); // allow par. to vary
      95           0 :           fTf1->SetParameter(2, fTau);
      96             :               }
      97             :         
      98             :               Short_t tmpStatus = 0;
      99             :               try {
     100           0 :           tmpStatus =  graph->Fit(fTf1, "Q0RW");
     101           0 :               }
     102             :               catch (const std::exception & e) {
     103           0 :           AliError( Form("TGraph Fit exception %s, fit status %d", e.what(),tmpStatus) );
     104           0 :           return AliCaloFitResults( maxamp, ped, Ret::kNoFit, maxf, time,
     105           0 :                                    (int)time, Ret::kDummy, Ret::kDummy,  Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
     106           0 :               }
     107             :         
     108           0 :               if( fVerbose == true )
     109             :         {
     110           0 :           AliCaloRawAnalyzer::PrintBunch( bunchvector.at(index) );
     111           0 :           PrintFitResult( fTf1 ) ;
     112           0 :         }
     113             :               // global tmax
     114           0 :               tmax = fTf1->GetParameter(1) + timebinOffset - (maxrev - first) // abs. t0
     115           0 :         + fTf1->GetParameter(2); // +tau, makes sum tmax
     116           0 :             Float_t timemax = (tmax*TIMEBINWITH)-fL1Phase;
     117           0 :         delete graph;
     118           0 :         return AliCaloFitResults( maxamp, ped , Ret::kFitPar,
     119           0 :                                  fTf1->GetParameter(0)/fkEulerSquared,
     120           0 :                                  timemax,
     121           0 :                                  (int)timemax,
     122           0 :                                  fTf1->GetChisquare(),
     123           0 :                                  fTf1->GetNDF(),
     124           0 :                                  Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
     125             :                                 
     126             :         //     delete graph;
     127             :         
     128             :             }
     129             :       else
     130             :             {
     131           0 :               Float_t chi2 = CalculateChi2(maxf, maxrev, first, last);
     132           0 :               Int_t ndf = last - first - 1; // nsamples - 2
     133           0 :               return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, time,
     134           0 :                                  (int)time, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
     135             :             }
     136           0 :     } // ampcut
     137           0 :   }
     138           0 :   return AliCaloFitResults(  Ret::kInvalid,  Ret::kInvalid );
     139           0 : }
     140             : 

Generated by: LCOV version 1.11