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 | |
cbab66dd |
16 | #include "AliHLTPHOSRawAnalyzer.h" |
17 | #include <iostream> |
18 | |
19 | using std::cout; |
20 | using std::endl; |
21 | |
e086ee30 |
22 | //AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer():fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999) |
23 | AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer():fIntDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999) |
cbab66dd |
24 | { |
e086ee30 |
25 | // fFloatDataPtr = new double[1008]; |
26 | fIntDataPtr = new UInt_t[1008]; |
cbab66dd |
27 | } |
28 | |
29 | AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer() |
30 | { |
31 | |
32 | } |
33 | |
e086ee30 |
34 | //AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(AliHLTPHOSRawAnalyzer const&):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), fStartIndex(0) |
35 | AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(AliHLTPHOSRawAnalyzer const&):fIntDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), fStartIndex(0) |
cbab66dd |
36 | { |
37 | |
38 | } |
39 | |
40 | /** |
41 | * Main constructor |
d504c864 |
42 | * @param dtaPtr Data array for wich a subarray will be taken to perform the fit |
cbab66dd |
43 | * @param fs the sampling frequency in entities of MHz. Needed in order to calculate physical time |
44 | **/ |
e086ee30 |
45 | //AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double *dtaPtr, double fs):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), fStartIndex(0) |
46 | AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double *dtaPtr, double fs):fIntDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), fStartIndex(0) |
cbab66dd |
47 | { |
e086ee30 |
48 | // fIntDataPtr = dtaPtr; |
cbab66dd |
49 | fSampleFrequency = fs; |
50 | } //end |
51 | |
52 | |
53 | /** |
54 | * Attemps to level the basline to zero. |
55 | * The baseline will be calculated from the pretrigger samples and subtracted from the |
56 | * data array. |
57 | * If pretrigger samples are not present then the basline correction will be incorrect. |
58 | * @param dataPtr array for wich to correct the basline |
59 | * @param N the number of pretrigger samples used to calculate the baseline. |
60 | **/ |
61 | void |
62 | AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, int N) |
63 | { |
e086ee30 |
64 | // fFloatDataPtr = dataPtr; |
65 | |
cbab66dd |
66 | cout << "Baseline correction not yet implemeted" << endl; |
67 | } //end BaselineCorrection |
68 | |
69 | |
70 | /** |
ee1684e6 |
71 | * Shifts the baseline with the amount given by baselineValue |
cbab66dd |
72 | * If pretrigger samples are not present then the basline correction will be incorrect. |
73 | * @param dataPtr array for wich to correct the basline |
d504c864 |
74 | * @param baselineValue the basline value to subtract.. |
cbab66dd |
75 | **/ |
76 | void |
77 | AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, double baselineValue) |
78 | { |
e086ee30 |
79 | // fFloatDataPtr = dataPtr; |
cbab66dd |
80 | printf("\nbaselineValue = %f\n", baselineValue); |
81 | cout << "Baseline correction not yet implemeted" << endl; |
82 | } //end BaslineCorrection |
83 | |
84 | |
85 | /** |
86 | * Gives the timing in entities of sample indexes |
87 | * Physical time is found by multiplying with the sampling intervall (Ts). |
88 | **/ |
89 | float |
d504c864 |
90 | AliHLTPHOSRawAnalyzer::GetTiming() const |
cbab66dd |
91 | { |
92 | return fDTof; |
93 | } //end GetTiming |
94 | |
95 | |
96 | /** |
97 | * Gives the time in entities of ADC channels (quantization levels). |
98 | * Absolute enrgy is found by multiplying with offline calibration constants. |
99 | **/ |
100 | float |
d504c864 |
101 | AliHLTPHOSRawAnalyzer::GetEnergy() const |
cbab66dd |
102 | { |
103 | return fDAmpl; |
104 | } //end GetEnergy |
105 | |
106 | |
e086ee30 |
107 | /** |
108 | * Set data array. Overrides data data array set in the constructor. |
109 | **/ |
110 | //void |
111 | //AliHLTPHOSRawAnalyzer::SetData(double *data) |
112 | //{ |
113 | // fFloatDataPtr = data; |
114 | //} |
115 | void |
116 | AliHLTPHOSRawAnalyzer::SetData(UInt_t *data) |
117 | { |
118 | // fFloatDataPtr = data; |
119 | fIntDataPtr = data; |
120 | } |
121 | |
cbab66dd |
122 | /** |
123 | * Set data array. Overrides data data array set in the constructor. |
124 | **/ |
125 | void |
126 | AliHLTPHOSRawAnalyzer::SetData(double *data) |
127 | { |
cbab66dd |
128 | fFloatDataPtr = data; |
cbab66dd |
129 | } |
130 | |
e086ee30 |
131 | |
132 | |
cbab66dd |
133 | void |
134 | AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq) |
135 | { |
a4a2a400 |
136 | fSampleFrequency = freq; |
cbab66dd |
137 | } |
138 | |
139 | int |
140 | AliHLTPHOSRawAnalyzer::FindStartIndex(double treshold) |
141 | { |
cbab66dd |
142 | cout << "Find Start index not yet implemented" << endl; |
143 | return 0; |
144 | } //end FindStartIndex |
145 | |
146 | |
147 | /** |
148 | * This function applies only to the Chi and Least mean square fit. An initial guess is made |
149 | * based on the average of the first 5 samples and the first value exeeding this value. |
150 | **/ |
151 | void |
152 | AliHLTPHOSRawAnalyzer::MakeInitialGuess() |
153 | { |
154 | cout << "Make initial guess not yet implemeted" << endl; |
155 | } |
156 | |
157 | |
158 | /** |
159 | * This function applies only to the Chi and Least mean square fit. An initial guess is made |
160 | * based on the average of the first 5 samples and the first value exeeding threshold + this value. |
161 | * @param treshold The index of the first value above treshold is ntaken to be the first value. |
162 | **/ |
163 | void |
164 | AliHLTPHOSRawAnalyzer::MakeInitialGuess(int treshold) |
165 | { |
cbab66dd |
166 | cout << "Make initial guess not yet implemeted" << endl; |
167 | } |
68d9caee |
168 | |
169 | void |
170 | AliHLTPHOSRawAnalyzer::SetStartIndex(int index) |
171 | { |
172 | fStartIndex = index; |
173 | } |
174 | |
d504c864 |
175 | |
68d9caee |
176 | void |
177 | AliHLTPHOSRawAnalyzer::SetTVector(Double_t *tVector, Int_t size) |
178 | { |
179 | cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl; |
180 | } |
181 | |
182 | |
183 | void |
184 | AliHLTPHOSRawAnalyzer::SetAVector(Double_t *aVector, Int_t size) |
185 | { |
186 | cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl; |
187 | } |
188 | |
189 | |
e086ee30 |
190 | UInt_t |
191 | AliHLTPHOSRawAnalyzer::GetMaxValue(UInt_t *dta, Int_t size) const |
192 | { |
193 | |
194 | Double_t tmpMax = 0; |
195 | |
196 | for(int i = 0; i < size; i++) |
197 | { |
198 | if(dta[i] > tmpMax) |
199 | { |
200 | tmpMax = dta[i]; |
201 | } |
202 | } |
203 | |
204 | return tmpMax; |
205 | |
206 | } |
207 | |
208 | |
209 | /* |
68d9caee |
210 | Double_t |
d504c864 |
211 | AliHLTPHOSRawAnalyzer::GetMaxValue(Double_t *dta, Int_t size) const |
68d9caee |
212 | { |
213 | |
214 | Double_t tmpMax = 0; |
215 | |
216 | for(int i = 0; i < size; i++) |
217 | { |
218 | if(dta[i] > tmpMax) |
219 | { |
220 | tmpMax = dta[i]; |
221 | } |
68d9caee |
222 | } |
223 | |
224 | return tmpMax; |
225 | |
226 | } |
e086ee30 |
227 | */ |