]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliCaloRawAnalyzerLMS.cxx
Change digitization threshold to >=3 ACD units, now cut on ADC value of digit after...
[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
e37e3c84 44AliCaloRawAnalyzerLMS::AliCaloRawAnalyzerLMS() : AliCaloRawAnalyzer("Chi Square Fit"),
57839add 45 fkEulerSquared(7.389056098930650227),
46 fSig(0),
47 fTf1(0)
d655d7dd 48{
49 //comment
50 for(int i=0; i < MAXSAMPLES; i++)
51 {
52 fXaxis[i] = i;
53 }
54
55 fTf1 = new TF1( "myformula", "[0]*((x - [1])/2.35)^2*exp(-2*(x -[1])/2.35)", 0, 30 );
56 // fTf1 = new TF1( "myformula", "[0]*((x - [1])/[2])^[3]*exp(-[3]*(x -[1])/[2])", 0, 30 );
57
58}
59
60
57839add 61AliCaloRawAnalyzerLMS::~AliCaloRawAnalyzerLMS()
d655d7dd 62{
63 delete fTf1;
64}
65
66
67
57839add 68AliCaloFitResults
69AliCaloRawAnalyzerLMS::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2 )
d655d7dd 70{
71 // Extracting signal parameters using fitting
72 short maxampindex; //index of maximum amplitude
73 short maxamp; //Maximum amplitude
74 int index = SelectBunch( bunchvector, &maxampindex, &maxamp );
75
76 if( index >= 0)
77 {
78 Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed );
79 int first;
80 int last;
81 Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed );
82
83 if ( maxf > fAmpCut )
84 {
85 SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxampindex - bunchvector.at(index).GetStartBin(), &first, &last);
86 int nsamples = last - first;
87
88 if( ( nsamples ) > fNsampleCut )
89 {
90
91 TGraph *graph = new TGraph( last - first, fXaxis, &fReversed[first] );
92 fTf1->SetParameter(0, maxf*fkEulerSquared );
57839add 93 fTf1->SetParameter(1, 0.2);
d655d7dd 94 // fTf1->SetParameter(2, 2);
95 // fTf1->SetParameter(2, 3);
96
57839add 97 // return AliCaloFitResults( -1 , -1 , -1, -1, -1, -1 , -1);
d655d7dd 98
99 Short_t tmpStatus = graph->Fit(fTf1, "Q0RW");
100
57839add 101 // return AliCaloFitResults( -1 , -1 , -1, -1, -1, -1 , -1);
d655d7dd 102
103 if( fVerbose == true )
104 {
57839add 105 AliCaloRawAnalyzer::PrintBunch( bunchvector.at(index) );
d655d7dd 106 PrintFitResult( fTf1 ) ;
107 }
108
109 delete graph;
57839add 110 return AliCaloFitResults( maxamp, ped , tmpStatus,
d655d7dd 111 fTf1->GetParameter(0)/fkEulerSquared,
112 fTf1->GetParameter(1) + maxampindex,
113 fTf1->GetChisquare(),
114 fTf1->GetNDF());
115
116
117 // delete graph;
118
119 }
120 else
121 {
57839add 122 return AliCaloFitResults( maxamp, ped, -1, maxf, -1, -1, -1 );
d655d7dd 123 }
124 }
125 else
126 {
57839add 127 return AliCaloFitResults( maxamp , ped, -1, maxf, -1, -1, -1 );
d655d7dd 128 }
129 }
130 else
131 {
57839add 132 return AliCaloFitResults( -99, -99 );
d655d7dd 133 }
134
57839add 135 return AliCaloFitResults( -99, -99 );
d655d7dd 136
137}
138
139
140void
57839add 141AliCaloRawAnalyzerLMS::PrintFitResult(const TF1 *f) const
d655d7dd 142{
143 //comment
144 cout << endl;
145 cout << __FILE__ << __LINE__ << "Using this samplerange we get" << endl;
146 cout << __FILE__ << __LINE__ << "AMPLITUDE = " << f->GetParameter(0)/fkEulerSquared << ",.. !!!!" << endl;
147 cout << __FILE__ << __LINE__ << "TOF = " << f->GetParameter(1) << ",.. !!!!" << endl;
148 cout << __FILE__ << __LINE__ << "NDF = " << f->GetNDF() << ",.. !!!!" << endl;
149 // cout << __FILE__ << __LINE__ << "STATUS = " << f->GetStatus() << ",.. !!!!" << endl << endl;
150 cout << endl << endl;
151}