1 /**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Per Thomas Hille for the ALICE HLT Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliHLTPHOSRawAnalyzer.h"
18 #include "AliHLTPHOSUtilities.h"
20 AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer(): AliHLTPHOSBase(),
21 // fDoCorrectBaselineUsingFirstFiveSamples(false),
22 fDoCorrectBaselineUsingFirstFiveSamples(true),
34 // fIntDataPtr = new UInt_t[1008];
37 fUtilitiesPtr = new AliHLTPHOSUtilities();
40 AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
42 // delete[] fIntDataPtr;
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
54 AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double * /*dtaPtr*/, double fs): AliHLTPHOSBase(),
55 fDoCorrectBaselineUsingFirstFiveSamples(false),
66 fSampleFrequency = fs;
72 AliHLTPHOSRawAnalyzer::SetCorrectBaselineUsingFirstFiveSamples()
74 fDoCorrectBaselineUsingFirstFiveSamples = true;
79 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(double *data, int length)
80 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(int *data, int length)
81 AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(UInt_t *data, const int length)
83 // cout << "AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples" << endl;
88 unsigned int sumOfFirstFiveSamples = 0;
90 for(int i=0; i< 5; i++)
92 sumOfFirstFiveSamples += data[i];
95 unsigned int valueToSubtract = sumOfFirstFiveSamples/5;
97 for(int j = 0; j < length; j++)
99 if( (int)(data[j] - valueToSubtract) > 0)
101 data[j] = data[j] - valueToSubtract;
114 // * Attemps to level the basline to zero.
115 // * The baseline will be calculated from the pretrigger samples and subtracted from the
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.
122 // AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, int /*N*/)
125 // } //end BaselineCorrection
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..
135 AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, double /*baselineValue*/)
138 } //end BaslineCorrection
142 * Gives the timing in entities of sample indexes
143 * Physical time is found by multiplying with the sampling intervall (Ts).
146 AliHLTPHOSRawAnalyzer::GetTiming() const
153 * Gives the time in entities of ADC channels (quantization levels).
154 * Absolute enrgy is found by multiplying with offline calibration constants.
157 AliHLTPHOSRawAnalyzer::GetEnergy() const
165 * Set data array. Overrides data data array set in the constructor.
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)
173 fIntDataPtr = const_cast<UInt_t *>(data);
175 if(fDoCorrectBaselineUsingFirstFiveSamples == true)
177 CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
180 // fIntDataPtr = data;
188 * Set data array. Overrides data data array set in the constructor.
191 // //AliHLTPHOSRawAnalyzer::SetData(const double *data)
192 // AliHLTPHOSRawAnalyzer::SetData(double *data, const int length)
194 // if(fDoCorrectBaselineUsingFirstFiveSamples == true)
196 // CorrectBaselineUsingFirstFiveSamples(data, length);
200 // fDoubleDataPtr = data;
206 AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
208 fSampleFrequency = freq;
212 AliHLTPHOSRawAnalyzer::FindStartIndex(double /*treshold*/)
214 // cout << "Find Start index not yet implemented" << endl;
216 } //end FindStartIndex
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.
224 AliHLTPHOSRawAnalyzer::MakeInitialGuess()
226 // cout << "Make initial guess not yet implemeted" << endl;
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.
236 AliHLTPHOSRawAnalyzer::MakeInitialGuess(int /*treshold*/)
238 // cout << "Make initial guess not yet implemeted" << endl;
243 AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
251 AliHLTPHOSRawAnalyzer::SetTVector(Double_t * /*tVector*/, Int_t /*size*/)
253 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
259 AliHLTPHOSRawAnalyzer::SetAVector(Double_t * /*aVector*/, Int_t /*size*/)
261 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;