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