add protection against truncated events + coverity - Rachid
[u/mrichter/AliRoot.git] / EMCAL / AliCaloRawAnalyzerCrude.cxx
CommitLineData
d655d7dd 1/**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
5 * *
6 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
7 * Contributors are mentioned in the code where appropriate. *
8 * Please report bugs to perthi@fys.uio.no *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
e37e3c84 18
19// Evaluation of amplitude
20// as max sample value - pedestal
21// Not veru accurate, but very robust
22// --------------
23// --------------
24
57839add 25#include "AliCaloRawAnalyzerCrude.h"
26#include "AliCaloFitResults.h"
27#include "AliCaloBunchInfo.h"
2cd0ffda 28#include "TMath.h"
ce95bae9 29using namespace std;
57839add 30
e37e3c84 31ClassImp(AliCaloRawAnalyzerCrude)
32
33
48a2e3eb 34AliCaloRawAnalyzerCrude::AliCaloRawAnalyzerCrude() : AliCaloRawAnalyzer("Crude", "Crude")
57839add 35{
4074cc41 36 //Comment
168c7b3c 37 fAlgo=Algo::kCrude;
57839add 38}
d655d7dd 39
40
57839add 41AliCaloRawAnalyzerCrude::~AliCaloRawAnalyzerCrude()
42{
4074cc41 43 //Comment
57839add 44}
d655d7dd 45
d655d7dd 46
57839add 47AliCaloFitResults
2cd0ffda 48AliCaloRawAnalyzerCrude::Evaluate(const vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2)
d655d7dd 49{
e37e3c84 50 // Evaluation of signal parameters
2cd0ffda 51 short maxampindex; //index of maximum amplitude
52 short maxamp; //Maximum amplitude
53 int index = SelectBunch( bunchvector, &maxampindex, &maxamp );
54
55 if( index >= 0)
57839add 56 {
2cd0ffda 57 Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed );
58 Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed );
59 short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
60
61 if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
62 {
168c7b3c 63 return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset);
2cd0ffda 64 }
65 else if ( maxf >= fAmpCut ) // no if statement needed really; keep for readability
66 {
67 int first = 0;
68 int last = 0;
69 int maxrev = maxampindex - bunchvector.at(index).GetStartBin();
92d9f317 70 SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last, fFitArrayCut );
2cd0ffda 71
72 Float_t chi2 = CalculateChi2(maxf, maxrev, first, last);
73 Int_t ndf = last - first - 1; // nsamples - 2
168c7b3c 74 return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset,
75 timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
2cd0ffda 76 } // ampcut
77 } // bunch index
78
168c7b3c 79 return AliCaloFitResults( Ret::kInvalid , Ret::kInvalid);
57839add 80
57839add 81} //end Crude
d655d7dd 82
d655d7dd 83