]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzer.cxx
Updating CMake files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzer.cxx
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
16
17 #include "AliHLTPHOSRawAnalyzer.h"
18 #include "AliHLTPHOSUtilities.h" 
19
20 AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer(): AliHLTPHOSBase(),  
21                                                  //      fDoCorrectBaselineUsingFirstFiveSamples(false),
22                                                  fDoCorrectBaselineUsingFirstFiveSamples(true),
23                                                  fDoubleDataPtr(0), 
24                                                  fIntDataPtr(0), 
25                                                  fSampleFrequency(10),
26                                                  fDTofGuess(-1),
27                                                  fDAmplGuess(-1),
28                                                  fTau(2), 
29                                                  fDTof(99999), 
30                                                  fDAmpl(99999),
31                                                  fStartIndex(0),
32                                                  fUtilitiesPtr(0)
33 {
34   //  fIntDataPtr = new UInt_t[1008];
35
36   //  fDoubleDataPtr;   
37   fUtilitiesPtr = new  AliHLTPHOSUtilities(); 
38 }
39
40 AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
41 {
42   //  delete[] fIntDataPtr;
43 }
44
45
46
47
48
49 /**
50 * Main constructor
51 * @param dtaPtr Data array for wich a subarray will be taken to perform the fit
52 * @param fs the sampling frequency in entities of MHz. Needed in order to calculate physical time
53 **/
54 AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double * /*dtaPtr*/, double fs): AliHLTPHOSBase(), 
55                                                                               fDoCorrectBaselineUsingFirstFiveSamples(false),
56                                                                               fDoubleDataPtr(0), 
57                                                                               fIntDataPtr(0), 
58                                                                               fSampleFrequency(10),
59                                                                               fDTofGuess(-1),
60                                                                               fDAmplGuess(-1),
61                                                                               fTau(2), 
62                                                                               fDTof(99999), 
63                                                                               fDAmpl(99999),
64                                                                               fStartIndex(0) 
65 {
66   fSampleFrequency = fs;
67 } //end  
68
69
70
71 void 
72 AliHLTPHOSRawAnalyzer::SetCorrectBaselineUsingFirstFiveSamples()
73 {
74   fDoCorrectBaselineUsingFirstFiveSamples = true;
75 }
76  
77
78 void 
79 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(double *data, int length)
80 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(int *data, int length)
81 AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(UInt_t *data, const int length)
82 {
83   //  cout << "AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples" << endl;
84
85   //CRAP PTH
86   /*
87   
88   unsigned int sumOfFirstFiveSamples = 0;
89
90   for(int i=0; i< 5; i++)
91     {
92       sumOfFirstFiveSamples += data[i];
93     }
94
95   unsigned int valueToSubtract = sumOfFirstFiveSamples/5;
96
97   for(int j = 0; j < length; j++)
98     {
99       if( (int)(data[j] - valueToSubtract) > 0)
100         {
101           data[j] = data[j] - valueToSubtract;
102         }
103       else
104         {
105           data[j] = 0;
106         }
107     }
108   */
109 }
110
111
112
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
126
127
128 /**
129 * Shifts the baseline with the amount given by baselineValue
130 * If pretrigger samples are not present then the basline correction will be incorrect. 
131 * @param dataPtr array for wich to correct the basline 
132 * @param baselineValue the basline value to subtract..
133 **/
134 void 
135 AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, double /*baselineValue*/)
136 {
137
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
146 AliHLTPHOSRawAnalyzer::GetTiming() const 
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
157 AliHLTPHOSRawAnalyzer::GetEnergy() const
158 {
159   return fDAmpl;
160 } //end GetEnergy
161
162
163
164 /**
165  * Set data array. Overrides data data array set in the constructor.
166  **/
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
186
187 /**
188  * Set data array. Overrides data data array set in the constructor.
189  **/
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 // }
202
203
204
205 void 
206 AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
207 {
208   fSampleFrequency = freq;
209 }
210
211 int 
212 AliHLTPHOSRawAnalyzer::FindStartIndex(double /*treshold*/)
213 {
214   // cout << "Find Start index not yet implemented" << endl;
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 {
226   //  cout << "Make initial guess not yet implemeted" << endl;
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 
236 AliHLTPHOSRawAnalyzer::MakeInitialGuess(int /*treshold*/)
237 {
238   //  cout << "Make initial guess not yet implemeted" << endl;  
239 }
240
241
242 void
243 AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
244 {
245   fStartIndex = index;
246 }
247
248
249
250 void 
251 AliHLTPHOSRawAnalyzer::SetTVector(Double_t * /*tVector*/, Int_t /*size*/)
252 {
253   //  cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector:  You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
254 }
255
256
257
258 void
259 AliHLTPHOSRawAnalyzer::SetAVector(Double_t * /*aVector*/, Int_t /*size*/)
260 {
261   // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector:  You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
262 }
263
264