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