-void AliHLTTPCPad::FindClusterCandidates()
-{
- // see header file for class documentation
- UInt_t seqcharge=0;
- UInt_t seqaverage=0;
- UInt_t seqerror=0;
- vector<Int_t> tmpPos;
- vector<Int_t> tmpSig;
- UInt_t isFalling=0;
-
- for(Int_t pos=fSizeOfSignalPositionArray-2;pos>=0;pos--){
-
- if(fSignalPositionArray[pos]==fSignalPositionArray[pos+1]+1){
- seqcharge+=fDataSignals[fSignalPositionArray[pos+1]];
- seqaverage += fSignalPositionArray[pos+1]*fDataSignals[fSignalPositionArray[pos+1]];
- seqerror += fSignalPositionArray[pos+1]*fSignalPositionArray[pos+1]*fDataSignals[fSignalPositionArray[pos+1]];
-
- tmpPos.push_back(fSignalPositionArray[pos+1]);
- tmpSig.push_back(fDataSignals[fSignalPositionArray[pos+1]]);
-
- if(fDataSignals[fSignalPositionArray[pos+1]]>fDataSignals[fSignalPositionArray[pos]]){
- isFalling=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, bool speedup){
+ //see headerfile for documentation
+
+ //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 && nRMS<=0){
+ //setting the data to -1 for this pad
+ HLTInfo("Neither of RMSThreshold and SignalThreshold set, zerosuppression aborted");
+ return;
+ }
+
+ Int_t fThresholdUsed=threshold;
+
+ Int_t maxVal=0;
+ Int_t nAdded=0;
+ Int_t sumNAdded=0;
+ fSizeOfSignalPositionArray=0;
+ if(useRMS){
+ for(Int_t i=beginTime;i<endTime+1;i++){
+ if(fDataSignals[i]>0){
+ nAdded++;
+ sumNAdded+=fDataSignals[i]*fDataSignals[i];
+ if (maxVal<fDataSignals[i]) maxVal=fDataSignals[i];
+ }
+ }
+ }
+ else if(threshold>0){
+ for(Int_t i=beginTime;i<endTime+1;i++){
+ if(fDataSignals[i]>0){
+ nAdded++;
+ sumNAdded+=fDataSignals[i];
+ if (maxVal<fDataSignals[i]) maxVal=fDataSignals[i];
+ }
+ }
+ }
+ 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;
+ }
+
+ if(nAdded==0){
+ HLTInfo("No signals added for this pad, zerosuppression aborted: pad %d row %d",fPadNo,fRowNo);
+ return;
+ }
+
+ Double_t averageValue=(Double_t)sumNAdded/nAdded;//true average for threshold approach, average of signals squared for rms approach
+
+ 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);
+ }
+ if (maxVal<fThresholdUsed) return;
+
+ // Do zero suppression on the adc values within [beginTime,endTime](add the good values)
+ for(Int_t i=beginTime;i<endTime;i++){
+ if(fDataSignals[i]>fThresholdUsed){
+ 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--;
+ }
+ else{
+ break;
+ }