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