]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliCaloRawAnalyzerLMS.cxx
skip unused TGraph + add access to TF1
[u/mrichter/AliRoot.git] / EMCAL / AliCaloRawAnalyzerLMS.cxx
CommitLineData
d655d7dd 1/**************************************************************************
2 * This file is property of and copyright by *
3 * the Relativistic Heavy Ion Group (RHIG), Yale University, US, 2009 *
4 * *
5 * Primary Author: Per Thomas Hille <p.t.hille@fys.uio.no> *
6 * *
7 * Contributors are mentioned in the code where appropriate. *
8 * Please report bugs to p.t.hille@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 **************************************************************************/
18
19
20// Extraction of amplitude and peak position
57839add 21// FRom CALO raw data using
d655d7dd 22// least square fit for the
23// Moment assuming identical and
24// independent errors (equivalent with chi square)
25//
26
57839add 27#include "AliCaloRawAnalyzerLMS.h"
28#include "AliCaloBunchInfo.h"
29#include "AliCaloFitResults.h"
d655d7dd 30#include "AliLog.h"
31#include "TMath.h"
32#include <iostream>
33#include "TF1.h"
34#include "TGraph.h"
35
36using namespace std;
37
38
39#define BAD 4 //CRAP PTH
e37e3c84 40
41ClassImp( AliCaloRawAnalyzerLMS )
d655d7dd 42
43
48a2e3eb 44AliCaloRawAnalyzerLMS::AliCaloRawAnalyzerLMS() : AliCaloRawAnalyzer("Chi Square Fit", "LMS"),
57839add 45 fkEulerSquared(7.389056098930650227),
f57baa2d 46 fTf1(0),
47 fTau(2.35),
48 fFixTau(kTRUE)
d655d7dd 49{
50 //comment
51 for(int i=0; i < MAXSAMPLES; i++)
52 {
53 fXaxis[i] = i;
54 }
55
f57baa2d 56 fTf1 = new TF1( "myformula", "[0]*((x - [1])/[2])^2*exp(-2*(x -[1])/[2])", 0, 30 );
57 if (fFixTau) {
58 fTf1->FixParameter(2, fTau);
59 }
60 else {
61 fTf1->ReleaseParameter(2); // allow par. to vary
62 fTf1->SetParameter(2, fTau);
63 }
64
d655d7dd 65}
66
67
57839add 68AliCaloRawAnalyzerLMS::~AliCaloRawAnalyzerLMS()
d655d7dd 69{
70 delete fTf1;
71}
72
73
74
57839add 75AliCaloFitResults
76AliCaloRawAnalyzerLMS::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2 )
d655d7dd 77{
78 // Extracting signal parameters using fitting
79 short maxampindex; //index of maximum amplitude
80 short maxamp; //Maximum amplitude
81 int index = SelectBunch( bunchvector, &maxampindex, &maxamp );
82
83 if( index >= 0)
84 {
85 Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed );
86 int first;
87 int last;
88 Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed );
f57baa2d 89 short maxrev = maxampindex - bunchvector.at(index).GetStartBin();
90 short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
d655d7dd 91
92 if ( maxf > fAmpCut )
93 {
3b8fd9fe 94 SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev, &first, &last);
95 int nsamples = last - first + 1;
d655d7dd 96
f57baa2d 97 if( ( nsamples ) >= fNsampleCut )
d655d7dd 98 {
99
3b8fd9fe 100 TGraph *graph = new TGraph( nsamples, fXaxis, &fReversed[first] );
d655d7dd 101 fTf1->SetParameter(0, maxf*fkEulerSquared );
57839add 102 fTf1->SetParameter(1, 0.2);
f57baa2d 103
104 if (fFixTau) {
105 fTf1->FixParameter(2, fTau);
106 }
107 else {
108 fTf1->ReleaseParameter(2); // allow par. to vary
109 fTf1->SetParameter(2, fTau);
110 }
d655d7dd 111
112 Short_t tmpStatus = graph->Fit(fTf1, "Q0RW");
113
d655d7dd 114 if( fVerbose == true )
115 {
57839add 116 AliCaloRawAnalyzer::PrintBunch( bunchvector.at(index) );
d655d7dd 117 PrintFitResult( fTf1 ) ;
118 }
119
120 delete graph;
57839add 121 return AliCaloFitResults( maxamp, ped , tmpStatus,
f57baa2d 122 fTf1->GetParameter(0)/fkEulerSquared,
123 fTf1->GetParameter(1) + timebinOffset,
124 fTf1->GetChisquare(),
125 fTf1->GetNDF(),
126 AliCaloFitResults::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
127
d655d7dd 128 // delete graph;
129
130 }
131 else
132 {
f57baa2d 133 return AliCaloFitResults( maxamp, ped, AliCaloFitResults::kNoFit, maxf, maxrev+timebinOffset, AliCaloFitResults::kNoFit, AliCaloFitResults::kNoFit,
134 AliCaloFitResults::kNoFit, AliCaloFitSubarray(index, maxrev, first, last) );
d655d7dd 135 }
136 }
137 else
138 {
f57baa2d 139 return AliCaloFitResults( maxamp , ped, AliCaloFitResults::kNoFit, maxf, maxrev+timebinOffset, AliCaloFitResults::kNoFit, AliCaloFitResults::kNoFit);
d655d7dd 140 }
141 }
d655d7dd 142
f57baa2d 143 return AliCaloFitResults( AliCaloFitResults::kInvalid, AliCaloFitResults::kInvalid );
d655d7dd 144
145}
146
147
148void
57839add 149AliCaloRawAnalyzerLMS::PrintFitResult(const TF1 *f) const
d655d7dd 150{
151 //comment
152 cout << endl;
153 cout << __FILE__ << __LINE__ << "Using this samplerange we get" << endl;
154 cout << __FILE__ << __LINE__ << "AMPLITUDE = " << f->GetParameter(0)/fkEulerSquared << ",.. !!!!" << endl;
155 cout << __FILE__ << __LINE__ << "TOF = " << f->GetParameter(1) << ",.. !!!!" << endl;
156 cout << __FILE__ << __LINE__ << "NDF = " << f->GetNDF() << ",.. !!!!" << endl;
157 // cout << __FILE__ << __LINE__ << "STATUS = " << f->GetStatus() << ",.. !!!!" << endl << endl;
158 cout << endl << endl;
159}
f57baa2d 160