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