--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ * *
+ * 7/1- 2007 *
+ * Author: Per Thomas Hille *
+ * code modified to include the two differnt gains of each detection *
+ * channel and also to include the Pedestals loaded into the ALTRO *
+ * registers for basline subtraction and zero supression *
+ * *
+ * *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// class for PHOS EmCal calibration //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliHLTPHOSEmcCalibData.h"
+
+ClassImp(AliHLTPHOSEmcCalibData)
+
+//________________________________________________________________
+ AliHLTPHOSEmcCalibData::AliHLTPHOSEmcCalibData(): TNamed()
+{
+ // Default constructor
+ Reset();
+}
+
+//________________________________________________________________
+AliHLTPHOSEmcCalibData::AliHLTPHOSEmcCalibData(const char* name)
+{
+ // Constructor
+ TString namst = "Calib_";
+ namst += name;
+ SetName(namst.Data());
+ SetTitle(namst.Data());
+ Reset();
+}
+
+//________________________________________________________________
+AliHLTPHOSEmcCalibData::AliHLTPHOSEmcCalibData(const AliHLTPHOSEmcCalibData& calibda) :
+ TNamed(calibda)
+{
+ // copy constructor
+ SetName(calibda.GetName());
+ SetTitle(calibda.GetName());
+
+
+ // for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ for(Int_t module=0; module<PHOS_MODULES; module++) {
+ for(Int_t column=0; column< PHOS_COLUMNS; column++) {
+ for(Int_t row=0; row<PHOS_ROWS; row++) {
+ for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ fADCchannelEnergy[module][column][row][gain] = calibda.fADCchannelEnergy[module][column][row][gain];
+ fADCpedestalEmcMeasured[module][column][row][gain] = calibda.fADCpedestalEmcMeasured[module][column][row][gain];
+ }
+ }
+ }
+ }
+}
+
+//________________________________________________________________
+AliHLTPHOSEmcCalibData &AliHLTPHOSEmcCalibData::operator =(const AliHLTPHOSEmcCalibData& calibda)
+{
+ // assignment operator
+
+ if(this != &calibda) {
+
+ SetName(calibda.GetName());
+ SetTitle(calibda.GetName());
+ // for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ for(Int_t module=0; module<PHOS_MODULES; module++) {
+ for(Int_t column=0; column< PHOS_COLUMNS; column++) {
+ for(Int_t row=0; row<PHOS_ROWS; row++) {
+ for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ fADCchannelEnergy[module][column][row][gain] = calibda.fADCchannelEnergy[module][column][row][gain];
+ fADCpedestalEmcMeasured[module][column][row][gain] = calibda.fADCpedestalEmcMeasured[module][column][row][gain];
+ }
+ }
+ }
+ }
+ }
+ return *this;
+}
+
+//________________________________________________________________
+AliHLTPHOSEmcCalibData::~AliHLTPHOSEmcCalibData()
+{
+ // Destructor
+}
+
+//________________________________________________________________
+void AliHLTPHOSEmcCalibData::Reset()
+{
+ // Set all pedestals and all ADC channels to its ideal values = 1.
+
+ // for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ for (Int_t module=0; module<PHOS_MODULES; module++){
+ for (Int_t column=0; column< PHOS_COLUMNS; column++){
+ for (Int_t row=0; row<PHOS_ROWS; row++){
+ for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ fADCpedestalEmcMeasured[module][column][row][gain] = 0.;
+ fADCchannelEnergy[module][column][row][gain] = 1.;
+ }
+ }
+ }
+ }
+}
+
+//________________________________________________________________
+void AliHLTPHOSEmcCalibData::Print(Option_t *option) const
+{
+ // Print tables of pedestals and ADC channels
+
+ if (strstr(option,"ped")) {
+ printf("\n ---- EMC Pedestal values ----\n\n");
+ // for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ for (Int_t module=0; module<PHOS_MODULES; module++){
+ printf("============== Module %d\n",module+1);
+ for (Int_t column=0; column< PHOS_COLUMNS; column++){
+ for (Int_t row=0; row<PHOS_ROWS; row++){
+ for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ printf("%4.1f",fADCpedestalEmcMeasured[module][column][row][gain]);
+ }
+ printf("\n");
+ }
+ }
+ }
+ }
+
+ if (strstr(option,"gain")) {
+ printf("\n ---- EMC ADC channel values ----\n\n");
+ // for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ for (Int_t module=0; module<PHOS_MODULES; module++){
+ printf("============== Module %d\n",module+1);
+ for (Int_t column=0; column< PHOS_COLUMNS; column++){
+ for (Int_t row=0; row<PHOS_ROWS; row++){
+ for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ printf("%4.1f",fADCchannelEnergy[module][column][row][gain]);
+ }
+ printf("\n");
+ }
+ }
+ }
+ }
+}
+
+
+void
+AliHLTPHOSEmcCalibData::MakeADCpedestalCorrectionTable()
+{
+ for (Int_t module=0; module<PHOS_MODULES; module++){
+ printf("============== Module %d\n",module+1);
+ for (Int_t column=0; column< PHOS_COLUMNS; column++){
+ for (Int_t row=0; row<PHOS_ROWS; row++){
+ for(Int_t gain = 0; gain < PHOS_GAINS; gain ++){
+ fADCpedestalCorrectionTable[module][column][row][gain] = fADCpedestalEmcMeasured[module][column][row][gain] - fADCpedestalAltroReg[module][column][row][gain];
+ // printf("%4.1f",fADCchannelEnergy[module][column][row][gain]);
+ //
+ }
+ printf("\n");
+ }
+ }
+ }
+}
+
+
+//________________________________________________________________
+Float_t AliHLTPHOSEmcCalibData::GetADCchannelEnergy(Int_t module, Int_t column, Int_t row, Int_t gain) const
+{
+ //Return EMC calibration coefficient
+ //module, column,raw should follow the internal PHOS convention:
+ //module 1:5, column 1:56, row 1:64
+
+ return fADCchannelEnergy[module-1][column-1][row-1][gain];
+}
+
+//________________________________________________________________
+Float_t AliHLTPHOSEmcCalibData::GetADCpedestalEmcMeasured(Int_t module, Int_t column, Int_t row, Int_t gain) const
+{
+ //Return EMC pedestal
+ //module, column,raw should follow the internal PHOS convention:
+ //module 1:5, column 1:56, row 1:64
+
+
+ return fADCpedestalEmcMeasured[module-1][column-1][row-1][gain];
+}
+
+//________________________________________________________________
+void AliHLTPHOSEmcCalibData::SetADCchannelEnergy(Int_t module, Int_t column, Int_t row, Int_t gain, Float_t value)
+{
+ //Set EMC calibration coefficient
+ //module, column,raw should follow the internal PHOS convention:
+ //module 1:5, column 1:56, row 1:64
+
+ fADCchannelEnergy[module-1][column-1][row-1][gain] = value;
+}
+
+//________________________________________________________________
+void AliHLTPHOSEmcCalibData::SetADCpedestalEmcMeasured(Int_t module, Int_t column, Int_t row, Int_t gain, Float_t value)
+{
+ //Set EMC pedestal
+ //module, column,raw should follow the internal PHOS convention:
+ //module 1:5, column 1:56, row 1:64
+ fADCpedestalEmcMeasured[module-1][column-1][row-1][gain] = value;
+}
--- /dev/null
+#ifndef ALIHLTPHOSEMCCALIBDATA_H
+#define ALIHLTPHOSEMCCALIBDATA_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+////////////////////////////////////////////////
+// class for EMC calibration //
+////////////////////////////////////////////////
+
+#include "TNamed.h"
+#include "AliPHOSCommonDefs.h"
+
+
+class AliHLTPHOSEmcCalibData: public TNamed {
+
+ public:
+ AliHLTPHOSEmcCalibData();
+ AliHLTPHOSEmcCalibData(const char* name);
+ AliHLTPHOSEmcCalibData(const AliHLTPHOSEmcCalibData &calibda);
+ AliHLTPHOSEmcCalibData& operator= (const AliHLTPHOSEmcCalibData &calibda);
+ virtual ~AliHLTPHOSEmcCalibData();
+ void Reset();
+ virtual void Print(Option_t *option = "") const;
+ Float_t GetADCchannelEnergy(Int_t module, Int_t column, Int_t row, Int_t gain) const;
+ Float_t GetADCpedestalEmcMeasured(Int_t module, Int_t column, Int_t row, Int_t gain) const;
+ void SetADCchannelEnergy(Int_t module, Int_t column, Int_t row, Int_t gain, Float_t value);
+ void SetADCpedestalEmcMeasured(Int_t module, Int_t column, Int_t row, Int_t gain, Float_t value);
+ void MakeADCpedestalCorrectionTable();
+ protected:
+ Float_t fADCchannelEnergy[PHOS_MODULES][PHOS_COLUMNS][PHOS_ROWS][PHOS_GAINS] ; /**<width of one EMC ADC channel in GeV*/
+ Float_t fADCpedestalEmcMeasured[PHOS_MODULES][PHOS_COLUMNS][PHOS_ROWS][PHOS_GAINS] ; /**<value of the EMC ADC pedestal measured from calibration run*/
+ Int_t fADCpedestalAltroReg[PHOS_MODULES][PHOS_COLUMNS][PHOS_ROWS][PHOS_GAINS] ; /**<value of the EMC ADC pedestal subtraction values stored in the ALTRO registers*/
+ Float_t fADCpedestalCorrectionTable[PHOS_MODULES][PHOS_COLUMNS][PHOS_ROWS][PHOS_GAINS] ; /**<value of the EMC ADC pedestal values to be subtracted form the decoed cahnnel data (= fADCpedestalEmcMeasured - fADCpedestalAltroReg)*/
+
+ ClassDef(AliHLTPHOSEmcCalibData,1) // PHOS EMC calibration data
+};
+
+#endif
--- /dev/null
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliHLTPHOSPeakFinder+;
+#pragma link C++ class AliHLTPHOSPulseGenerator+;
+#pragma link C++ class AliHLTPHOSEmcCalibData+;
+
+#endif
--- /dev/null
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliHLTPHOSPeakFinder+;
+#pragma link C++ class AliHLTPHOSPulseGenerator+;
+#pragma link C++ class AliHLTPHOSEmcCalibData+;
+
+#endif
--- /dev/null
+
+/**************************************************************************
+ * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: Per Thomas Hille for the ALICE HLT Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+
+
+#include "AliHLTPHOSPeakFinder.h"
+#include <iostream>
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliHLTPHOSPeakFinder)
+
+
+AliHLTPHOSPeakFinder::AliHLTPHOSPeakFinder(const AliHLTPHOSPeakFinder&):TObject(), AliHLTPHOSRawAnalyzer(), fDTofGuess(0), fDAmplGuess(0), kfMCovarPtrPtr(0), fPCovarPtrPtr(0)
+{
+
+}
+
+//AliHLTComponent::GetComponentID()}
+
+/**
+ * The AliHLTPHOSPeakfinder class is the class for extracting the basic signal parameters
+ * "timing" and "energy" from the PHOS raw data. Physical data will for a given readout channel be
+ * a sequense of ADC digitized 10 bit integer values, however for performance reasons all values used in
+ * calculation is of type double.
+ **/
+AliHLTPHOSPeakFinder::AliHLTPHOSPeakFinder():fDTofGuess(0), fDAmplGuess(0), kfMCovarPtrPtr(0), fPCovarPtrPtr(0)
+{
+ cout <<"You cannot invoke the Fitter without arguments"<<endl;;
+}
+
+
+/**
+* Main constructor
+* @param dataPtr 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
+**/
+AliHLTPHOSPeakFinder::AliHLTPHOSPeakFinder(double *dtaPtr, double fs): fDTofGuess(0), fDAmplGuess(0), kfMCovarPtrPtr(0), fPCovarPtrPtr(0)
+{
+ fFloatDataPtr = dtaPtr;
+ fSampleFrequency = fs;
+} //end AliHLTPHOSPeakFinder
+
+
+AliHLTPHOSPeakFinder::~AliHLTPHOSPeakFinder()
+{
+
+} //end AliHLTPHOSPeakFinder
+
+
+void
+AliHLTPHOSPeakFinder::Analyze() const
+{
+
+}
+
+/**
+* Extraction of timing and energy using the Peakfinde Algorithm.
+* The. The parameters "start" and "length" defines a sub array of the data array
+* that will be used for the the fit. If start+length must not exeed the total length
+* of the Data array. "start" must be chosen as close as possible to t0.
+* The baseline must also be subtracted.
+* The length of "tVector" and "aVector" mus be equal to length.
+* "index + length" must not exeed the length of the data array set in the constructor.
+* @param start the start index of the subarray of the data array.
+* @param length the number of samples to use starting from index
+* @param tVector the peakfinder vector for timing
+* @param aVector the peakfinder vector for amplitude (energy)
+**/
+void
+AliHLTPHOSPeakFinder::FitPeakFinder(int start, int length, double *tVector, double *aVector)
+{
+ fDTof = 0;
+ fDAmpl = 0;
+
+ printf("\nstart = %d, length = %d\n", start, length);
+
+ double tmpTime[1008];
+
+ // double tmpTime[length];
+
+ for(int i=0; i < length; i++)
+ {
+ fDAmpl += aVector[i]*fFloatDataPtr[i];
+ }
+
+ for(int i=0; i < length; i++)
+ {
+ tmpTime[i] = tVector[i]*fFloatDataPtr[i];
+ fDTof = fDTof + tmpTime[i];
+ }
+
+ fDTof = fDTof/fDAmpl;
+ //thats all
+} //end FitPeakFinder
+
+
+
+/**
+ * This method finds the start index of the pulse (relative to the data array) by serching for
+ * three or more continious samples above trheshold.
+ * @param treshold treshold to use when searchin for the start of the pulse
+ **/
+int
+AliHLTPHOSPeakFinder::FindStartIndex(double treshold)
+{
+ printf("\ntreshold = %f \n", treshold);
+ cout << "Find Start index not yet implemented" << endl;
+ return 0;
+} //end FindStartIndex
+
+
+/**
+ * This function applies only to the Chi and Least mean square fit. An initial guess is made
+ * based on the average of the first 5 samples and the first value exeeding this value.
+ **/
+void
+AliHLTPHOSPeakFinder::MakeInitialGuess()
+{
+ cout << "Make initial guess not yet implemeted" << endl;
+}
+
+
+/**
+ * This function applies only to the Chi and Least mean square fit. An initial guess is made
+ * based on the average of the first 5 samples and the first value exeeding threshold + this value.
+ * @param treshold The index of the first value above treshold is ntaken to be the first value.
+ **/
+void
+AliHLTPHOSPeakFinder::MakeInitialGuess(int treshold)
+{
+ printf("\ntreshold = %d\n", treshold);
+ cout << "Make initial guess not yet implemeted" << endl;
+}
+
+
--- /dev/null
+
+/**************************************************************************
+ * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: Per Thomas Hille for the ALICE HLT Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+
+#include "AliHLTPHOSPeakFinder.h"
+#include <iostream>
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliHLTPHOSPeakFinder)
+
+
+AliHLTPHOSPeakFinder::AliHLTPHOSPeakFinder(const AliHLTPHOSPeakFinder&):TObject(), AliHLTPHOSRawAnalyzer(), fDTofGuess(0), fDAmplGuess(0), kfMCovarPtrPtr(0), fPCovarPtrPtr(0)
+{
+
+}
+
+
+
+/**
+ * The AliHLTPHOSPeakfinder class is the class for extracting the basic signal parameters
+ * "timing" and "energy" from the PHOS raw data. Physical data will for a given readout channel be
+ * a sequense of ADC digitized 10 bit integer values, however for performance reasons all values used in
+ * calculation is of type double.
+ **/
+AliHLTPHOSPeakFinder::AliHLTPHOSPeakFinder():fDTofGuess(0), fDAmplGuess(0), kfMCovarPtrPtr(0), fPCovarPtrPtr(0)
+{
+ cout <<"You cannot invoke the Fitter without arguments"<<endl;;
+}
+
+
+/**
+* Main constructor
+* @param dataPtr 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
+**/
+AliHLTPHOSPeakFinder::AliHLTPHOSPeakFinder(double *dtaPtr, double fs): fDTofGuess(0), fDAmplGuess(0), kfMCovarPtrPtr(0), fPCovarPtrPtr(0)
+{
+ fFloatDataPtr = dtaPtr;
+ fSampleFrequency = fs;
+} //end AliHLTPHOSPeakFinder
+
+
+AliHLTPHOSPeakFinder::~AliHLTPHOSPeakFinder()
+{
+
+} //end AliHLTPHOSPeakFinder
+
+
+void
+AliHLTPHOSPeakFinder::Analyze() const
+{
+
+}
+
+/**
+* Extraction of timing and energy using the Peakfinde Algorithm.
+* The. The parameters "start" and "length" defines a sub array of the data array
+* that will be used for the the fit. If start+length must not exeed the total length
+* of the Data array. "start" must be chosen as close as possible to t0.
+* The baseline must also be subtracted.
+* The length of "tVector" and "aVector" mus be equal to length.
+* "index + length" must not exeed the length of the data array set in the constructor.
+* @param start the start index of the subarray of the data array.
+* @param length the number of samples to use starting from index
+* @param tVector the peakfinder vector for timing
+* @param aVector the peakfinder vector for amplitude (energy)
+**/
+void
+AliHLTPHOSPeakFinder::FitPeakFinder(int start, int length, double *tVector, double *aVector)
+{
+ fDTof = 0;
+ fDAmpl = 0;
+
+ printf("\nstart = %d, length = %d\n", start, length);
+
+ double tmpTime[1008];
+
+ // double tmpTime[length];
+
+ for(int i=0; i < length; i++)
+ {
+ fDAmpl += aVector[i]*fFloatDataPtr[i];
+ }
+
+ for(int i=0; i < length; i++)
+ {
+ tmpTime[i] = tVector[i]*fFloatDataPtr[i];
+ fDTof = fDTof + tmpTime[i];
+ }
+
+ fDTof = fDTof/fDAmpl;
+ //thats all
+} //end FitPeakFinder
+
+
+
+/**
+ * This method finds the start index of the pulse (relative to the data array) by serching for
+ * three or more continious samples above trheshold.
+ * @param treshold treshold to use when searchin for the start of the pulse
+ **/
+int
+AliHLTPHOSPeakFinder::FindStartIndex(double treshold)
+{
+ printf("\ntreshold = %f \n", treshold);
+ cout << "Find Start index not yet implemented" << endl;
+ return 0;
+} //end FindStartIndex
+
+
+/**
+ * This function applies only to the Chi and Least mean square fit. An initial guess is made
+ * based on the average of the first 5 samples and the first value exeeding this value.
+ **/
+void
+AliHLTPHOSPeakFinder::MakeInitialGuess()
+{
+ cout << "Make initial guess not yet implemeted" << endl;
+}
+
+
+/**
+ * This function applies only to the Chi and Least mean square fit. An initial guess is made
+ * based on the average of the first 5 samples and the first value exeeding threshold + this value.
+ * @param treshold The index of the first value above treshold is ntaken to be the first value.
+ **/
+void
+AliHLTPHOSPeakFinder::MakeInitialGuess(int treshold)
+{
+ printf("\ntreshold = %d\n", treshold);
+ cout << "Make initial guess not yet implemeted" << endl;
+}
+
+
--- /dev/null
+#ifndef ALIHLTPHOSPEAKFINDER_H
+#define ALIHLTPHOSPEAKFINDER_H
+#include <Rtypes.h>
+#include "TObject.h"
+#include "AliHLTPHOSRawAnalyzer.h"
+
+
+
+
+/* Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+class AliHLTPHOSPeakFinder : public TObject, public AliHLTPHOSRawAnalyzer
+//class AliHLTPHOSPeakFinder : public TObject
+{
+ public:
+ AliHLTPHOSPeakFinder();
+ AliHLTPHOSPeakFinder(double *dataPtr, double fs);
+ AliHLTPHOSPeakFinder(const AliHLTPHOSPeakFinder & );
+ AliHLTPHOSPeakFinder & operator = (const AliHLTPHOSPeakFinder)
+ {
+ return *this;
+ }
+
+ virtual ~AliHLTPHOSPeakFinder();
+ void FitPeakFinder(int start = 0, int lenght = 100, double *tVector = 0, double *aVector = 0);
+ int FindStartIndex(double treshold);
+ // virtual void Analyze(int start = 0, int lenght = 100, double *tVector = 0, double *aVector = 0) const;
+ virtual void Analyze() const;
+ virtual const char* GetComponentID(){return 0;};
+ // AliHLTPHOSPeakFinder::GetOutputDataSize(long int&, double&)'
+
+ //void AliHLTComponent::GetOutputDataSize(long unsigned int&, double&)
+
+ virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){};
+ virtual void GetOutputDataSize(long int&, double&) {};
+
+ virtual AliHLTComponent* Spawn(){return 0;};
+
+ virtual AliHLTComponentDataType GetOutputDataType(){};
+ virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& ) {};
+ //(std::vector<AliHLTComponentDataType, std>&){};
+
+
+ virtual int DoEvent(const AliHLTComponentEventData&, const AliHLTComponentBlockData*, AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&, std::vector<AliHLTComponentBlockData, std::allocator<AliHLTComponentBlockData> >&){return 0;};
+
+
+ private:
+ void MakeInitialGuess();
+ void MakeInitialGuess(int treshold);
+ double fDTofGuess; /**<Initial guess for t0*/
+ double fDAmplGuess; /**<Initial guess for amplitude*/
+ double **kfMCovarPtrPtr; /**<Covariance matrix of the measurements*/
+ double **fPCovarPtrPtr; /**<Covariance matrix of the estimated parameters*/
+ ClassDef(AliHLTPHOSPeakFinder, 2)
+
+ };
+
+#endif
--- /dev/null
+#ifndef ALIHLTPHOSPEAKFINDER_H
+#define ALIHLTPHOSPEAKFINDER_H
+#include <Rtypes.h>
+#include "TObject.h"
+#include "AliHLTPHOSRawAnalyzer.h"
+
+
+
+/* Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+class AliHLTPHOSPeakFinder : public TObject, public AliHLTPHOSRawAnalyzer
+//class AliHLTPHOSPeakFinder : public TObject
+{
+ public:
+ AliHLTPHOSPeakFinder();
+ AliHLTPHOSPeakFinder(double *dataPtr, double fs);
+ AliHLTPHOSPeakFinder(const AliHLTPHOSPeakFinder & );
+ AliHLTPHOSPeakFinder & operator = (const AliHLTPHOSPeakFinder)
+ {
+ return *this;
+ }
+
+ virtual ~AliHLTPHOSPeakFinder();
+ void FitPeakFinder(int start = 0, int lenght = 100, double *tVector = 0, double *aVector = 0);
+ int FindStartIndex(double treshold);
+ // virtual void Analyze(int start = 0, int lenght = 100, double *tVector = 0, double *aVector = 0) const;
+ virtual void Analyze() const;
+ private:
+ void MakeInitialGuess();
+ void MakeInitialGuess(int treshold);
+ double fDTofGuess; /**<Initial guess for t0*/
+ double fDAmplGuess; /**<Initial guess for amplitude*/
+ double **kfMCovarPtrPtr; /**<Covariance matrix of the measurements*/
+ double **fPCovarPtrPtr; /**<Covariance matrix of the estimated parameters*/
+ ClassDef(AliHLTPHOSPeakFinder, 2)
+
+ };
+
+#endif
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: Per Thomas Hille for the ALICE HLT Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+
+
+#include "AliHLTPHOSPulseGenerator.h"
+//#include <stdio.h>
+#include <cmath>
+#include <iostream>
+
+
+using std::cout;
+using std::endl;
+
+
+ClassImp(AliHLTPHOSPulseGenerator)
+
+/**
+ * Default constructor, not to be called without argumets
+ **/
+AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
+{
+ cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
+}
+
+AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
+{
+
+}
+
+
+AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
+{
+ delete fDataPtr;
+ fDataPtr=0;
+}
+
+/**
+ * Contruct a pulsegenrator object an initializes all necessary parameters
+ * @param a Amplitude in ADC levels (0 -1023)
+ * @param t0 Timedelay in nanoseconds of signal relative the first sample. This value should be between 0 and Ts
+ * where Ts is the sample interval
+ **/
+AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(double a, double t0, int N, double t, double fs): fAmplitude(a), fNSamples(N),fTau(0), fSampleFreq(fs), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
+{
+
+ fDataPtr = new double[100];
+
+
+
+ SetAmplitude(a);
+ SetDT(fs);
+ SetTZero(t0);
+ fNSamples=N;
+ fTau=t;
+ fSampleFreq=fs;
+ // dT=tau/fs; //Function values are calculated at intervals dT
+ // fDT=1/fs; //Function values are calculated at intervals dT
+ MakePulse(fDataPtr);
+}
+
+/**
+ * Adds a baseline offset to the signal
+ * @param baselineLevel The basline level to add
+ * @param *samples The sample array for which to add te basline offset
+ **/
+void
+AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
+{
+ double *tmpSamples;
+ tmpSamples = samples;
+ printf("\nbaselineLevel = %f\n", baselineLevel);
+ cout << "AddBaseline not implemented yet" << endl;
+}
+
+/**
+ * Adds Gaussian white noise to the sample array given by *dataPtr.
+ * @param dataPtr array of samples
+ * @param sigma the noise amplitude in entities of ADC levels
+ **/
+void
+AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
+{
+ printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
+ cout << "AddNoise is not implemented yet" << endl;
+}
+
+
+/**
+ * Adds correlated Gaussian noise with cutof frequency "cutoff"
+ * @param dataPtr array of values
+ * @param sigma noise amplitude in entities of ADC levels
+ * @param -30DB cutoff frequency of the noise in entities of sampling frequency
+ **/
+void
+AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
+{
+ printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
+ cout << "AddNoise is not implemeted yet" << endl;
+}
+
+/**
+ * Adds pretrigger samples to the sample array and returns
+ * a new array containing the pretrigger samples concatenatet
+ * in front of the samples given by "samples"
+ * @param The baseline value of the pretrigger samples
+ * @param The sample array for which to add the pretrigger samples
+ **/
+double *
+AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
+{
+ printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
+ cout << "AddPretriggerSamples not implemented yet" << endl;
+ return 0;
+}
+
+
+/**
+ * Returns the generated pulse with the parameters given in the constructor
+ **/
+double *
+AliHLTPHOSPulseGenerator::GetPulse()
+{
+ return fDataPtr;
+}
+
+
+/**
+ * Returns a Pulse with new amplidude and t0
+ * @param a new amplidude, overriding the one given in the constructor
+ **/
+double *
+AliHLTPHOSPulseGenerator::GetPulse(double a, double t0)
+{
+ return fDataPtr;
+}
+
+/**
+ * Emulates the ADC. Rounds down to nearest Integerevalue all entries given by
+ * dataPtr
+ **/
+void
+AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr)
+{
+ double *dtaPtr;
+ dtaPtr = new double[100];
+ dtaPtr = dataPtr;
+ // cout << "Quantisize is not implemented yet" << endl;
+}
+
+void
+AliHLTPHOSPulseGenerator::SetAmplitude(double a)
+{
+ fAmplitude=a;
+}
+
+void
+AliHLTPHOSPulseGenerator::SetDT(double fs)
+{
+ fDT=1/fs;
+}
+
+void
+AliHLTPHOSPulseGenerator::SetTZero(double t0)
+{
+ fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
+}
+
+
+void
+AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
+{
+for(int i=0; i<fNSamples; i++)
+ {
+ dtaPtr[i]=fAmplitude*exp(2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
+ }
+}
--- /dev/null
+#ifndef ALIHLTPHOSPULSEGENERATOR_H
+#define ALIHLTPHOSPULSEGENERATOR_H
+/* Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+#include <Rtypes.h>
+
+class AliHLTPHOSPulseGenerator
+{
+ public:
+ AliHLTPHOSPulseGenerator();
+ virtual ~AliHLTPHOSPulseGenerator();
+ AliHLTPHOSPulseGenerator(double a, double t0, const int N, const double t, const double f);
+ AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator & );
+ AliHLTPHOSPulseGenerator & operator = (const AliHLTPHOSPulseGenerator)
+ {
+ return *this;
+ }
+ void AddBaseline(double baselineLevel, double *samples);
+ void AddNoise(double *dataPtr, double *sigma);
+ void AddNoise(double *dataPtr, double *sigma, double cutoff);
+ double *AddPretriggerSamples(double baslineLevel, double *samples);
+ double *GetPulse();
+ double *GetPulse(double a, double t0);
+ void Quantisize(double *dataPtr);
+ void SetAmplitude(double a);
+ void SetDT(double fs);
+ void SetTZero(double t0);
+
+ private:
+ void MakePulse(double *dtaPtr);
+ void MakePulse(double *dtaPtr, double ampl);
+ double fAmplitude;
+ int fNSamples;
+ double fTau;
+ double fSampleFreq;
+ double fTZero;
+ double *fDataPtr;
+ double fDT;
+ double *fEvent;
+
+ ClassDef(AliHLTPHOSPulseGenerator,1) //
+};
+
+#endif
+
--- /dev/null
+#include "AliHLTPHOSRawAnalyzer.h"
+#include <iostream>
+
+using std::cout;
+using std::endl;
+
+
+
+AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer():fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999)
+{
+
+
+}
+
+
+
+/**
+* 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)
+{
+ fFloatDataPtr = dataPtr;
+ n=N;
+ cout << "Baseline correction not yet implemeted" << endl;
+} //end BaselineCorrection
+
+/**
+* Shifts the basline 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..
+**/
+void
+AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, double baselineValue)
+{
+ fFloatDataPtr = dataPtr;
+ printf("\nbaselineValue = %f\n", baselineValue);
+ cout << "Baseline correction not yet implemeted" << endl;
+} //end BaslineCorrection
+
+
+/**
+ * Gives the timing in entities of sample indexes
+ * Physical time is found by multiplying with the sampling intervall (Ts).
+ **/
+float
+AliHLTPHOSRawAnalyzer::GetTiming()
+{
+ return fDTof;
+} //end GetTiming
+
+
+/**
+ * Gives the time in entities of ADC channels (quantization levels).
+ * Absolute enrgy is found by multiplying with offline calibration constants.
+ **/
+float
+AliHLTPHOSRawAnalyzer::GetEnergy()
+{
+ return fDAmpl;
+} //end GetEnergy
+
+
+/**
+ * Set data array. Overrides data data array set in the constructor.
+ **/
+void
+AliHLTPHOSRawAnalyzer::SetData(double *data)
+{
+ double *dta;
+ dta = data;
+ cout << "Set data not yet implemented" << endl;
+}
--- /dev/null
+#include "AliHLTPHOSRawAnalyzer.h"
+#include <iostream>
+
+using std::cout;
+using std::endl;
+
+
+AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer():fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999)
+{
+
+
+}
+
+
+
+/**
+* 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)
+{
+ fFloatDataPtr = dataPtr;
+ n=N;
+ cout << "Baseline correction not yet implemeted" << endl;
+} //end BaselineCorrection
+
+/**
+* Shifts the basline 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..
+**/
+void
+AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, double baselineValue)
+{
+ fFloatDataPtr = dataPtr;
+ printf("\nbaselineValue = %f\n", baselineValue);
+ cout << "Baseline correction not yet implemeted" << endl;
+} //end BaslineCorrection
+
+
+/**
+ * Gives the timing in entities of sample indexes
+ * Physical time is found by multiplying with the sampling intervall (Ts).
+ **/
+float
+AliHLTPHOSRawAnalyzer::GetTiming()
+{
+ return fDTof;
+} //end GetTiming
+
+
+/**
+ * Gives the time in entities of ADC channels (quantization levels).
+ * Absolute enrgy is found by multiplying with offline calibration constants.
+ **/
+float
+AliHLTPHOSRawAnalyzer::GetEnergy()
+{
+ return fDAmpl;
+} //end GetEnergy
+
+
+/**
+ * Set data array. Overrides data data array set in the constructor.
+ **/
+void
+AliHLTPHOSRawAnalyzer::SetData(double *data)
+{
+ double *dta;
+ dta = data;
+ cout << "Set data not yet implemented" << endl;
+}
--- /dev/null
+#ifndef ALIHLTPHOSRAWANALYZER_H
+#define ALIHLTPHOSRAWANALYZER_H
+
+#include "AliHLTProcessor.h"
+
+
+class AliHLTPHOSRawAnalyzer: public AliHLTProcessor
+{
+ public:
+ AliHLTPHOSRawAnalyzer();
+ ~AliHLTPHOSRawAnalyzer();
+ AliHLTPHOSRawAnalyzer(const AliHLTPHOSRawAnalyzer & );
+ AliHLTPHOSRawAnalyzer & operator = (const AliHLTPHOSRawAnalyzer);
+ void BaselineCorrection(double *dataPtr, int N);
+ void BaselineCorrection(double *dataPtr, double baselineValue);
+ float GetTiming();
+ float GetEnergy();
+ void SetData(double *data);
+ virtual void Analyze() const = 0;
+
+ protected:
+ double *fFloatDataPtr; /**<Float representation of data that should be fitted */
+ double fSampleFrequency; /**<The ADC sample frequency in MHz used under data taking */
+ double fTau; /**<The risetime in micro seconds*/
+ double fDTof; /**<Time of flight in entities of sample intervals */
+ double fDAmpl; /**<Amplitude in entities of ADC levels*/
+ int n;
+
+};
+
+
+#endif
--- /dev/null
+#ifndef ALIHLTPHOSRAWANALYZER_H
+#define ALIHLTPHOSRAWANALYZER_H
+
+
+class AliHLTPHOSRawAnalyzer
+{
+ public:
+ AliHLTPHOSRawAnalyzer();
+ ~AliHLTPHOSRawAnalyzer();
+ AliHLTPHOSRawAnalyzer(const AliHLTPHOSRawAnalyzer & );
+ AliHLTPHOSRawAnalyzer & operator = (const AliHLTPHOSRawAnalyzer);
+ void BaselineCorrection(double *dataPtr, int N);
+ void BaselineCorrection(double *dataPtr, double baselineValue);
+ float GetTiming();
+ float GetEnergy();
+ void SetData(double *data);
+ virtual void Analyze() const = 0;
+
+ protected:
+ double *fFloatDataPtr; /**<Float representation of data that should be fitted */
+ double fSampleFrequency; /**<The ADC sample frequency in MHz used under data taking */
+ double fTau; /**<The risetime in micro seconds*/
+ double fDTof; /**<Time of flight in entities of sample intervals */
+ double fDAmpl; /**<Amplitude in entities of ADC levels*/
+ int n;
+
+};
+
+
+#endif