]>
Commit | Line | Data |
---|---|---|
de39a0ff | 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 | /* | |
652d1723 | 17 | Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 |
de39a0ff | 18 | */ |
19 | ||
652d1723 | 20 | |
de39a0ff | 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" | |
168c7b3c | 30 | #include "AliCaloConstants.h" |
de39a0ff | 31 | |
32 | using namespace std; | |
33 | ||
de39a0ff | 34 | ClassImp( AliCaloRawAnalyzerFakeALTRO ) |
35 | ||
36 | ||
aa79a0ff | 37 | AliCaloRawAnalyzerFakeALTRO::AliCaloRawAnalyzerFakeALTRO() : AliCaloRawAnalyzerFitter("Chi Square Fit", "FakeAltro") |
de39a0ff | 38 | { |
aa79a0ff | 39 | // constructor |
40 | ||
41da8832 | 41 | fAlgo= Algo::kFakeAltro; |
de39a0ff | 42 | } |
43 | ||
de39a0ff | 44 | AliCaloRawAnalyzerFakeALTRO::~AliCaloRawAnalyzerFakeALTRO() |
45 | { | |
aa79a0ff | 46 | // destructor |
47 | ||
396baaf6 | 48 | //delete fTf1; |
de39a0ff | 49 | } |
50 | ||
de39a0ff | 51 | AliCaloFitResults |
52 | AliCaloRawAnalyzerFakeALTRO::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2 ) | |
53 | { | |
54 | // Extracting signal parameters using fitting | |
55 | short maxampindex; //index of maximum amplitude | |
56 | short maxamp; //Maximum amplitude | |
57 | int index = SelectBunch( bunchvector, &maxampindex, &maxamp ); | |
58 | ||
59 | if( index >= 0) | |
852a34a0 | 60 | { |
61 | Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed ); | |
62 | Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed ); | |
63 | short maxrev = maxampindex - bunchvector.at(index).GetStartBin(); | |
64 | // timebinOffset is timebin value at maximum (maxrev) | |
65 | short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1); | |
66 | if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then) | |
de39a0ff | 67 | { |
852a34a0 | 68 | return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset); |
69 | } | |
70 | else if ( maxf >= fAmpCut ) | |
71 | { | |
72 | int first = 0; | |
73 | int last = 0; | |
74 | SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev, &first, &last, fFitArrayCut ); | |
75 | int nsamples = last - first + 1; | |
76 | ||
77 | if( ( nsamples ) >= fNsampleCut ) | |
de39a0ff | 78 | { |
79 | Float_t tmax = (maxrev - first); // local tmax estimate | |
80 | TGraph *graph = new TGraph( nsamples, fXaxis, &fReversed[first] ); | |
81 | fTf1->SetParameter(0, maxf*fkEulerSquared ); | |
852a34a0 | 82 | fTf1->SetParameter(1, tmax - fTau); |
de39a0ff | 83 | // set rather loose parameter limits |
84 | fTf1->SetParLimits(0, 0.5*maxf*fkEulerSquared, 2*maxf*fkEulerSquared ); | |
852a34a0 | 85 | fTf1->SetParLimits(1, tmax - fTau - 4, tmax - fTau + 4); |
86 | ||
de39a0ff | 87 | if (fFixTau) { |
852a34a0 | 88 | fTf1->FixParameter(2, fTau); |
de39a0ff | 89 | } |
90 | else { | |
852a34a0 | 91 | fTf1->ReleaseParameter(2); // allow par. to vary |
92 | fTf1->SetParameter(2, fTau); | |
de39a0ff | 93 | } |
852a34a0 | 94 | |
de39a0ff | 95 | Short_t tmpStatus = 0; |
96 | try { | |
852a34a0 | 97 | tmpStatus = graph->Fit(fTf1, "Q0RW"); |
de39a0ff | 98 | } |
99 | catch (const std::exception & e) { | |
852a34a0 | 100 | AliError( Form("TGraph Fit exception %s, fit status %d", e.what(),tmpStatus) ); |
101 | return AliCaloFitResults( maxamp, ped, Ret::kNoFit, maxf, timebinOffset, | |
102 | timebinOffset, Ret::kDummy, Ret::kDummy, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
de39a0ff | 103 | } |
852a34a0 | 104 | |
de39a0ff | 105 | if( fVerbose == true ) |
852a34a0 | 106 | { |
107 | AliCaloRawAnalyzer::PrintBunch( bunchvector.at(index) ); | |
108 | PrintFitResult( fTf1 ) ; | |
109 | } | |
de39a0ff | 110 | // global tmax |
111 | tmax = fTf1->GetParameter(1) + timebinOffset - (maxrev - first) // abs. t0 | |
852a34a0 | 112 | + fTf1->GetParameter(2); // +tau, makes sum tmax |
de39a0ff | 113 | |
852a34a0 | 114 | delete graph; |
115 | return AliCaloFitResults( maxamp, ped , Ret::kFitPar, | |
116 | fTf1->GetParameter(0)/fkEulerSquared, | |
117 | tmax, | |
118 | timebinOffset, | |
119 | fTf1->GetChisquare(), | |
120 | fTf1->GetNDF(), | |
121 | Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
de39a0ff | 122 | |
852a34a0 | 123 | // delete graph; |
124 | ||
de39a0ff | 125 | } |
852a34a0 | 126 | else |
de39a0ff | 127 | { |
128 | Float_t chi2 = CalculateChi2(maxf, maxrev, first, last); | |
129 | Int_t ndf = last - first - 1; // nsamples - 2 | |
168c7b3c | 130 | return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset, |
852a34a0 | 131 | timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); |
de39a0ff | 132 | } |
852a34a0 | 133 | } // ampcut |
134 | } | |
168c7b3c | 135 | return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid ); |
de39a0ff | 136 | } |
137 |