}
-AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(AliHLTPHOSRawAnalyzer const&):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999)
+AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(AliHLTPHOSRawAnalyzer const&):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999), fStartIndex(0)
{
}
* @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
**/
-AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double *dtaPtr, double fs):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999)
+AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double *dtaPtr, double fs):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999), fStartIndex(0)
{
fFloatDataPtr = dtaPtr;
fSampleFrequency = fs;
printf("\ntreshold = %d\n", treshold);
cout << "Make initial guess not yet implemeted" << endl;
}
+
+void
+AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
+{
+ fStartIndex = index;
+}
+
+void
+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;
+}
+
+
+void
+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;
+}
+
+
+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;
+
+}
/* $Id$ */
+#include "Rtypes.h"
+
class AliHLTPHOSRawAnalyzer
{
public:
float GetEnergy();
void SetData(double *data);
void SetSampleFreq(double freq);
+ void SetStartIndex(int startIndex);
void MakeInitialGuess();
void MakeInitialGuess(int treshold);
+
+ // virtual void SetTVector(double *tVector);
+ // virtual void SetAVector(double *aVector);
+ virtual void SetTVector(Double_t *tVector, Int_t size);
+ virtual void SetAVector(Double_t *aVector, Int_t size);
+
virtual void Evaluate(int start = 0, int lenght = 100) = 0;
+ Double_t GetMaxValue(Double_t *dta, Int_t size);
protected:
- double *fFloatDataPtr; /**<Float representation of data that should be fitted */
+ // double *fFloatDataPtr; /**<Float representation of data that should be fitted */
+ Double_t *fFloatDataPtr; /**<Float representation of data that should be fitted */
double fSampleFrequency; /**<The ADC sample frequency in MHz used under data taking */
double fDTofGuess; /**<Initial guess for t0*/
double fDAmplGuess; /**<Initial guess for amplitude*/
double fDTof; /**<Time of flight in entities of sample intervals */
double fDAmpl; /**<Amplitude in entities of ADC levels*/
int n;
-
+ int fStartIndex;
};
const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0;
-AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEquippmentID(0), fPHOSRawStream(), fRawMemoryReader(0)
+AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), outPtr(0)
{
}
-AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), fEquippmentID(0), fPHOSRawStream(),fRawMemoryReader(0)
+AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), outPtr(0)
{
}
Int_t tmpChannelCnt = 0;
- cout << "analyzing event: " << fEventCount << endl;
-
- // AliHLTPHOSRcuCellEnergyDataStruct
- // AliHLTPHOSRcuCellEnergyDataStruct* outPtr;
+ // cout << "analyzing event: " << fEventCount << endl;
AliHLTUInt8_t* outBPtr;
outBPtr = outputPtr;
const AliHLTComponentBlockData* iter = NULL;
unsigned long ndx;
- Reset();
+ if((fEventCount % 100) == 0)
+ {
+ cout << "analyzing event: " << fEventCount << endl;
+ }
+ // Reset();
for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
{
-
iter = blocks+ndx;
mysize = 0;
offset = tSize;
-
if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
{
cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
outPtr->fRcuX = fRcuX;
outPtr->fRcuZ = fRcuZ;
outPtr->fModuleID = fModuleID;
-
- // cout << "analyzing evnt: " << fEventCount << "Module:" << fModuleID << "Rcu(" << fRcuZ <<"," << fRcuX << ")" << endl;
-
- // outPtr->fCnt = 0;
tmpChannelCnt = 0;
- // outPtr->fValidData.fRcuX = fRcuX;
- // outPtr->fValidData.fRcuZ = fRcuZ;
-
while(fPHOSRawStream->Next())
{
if (fPHOSRawStream->IsNewHWAddress())
{
+ // cout << "samplCount =" << sampleCnt <<endl;
+ // sampleCnt = 0;
+
+
if(processedChannels > 0)
{
analyzerPtr->SetData(fTmpChannelData);
- // cout << "sampleCnt = " << sampleCnt << endl;
- analyzerPtr->Evaluate(0, sampleCnt);
- // fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
- // outPtr->fValidData[fCnt] = ;
- // outPtr->fCnt ++;
- //fCnt;
- // outPtr->fCellEnergies[tmpRow - fRcuRowOffeset][tmpCol - fRcuColOffeset][tmpGain] = fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain];
- // outPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain];
+ // DumpChannelData(fTmpChannelData);
+
+ analyzerPtr->Evaluate(0, sampleCnt);
outPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
- sampleCnt = 0;
+
+ sampleCnt = 0;
outPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
outPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
outPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
-
tmpChannelCnt ++;
-
- // outPtr->fCnt ++;
- // ResetDataPtr();
+ ResetDataPtr();
+ sampleCnt = 0;
}
-
-
tmpMod = fPHOSRawStream->GetModule() ;
tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
tmpGain = fPHOSRawStream->IsLowGain();
-
- // outPtr->fValidData.fRow = tmpRow;
- // outPtr->fValidData).fCol = tmpCol;
-
-
processedChannels ++;
}
fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
sampleCnt ++;
+
}
-
-
+
+
+
outPtr->fCnt = tmpChannelCnt;
- // cout << "outPtr->fCnt = " << outPtr->fCnt << endl;
-
AliHLTComponentBlockData bd;
FillBlockData( bd );
bd.fOffset = offset;
, tSize, size );
return EMSGSIZE;
}
+
+ // DumpData();
+
}
}
}
+void
+AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
+{
+ cout << endl;
+
+ for(int i=0; i< 1008; i++)
+ {
+ if (data[i] != 0)
+ {
+ cout <<i <<"\t";
+ }
+ }
+ cout << endl;
+
+ for(int i=0; i< 1008; i++)
+ {
+ if (data[i] != 0)
+ {
+ cout <<data[i] <<"\t";
+ }
+ }
+
+ cout << endl;
+}
+
+
void
AliHLTPHOSRawAnalyzerComponent::Reset()
virtual int Deinit();
virtual int DoDeinit();
void DumpData();
+ void DumpChannelData(Double_t *data);
void SetEquippmentID(AliHLTUInt32_t id);
int GetEquippmentID();
void SetCoordinates( AliHLTUInt32_t equippmentID);
#include "AliHLTPHOSRawAnalyzerPeakFinder.h"
#include <iostream>
+#include <cmath>
using std::cout;
using std::endl;
ClassImp(AliHLTPHOSRawAnalyzerPeakFinder)
-AliHLTPHOSRawAnalyzerPeakFinder::AliHLTPHOSRawAnalyzerPeakFinder(const AliHLTPHOSRawAnalyzerPeakFinder&):AliHLTPHOSRawAnalyzer(),tVector(0), aVector(0)
+AliHLTPHOSRawAnalyzerPeakFinder::AliHLTPHOSRawAnalyzerPeakFinder(const AliHLTPHOSRawAnalyzerPeakFinder&):AliHLTPHOSRawAnalyzer() , fTVectorPtr(0), fAVectorPtr(0), fTVectorSize(0), fAVectorSize(0)
{
+
}
* a sequense of ADC digitized 10 bit integer values, however for performance reasons all values used in
* calculation is of type double.
**/
-AliHLTPHOSRawAnalyzerPeakFinder::AliHLTPHOSRawAnalyzerPeakFinder():AliHLTPHOSRawAnalyzer(),tVector(0), aVector(0)
+AliHLTPHOSRawAnalyzerPeakFinder::AliHLTPHOSRawAnalyzerPeakFinder():AliHLTPHOSRawAnalyzer(), fTVectorPtr(0), fAVectorPtr(0), fTVectorSize(0), fAVectorSize(0)
{
// cout <<"PeakFinder:You cannot invoke the Fitter without arguments"<<endl;;
}
} //end AliHLTPHOSRawAnalyzerPeakFinder
void
-AliHLTPHOSRawAnalyzerPeakFinder::SetTVector(double *tVec)
+AliHLTPHOSRawAnalyzerPeakFinder::SetTVector(Double_t *tVec, Int_t size)
{
- tVector = tVec;
+ fTVectorSize = size;
+
+ if(fTVectorPtr != 0)
+ {
+ delete fTVectorPtr;
+ }
+
+ fTVectorPtr = new Double_t[size];
+
+ for(int i=0; i< size; i++)
+ {
+ fTVectorPtr[i] = tVec[i];
+ }
}
+
void
-AliHLTPHOSRawAnalyzerPeakFinder::SetAVector(double *aVec)
+AliHLTPHOSRawAnalyzerPeakFinder::SetAVector(Double_t *aVec, Int_t size)
{
- aVector = aVec;
+
+ fAVectorSize = size;
+ if(fAVectorPtr != 0)
+ {
+ delete fAVectorPtr;
+ }
+
+ fAVectorPtr = new Double_t[size];
+
+ for(int i=0; i< size; i++)
+ {
+ fAVectorPtr[i] = aVec[i];
+ }
}
+
+
/**
* Extraction of timing and energy using the Peakfinde Algorithm.
* The. The parameters "start" and "length" defines a sub array of the data array
void
AliHLTPHOSRawAnalyzerPeakFinder::Evaluate(int start, int length)
{
- printf("\n AliHLTPHOSRawAnalyzerPeakFinder::Evaluat from index %d to %d\n", start, start + length);
+ // printf("\n AliHLTPHOSRawAnalyzerPeakFinder::Evaluat from index %d to %d\n", start, start + length);
fDTof = 0;
fDAmpl = 0;
+ Int_t tmpLength;
-
- if(tVector == 0 || aVector == 0)
+
+ if(fTVectorPtr == 0 || fAVectorPtr == 0)
{
printf("\nError: the peakfinder vectors are not specified, aborting !!!\n");
}
else
{
+
+ if(length < fTVectorSize)
+ {
+ tmpLength = length;
+ }
+ else
+ {
+ tmpLength = fTVectorSize;
+ }
- printf("\nstart = %d, length = %d\n", start, length);
- double tmpTime[1008];
+ printf("\nstart = %d, length = %d\n", start, tmpLength);
- for(int i=0; i < length; i++)
+ for(int i=0; i < tmpLength; i++)
{
- fDAmpl += aVector[i]*fFloatDataPtr[i];
+ cout <<fFloatDataPtr[i]<< " ";
+ fDAmpl += fAVectorPtr[i]*fFloatDataPtr[i];
}
- for(int i=0; i < length; i++)
+ cout<<endl;
+
+ for(int i=0; i < tmpLength; i++)
{
- tmpTime[i] = tVector[i]*fFloatDataPtr[i];
- fDTof = fDTof + tmpTime[i];
+ fDTof += fTVectorPtr[i]*fFloatDataPtr[i];
+ cout <<fFloatDataPtr[i]<< " ";
+ }
+
+ cout <<endl;
+
+ if(fDAmpl > 900)
+ {
+ Double_t tmpMax = GetMaxValue(fFloatDataPtr, tmpLength);
+ if(tmpMax == 1023)
+ {
+ fDAmpl = tmpMax;
+ }
}
fDTof = fDTof/fDAmpl;
+
}
-
+ cout <<" AliHLTPHOSRawAnalyzerPeakFinder: amplitude ="<<fDAmpl<< endl;
+ cout <<" AliHLTPHOSRawAnalyzerPeakFinder: time ="<<fDTof<< endl << endl;
//thats all
} //end FitPeakFinder
{
return *this;
}
-
-
virtual ~AliHLTPHOSRawAnalyzerPeakFinder();
- void SetTVector(double *tVector);
- void SetAVector(double *aVector);
- virtual void Evaluate(int start = 0, int lenght = 100);
+ virtual void SetTVector(Double_t *tVect, Int_t size);
+ virtual void SetAVector(Double_t *aVect, Int_t size);
+ virtual void Evaluate(Int_t start = 0, Int_t lenght = 100);
private:
- double *tVector; //[1008] /**<Peakfinder vector for TOF reconstruction*/
- double *aVector; //[1008] /**<Peakfinder vector for Energy reconstruction*/
+ Double_t *fTVectorPtr; //[1008] /**<Peakfinder vector for TOF reconstruction*/
+ Double_t *fAVectorPtr; //[1008] /**<Peakfinder vector for Energy reconstruction*/
+ Int_t fTVectorSize;
+ Int_t fAVectorSize;
ClassDef(AliHLTPHOSRawAnalyzerPeakFinder, 2)
AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent():AliHLTPHOSRawAnalyzerComponent()
{
+ Double_t tmpAVector[70];
+ Double_t tmpTVector[70];
analyzerPtr = new AliHLTPHOSRawAnalyzerPeakFinder();
+ analyzerPtr->SetStartIndex(0);
+ FILE *fp;
+ fp = fopen("/home/perthi/cern/aliroot/AliRoot_head/HLT/PHOS/PFVectors/start0N70tau2fs10.txt", "r");
+
+ if(fp != 0)
+ {
+ for(int i=0; i < 70; i++)
+ {
+ fscanf(fp, "%lf", &tmpAVector[i]);
+ }
+
+ fscanf(fp, "\n");
+
+ for(int i=0; i < 70; i++)
+ {
+ fscanf(fp, "%lf", &tmpTVector[i]);
+ }
+
+ analyzerPtr->SetAVector(tmpAVector, 70);
+ analyzerPtr->SetTVector(tmpTVector, 70);
+
+ fclose(fp);
+
+ }
+
+ else
+ {
+ cout <<"AliHLTPHOSRawAnalyzerPeakFinderComponent, ERROR: could not open PF vector file" << endl;
+ }
+
+
}
AliHLTPHOSRawAnalyzerPeakFinderComponent::~AliHLTPHOSRawAnalyzerPeakFinderComponent()
{
return new AliHLTPHOSRawAnalyzerPeakFinderComponent;
}
+
AliHLTPHOSRawAnalyzerPeakFinderComponent();
~AliHLTPHOSRawAnalyzerPeakFinderComponent();
AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & );
+
AliHLTPHOSRawAnalyzerPeakFinderComponent & operator = (const AliHLTPHOSRawAnalyzerPeakFinderComponent)
{
return *this;
};
-
- virtual const char* GetComponentID();
- virtual AliHLTComponent* Spawn();
+
+
+
+ virtual const char* GetComponentID();
+ virtual AliHLTComponent* Spawn();
//ClassDef(AliHLTPHOSRawAnalyzerPeakFinderComponent, 2)
};