]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRawAnalyzer.cxx
Refactoring: Removing man in the middle classes
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzer.cxx
CommitLineData
0a211711 1/**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Per Thomas Hille for the ALICE HLT 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
04751caa 16
cbab66dd 17#include "AliHLTPHOSRawAnalyzer.h"
2589c3a3 18#include "AliHLTPHOSUtilities.h"
cbab66dd 19
04751caa 20AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer(): AliHLTPHOSBase(),
2589c3a3 21 // fDoCorrectBaselineUsingFirstFiveSamples(false),
22 fDoCorrectBaselineUsingFirstFiveSamples(true),
04751caa 23 fDoubleDataPtr(0),
b444d727 24 fIntDataPtr(0),
25 fSampleFrequency(10),
26 fDTofGuess(-1),
27 fDAmplGuess(-1),
28 fTau(2),
29 fDTof(99999),
30 fDAmpl(99999),
2589c3a3 31 fStartIndex(0),
32 fUtilitiesPtr(0)
cbab66dd 33{
04751caa 34 // fIntDataPtr = new UInt_t[1008];
35
36 // fDoubleDataPtr;
2589c3a3 37 fUtilitiesPtr = new AliHLTPHOSUtilities();
cbab66dd 38}
39
40AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
41{
04751caa 42 // delete[] fIntDataPtr;
cbab66dd 43}
44
43dd7c5e 45
cbab66dd 46
04751caa 47
48
cbab66dd 49/**
50* Main constructor
d504c864 51* @param dtaPtr Data array for wich a subarray will be taken to perform the fit
cbab66dd 52* @param fs the sampling frequency in entities of MHz. Needed in order to calculate physical time
53**/
b444d727 54AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double * /*dtaPtr*/, double fs): AliHLTPHOSBase(),
04751caa 55 fDoCorrectBaselineUsingFirstFiveSamples(false),
56 fDoubleDataPtr(0),
b444d727 57 fIntDataPtr(0),
58 fSampleFrequency(10),
59 fDTofGuess(-1),
60 fDAmplGuess(-1),
61 fTau(2),
62 fDTof(99999),
63 fDAmpl(99999),
64 fStartIndex(0)
cbab66dd 65{
cbab66dd 66 fSampleFrequency = fs;
67} //end
68
69
04751caa 70
71void
72AliHLTPHOSRawAnalyzer::SetCorrectBaselineUsingFirstFiveSamples()
73{
74 fDoCorrectBaselineUsingFirstFiveSamples = true;
75}
76
77
cbab66dd 78void
04751caa 79//AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(double *data, int length)
80//AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(int *data, int length)
81AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(UInt_t *data, const int length)
cbab66dd 82{
04751caa 83 // cout << "AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples" << endl;
84
2589c3a3 85
86 unsigned int sumOfFirstFiveSamples = 0;
04751caa 87
88 for(int i=0; i< 5; i++)
89 {
90 sumOfFirstFiveSamples += data[i];
91 }
92
2589c3a3 93 unsigned int valueToSubtract = sumOfFirstFiveSamples/5;
04751caa 94
95 for(int j = 0; j < length; j++)
96 {
2589c3a3 97 if( (int)(data[j] - valueToSubtract) > 0)
98 {
99 data[j] = data[j] - valueToSubtract;
100 }
101 else
102 {
103 data[j] = 0;
104 }
04751caa 105 }
2589c3a3 106
04751caa 107}
108
109
8efbf5fe 110
04751caa 111// /**
112// * Attemps to level the basline to zero.
113// * The baseline will be calculated from the pretrigger samples and subtracted from the
114// * data array.
115// * If pretrigger samples are not present then the basline correction will be incorrect.
116// * @param dataPtr array for wich to correct the basline
117// * @param N the number of pretrigger samples used to calculate the baseline.
118// **/
119// void
120// AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, int /*N*/)
121// {
122
123// } //end BaselineCorrection
cbab66dd 124
125
126/**
ee1684e6 127* Shifts the baseline with the amount given by baselineValue
cbab66dd 128* If pretrigger samples are not present then the basline correction will be incorrect.
129* @param dataPtr array for wich to correct the basline
d504c864 130* @param baselineValue the basline value to subtract..
cbab66dd 131**/
132void
ff656fe2 133AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, double /*baselineValue*/)
cbab66dd 134{
8efbf5fe 135
cbab66dd 136} //end BaslineCorrection
137
138
139/**
140 * Gives the timing in entities of sample indexes
141 * Physical time is found by multiplying with the sampling intervall (Ts).
142 **/
143float
d504c864 144AliHLTPHOSRawAnalyzer::GetTiming() const
cbab66dd 145{
146 return fDTof;
147} //end GetTiming
148
149
150/**
151 * Gives the time in entities of ADC channels (quantization levels).
152 * Absolute enrgy is found by multiplying with offline calibration constants.
153 **/
154float
d504c864 155AliHLTPHOSRawAnalyzer::GetEnergy() const
cbab66dd 156{
157 return fDAmpl;
158} //end GetEnergy
159
160
04751caa 161
e086ee30 162/**
163 * Set data array. Overrides data data array set in the constructor.
164 **/
04751caa 165 void
166
167 AliHLTPHOSRawAnalyzer::SetData(const UInt_t *data, const int length)
168 // AliHLTPHOSRawAnalyzer::SetData(UInt_t *data, const int length)
169// AliHLTPHOSRawAnalyzer::SetData(int *data, const int length)
170 {
171 fIntDataPtr = const_cast<UInt_t *>(data);
172
173 if(fDoCorrectBaselineUsingFirstFiveSamples == true)
174 {
175 CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
176 }
177
178 // fIntDataPtr = data;
179
180 }
181
182
183
e086ee30 184
cbab66dd 185/**
186 * Set data array. Overrides data data array set in the constructor.
187 **/
04751caa 188// void
189// //AliHLTPHOSRawAnalyzer::SetData(const double *data)
190// AliHLTPHOSRawAnalyzer::SetData(double *data, const int length)
191// {
192// if(fDoCorrectBaselineUsingFirstFiveSamples == true)
193// {
194// CorrectBaselineUsingFirstFiveSamples(data, length);
195// }
196
197
198// fDoubleDataPtr = data;
199// }
cbab66dd 200
e086ee30 201
202
cbab66dd 203void
204AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
205{
a4a2a400 206 fSampleFrequency = freq;
cbab66dd 207}
208
209int
1804b020 210AliHLTPHOSRawAnalyzer::FindStartIndex(double /*treshold*/)
cbab66dd 211{
8efbf5fe 212 // cout << "Find Start index not yet implemented" << endl;
cbab66dd 213 return 0;
214} //end FindStartIndex
215
216
217/**
218 * This function applies only to the Chi and Least mean square fit. An initial guess is made
219 * based on the average of the first 5 samples and the first value exeeding this value.
220 **/
221void
222AliHLTPHOSRawAnalyzer::MakeInitialGuess()
223{
8efbf5fe 224 // cout << "Make initial guess not yet implemeted" << endl;
cbab66dd 225}
226
227
228/**
229 * This function applies only to the Chi and Least mean square fit. An initial guess is made
230 * based on the average of the first 5 samples and the first value exeeding threshold + this value.
231 * @param treshold The index of the first value above treshold is ntaken to be the first value.
232 **/
233void
1804b020 234AliHLTPHOSRawAnalyzer::MakeInitialGuess(int /*treshold*/)
cbab66dd 235{
8efbf5fe 236 // cout << "Make initial guess not yet implemeted" << endl;
cbab66dd 237}
68d9caee 238
dbd79fad 239
68d9caee 240void
241AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
242{
243 fStartIndex = index;
244}
245
d504c864 246
43dd7c5e 247
68d9caee 248void
1804b020 249AliHLTPHOSRawAnalyzer::SetTVector(Double_t * /*tVector*/, Int_t /*size*/)
68d9caee 250{
8efbf5fe 251 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
68d9caee 252}
253
254
43dd7c5e 255
68d9caee 256void
1804b020 257AliHLTPHOSRawAnalyzer::SetAVector(Double_t * /*aVector*/, Int_t /*size*/)
68d9caee 258{
8efbf5fe 259 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
68d9caee 260}
261
68d9caee 262