3 /**************************************************************************
4 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
6 * Author: Per Thomas Hille for the ALICE HLT Project. *
7 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include "AliHLTPHOSRawAnalyzer.h"
20 #include "AliHLTCaloUtilities.h"
22 AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer(): //AliHLTPHOSBase(),
23 // fDoCorrectBaselineUsingFirstFiveSamples(false),
24 fDoCorrectBaselineUsingFirstFiveSamples(true),
35 fUseShortValues(false),
39 // fIntDataPtr = new UInt_t[1008];
43 // fUtilitiesPtr = new AliHLTPHOSUtilities();
47 AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
49 // delete[] fIntDataPtr;
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
61 AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double * /*dtaPtr*/, double fs): //AliHLTPHOSBase(),
62 fDoCorrectBaselineUsingFirstFiveSamples(false),
73 fUseShortValues(false),
77 fSampleFrequency = fs;
83 AliHLTPHOSRawAnalyzer::SetCorrectBaselineUsingFirstFiveSamples()
85 fDoCorrectBaselineUsingFirstFiveSamples = true;
90 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(double *data, int length)
91 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(int *data, int length)
92 AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(UInt_t */*data*/, const int /*length*/)
94 // cout << "AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples" << endl;
99 unsigned int sumOfFirstFiveSamples = 0;
101 for(int i=0; i< 5; i++)
103 sumOfFirstFiveSamples += data[i];
106 unsigned int valueToSubtract = sumOfFirstFiveSamples/5;
108 for(int j = 0; j < length; j++)
110 if( (int)(data[j] - valueToSubtract) > 0)
112 data[j] = data[j] - valueToSubtract;
125 // * Attemps to level the basline to zero.
126 // * The baseline will be calculated from the pretrigger samples and subtracted from the
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.
133 // AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, int /*N*/)
136 // } //end BaselineCorrection
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..
146 AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, double /*baselineValue*/)
149 } //end BaslineCorrection
153 * Gives the timing in entities of sample indexes
154 * Physical time is found by multiplying with the sampling intervall (Ts).
157 AliHLTPHOSRawAnalyzer::GetTiming() const
164 * Gives the time in entities of ADC channels (quantization levels).
165 * Absolute enrgy is found by multiplying with offline calibration constants.
168 AliHLTPHOSRawAnalyzer::GetEnergy() const
176 * Set data array. Overrides data data array set in the constructor.
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)
184 fIntDataPtr = const_cast<UInt_t *>(data);
186 if(fDoCorrectBaselineUsingFirstFiveSamples == true)
188 CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
191 // fIntDataPtr = data;
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)
201 fShortDataPtr = const_cast<UShort_t *>(data);
202 fUseShortValues = true;
203 if(fDoCorrectBaselineUsingFirstFiveSamples == true)
205 CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
208 // fIntDataPtr = data;
216 * Set data array. Overrides data data array set in the constructor.
219 // //AliHLTPHOSRawAnalyzer::SetData(const double *data)
220 // AliHLTPHOSRawAnalyzer::SetData(double *data, const int length)
222 // if(fDoCorrectBaselineUsingFirstFiveSamples == true)
224 // CorrectBaselineUsingFirstFiveSamples(data, length);
228 // fDoubleDataPtr = data;
234 AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
236 fSampleFrequency = freq;
240 AliHLTPHOSRawAnalyzer::FindStartIndex(double /*treshold*/)
242 // cout << "Find Start index not yet implemented" << endl;
244 } //end FindStartIndex
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.
252 AliHLTPHOSRawAnalyzer::MakeInitialGuess()
254 // cout << "Make initial guess not yet implemeted" << endl;
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.
264 AliHLTPHOSRawAnalyzer::MakeInitialGuess(int /*treshold*/)
266 // cout << "Make initial guess not yet implemeted" << endl;
271 AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
279 AliHLTPHOSRawAnalyzer::SetTVector(Double_t * /*tVector*/, Int_t /*size*/)
281 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
287 AliHLTPHOSRawAnalyzer::SetAVector(Double_t * /*aVector*/, Int_t /*size*/)
289 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;