+// $Id$
+
/**************************************************************************
* Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
* *
* provided "as is" without express or implied warranty. *
**************************************************************************/
+
#include "AliHLTPHOSRawAnalyzer.h"
-#include <iostream>
+#include "AliHLTCaloUtilities.h"
+
+AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer(): //AliHLTPHOSBase(),
+ // fDoCorrectBaselineUsingFirstFiveSamples(false),
+ fDoCorrectBaselineUsingFirstFiveSamples(true),
+ fDoubleDataPtr(0),
+ fIntDataPtr(0),
+ fShortDataPtr(0),
+ fSampleFrequency(10),
+ fDTofGuess(-1),
+ fDAmplGuess(-1),
+ fTau(2),
+ fDTof(99999),
+ fDAmpl(99999),
+ fStartIndex(0),
+ fUseShortValues(false),
+ fUtilitiesPtr(0)
-using std::cout;
-using std::endl;
+{
+ // fIntDataPtr = new UInt_t[1008];
+ // fDoubleDataPtr;
+ // fUtilitiesPtr = new AliHLTPHOSUtilities();
-AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer():fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999)
-{
- fFloatDataPtr = new double[1008];
}
AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
{
-
+ // delete[] fIntDataPtr;
}
-AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(AliHLTPHOSRawAnalyzer const&):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), fStartIndex(0)
-{
-}
+
+
/**
* Main constructor
-* @param dataPtr Data array for wich a subarray will be taken to perform the fit
+* param dtaPtr Data array for wich a subarray will be taken to perform the fit
* @param fs the sampling frequency in entities of MHz. Needed in order to calculate physical time
**/
-AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double *dtaPtr, double fs):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), fStartIndex(0)
+AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double * /*dtaPtr*/, double fs): //AliHLTPHOSBase(),
+ fDoCorrectBaselineUsingFirstFiveSamples(false),
+ fDoubleDataPtr(0),
+ fIntDataPtr(0),
+ fShortDataPtr(0),
+ fSampleFrequency(10),
+ fDTofGuess(-1),
+ fDAmplGuess(-1),
+ fTau(2),
+ fDTof(99999),
+ fDAmpl(99999),
+ fStartIndex(0),
+ fUseShortValues(false),
+ fUtilitiesPtr(0)
+
{
- fFloatDataPtr = dtaPtr;
fSampleFrequency = fs;
} //end
-/**
-* Attemps to level the basline to zero.
-* The baseline will be calculated from the pretrigger samples and subtracted from the
-* data array.
-* If pretrigger samples are not present then the basline correction will be incorrect.
-* @param dataPtr array for wich to correct the basline
-* @param N the number of pretrigger samples used to calculate the baseline.
-**/
+
void
-AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, int N)
+AliHLTPHOSRawAnalyzer::SetCorrectBaselineUsingFirstFiveSamples()
{
- fFloatDataPtr = dataPtr;
- // n=N;
- cout << "Baseline correction not yet implemeted" << endl;
-} //end BaselineCorrection
+ fDoCorrectBaselineUsingFirstFiveSamples = true;
+}
+
+
+void
+//AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(double *data, int length)
+//AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(int *data, int length)
+AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples(UInt_t */*data*/, const int /*length*/)
+{
+ // cout << "AliHLTPHOSRawAnalyzer::CorrectBaselineUsingFirstFiveSamples" << endl;
+
+ //CRAP PTH
+ /*
+
+ unsigned int sumOfFirstFiveSamples = 0;
+
+ for(int i=0; i< 5; i++)
+ {
+ sumOfFirstFiveSamples += data[i];
+ }
+
+ unsigned int valueToSubtract = sumOfFirstFiveSamples/5;
+
+ for(int j = 0; j < length; j++)
+ {
+ if( (int)(data[j] - valueToSubtract) > 0)
+ {
+ data[j] = data[j] - valueToSubtract;
+ }
+ else
+ {
+ data[j] = 0;
+ }
+ }
+ */
+}
+
+
+
+// /**
+// * Attemps to level the basline to zero.
+// * The baseline will be calculated from the pretrigger samples and subtracted from the
+// * data array.
+// * If pretrigger samples are not present then the basline correction will be incorrect.
+// * @param dataPtr array for wich to correct the basline
+// * @param N the number of pretrigger samples used to calculate the baseline.
+// **/
+// void
+// AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, int /*N*/)
+// {
+
+// } //end BaselineCorrection
/**
* Shifts the baseline with the amount given by baselineValue
* If pretrigger samples are not present then the basline correction will be incorrect.
* @param dataPtr array for wich to correct the basline
-* @param BaslineValue the basline value to subtract..
+* @param baselineValue the basline value to subtract..
**/
void
-AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, double baselineValue)
+AliHLTPHOSRawAnalyzer::BaselineCorrection(double * /*dataPtr*/, double /*baselineValue*/)
{
- fFloatDataPtr = dataPtr;
- printf("\nbaselineValue = %f\n", baselineValue);
- cout << "Baseline correction not yet implemeted" << endl;
+
} //end BaslineCorrection
* Physical time is found by multiplying with the sampling intervall (Ts).
**/
float
-AliHLTPHOSRawAnalyzer::GetTiming()
+AliHLTPHOSRawAnalyzer::GetTiming() const
{
return fDTof;
} //end GetTiming
* Absolute enrgy is found by multiplying with offline calibration constants.
**/
float
-AliHLTPHOSRawAnalyzer::GetEnergy()
+AliHLTPHOSRawAnalyzer::GetEnergy() const
{
return fDAmpl;
} //end GetEnergy
+
/**
* Set data array. Overrides data data array set in the constructor.
**/
-void
-AliHLTPHOSRawAnalyzer::SetData(double *data)
-{
- // double *dta;
- // dta = data;
- fFloatDataPtr = data;
- // cout << "Set data not yet implemented" << endl;
-}
+ void
+
+ AliHLTPHOSRawAnalyzer::SetData(const UInt_t *data, const int length)
+ // AliHLTPHOSRawAnalyzer::SetData(UInt_t *data, const int length)
+// AliHLTPHOSRawAnalyzer::SetData(int *data, const int length)
+ {
+ fIntDataPtr = const_cast<UInt_t *>(data);
+
+ if(fDoCorrectBaselineUsingFirstFiveSamples == true)
+ {
+ CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
+ }
+
+ // fIntDataPtr = data;
+
+ }
+
+void
+ AliHLTPHOSRawAnalyzer::SetData(const UShort_t *data, const int length)
+ // AliHLTPHOSRawAnalyzer::SetData(UInt_t *data, const int length)
+// AliHLTPHOSRawAnalyzer::SetData(int *data, const int length)
+ {
+
+ fShortDataPtr = const_cast<UShort_t *>(data);
+ fUseShortValues = true;
+ if(fDoCorrectBaselineUsingFirstFiveSamples == true)
+ {
+ CorrectBaselineUsingFirstFiveSamples(fIntDataPtr, length);
+ }
+
+ // fIntDataPtr = data;
+
+ }
+
+
+
+
+/**
+ * Set data array. Overrides data data array set in the constructor.
+ **/
+// void
+// //AliHLTPHOSRawAnalyzer::SetData(const double *data)
+// AliHLTPHOSRawAnalyzer::SetData(double *data, const int length)
+// {
+// if(fDoCorrectBaselineUsingFirstFiveSamples == true)
+// {
+// CorrectBaselineUsingFirstFiveSamples(data, length);
+// }
+
+
+// fDoubleDataPtr = data;
+// }
+
+
void
AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
}
int
-AliHLTPHOSRawAnalyzer::FindStartIndex(double treshold)
+AliHLTPHOSRawAnalyzer::FindStartIndex(double /*treshold*/)
{
- printf("\ntreshold = %f \n", treshold);
- cout << "Find Start index not yet implemented" << endl;
+ // cout << "Find Start index not yet implemented" << endl;
return 0;
} //end FindStartIndex
void
AliHLTPHOSRawAnalyzer::MakeInitialGuess()
{
- cout << "Make initial guess not yet implemeted" << endl;
+ // cout << "Make initial guess not yet implemeted" << endl;
}
* @param treshold The index of the first value above treshold is ntaken to be the first value.
**/
void
-AliHLTPHOSRawAnalyzer::MakeInitialGuess(int treshold)
+AliHLTPHOSRawAnalyzer::MakeInitialGuess(int /*treshold*/)
{
- printf("\ntreshold = %d\n", treshold);
- cout << "Make initial guess not yet implemeted" << endl;
+ // cout << "Make initial guess not yet implemeted" << endl;
}
+
void
AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
{
fStartIndex = index;
}
+
+
void
-AliHLTPHOSRawAnalyzer::SetTVector(Double_t *tVector, Int_t size)
+AliHLTPHOSRawAnalyzer::SetTVector(Double_t * /*tVector*/, Int_t /*size*/)
{
- cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
+ // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
}
+
void
-AliHLTPHOSRawAnalyzer::SetAVector(Double_t *aVector, Int_t size)
+AliHLTPHOSRawAnalyzer::SetAVector(Double_t * /*aVector*/, Int_t /*size*/)
{
- cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
+ // cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector: You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
}
-Double_t
-AliHLTPHOSRawAnalyzer::GetMaxValue(Double_t *dta, Int_t size)
-{
-
- Double_t tmpMax = 0;
-
- for(int i = 0; i < size; i++)
- {
- if(dta[i] > tmpMax)
- {
- tmpMax = dta[i];
- }
-
- }
-
- return tmpMax;
-
-}