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