]>
Commit | Line | Data |
---|---|---|
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 | |
22 | // position using specila algorithm | |
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 | ||
168c7b3c | 34 | |
e37e3c84 | 35 | using namespace std; |
36 | ||
168c7b3c | 37 | #include "AliCaloConstants.h" |
38 | //using namespace CaloConstants::FitAlgorithm; | |
39 | //using namespace CaloConstants::ReturnCodes; | |
40 | ||
e37e3c84 | 41 | ClassImp( AliCaloRawAnalyzerFastFit ) |
42 | ||
48a2e3eb | 43 | AliCaloRawAnalyzerFastFit::AliCaloRawAnalyzerFastFit() : AliCaloRawAnalyzer("Fast Fit (Alexei)", "FF") |
e37e3c84 | 44 | { |
45 | // Comment | |
168c7b3c | 46 | fAlgo= Algo::kFastFit; |
e37e3c84 | 47 | |
48 | for(int i=0; i < 1008; i++) | |
49 | { | |
50 | fXAxis[i] = i; | |
51 | } | |
52 | ||
53 | } | |
54 | ||
55 | AliCaloRawAnalyzerFastFit::~AliCaloRawAnalyzerFastFit() | |
56 | { | |
57 | ||
58 | } | |
59 | ||
60 | ||
61 | AliCaloFitResults | |
62 | AliCaloRawAnalyzerFastFit::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, | |
63 | const UInt_t altrocfg1, const UInt_t altrocfg2 ) | |
64 | { | |
65 | // Comment | |
66 | ||
67 | short maxampindex; //index of maximum amplitude | |
68 | short maxamp; //Maximum amplitude | |
69 | int index = SelectBunch( bunchvector, &maxampindex, &maxamp ); | |
70 | ||
71 | if( index >= 0) | |
72 | { | |
73 | Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed ); | |
f57baa2d | 74 | Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed ); |
3b8fd9fe | 75 | short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1); |
2cd0ffda | 76 | |
77 | if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then) | |
78 | { | |
168c7b3c | 79 | return AliCaloFitResults( maxamp, ped, Algo::kCrude, maxf, timebinOffset); |
2cd0ffda | 80 | } |
81 | else if ( maxf >= fAmpCut ) // no if statement needed really; keep for readability | |
e37e3c84 | 82 | { |
2cd0ffda | 83 | int first = 0; |
84 | int last = 0; | |
85 | int maxrev = maxampindex - bunchvector.at(index).GetStartBin(); | |
86 | ||
e37e3c84 | 87 | SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last); |
3b8fd9fe | 88 | int nsamples = last - first + 1; |
e37e3c84 | 89 | |
e37e3c84 | 90 | if( ( nsamples ) >= fNsampleCut ) |
91 | { | |
92 | Double_t ordered[1008]; | |
93 | ||
e211d601 | 94 | for(int i=0; i < nsamples ; i++ ) |
95 | { | |
96 | ordered[i] = fReversed[first + i]; | |
97 | } | |
e37e3c84 | 98 | |
99 | Double_t eSignal = 1; // nominal 1 ADC error | |
100 | Double_t dAmp = maxf; | |
101 | Double_t eAmp = 0; | |
507751ce | 102 | Double_t dTime0 = 0; |
e37e3c84 | 103 | Double_t eTime = 0; |
104 | Double_t chi2 = 0; | |
e211d601 | 105 | Double_t dTau = 2.35; // time-bin units |
e37e3c84 | 106 | |
e37e3c84 | 107 | AliCaloFastAltroFitv0::FastFit(fXAxis, ordered , nsamples, |
507751ce | 108 | eSignal, dTau, dAmp, eAmp, dTime0, eTime, chi2); |
e37e3c84 | 109 | |
507751ce | 110 | Double_t dTimeMax = dTime0 + timebinOffset - (maxrev - first) // abs. t0 |
111 | + dTau; // +tau, makes sum tmax | |
168c7b3c | 112 | return AliCaloFitResults(maxamp, ped, Ret::kFitPar, dAmp, dTimeMax, timebinOffset, chi2, Ret::kDummy, |
113 | Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
f57baa2d | 114 | } // samplecut |
115 | else | |
116 | { | |
2cd0ffda | 117 | Float_t chi2 = CalculateChi2(maxf, maxrev, first, last); |
118 | Int_t ndf = last - first - 1; // nsamples - 2 | |
168c7b3c | 119 | return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset, |
120 | timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
e37e3c84 | 121 | } |
f57baa2d | 122 | } // ampcut |
f57baa2d | 123 | } // bunch index |
124 | ||
168c7b3c | 125 | return AliCaloFitResults( Ret::kInvalid , Ret::kInvalid ); |
126 | ||
127 | // return AliCaloFitResults( kInvalid , kInvalid, | |
128 | // kInvalid, kInvalid, kInvalid ); | |
129 | ||
e37e3c84 | 130 | } |