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 "AliHLTPHOSUtilities.h"
22 AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer(): //AliHLTPHOSBase(),
23 // fDoCorrectBaselineUsingFirstFiveSamples(false),
24 fDoCorrectBaselineUsingFirstFiveSamples(true),
35 fUseShortValues(false),
39 // fIntDataPtr = new UInt_t[1008];
42 fUtilitiesPtr = new AliHLTPHOSUtilities();
45 AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
47 // delete[] fIntDataPtr;
56 * param dtaPtr Data array for wich a subarray will be taken to perform the fit
57 * @param fs the sampling frequency in entities of MHz. Needed in order to calculate physical time
59 AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double * /*dtaPtr*/, double fs): //AliHLTPHOSBase(),
60 fDoCorrectBaselineUsingFirstFiveSamples(false),
71 fUseShortValues(false),
75 fSampleFrequency = fs;
81 AliHLTPHOSRawAnalyzer::SetCorrectBaselineUsingFirstFiveSamples()
83 fDoCorrectBaselineUsingFirstFiveSamples = true;
88 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(double *data, int length)
89 //AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(int *data, int length)
90 AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(UInt_t */*data*/, const int /*length*/)
92 // cout << "AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples" << endl;
97 unsigned int sumOfFirstFiveSamples = 0;
99 for(int i=0; i< 5; i++)
101 sumOfFirstFiveSamples += data[i];
104 unsigned int valueToSubtract = sumOfFirstFiveSamples/5;
106 for(int j = 0; j < length; j++)
108 if( (int)(data[j] - valueToSubtract) > 0)
110 data[j] = data[j] - valueToSubtract;
123 // * Attemps to level the basline to zero.
124 // * The baseline will be calculated from the pretrigger samples and subtracted from the
126 // * If pretrigger samples are not present then the basline correction will be incorrect.
127 // * @param dataPtr array for wich to correct the basline
128 // * @param N the number of pretrigger samples used to calculate the baseline.
131 // AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, int /*N*/)
134 // } //end BaselineCorrection
138 * Shifts the baseline with the amount given by baselineValue
139 * If pretrigger samples are not present then the basline correction will be incorrect.
140 * @param dataPtr array for wich to correct the basline
141 * @param baselineValue the basline value to subtract..
144 AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, double /*baselineValue*/)
147 } //end BaslineCorrection
151 * Gives the timing in entities of sample indexes
152 * Physical time is found by multiplying with the sampling intervall (Ts).
155 AliHLTPHOSRawAnalyzer::GetTiming() const
162 * Gives the time in entities of ADC channels (quantization levels).
163 * Absolute enrgy is found by multiplying with offline calibration constants.
166 AliHLTPHOSRawAnalyzer::GetEnergy() const
174 * Set data array. Overrides data data array set in the constructor.
178 AliHLTPHOSRawAnalyzer::SetData(const UInt_t *data, const int length)
179 // AliHLTPHOSRawAnalyzer::SetData(UInt_t *data, const int length)
180 // AliHLTPHOSRawAnalyzer::SetData(int *data, const int length)
182 fIntDataPtr = const_cast<UInt_t *>(data);
184 if(fDoCorrectBaselineUsingFirstFiveSamples == true)
186 CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
189 // fIntDataPtr = data;
194 AliHLTPHOSRawAnalyzer::SetData(const UShort_t *data, const int length)
195 // AliHLTPHOSRawAnalyzer::SetData(UInt_t *data, const int length)
196 // AliHLTPHOSRawAnalyzer::SetData(int *data, const int length)
199 fShortDataPtr = const_cast<UShort_t *>(data);
200 fUseShortValues = true;
201 if(fDoCorrectBaselineUsingFirstFiveSamples == true)
203 CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
206 // fIntDataPtr = data;
214 * Set data array. Overrides data data array set in the constructor.
217 // //AliHLTPHOSRawAnalyzer::SetData(const double *data)
218 // AliHLTPHOSRawAnalyzer::SetData(double *data, const int length)
220 // if(fDoCorrectBaselineUsingFirstFiveSamples == true)
222 // CorrectBaselineUsingFirstFiveSamples(data, length);
226 // fDoubleDataPtr = data;
232 AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
234 fSampleFrequency = freq;
238 AliHLTPHOSRawAnalyzer::FindStartIndex(double /*treshold*/)
240 // cout << "Find Start index not yet implemented" << endl;
242 } //end FindStartIndex
246 * This function applies only to the Chi and Least mean square fit. An initial guess is made
247 * based on the average of the first 5 samples and the first value exeeding this value.
250 AliHLTPHOSRawAnalyzer::MakeInitialGuess()
252 // cout << "Make initial guess not yet implemeted" << endl;
257 * This function applies only to the Chi and Least mean square fit. An initial guess is made
258 * based on the average of the first 5 samples and the first value exeeding threshold + this value.
259 * @param treshold The index of the first value above treshold is ntaken to be the first value.
262 AliHLTPHOSRawAnalyzer::MakeInitialGuess(int /*treshold*/)
264 // cout << "Make initial guess not yet implemeted" << endl;
269 AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
277 AliHLTPHOSRawAnalyzer::SetTVector(Double_t * /*tVector*/, Int_t /*size*/)
279 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
285 AliHLTPHOSRawAnalyzer::SetAVector(Double_t * /*aVector*/, Int_t /*size*/)
287 // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;