]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliCaloRawAnalyzerFastFit.cxx
Merge branch 'MyDevBranch'
[u/mrichter/AliRoot.git] / EMCAL / AliCaloRawAnalyzerFastFit.cxx
CommitLineData
168c7b3c 1// -*- mode: c++ -*-
e37e3c84 2/**************************************************************************
3 * This file is property of and copyright by the Experimental Nuclear *
4 * Physics Group, Dep. of Physics *
5 * University of Oslo, Norway, 2007 *
6 * *
7 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
8 * Contributors are mentioned in the code where appropriate. *
9 * Please report bugs to perthi@fys.uio.no *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19
20
21// Extraction of Amplitude and peak
5c9243fa 22// position using special algorithm
e37e3c84 23// from Alexei Pavlinov
24// ----------------
25// ----------------
26
27#include "AliCaloRawAnalyzerFastFit.h"
28#include "AliCaloFastAltroFitv0.h"
29#include "AliCaloFitResults.h"
30#include "AliCaloBunchInfo.h"
f57baa2d 31#include "TMath.h"
e37e3c84 32#include <iostream>
33
34using namespace std;
168c7b3c 35#include "AliCaloConstants.h"
168c7b3c 36
e37e3c84 37ClassImp( AliCaloRawAnalyzerFastFit )
38
40bd46e7 39
40AliCaloRawAnalyzerFastFit::AliCaloRawAnalyzerFastFit() : AliCaloRawAnalyzerFitter("Fast Fit (Alexei)", "FF")
e37e3c84 41{
5c9243fa 42 // Constructor
168c7b3c 43 fAlgo= Algo::kFastFit;
e37e3c84 44}
45
e37e3c84 46AliCaloFitResults
47AliCaloRawAnalyzerFastFit::Evaluate( const vector<AliCaloBunchInfo> &bunchvector,
6656f267 48 UInt_t altrocfg1, UInt_t altrocfg2 )
e37e3c84 49{
5c9243fa 50 // Execute algorithm
51
e37e3c84 52 short maxampindex; //index of maximum amplitude
53 short maxamp; //Maximum amplitude
54 int index = SelectBunch( bunchvector, &maxampindex, &maxamp );
5c9243fa 55
e37e3c84 56 if( index >= 0)
5c9243fa 57 {
58 Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed );
59 Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed );
60 short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
61
62 if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
e37e3c84 63 {
5c9243fa 64 return AliCaloFitResults( maxamp, ped, Algo::kCrude, maxf, timebinOffset*TIMEBINWITH); //Time scale 19/08/2014 (Antônio)
65 }
66 else if ( maxf >= fAmpCut ) // no if statement needed really; keep for readability
67 {
68 int first = 0;
69 int last = 0;
70 int maxrev = maxampindex - bunchvector.at(index).GetStartBin();
71
72 SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last, fFitArrayCut);
73
74 int nsamples = last - first + 1;
75
76 if( ( nsamples ) >= fNsampleCut )
e37e3c84 77 {
78 Double_t ordered[1008];
5c9243fa 79
e211d601 80 for(int i=0; i < nsamples ; i++ )
5c9243fa 81 {
82 ordered[i] = fReversed[first + i];
83 }
84
e37e3c84 85 Double_t eSignal = 1; // nominal 1 ADC error
5c9243fa 86 Double_t dAmp = maxf;
e37e3c84 87 Double_t eAmp = 0;
507751ce 88 Double_t dTime0 = 0;
e37e3c84 89 Double_t eTime = 0;
90 Double_t chi2 = 0;
e211d601 91 Double_t dTau = 2.35; // time-bin units
e37e3c84 92
40bd46e7 93 AliCaloFastAltroFitv0::FastFit(fXaxis, ordered , nsamples,
5c9243fa 94 eSignal, dTau, dAmp, eAmp, dTime0, eTime, chi2);
507751ce 95 Double_t dTimeMax = dTime0 + timebinOffset - (maxrev - first) // abs. t0
5c9243fa 96 + dTau; // +tau, makes sum tmax
97
98 return AliCaloFitResults(maxamp,ped,Ret::kFitPar,dAmp,dTimeMax*TIMEBINWITH,timebinOffset,chi2,Ret::kDummy,Ret::kDummy,AliCaloFitSubarray(index,maxrev,first,last)); //Time scale 19/08/2014 (Antônio)
f57baa2d 99 } // samplecut
5c9243fa 100 else
f57baa2d 101 {
5c9243fa 102
2cd0ffda 103 Float_t chi2 = CalculateChi2(maxf, maxrev, first, last);
104 Int_t ndf = last - first - 1; // nsamples - 2
5c9243fa 105 return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset*TIMEBINWITH, timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); //Time scale 19/08/2014 (Antônio)
e37e3c84 106 }
5c9243fa 107 } // ampcut
108 } // bunch index
109
168c7b3c 110 return AliCaloFitResults( Ret::kInvalid , Ret::kInvalid );
e37e3c84 111}