fBin++;
if ( fBin >= (Int_t)fActRowData->fNDigit ){
-
fRow++;
-
if ((fRow >= fFirstRow) && (fRow <= fLastRow)){
//new row
rreadvalue = false;
return rreadvalue;
}
-
+ if(!fActRowData){
+ return false;
+ }
if ((Int_t)fActRowData->fRow != fRow){
HLTWarning("Row number should match! fActRowData->fRow=%d fRow=%d", fActRowData->fRow, fRow);
}
#include "AliHLTTPCTransform.h"
#include "AliHLTTPCClusters.h"
#include <sys/time.h>
+#include "TMath.h"
+#include "TFile.h"
//------------------------------
/** margin for the base line be re-avaluated */
fSizeOfSignalPositionArray(0),
fNSigmaThreshold(0),
fSignalThreshold(0),
- fModeSwitch(0)
+ fModeSwitch(0),
+ fNGoodSignalsSent(0),
+ fDebugHistoBeforeZS(NULL),
+ fDebugHistoAfterZS(NULL)
{
// see header file for class documentation
// or
fSignalPositionArray= new AliHLTTPCSignal_t[AliHLTTPCTransform::GetNTimeBins()];
memset( fSignalPositionArray, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
fSizeOfSignalPositionArray=0;
+
}
AliHLTTPCPad::AliHLTTPCPad(Int_t mode)
fSizeOfSignalPositionArray(0),
fNSigmaThreshold(0),
fSignalThreshold(0),
- fModeSwitch(mode)
+ fModeSwitch(mode),
+ fNGoodSignalsSent(0),
+ fDebugHistoBeforeZS(NULL),
+ fDebugHistoAfterZS(NULL)
{
// see header file for class documentation
// or
fSignalPositionArray(NULL),
fSizeOfSignalPositionArray(0),
fNSigmaThreshold(0),
- fSignalThreshold(0)
+ fSignalThreshold(0),
+ fModeSwitch(0),
+ fNGoodSignalsSent(0),
+ fDebugHistoBeforeZS(NULL),
+ fDebugHistoAfterZS(NULL)
{
// see header file for class documentation
}
StopEvent();
}
if (fDataSignals) {
- AliHLTTPCSignal_t* pData=fDataSignals;
+ delete [] fDataSignals;
fDataSignals=NULL;
- delete [] pData;
}
if (fSignalPositionArray) {
- //AliHLTTPCSignal_t* pData=fSignalPositionArray;
+ delete [] fSignalPositionArray;
fSignalPositionArray=NULL;
- // delete [] pData;
}
-
+ if(fDebugHistoBeforeZS){
+ delete fDebugHistoBeforeZS;
+ fDebugHistoBeforeZS=NULL;
+ }
+ if(fDebugHistoAfterZS){
+ delete fDebugHistoAfterZS;
+ fDebugHistoAfterZS=NULL;
+ }
}
Int_t AliHLTTPCPad::SetID(Int_t rowno, Int_t padno)
// see header file for class documentation
fRowNo=rowno;
fPadNo=padno;
+
+#if DebugHisto
+ char *nameBefore;
+ sprintf(nameBefore,"beforeRow%dPad%d",fRowNo,fPadNo);
+ char *nameAfter;
+ sprintf(nameAfter,"afterRow%dPad%d",fRowNo,fPadNo);
+ fDebugHistoBeforeZS = new TH1F(nameBefore,nameBefore,1024,0,1024);
+ fDebugHistoAfterZS = new TH1F(nameAfter,nameAfter,1024,0,1024);
+#endif
+
return 0;
}
Int_t AliHLTTPCPad::SetRawData(Int_t bin, AliHLTTPCSignal_t value)
{
// see header file for class documentation
+ // printf("Row: %d Pad: %d Time: %d Charge %d", fRowNo, fPadNo, bin, value);
Int_t iResult=0;
if (fpRawData) {
if (bin<fNofBins) {
if(GetDataSignal(bin)>0)
cout<<fRowNo<<"\t"<<fPadNo<<"\t"<<bin<<"\t"<<GetDataSignal(bin)<<endl;;
}
- cout<<"bins: "<<AliHLTTPCTransform::GetNTimeBins()<<endl;
+ // cout<<"bins: "<<AliHLTTPCTransform::GetNTimeBins()<<endl;
}
void AliHLTTPCPad::ClearCandidates(){
void AliHLTTPCPad::SetDataToDefault()
{
// see header file for class documentation
- /*
- if(fpRawData){
- memset( fDataSignals, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
- memset( fSignalPositionArray, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
+ if(fDataSignals && fSignalPositionArray){
+ for(Int_t i =0;i<fSizeOfSignalPositionArray;i++){
+ fDataSignals[fSignalPositionArray[i]]=-1;
+ }
fSizeOfSignalPositionArray=0;
}
- */
- fClusterCandidates.clear();
}
void AliHLTTPCPad::SetDataSignal(Int_t bin,Int_t signal)
fDataSignals[bin]=signal;
fSignalPositionArray[fSizeOfSignalPositionArray]=bin;
fSizeOfSignalPositionArray++;
+#if DebugHisto
+ fDebugHistoBeforeZS->Fill(bin,signal);
+#endif
+}
+
+Bool_t AliHLTTPCPad::GetNextGoodSignal(Int_t &time, Int_t &signal ){
+ /* for(Int_t i=70;i<900;i++){
+ if(fDataSignals[i]>0){
+ printf("Signals which are good: Bin: %d Signal: %d\n",i,fDataSignals[i]);
+ }
+ }*/
+ if(fNGoodSignalsSent<fSizeOfSignalPositionArray&&fSizeOfSignalPositionArray>0){
+ time = fSignalPositionArray[fNGoodSignalsSent];
+ signal = GetDataSignal(time);
+ // printf("GoodSignal: Row: %d Pad: %d time %d signal %d signalsSent: %d\n",fRowNo,fPadNo,fSignalPositionArray[fNGoodSignalsSent],GetDataSignal(time), fNGoodSignalsSent);
+ fNGoodSignalsSent++;
+ return kTRUE;
+ }
+ return kFALSE;
}
Int_t AliHLTTPCPad::GetDataSignal(Int_t bin) const
return fDataSignals[bin];
}
-void AliHLTTPCPad::ZeroSuppress(Double_t nSigma = 3,Int_t threshold = 20 ,Int_t reqMinPoint = AliHLTTPCTransform::GetNTimeBins()/2, Int_t beginTime = 50,Int_t endTime = AliHLTTPCTransform::GetNTimeBins()-1){
+void AliHLTTPCPad::ZeroSuppress(Double_t nRMS, Int_t threshold, Int_t reqMinPoint, Int_t beginTime, Int_t endTime, Int_t timebinsLeft, Int_t timebinsRight, Int_t valueUnderAverage){
//see headerfile for documentation
- Bool_t useSigma= kFALSE;
- if(nSigma>0){
- useSigma=kTRUE;
+ //HLTDebug("In Pad: nRMS=%d, threshold=%d, reqMinPoint=%d, beginTime=%d, endTime=%d, timebinsLeft=%d timebinsRight=%d valueUnderAverage=%d \n",nRMS,threshold,reqMinPoint,beginTime,endTime,timebinsLeft,timebinsRight,valueUnderAverage);
+
+ Bool_t useRMS= kFALSE;
+ if(nRMS>0){
+ useRMS=kTRUE;
+ if(threshold>0){
+ HLTInfo("Both RMSThreshold and SignalThreshold defined, using RMSThreshold");
+ }
}
- if(threshold<1 && nSigma<=0){
+ if(threshold<1 && nRMS<=0){
//setting the data to -1 for this pad
- memset( fDataSignals, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
- fSizeOfSignalPositionArray=0;
+ HLTInfo("Neither of RMSThreshold and SignalThreshold set, zerosuppression aborted");
return;
}
- if(endTime>=AliHLTTPCTransform::GetNTimeBins()){
- endTime=AliHLTTPCTransform::GetNTimeBins()-1;
- }
Int_t fThresholdUsed=threshold;
Int_t nAdded=0;
Int_t sumNAdded=0;
fSizeOfSignalPositionArray=0;
- for(Int_t i=beginTime;i<endTime+1;i++){
- if(fDataSignals[i]>0){
- nAdded++;
- sumNAdded+=fDataSignals[i];
+ if(useRMS){
+ for(Int_t i=beginTime;i<endTime+1;i++){
+ if(fDataSignals[i]>0){
+ nAdded++;
+ sumNAdded+=fDataSignals[i]*fDataSignals[i];
+ }
}
}
-
- if(nAdded<reqMinPoint){
- return; //This will ensure that no data is read in FindClusterCandidates() (since fSizeOfSignalPositionArray=0)
- }
-
- Double_t averageValue=sumNAdded/nAdded;
-
- Double_t sigma=0;
- if(useSigma){
- //Calculate the sigma
- Double_t sumOfDifferenceSquared=0;
- for(Int_t i=endTime;i>=beginTime;i--){
+ else if(threshold>0){
+ for(Int_t i=beginTime;i<endTime+1;i++){
if(fDataSignals[i]>0){
- if(fDataSignals[i]-averageValue<50){
- sumOfDifferenceSquared+=(fDataSignals[i]-averageValue)*(fDataSignals[i]-averageValue);
- }
- else{
- nAdded--;
- }
+ nAdded++;
+ sumNAdded+=fDataSignals[i];
}
}
- sigma=sumOfDifferenceSquared/nAdded;
- fThresholdUsed=(Int_t)(nSigma*sigma);
}
-
- //For now just set the adc value outside [beginTime,endTime] to -1
- for(Int_t i=0;i<beginTime;i++){
- fDataSignals[i]=-1;
+ else{
+ HLTFatal("This should never happen because this is tested earlier in the code.(nRMSThreshold<1&&signal-threshold<1)");
+ }
+ if(nAdded<reqMinPoint){
+ HLTInfo("Number of signals is less than required, zero suppression aborted");
+ return;
}
- for(Int_t i=endTime+1;i<AliHLTTPCTransform::GetNTimeBins();i++){
- fDataSignals[i]=-1;
+
+ if(nAdded==0){
+ HLTInfo("No signals added for this pad, zerosuppression aborted: pad %d row %d",fPadNo,fRowNo);
+ return;
}
+ // HLTInfo("sumNAdded=%d nAdded=%d pad %d ",sumNAdded,nAdded,fPadNo);
+ Double_t averageValue=(Double_t)sumNAdded/nAdded;//true average for threshold approach, average of signals squared for rms approach
+ // Double_t rms=0;
+ if(useRMS){
+ //Calculate the RMS
+ if(averageValue>0){
+ fThresholdUsed =(Int_t)(TMath::Sqrt(averageValue)*nRMS);
+ }
+ else{
+ HLTFatal("average value in ZeroSuppression less than 0, investigation needed. This should never happen");
+ }
+ }
+ else{
+ fThresholdUsed = (Int_t)(averageValue + threshold);
+ }
+
+ averageValue = 55.3;
// Do zero suppression on the adc values within [beginTime,endTime]
- for(Int_t i=endTime;i>=beginTime;i--){
- //the +1 in the if below is there to avoid getting a signal which is 0, adding to the numbers you have to loop over in the end
- //(better to set it to -1 which is default for no signal)
- if(fDataSignals[i]>(Int_t)(averageValue+fThresholdUsed+1) && fDataSignals[i-1]>(Int_t)(averageValue+fThresholdUsed+1)){
- //here the signals below threshold to the right of the candidate is added
- Bool_t contRight=kTRUE;
- Int_t endRight=i;
- Int_t nToAddRight=0;
- while(contRight){
- if(endRight+1<endTime){
- // cout<<fDataSignals[endRight+1]<<" "<<fDataSignals[endRight+2]<<endl;;
- if(fDataSignals[endRight+1]>=fDataSignals[endRight+2] && fDataSignals[endRight+1]>averageValue){
- nToAddRight++;
- }
- else{
- if(fDataSignals[endRight+1]> averageValue){
- nToAddRight++;
- }
- contRight=kFALSE;
- }
- }
- else if(endRight>endTime+1){
- contRight=kFALSE;
+ for(Int_t i=beginTime;i<endTime;i++){
+ if(fDataSignals[i]>fThresholdUsed){
+ // HLTInfo("Signal Larger in pad %d time %d signal %d , threshold: %d averageValue %e",fPadNo,i,fDataSignals[i],fThresholdUsed, averageValue);
+ Int_t firstSignalTime=i;
+ for(Int_t left=1;left<timebinsLeft;left++){//looking 5 to the left of the signal to add tail
+ if(fDataSignals[i-left]-averageValue+valueUnderAverage>0&&i-left>=beginTime){
+ firstSignalTime--;
}
- endRight++;
- }
- for(int j=i+nToAddRight;j>i;j--){
- fDataSignals[j]=(Int_t)(fDataSignals[j]-averageValue);
- fSignalPositionArray[fSizeOfSignalPositionArray]=j;
- fSizeOfSignalPositionArray++;
- }
-
-
- //before while the two consecutive timebin values are added
- fDataSignals[i]=(Int_t)(fDataSignals[i]-averageValue);
- fSignalPositionArray[fSizeOfSignalPositionArray]=i;
- fSizeOfSignalPositionArray++;
- fDataSignals[i-1]=(Int_t)(fDataSignals[i-1]-averageValue);
- fSignalPositionArray[fSizeOfSignalPositionArray]=i-1;
- fSizeOfSignalPositionArray++;
- i--;
- // cout<<""<<endl;
- //Here the consecutive pads after the two first are added
- if(i-1>0){
- while(fDataSignals[i-1]>(Int_t)(averageValue+fThresholdUsed+1)){
- fDataSignals[i-1]=(Int_t)(fDataSignals[i-1]-averageValue);
- fSignalPositionArray[fSizeOfSignalPositionArray]=i-1;
- fSizeOfSignalPositionArray++;
- i--;
+ else{
+ break;
}
}
- //adding the signal below threshold belonging to the total signal
- Bool_t contLeft=kTRUE;
- while(contLeft){
- if(i-2>0){
- if(fDataSignals[i-1]>=fDataSignals[i-2] && fDataSignals[i-1]>averageValue){
- fDataSignals[i-1]=(Int_t)(fDataSignals[i-1]-averageValue);
- fSignalPositionArray[fSizeOfSignalPositionArray]=i-1;
- fSizeOfSignalPositionArray++;
- i--;
- }
- else{
- if(fDataSignals[i-1]> averageValue){
- fDataSignals[i-1]=(Int_t)(fDataSignals[i-1]-averageValue);
- fSignalPositionArray[fSizeOfSignalPositionArray]=i-1;
- fSizeOfSignalPositionArray++;
- i--;
- }
- contLeft=kFALSE;
- }
+ Int_t lastSignalTime=i;
+ for(Int_t right=1;right<timebinsRight;right++){//looking 5 to the left of the signal to add tail
+ if(fDataSignals[i+right]-averageValue+valueUnderAverage>0&&i+right<endTime){
+ lastSignalTime++;
}
else{
- contLeft=kFALSE;
+ break;
+ }
+ }
+ for(Int_t t=firstSignalTime;t<lastSignalTime;t++){
+ // cout<<"Row: "<<fRowNo<<" Pad: "<<fPadNo<<" Adding to tmebin: "<<t<<" signal: "<<(AliHLTTPCSignal_t)(fDataSignals[t]-averageValue + valueUnderAverage)<<endl;
+ fDataSignals[t]=(AliHLTTPCSignal_t)(fDataSignals[t]-averageValue + valueUnderAverage);
+ // cout<<"Adding to signalPosition array bin number: "<<fSizeOfSignalPositionArray<<" timebin number: "<<t<<endl;
+ fSignalPositionArray[fSizeOfSignalPositionArray]=t;
+ fSizeOfSignalPositionArray++;
+ // cout<<"Number of signals added so far: "<<fSizeOfSignalPositionArray<<" firstSignalTimeBin: "<<firstSignalTime<<" lastSignalTimeBin: "<<lastSignalTime<<endl;
+ /* if(fRowNo==29&&fPadNo==58){
+ cout<<"Signal added: Row: "<<fRowNo<<" Pad: "<<fPadNo<<" Time: "<<t<<" signal: "<<fDataSignals[t]<<" #signals: "<<fSizeOfSignalPositionArray<<endl;
}
-
+ */
+#if DebugHisto
+ fDebugHistoAfterZS->Fill(t,fDataSignals[t]);
+#endif
}
- }
- }
- Int_t nReadFromPositionArray=0;
- for(Int_t i=endTime;i>=beginTime;i--){
- if(i==fSignalPositionArray[nReadFromPositionArray]){
- nReadFromPositionArray++;
+ i+=lastSignalTime;
}
else{
fDataSignals[i]=-1;
- }
+ }
}
}
+
void AliHLTTPCPad::AddClusterCandidate(AliHLTTPCClusters candidate){
fClusterCandidates.push_back(candidate);
fUsedClusterCandidates.push_back(0);
}
+void AliHLTTPCPad::SaveHistograms(){
+#if DebugHisto
+ if(fSizeOfSignalPositionArray==0){
+ return;
+ }
+ char* filename;
+ sprintf(filename,"/afsuser/kenneth/SimpleComponentWrapper/histos/HistogramsRow%dPad%d.root",fRowNo,fPadNo);
+ TFile file(filename,"RECREATE");
+ fDebugHistoBeforeZS->Write();
+ fDebugHistoAfterZS->Write();
+ file.Close();
+#endif
+}
+
void AliHLTTPCPad::FindClusterCandidates()
{
// see header file for class documentation
-
+ /*
if(fSizeOfSignalPositionArray<2){
return;
}
tmpSig.clear();
}
}
+ */
}
#include "AliHLTLogging.h"
#include "AliHLTTPCClusters.h"
+#include "TH1F.h"
#include <vector>
typedef Int_t AliHLTTPCSignal_t;
+#define DebugHisto 0
+
/**
* @class AliHLTTPCPad
* The class is a container for the raw ADC data of one TPCS pad. In order to
* The method is checked with 2006 cosmics data, and it looks good.
* If you want to use the threshold approach you HAVE to set nSigma=-1 and threshold>0. For example: If you want all signals
* 30 adc counts above threshold you should call the function like this: ZeroSuppress(-1,30)
- * @param nSigma Specify nSigma above threshold default=3
- * @param threshold Specify what adc threshold above average default=20 (remember to give nSigma=-1 if you want to use this approach)
+ * @param nRMS Specify nRMS threshold
+ * @param threshold Specify what adc threshold above average (remember to give nRMS=-1 if you want to use this approach)
* @param reqMinPoint Required minimum number of points to do zerosuppression default AliHLTTPCTransform::GetNTimeBins/2 (1024/2).
- * @param beginTime Lowest timebin value. Gating grid causes some problems in the first timebins. default= 50
- * @param endTime Highest timebin value. Default AliHLTTPCTransform::GetNTimeBins-1
+ * @param beginTime Lowest timebin value. Gating grid causes some problems in the first timebins.
+ * @param endTime Highest timebin value.
*/
- void ZeroSuppress(Double_t nSigma,Int_t threshold,Int_t reqMinPoint,Int_t beginTime,Int_t endTime);
+ void ZeroSuppress(Double_t nRMS,Int_t threshold,Int_t reqMinPoint,Int_t beginTime,Int_t endTime,Int_t timebinsLeft, Int_t timebinsRight, Int_t valueBelowAverage);
+
+
+ Bool_t GetNextGoodSignal(Int_t &time,Int_t &signal);
+
+ UInt_t GetNAddedSignals(){return fSizeOfSignalPositionArray;}
/**
* Finds the cluster candidate. If atleast two signals in the data array are neighbours
*/
void SetNSigmaThreshold(Double_t i){fNSigmaThreshold=i;}
+ void SaveHistograms();
/**
* Vector of cluster candidates
*/
Int_t *fSignalPositionArray; //! transient
Int_t fSizeOfSignalPositionArray; //! transient
+
+ Int_t fNGoodSignalsSent;
Double_t fNSigmaThreshold; //! transient
Double_t fSignalThreshold; //! transient
+ TH1F *fDebugHistoBeforeZS; //! transient
+ TH1F *fDebugHistoAfterZS; //! transient
+
Int_t fModeSwitch; //! transient
ClassDef(AliHLTTPCPad, 4)
};
--- /dev/null
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Primary Authors: Kenneth Aamodt <Kenneth.Aamodt@student.uib.no> *
+ * for The ALICE HLT Project. *
+ * *
+ * 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. *
+ **************************************************************************/
+
+/** @file AliHLTTPCZeroSuppressionComponent.cxx
+ @author Kenneth Aamodt
+ @date
+ @brief The TPC ZeroSuppression component
+*/
+
+// see header file for class documentation //
+// or //
+// refer to README to build package //
+// or //
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
+
+#if __GNUC__>= 3
+using namespace std;
+#endif
+#include "AliHLTTPCZeroSuppressionComponent.h"
+#include "AliHLTTPCDigitReaderDecoder.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCPad.h"
+#include "AliHLTTPCDigitData.h"
+#include <cstdlib>
+#include <cerrno>
+#include "TString.h"
+#include <sys/time.h>
+
+AliHLTTPCZeroSuppressionComponent gAliHLTTPCZeroSuppressionComponent;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTTPCZeroSuppressionComponent)
+
+AliHLTTPCZeroSuppressionComponent::AliHLTTPCZeroSuppressionComponent()
+ :
+ fNTimeBins(0),
+ fStartTimeBin(0),
+ fEndTimeBin(AliHLTTPCTransform::GetNTimeBins()),
+ fNRMSThreshold(0),
+ fSignalThreshold(0),
+ fMinimumNumberOfSignals(AliHLTTPCTransform::GetNTimeBins()/2),
+ fOldRCUFormat(0),
+ fSortPads(0),
+ fRowPadVector(),
+ fDigitReader(NULL),
+ fVectorInitialized(kFALSE),
+ fNumberOfPadsInRow(NULL),
+ fNumberOfRows(0),
+ fCurrentPatch(0),
+ fFirstRow(0),
+ fLastRow(0),
+ fValueBelowAverage(5),
+ fLeftTimeBin(5),
+ fRightTimeBin(5)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTTPCZeroSuppressionComponent::~AliHLTTPCZeroSuppressionComponent()
+{
+ // see header file for class documentation
+ if(fVectorInitialized){
+ DeInitializePadArray();
+ }
+ if(fNumberOfPadsInRow){
+ delete [] fNumberOfPadsInRow;
+ fNumberOfPadsInRow=NULL;
+ }
+}
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCZeroSuppressionComponent::GetComponentID()
+{
+ // see header file for class documentation
+ return "TPCZeroSuppression";
+}
+
+void AliHLTTPCZeroSuppressionComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+{
+ // see header file for class documentation
+ list.clear();
+ list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
+}
+
+AliHLTComponentDataType AliHLTTPCZeroSuppressionComponent::GetOutputDataType()
+{
+ // see header file for class documentation
+ return AliHLTTPCDefinitions::fgkUnpackedRawDataType;
+}
+
+int AliHLTTPCZeroSuppressionComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+ // see header file for class documentation
+ tgtList.clear();
+ tgtList.push_back(AliHLTTPCDefinitions::fgkUnpackedRawDataType);
+ return tgtList.size();
+}
+
+void AliHLTTPCZeroSuppressionComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+ // see header file for class documentation
+ constBase=0;
+ inputMultiplier=1.0;
+}
+
+AliHLTComponent* AliHLTTPCZeroSuppressionComponent::Spawn()
+{
+ // see header file for class documentation
+ return new AliHLTTPCZeroSuppressionComponent();
+}
+
+int AliHLTTPCZeroSuppressionComponent::DoInit( int argc, const char** argv )
+{
+ // see header file for class documentation
+
+ Int_t i = 0;
+ Char_t* cpErr;
+
+ while ( i < argc ) {
+
+ // -- zero suppression threshold
+ if ( !strcmp( argv[i], "signal-threshold" ) ) {
+ fSignalThreshold = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert signal-threshold specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- checking for nsigma-threshold, used in 2007 December run in ZeroSuppression
+ if ( !strcmp( argv[i], "rms-threshold" ) ) {
+ fNRMSThreshold = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ){
+ HLTError("Cannot convert rms-threshold specifier '%s'. Must be integer", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- number of timebins
+ if ( !strcmp( argv[i], "ntimebins" ) ) {
+ fNTimeBins = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert ntimebins specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- first timebin
+ if ( !strcmp( argv[i], "start-timebin" ) ) {
+ fStartTimeBin = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert start-timebin specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- last timebin
+ if ( !strcmp( argv[i], "end-timebin" ) ) {
+ fEndTimeBin = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert end-timebin specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- timebins to keep left of signal
+ if ( !strcmp( argv[i], "timebin-left" ) ) {
+ fLeftTimeBin = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert timebin-left specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- timebin to keep right of signal
+ if ( !strcmp( argv[i], "timebin-right" ) ) {
+ fRightTimeBin = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert timebin-right specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- value below average to subtract
+ if ( !strcmp( argv[i], "value-below-average" ) ) {
+ fValueBelowAverage = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert value-below-average specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- pad occupancy limit
+ if ( !strcmp( argv[i], "occupancy-limit" ) ) {
+ fMinimumNumberOfSignals = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ) {
+ HLTError("Cannot convert occupancy-limit specifier '%s'.", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- checking for rcu format
+ if ( !strcmp( argv[i], "oldrcuformat" ) ) {
+ fOldRCUFormat = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ){
+ HLTError("Cannot convert oldrcuformat specifier '%s'. Should be 0(off) or 1(on), must be integer", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ // -- checking for rcu format
+ if ( !strcmp( argv[i], "sort-pads" ) ) {
+ fSortPads = strtoul( argv[i+1], &cpErr ,0);
+ if ( *cpErr ){
+ HLTError("Cannot convert sort-pads specifier '%s'. Should be 0(off) or 1(on), must be integer", argv[i+1]);
+ return EINVAL;
+ }
+ i+=2;
+ continue;
+ }
+
+ Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+ return EINVAL;
+
+ }
+
+ HLTDebug("using AliHLTTPCDigitReaderDecoder");
+ fDigitReader = new AliHLTTPCDigitReaderDecoder();
+
+ return 0;
+}
+
+int AliHLTTPCZeroSuppressionComponent::DoDeinit()
+{
+ // see header file for class documentation
+
+ return 0;
+}
+
+Int_t AliHLTTPCZeroSuppressionComponent::DeInitializePadArray()
+{
+ // see header file for class documentation
+ if(fVectorInitialized){
+ for(Int_t i=0;i<fNumberOfRows;i++){
+ for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){
+ delete fRowPadVector[i][j];
+ fRowPadVector[i][j]=NULL;
+ }
+ fRowPadVector[i].clear();
+ }
+ fRowPadVector.clear();
+ }
+
+ return 1;
+}
+
+void AliHLTTPCZeroSuppressionComponent::InitializePadArray(){
+ // see header file for class documentation
+ // HLTInfo("InitializingPadArray");
+ if(fCurrentPatch>5||fCurrentPatch<0){
+ HLTFatal("Patch is not set");
+ return;
+ }
+
+ fFirstRow = AliHLTTPCTransform::GetFirstRow(fCurrentPatch);
+ fLastRow = AliHLTTPCTransform::GetLastRow(fCurrentPatch);
+
+ fNumberOfRows=fLastRow-fFirstRow+1;
+ fNumberOfPadsInRow= new UInt_t[fNumberOfRows];
+
+ memset( fNumberOfPadsInRow, 0, sizeof(Int_t)*(fNumberOfRows));
+
+ for(Int_t i=0;i<fNumberOfRows;i++){
+ fNumberOfPadsInRow[i]=AliHLTTPCTransform::GetNPads(i+fFirstRow);
+ AliHLTTPCPadVector tmpRow;
+ for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){
+ AliHLTTPCPad *tmpPad = new AliHLTTPCPad();
+ tmpPad->SetID(i,j);
+ tmpRow.push_back(tmpPad);
+ }
+ fRowPadVector.push_back(tmpRow);
+ }
+ fVectorInitialized=kTRUE;
+}
+
+
+int AliHLTTPCZeroSuppressionComponent::DoEvent( const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ vector<AliHLTComponentBlockData>& outputBlocks )
+{
+ // see header file for class documentation
+
+ // HLTInfo("Entering DoEvent in ZeroSuppression");
+
+ // == init iter (pointer to datablock)
+ const AliHLTComponentBlockData* iter = NULL;
+ unsigned long ndx;
+ // HLTInfo("Number of blocks: ",evtData.fBlockCnt);
+
+ //reading the data
+ for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+ {
+ iter = blocks+ndx;
+
+ HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
+ evtData.fEventID, evtData.fEventID,
+ DataType2Text( iter->fDataType).c_str(),
+ DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
+
+ if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType &&
+ GetEventCount()<2) {
+ HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!",
+ DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
+ DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
+ }
+
+ if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) &&
+ iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ){
+ continue;
+ }
+
+
+ UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+ UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+
+ if(!fVectorInitialized){
+ fCurrentPatch=patch;
+ InitializePadArray();
+ }
+
+ // HLTInfo("Slice number: %d Patch number: %d",slice,patch);
+
+ fDigitReader->InitBlock(iter->fPtr,iter->fSize,patch,slice);
+
+ //Here the reading of the data and the zerosuppression takes place
+ while(fDigitReader->NextChannel()){//Pad
+ AliHLTTPCPad *tmpPad = fRowPadVector[fDigitReader->GetRow()][fDigitReader->GetPad()];
+ //reading data to pad
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ if(bunchData[i]>0){// disregarding 0 data.
+ if(time+i>=fStartTimeBin && time+i<=fEndTimeBin){
+ //HLTInfo("Adding %d to time %d row %d and pad %d",bunchData[i], time+i, row,pad);
+ tmpPad->SetDataSignal(time+i,bunchData[i]);
+ }
+ }
+ }
+ }
+ if(tmpPad->GetNAddedSignals()>=fMinimumNumberOfSignals){
+ //HLTDebug("In ZSC: nRMS=%d, threshold=%d, reqMinPoint=%d, beginTime=%d, endTime=%d, timebinsLeft=%d timebinsRight=%d valueUnderAverage=%d \n",fNRMSThreshold,fSignalThreshold,fMinimumNumberOfSignals,fStartTimeBin,fEndTimeBin,fLeftTimeBin,fRightTimeBin,fValueBelowAverage);
+ tmpPad->ZeroSuppress(fNRMSThreshold, fSignalThreshold, fMinimumNumberOfSignals, fStartTimeBin, fEndTimeBin, fLeftTimeBin, fRightTimeBin, fValueBelowAverage);
+ tmpPad->SaveHistograms();
+ }
+ }
+ }
+
+ //writing to output
+ AliHLTUInt8_t* outBPtr;
+ outBPtr = outputPtr;
+ AliHLTTPCUnpackedRawData* outPtr;
+ outPtr = (AliHLTTPCUnpackedRawData*)outputPtr;
+ unsigned long long outputSize = 0;
+ unsigned long blockOutputSize = 0;
+ unsigned long rowSize = 0;
+ AliHLTTPCDigitRowData* currentRow=outPtr->fDigits;
+ AliHLTTPCDigitData* currentDigit=currentRow->fDigitData;
+ Int_t rowOffset = 0;
+ switch (fCurrentPatch){
+ case 0:
+ rowOffset=0;
+ break;
+ case 1:
+ rowOffset=30;
+ break;
+ case 2:
+ rowOffset=0;
+ break;
+ case 3:
+ rowOffset=28-2;
+ break;
+ case 4:
+ rowOffset=28+26;
+ break;
+ case 5:
+ rowOffset=28+26+22;
+ break;
+ }
+ /* if ( fCurrentPatch >= 2 ){ // Outer sector, patches 2, 3, 4, 5
+ rowOffset = AliHLTTPCTransform::GetFirstRow( 2 );
+ }
+ */
+ Int_t lastRow=-1;
+ for(Int_t row=0;row<fNumberOfRows;row++){
+ for(Int_t pad=0;pad<fNumberOfPadsInRow[row];pad++){
+ AliHLTTPCPad * zerosuppressedPad= fRowPadVector[row][pad];
+ Int_t time=0;
+ Int_t signal=0;
+ while(zerosuppressedPad->GetNextGoodSignal(time, signal)){
+ if(lastRow!=row){
+ rowSize=0;
+ currentRow = (AliHLTTPCDigitRowData*)(outBPtr+outputSize);
+ currentDigit = currentRow->fDigitData;
+ currentRow->fRow = row+rowOffset;
+ currentRow->fNDigit = 0;
+ outputSize += sizeof(AliHLTTPCDigitRowData);
+ blockOutputSize += sizeof(AliHLTTPCDigitRowData);
+ rowSize += sizeof(AliHLTTPCDigitRowData);
+ lastRow=row;
+ }
+ currentDigit->fCharge = signal;
+ currentDigit->fPad = pad;
+ currentDigit->fTime = time;
+ printf("Row: %d Pad: %d Time: %d Charge %d\n", row + rowOffset, pad, time, signal);
+ currentRow->fNDigit++;
+ currentDigit++;
+ outputSize += sizeof(AliHLTTPCDigitData);
+ blockOutputSize += sizeof(AliHLTTPCDigitData);
+ rowSize += sizeof(AliHLTTPCDigitData);
+ }
+ // printf("\n");
+ }
+ }
+
+ AliHLTComponentBlockData bd;
+ FillBlockData( bd );
+ bd.fOffset = outputSize-blockOutputSize;
+ bd.fSize = blockOutputSize;
+ bd.fSpecification = iter->fSpecification;
+ Logging( kHLTLogDebug, "HLT::TPCZeroSuppressionComponent::DoEvent", "Event received",
+ "Event 0x%08LX (%Lu) output data block %lu of %lu bytes at offset %lu",
+ evtData.fEventID, evtData.fEventID, ndx, blockOutputSize, outputSize-blockOutputSize );
+ outputBlocks.push_back( bd );
+
+ return 0;
+}
--- /dev/null
+// XEmacs -*-C++-*-
+// @(#) $Id: AliHLTTPCClusterFinderComponent.h 23318 2008-01-14 12:43:28Z hristov $
+
+#ifndef ALIHLTTPCZEROSUPPRESSIONCOMPONENT_H
+#define ALIHLTTPCZEROSUPPRESSIONCOMPONENT_H
+
+/* This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/** @file AliHLTTPCZeroSuppressionComponent.h
+ @author Kenneth Aamodt
+ @date
+ @brief Component for ZeroSuppression
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCPad.h"
+
+class AliHLTTPCDigitReader;
+
+/**
+ * @class AliHLTTPCZeroSuppressionComponent
+ * Implementation of the zero suppression component.
+ * The component implements the interface methods of the @ref AliHLTProcessor.
+ * It reads the data pad by pad and zerosuppress the data. The output is unpacked which is
+ * sent to the clulsterfinder.
+ *
+ * The component has the following component arguments:
+ * - adc-threshold ADC count threshold for zero suppression.
+ *
+ * - rms-threshold RMS threshold for zero suppression.
+ *
+ * - first-timebin The first timebin for zero suppression
+ *
+ * - last-timebin The last timebin for zero suppression
+ *
+ * - occupancy-limit Minimum number of timebins with signal
+ *
+ * - sort-pads Flag to switch on pad sorting(needed by the SORTED clusterfinder)
+ *
+ * @ingroup alihlt_tpc
+ */
+class AliHLTTPCZeroSuppressionComponent : public AliHLTProcessor
+ {
+ public:
+ /** constructor */
+ AliHLTTPCZeroSuppressionComponent();
+ /** destructor */
+ virtual ~AliHLTTPCZeroSuppressionComponent();
+
+ // Public functions to implement AliHLTComponent's interface.
+ // These functions are required for the registration process
+
+ /** interface function, see @ref AliHLTComponent for description */
+ const char* GetComponentID();
+ /** interface function, see @ref AliHLTComponent for description */
+ void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+ /** interface function, see @ref AliHLTComponent for description */
+ AliHLTComponentDataType GetOutputDataType();
+ /** interface function, see @ref AliHLTComponent for description */
+ int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+ /** interface function, see @ref AliHLTComponent for description */
+ virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+ /** interface function, see @ref AliHLTComponent for description */
+ AliHLTComponent* Spawn();
+
+ Int_t DeInitializePadArray();
+ void InitializePadArray();
+ protected:
+
+ // Protected functions to implement AliHLTComponent's interface.
+ // These functions provide initialization as well as the actual processing
+ // capabilities of the component.
+
+ int DoInit( int argc, const char** argv );
+ int DoDeinit();
+ int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
+
+ using AliHLTProcessor::DoEvent;
+
+ private:
+
+ /** copy constructor prohibited */
+ AliHLTTPCZeroSuppressionComponent(const AliHLTTPCZeroSuppressionComponent&);
+
+ /** assignment operator prohibited */
+ AliHLTTPCZeroSuppressionComponent& operator=(const AliHLTTPCZeroSuppressionComponent&);
+
+ /** the reader object for data decoding */
+ AliHLTTPCDigitReader* fDigitReader; //!transient
+
+
+ typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
+
+ vector<AliHLTTPCPadVector> fRowPadVector; //! transient
+
+ UInt_t* fNumberOfPadsInRow; //! transient
+
+ UInt_t fNumberOfRows; //! transient
+
+ UInt_t fCurrentPatch; //! transient
+ UInt_t fFirstRow; //! transient
+ UInt_t fLastRow; //! transient
+
+
+ Int_t fStartTimeBin; //! transient
+ Int_t fEndTimeBin; //! transient
+ Int_t fNTimeBins; //! transient
+ Double_t fNRMSThreshold; //! transient
+ Int_t fSignalThreshold; //! transient
+ Int_t fMinimumNumberOfSignals; //! transient
+ UInt_t fOldRCUFormat; //! transient
+ Bool_t fSortPads; //! transient
+ Bool_t fVectorInitialized; //! transient
+
+ Int_t fValueBelowAverage; //! transient
+ Int_t fLeftTimeBin; //! transient
+ Int_t fRightTimeBin; //! transient
+ ClassDef(AliHLTTPCZeroSuppressionComponent, 0)
+ };
+#endif