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