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