LCOV - code coverage report
Current view: top level - HLT/TPCLib - AliHLTTPCPad.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 329 0.3 %
Date: 2016-06-14 17:26:59 Functions: 1 36 2.8 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the ALICE HLT Project        * 
       5             : //* ALICE Experiment at CERN, All rights reserved.                         *
       6             : //*                                                                        *
       7             : //* Primary Authors: Timm Steinbeck, Matthias Richter                      *
       8             : //* Developers:      Kenneth Aamodt <kenneth.aamodt@student.uib.no>        *
       9             : //*                  for The ALICE HLT Project.                            *
      10             : //*                                                                        *
      11             : //* Permission to use, copy, modify and distribute this software and its   *
      12             : //* documentation strictly for non-commercial purposes is hereby granted   *
      13             : //* without fee, provided that the above copyright notice appears in all   *
      14             : //* copies and that both the copyright notice and this permission notice   *
      15             : //* appear in the supporting documentation. The authors make no claims     *
      16             : //* about the suitability of this software for any purpose. It is          *
      17             : //* provided "as is" without express or implied warranty.                  *
      18             : //**************************************************************************
      19             : 
      20             : /// @file   AliHLTTPCPad.cxx
      21             : /// @author Matthias Richter, Kenneth Aamodt
      22             : /// @date   
      23             : /// @brief  Container Class for TPC Pads.
      24             : ///
      25             : 
      26             : #include <cerrno>
      27             : #include "AliHLTTPCPad.h"
      28             : #include "AliHLTStdIncludes.h"
      29             : 
      30             : 
      31             : //added by kenneth
      32             : #include "AliHLTTPCGeometry.h"
      33             : #include "AliHLTTPCClusters.h"
      34             : #include <sys/time.h>
      35             : #include "TMath.h"
      36             : #include "TFile.h"
      37             : //------------------------------
      38             : 
      39             : /** margin for the base line be re-avaluated */
      40             : #define ALIHLTPAD_BASELINE_MARGIN (2*fAverage)
      41             : 
      42             : /** ROOT macro for the implementation of ROOT specific class methods */
      43           6 : ClassImp(AliHLTTPCPad)
      44             : 
      45           0 : AliHLTTPCPad::AliHLTTPCPad()
      46             :   :
      47           0 :   fClusterCandidates(),
      48           0 :   fUsedClusterCandidates(),
      49           0 :   fSelectedPad(kFALSE),
      50           0 :   fHWAddress(0),
      51           0 :   fRowNo(-1),
      52           0 :   fPadNo(-1),
      53           0 :   fThreshold(0),
      54           0 :   fAverage(-1),
      55           0 :   fNofEvents(0),
      56           0 :   fSum(0),
      57           0 :   fCount(0),
      58           0 :   fTotal(0),
      59           0 :   fBLMax(-1),
      60           0 :   fBLMaxBin(-1),
      61           0 :   fBLMin(-1),
      62           0 :   fBLMinBin(-1),
      63           0 :   fFirstBLBin(0),
      64           0 :   fNofBins(0),
      65           0 :   fReadPos(0),
      66           0 :   fpRawData(NULL),
      67           0 :   fDataSignals(NULL),
      68           0 :   fSignalPositionArray(NULL),
      69           0 :   fSizeOfSignalPositionArray(0),
      70           0 :   fNGoodSignalsSent(0),
      71           0 :   fCandidateDigitsVector()
      72           0 : {
      73             :   // see header file for class documentation
      74             :   // or
      75             :   // refer to README to build package
      76             :   // or
      77             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      78             :   //  HLTInfo("Entering default constructor");
      79           0 :   fDataSignals= new AliHLTTPCSignal_t[AliHLTTPCGeometry::GetNTimeBins()];
      80           0 :   memset( fDataSignals, 0xFF, sizeof(Int_t)*(AliHLTTPCGeometry::GetNTimeBins()));
      81             :   
      82           0 :   fSignalPositionArray= new Int_t[AliHLTTPCGeometry::GetNTimeBins()];
      83           0 :   memset( fSignalPositionArray, 0xFF, sizeof(Int_t)*(AliHLTTPCGeometry::GetNTimeBins()));
      84           0 :   fSizeOfSignalPositionArray=0;
      85             : 
      86           0 : }
      87             : 
      88           0 : AliHLTTPCPad::AliHLTTPCPad(Int_t /*dummy*/)
      89             :   :
      90           0 :   fClusterCandidates(),
      91           0 :   fUsedClusterCandidates(),
      92           0 :   fSelectedPad(kFALSE),
      93           0 :   fHWAddress(0),
      94           0 :   fRowNo(-1),
      95           0 :   fPadNo(-1),
      96           0 :   fThreshold(0),
      97           0 :   fAverage(-1),
      98           0 :   fNofEvents(0),
      99           0 :   fSum(0),
     100           0 :   fCount(0),
     101           0 :   fTotal(0),
     102           0 :   fBLMax(-1),
     103           0 :   fBLMaxBin(-1),
     104           0 :   fBLMin(-1),
     105           0 :   fBLMinBin(-1),
     106           0 :   fFirstBLBin(0),
     107           0 :   fNofBins(0),
     108           0 :   fReadPos(0),
     109           0 :   fpRawData(NULL),
     110           0 :   fDataSignals(NULL),
     111           0 :   fSignalPositionArray(NULL),
     112           0 :   fSizeOfSignalPositionArray(0),
     113           0 :   fNGoodSignalsSent(0),
     114           0 :   fCandidateDigitsVector()
     115           0 : {
     116             :   // see header file for class documentation
     117             :   // or
     118             :   // refer to README to build package
     119             :   // or
     120             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
     121           0 : }
     122             : 
     123           0 : AliHLTTPCPad::AliHLTTPCPad(Int_t offset, Int_t nofBins)
     124             :   :
     125           0 :   fClusterCandidates(),
     126           0 :   fUsedClusterCandidates(),
     127           0 :   fSelectedPad(kFALSE),
     128           0 :   fHWAddress(0),
     129           0 :   fRowNo(-1),
     130           0 :   fPadNo(-1),
     131           0 :   fThreshold(0),
     132           0 :   fAverage(-1),
     133           0 :   fNofEvents(0),
     134           0 :   fSum(0),
     135           0 :   fCount(0),
     136           0 :   fTotal(0),
     137           0 :   fBLMax(-1),
     138           0 :   fBLMaxBin(-1),
     139           0 :   fBLMin(-1),
     140           0 :   fBLMinBin(-1),
     141           0 :   fFirstBLBin(offset),
     142           0 :   fNofBins(nofBins),
     143           0 :   fReadPos(0),
     144           0 :   fpRawData(NULL),
     145           0 :   fDataSignals(NULL),
     146           0 :   fSignalPositionArray(NULL),
     147           0 :   fSizeOfSignalPositionArray(0),
     148           0 :   fNGoodSignalsSent(0),
     149           0 :   fCandidateDigitsVector()
     150           0 : {
     151             :   // see header file for class documentation
     152           0 : }
     153             : 
     154             : AliHLTTPCPad::~AliHLTTPCPad()
     155           0 : {
     156             :   // see header file for class documentation
     157           0 :   if (fpRawData) {
     158           0 :     HLTWarning("event data acquisition not stopped");
     159           0 :     StopEvent();
     160             :   }
     161           0 :   if (fDataSignals) {
     162           0 :     delete [] fDataSignals;
     163           0 :     fDataSignals=NULL;
     164           0 :   }
     165           0 :   if (fSignalPositionArray!=NULL) {
     166           0 :     delete [] fSignalPositionArray;
     167           0 :     fSignalPositionArray=NULL;
     168           0 :   }
     169           0 : }
     170             : 
     171             : Int_t AliHLTTPCPad::SetID(Int_t rowno, Int_t padno)
     172             : {
     173             :   // see header file for class documentation
     174           0 :   fRowNo=rowno;
     175           0 :   fPadNo=padno;
     176             : 
     177           0 :   return 0;
     178             : }
     179             : 
     180             : Int_t AliHLTTPCPad::StartEvent()
     181             : {
     182             :   // see header file for class documentation
     183             :   Int_t iResult=0;
     184           0 :   if (fpRawData==NULL) {
     185           0 :     fBLMax=-1;
     186           0 :     fBLMaxBin=-1;
     187           0 :     fBLMin=-1;
     188           0 :     fBLMinBin=-1;
     189           0 :     fSum=0;
     190           0 :     fCount=0;
     191           0 :     fTotal=0;
     192           0 :     if (fNofBins>0) {
     193           0 :       fpRawData=new AliHLTTPCSignal_t[fNofBins];
     194           0 :       if (fpRawData) {
     195           0 :         for (int i=0; i<fNofBins; i++) fpRawData[i]=-1;
     196           0 :       } else {
     197           0 :         HLTError("memory allocation failed");
     198             :         iResult=-ENOMEM;
     199             :       }
     200             :     }
     201             :   } else {
     202           0 :     HLTWarning("event data acquisition already started");
     203             :     iResult=-EALREADY;
     204             :   }
     205           0 :   return iResult;
     206             : }
     207             : 
     208             : Int_t AliHLTTPCPad::CalculateBaseLine(Int_t reqMinCount)
     209             : {
     210             :   // see header file for class documentation
     211             :   Int_t iResult=0;
     212           0 :   AliHLTTPCSignal_t avBackup=fAverage;
     213             :   //HLTDebug("reqMinCount=%d fCount=%d fTotal=%d fSum=%d fBLMax=%d fBLMin=%d", reqMinCount, fCount, fTotal, fSum, fBLMax, fBLMin);
     214           0 :   if (fCount>=reqMinCount && fCount>=fTotal/2) {
     215           0 :     fAverage=fCount>0?fSum/fCount:0;
     216           0 :     if (fAverage>0) {
     217             :       //HLTDebug("average for current event %d (%d - %d)", fAverage, fBLMax, fBLMin);
     218           0 :       fCount=0;fSum=-1;
     219           0 :       if (fBLMax>ALIHLTPAD_BASELINE_MARGIN) {
     220             :         // calculate again
     221             :         //HLTDebug("maximum value %d exceeds margin for base line (%d) "
     222             :         //       "-> re-evaluate base line", fBLMax, ALIHLTPAD_BASELINE_MARGIN);
     223           0 :         if (fpRawData) {
     224           0 :           for (Int_t i=fFirstBLBin; i<fNofBins; i++)
     225           0 :             if (fpRawData[i]>=0) AddBaseLineValue(i, fpRawData[i]);
     226           0 :           if (fCount>0 && fCount>=reqMinCount && fCount>=fTotal/2) {
     227           0 :             fAverage=fSum/fCount;
     228             :             //HLTDebug("new average %d", fAverage);
     229           0 :           } else {
     230             :             //      HLTDebug("baseline re-eveluation skipped because of to few "
     231             :             //                 "contributing bins: total=%d, contributing=%d, req=%d"
     232             :             //                 "\ndata might be already zero suppressed"
     233             :             //                 , fTotal, fCount, reqMinCount);
     234             :             iResult=-ENODATA;
     235             :           }
     236           0 :           fCount=0;fSum=-1;
     237           0 :         } else {
     238           0 :           HLTError("missing raw data for base line calculation");
     239             :           iResult=-ENOBUFS;
     240             :         }
     241             :       }
     242           0 :       if (iResult>=0) {
     243             :         // calculate average for all events
     244           0 :         fAverage=((avBackup*fNofEvents)+fAverage)/(fNofEvents+1);
     245             :         //HLTDebug("base line average for %d event(s): %d", fNofEvents+1, fAverage);
     246           0 :       } else {
     247           0 :         fAverage=avBackup;      
     248             :       }
     249             :     } else {
     250           0 :       fAverage=avBackup;
     251             :     }
     252             :   } else {
     253             :     //     HLTDebug("baseline calculation skipped because of to few contributing "
     254             :     //         "bins: total=%d, contributing=%d, required=%d \ndata might be "
     255             :     //         "already zero suppressed", fTotal, fCount, reqMinCount);
     256             :   }
     257             : 
     258           0 :   return iResult;
     259             : }
     260             : 
     261             : Int_t AliHLTTPCPad::StopEvent()
     262             : {
     263             :   // see header file for class documentation
     264             :   Int_t iResult=0;
     265           0 :   if (fpRawData) {
     266             :     AliHLTTPCSignal_t* pData=fpRawData;
     267           0 :     fpRawData=NULL;
     268           0 :     delete [] pData;
     269           0 :     fTotal=0;
     270           0 :     fNofEvents++;
     271           0 :     Rewind();
     272           0 :   } else if (fNofBins>0) {
     273           0 :     HLTError("event data acquisition not started");
     274             :     iResult=-EBADF;
     275           0 :   }
     276           0 :   return iResult;
     277             : }
     278             : 
     279             : Int_t AliHLTTPCPad::ResetHistory()
     280             : {
     281             :   // see header file for class documentation
     282             :   Int_t iResult=0;
     283           0 :   fAverage=-1;
     284           0 :   fNofEvents=0;
     285           0 :   return iResult;
     286             : }
     287             : 
     288             : Int_t AliHLTTPCPad::SetThreshold(AliHLTTPCSignal_t thresh)
     289             : {
     290             :   // see header file for class documentation
     291             :   Int_t iResult=0;
     292           0 :   fThreshold=thresh;
     293           0 :   return iResult;
     294             : }
     295             : 
     296             : Int_t AliHLTTPCPad::AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value)
     297             : {
     298             :   // see header file for class documentation
     299             :   Int_t iResult=0;
     300           0 :   if (bin>=fFirstBLBin) {
     301           0 :     if (fAverage<0 || value<ALIHLTPAD_BASELINE_MARGIN) {
     302             :       // add to the current sum and count
     303           0 :       fSum+=value;
     304           0 :       fCount++;
     305           0 :       if (fBLMax<value) {
     306             :         // keep the maximum value for later quality control of the base 
     307             :         // line calculation
     308           0 :         fBLMax=value;
     309           0 :         fBLMaxBin=bin;
     310           0 :       }
     311           0 :       if (fBLMin<0 || fBLMin>value) {
     312             :         // keep the minimum value for later quality control of the base 
     313             :         // line calculation
     314           0 :         fBLMin=value;
     315           0 :         fBLMinBin=bin;
     316           0 :       }
     317             :     } else {
     318             :       //       HLTDebug("ignoring value %d (bin %d) for base line calculation "
     319             :       //               "(current average is %d)",
     320             :       //               value, bin, fAverage);
     321             :     }
     322             :   }
     323           0 :   return iResult;
     324             : }
     325             : 
     326             : Int_t AliHLTTPCPad::SetRawData(Int_t bin, AliHLTTPCSignal_t value)
     327             : {
     328             :   // see header file for class documentation
     329             :   //  printf("Row: %d    Pad: %d  Time: %d Charge %d", fRowNo, fPadNo, bin, value);
     330             :   Int_t iResult=0;
     331           0 :   if (fpRawData) {
     332           0 :     if (bin<fNofBins) {
     333           0 :       if (value>=0) {
     334           0 :         if (fpRawData[bin]<0) {
     335           0 :           AddBaseLineValue(bin, value);
     336           0 :           fTotal++;
     337           0 :         } else {
     338             :           // ignore value for average calculation
     339           0 :           HLTWarning("overriding content of bin %d (%d)", bin, fpRawData[bin]);
     340             :         }
     341           0 :         fpRawData[bin]=value;
     342           0 :       } else {
     343           0 :         HLTWarning("ignoring neg. raw data");
     344             :       }
     345             :     } else {
     346           0 :       HLTWarning("bin %d out of range (%d)", bin, fNofBins);
     347             :       iResult=-ERANGE;
     348             :     }
     349           0 :   } else if (fNofBins>0) {
     350           0 :     HLTError("event cycle not started");
     351             :     iResult=-EBADF;
     352           0 :   }
     353           0 :   return iResult;
     354             : }
     355             : 
     356             : Int_t AliHLTTPCPad::Next(Int_t bZeroSuppression) 
     357             : {
     358             :   // see header file for class documentation
     359           0 :   if (fpRawData==NULL) return 0;
     360           0 :   Int_t iResult=fReadPos<fNofBins;
     361           0 :   if (iResult>0 && (iResult=(++fReadPos<fNofBins))>0) {
     362           0 :     if (bZeroSuppression) {
     363           0 :       while ((iResult=(fReadPos<fNofBins))>0 &&
     364           0 :              GetCorrectedData(fReadPos)<=0)
     365           0 :         fReadPos++;
     366             :     }
     367             :   }
     368             :   return iResult;
     369           0 : }
     370             : 
     371             : Int_t AliHLTTPCPad::Rewind(Int_t bZeroSuppression)
     372             : {
     373             :   // see header file for class documentation
     374           0 :   fReadPos=(bZeroSuppression>0?0:fFirstBLBin)-1;
     375           0 :   return Next(bZeroSuppression);
     376             : }
     377             : 
     378             : AliHLTTPCSignal_t AliHLTTPCPad::GetRawData(Int_t bin) const
     379             : {
     380             :   // see header file for class documentation
     381             :   AliHLTTPCSignal_t data=0;
     382           0 :   if (fpRawData) {
     383           0 :     if (bin<fNofBins) {
     384           0 :       data=fpRawData[bin];
     385           0 :     } else {
     386           0 :       HLTWarning("requested bin %d out of range (%d)", bin, fNofBins);
     387             :     }
     388           0 :   } else if (fNofBins>0) {
     389           0 :     HLTWarning("data only available within event cycle");
     390             :   }
     391           0 :   return data;
     392             : }
     393             : 
     394             : AliHLTTPCSignal_t AliHLTTPCPad::GetCorrectedData(Int_t bin) const
     395             : {
     396             :   // see header file for class documentation
     397           0 :   AliHLTTPCSignal_t data=GetRawData(bin)-GetBaseLine(bin);
     398             :   AliHLTTPCSignal_t prev=0;
     399           0 :   if (bin>1) prev=GetRawData(bin-1)-GetBaseLine(bin-1);
     400             :   AliHLTTPCSignal_t succ=0;
     401           0 :   if (bin+1<GetSize()) succ=GetRawData(bin+1)-GetBaseLine(bin+1);
     402           0 :   if (fThreshold>0) {
     403           0 :     data-=fThreshold;
     404           0 :     prev-=fThreshold;
     405           0 :     succ-=fThreshold;
     406           0 :   }
     407             :  
     408             :   // case 1:
     409             :   // the signal is below the base-line and threshold
     410           0 :   if (data<0) data=0;
     411             : 
     412             :   //case 2:
     413             :   // the neighboring bins are both below base-line/threshold
     414             :   // a real signal is always more than one bin wide because of the shaper 
     415           0 :   if (prev<=0 && succ<=0) data=0;
     416             :  
     417             :   // case 3:
     418             :   // the bin is inside the range of ignored bins
     419           0 :   if (bin<fFirstBLBin) data=0;
     420             :   //HLTDebug("fReadPos=%d data=%d threshold=%d raw data=%d base line=%d", fReadPos, data, fThreshold, GetRawData(bin), GetBaseLine(bin));
     421           0 :   return data;
     422             : }
     423             : 
     424             : AliHLTTPCSignal_t AliHLTTPCPad::GetBaseLine(Int_t /*bin*/) const //TODO: Why is bin being ignored?
     425             : {
     426             :   // see header file for class documentation
     427             :   AliHLTTPCSignal_t val=0;
     428           0 :   if (fAverage>0) {
     429             :     // we take the minumum value as the base line if it doesn't differ from
     430             :     // the average to much
     431             :     val=fAverage;
     432             : #ifdef KEEP_NOISE
     433             :     const AliHLTTPCSignal_t kMaxDifference=15;
     434             :     if ((fAverage-fBLMin)<=kMaxDifference) val=fBLMin;
     435             :     else val>kMaxDifference?val-=kMaxDifference:0;
     436             : #endif
     437           0 :   }
     438           0 :   if (val<0) {
     439             :     // here we should never get
     440             :     val=0;
     441           0 :     HLTFatal("wrong base line value");
     442             :   }
     443           0 :   return val;
     444             : }
     445             : 
     446             : AliHLTTPCSignal_t AliHLTTPCPad::GetAverage() const
     447             : {
     448             :   // see header file for class documentation
     449           0 :   return fAverage>0?fAverage:0;
     450             : }
     451             : 
     452             : Float_t AliHLTTPCPad::GetOccupancy() const
     453             : {
     454             :   // see header file for class documentation
     455             :   Float_t occupancy=0;
     456           0 :   if (fpRawData && fNofBins>0) {
     457           0 :     for (Int_t i=fFirstBLBin; i<fNofBins; i++) {
     458           0 :       if (GetCorrectedData(i)>0) occupancy+=1;
     459             :     }
     460           0 :     if (fNofBins-fFirstBLBin>0)
     461           0 :       occupancy/=fNofBins-fFirstBLBin;
     462             :   }
     463           0 :   return occupancy;
     464             : }
     465             : 
     466             : Float_t AliHLTTPCPad::GetAveragedOccupancy() const
     467             : {
     468             :   // see header file for class documentation
     469             : 
     470             :   // history is not yet implemented
     471           0 :   return GetOccupancy();
     472             : }
     473             : void AliHLTTPCPad::PrintRawData()
     474             : {
     475             :   // see header file for class documentation
     476           0 :   for(Int_t bin=0;bin<AliHLTTPCGeometry::GetNTimeBins();bin++){
     477           0 :     if(GetDataSignal(bin)>0)
     478             :       //This cout should be here since using logging produces output that is much more difficult to read
     479           0 :         cout<<fRowNo<<"\t"<<fPadNo<<"\t"<<bin<<"\t"<<GetDataSignal(bin)<<endl;
     480             :   }
     481           0 : }
     482             : 
     483             : void AliHLTTPCPad::ClearCandidates(){
     484           0 :   fClusterCandidates.clear();
     485           0 :   fUsedClusterCandidates.clear();
     486           0 :   fCandidateDigitsVector.clear();
     487           0 : }
     488             : 
     489             : void AliHLTTPCPad::SetDataToDefault()
     490             : {
     491             :   // see header file for class documentation
     492             :   //  if(fDataSignals && fSignalPositionArray){
     493           0 :     for(Int_t i =0;i<fSizeOfSignalPositionArray;i++){
     494           0 :       fDataSignals[fSignalPositionArray[i]]=-1;
     495             :     }
     496           0 :     fSizeOfSignalPositionArray=0;
     497           0 :     fNGoodSignalsSent = 0;
     498             :     //  }
     499           0 : }
     500             : 
     501             : void AliHLTTPCPad::SetDataSignal(Int_t bin,Int_t signal)
     502             : {
     503             :   // see header file for class documentation
     504           0 :   fDataSignals[bin]=signal;
     505           0 :   fSignalPositionArray[fSizeOfSignalPositionArray]=bin;
     506           0 :   fSizeOfSignalPositionArray++;
     507           0 : }
     508             : 
     509             : Bool_t AliHLTTPCPad::GetNextGoodSignal(Int_t &time,Int_t &bunchSize){
     510             : 
     511           0 :   if(fNGoodSignalsSent<fSizeOfSignalPositionArray&&fSizeOfSignalPositionArray>0){
     512           0 :     time = fSignalPositionArray[fNGoodSignalsSent];
     513           0 :     bunchSize=1;
     514           0 :     fNGoodSignalsSent++;
     515           0 :     while(fNGoodSignalsSent<fSizeOfSignalPositionArray){
     516           0 :       if(fDataSignals[time+bunchSize+1]>0){
     517           0 :         bunchSize++;
     518           0 :         fNGoodSignalsSent++;
     519             :       }
     520             :       else{
     521             :         break;
     522             :       }
     523             :     }
     524             :     //    fNGoodSignalsSent++;
     525           0 :    return kTRUE;
     526             :   }
     527           0 :   return kFALSE;
     528           0 : }
     529             : 
     530             : Int_t AliHLTTPCPad::GetDataSignal(Int_t bin) const
     531             : {
     532             :   // see header file for class documentation
     533           0 :   return fDataSignals[bin];
     534             : }
     535             : 
     536             : 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){
     537             :   //see headerfile for documentation
     538             :  
     539             :   //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);
     540             : 
     541             :   Bool_t useRMS= kFALSE;
     542           0 :   if(nRMS>0){
     543             :     useRMS=kTRUE;
     544           0 :     if(threshold>0){
     545           0 :       HLTInfo("Both RMSThreshold and SignalThreshold defined, using RMSThreshold");
     546             :     }
     547             :   }
     548           0 :   if(threshold<1 && nRMS<=0){
     549             :     //setting the data to -1 for this pad
     550           0 :     HLTInfo("Neither of RMSThreshold and SignalThreshold set, zerosuppression aborted");
     551           0 :     return;
     552             :   }
     553             :  
     554             :   Int_t fThresholdUsed=threshold;
     555             : 
     556             :   Int_t maxVal=0;
     557             :   Int_t nAdded=0;
     558             :   Int_t sumNAdded=0;
     559           0 :   fSizeOfSignalPositionArray=0;
     560           0 :   if(useRMS){
     561           0 :     for(Int_t i=beginTime;i<endTime+1;i++){
     562           0 :       if(fDataSignals[i]>0){
     563           0 :         nAdded++;
     564           0 :         sumNAdded+=fDataSignals[i]*fDataSignals[i];
     565           0 :         if (maxVal<fDataSignals[i]) maxVal=fDataSignals[i];
     566             :       }
     567             :     }
     568           0 :   }
     569           0 :   else if(threshold>0){
     570           0 :     for(Int_t i=beginTime;i<endTime+1;i++){
     571           0 :       if(fDataSignals[i]>0){
     572           0 :         nAdded++;
     573           0 :         sumNAdded+=fDataSignals[i];
     574           0 :         if (maxVal<fDataSignals[i]) maxVal=fDataSignals[i];
     575             :       }
     576             :     }
     577           0 :   }
     578             :   else{
     579           0 :     HLTFatal("This should never happen because this is tested earlier in the code.(nRMSThreshold<1&&signal-threshold<1)");
     580             :   }
     581           0 :   if(nAdded<reqMinPoint){
     582           0 :     HLTInfo("Number of signals is less than required, zero suppression aborted");
     583           0 :     return;
     584             :   }
     585             :  
     586           0 :   if(nAdded==0){
     587           0 :     HLTInfo("No signals added for this pad, zerosuppression aborted: pad %d row %d",fPadNo,fRowNo);
     588           0 :     return;
     589             :   }
     590             : 
     591           0 :   Double_t averageValue=(Double_t)sumNAdded/nAdded;//true average for threshold approach, average of signals squared for rms approach
     592             :  
     593           0 :   if(useRMS){
     594             :     //Calculate the RMS
     595           0 :     if(averageValue>0){
     596           0 :       fThresholdUsed =(Int_t)(TMath::Sqrt(averageValue)*nRMS);
     597           0 :     }
     598             :     else{
     599           0 :       HLTFatal("average value in ZeroSuppression less than 0, investigation needed. This should never happen");
     600             :     }
     601             :   }
     602             :   else{
     603           0 :     fThresholdUsed = (Int_t)(averageValue + threshold); 
     604             :   }
     605           0 :   if (maxVal<fThresholdUsed) return;
     606             : 
     607             :   // Do zero suppression on the adc values within [beginTime,endTime](add the good values)
     608           0 :   for(Int_t i=beginTime;i<endTime;i++){
     609           0 :     if(fDataSignals[i]>fThresholdUsed){
     610             :       Int_t firstSignalTime=i;
     611           0 :       for(Int_t left=1;left<timebinsLeft;left++){//looking 5 to the left of the signal to add tail
     612           0 :         if(fDataSignals[i-left]-averageValue+valueUnderAverage>0 && i-left>=beginTime){
     613           0 :           firstSignalTime--;
     614             :         }
     615             :         else{
     616           0 :           break;
     617             :         }
     618             :       }
     619             :       Int_t lastSignalTime=i;
     620           0 :       while(fDataSignals[lastSignalTime+1]>fThresholdUsed && lastSignalTime+1<endTime){
     621             :         lastSignalTime++;
     622             :       }
     623           0 :       for(Int_t right=1;right<timebinsRight;right++){//looking 5 to the left of the signal to add tail
     624           0 :         if(fDataSignals[i+right]-averageValue+valueUnderAverage>0&&i+right<endTime){
     625           0 :           lastSignalTime++;
     626             :         }
     627             :         else{
     628           0 :           break;
     629             :         }       
     630             :       }
     631             :       
     632           0 :       for(Int_t t=firstSignalTime;t<lastSignalTime;t++){
     633           0 :         fDataSignals[t]=(AliHLTTPCSignal_t)(fDataSignals[t]-averageValue + valueUnderAverage);
     634           0 :         fSignalPositionArray[fSizeOfSignalPositionArray]=t;
     635           0 :         fSizeOfSignalPositionArray++;
     636             :         // Matthias Oct 10 2008: trying hard to make the code faster for the
     637             :         // AltroChannelSelection. For that we only need to know there is data
     638           0 :         if (speedup) return;
     639             :       }
     640           0 :       i+=lastSignalTime;
     641           0 :     }
     642             :   }
     643             :   //reset the rest of the data
     644           0 :   Int_t counterSize=fSizeOfSignalPositionArray;
     645             : 
     646           0 :   for(Int_t d=endTime;d>=beginTime;d--){
     647           0 :     if(d==fSignalPositionArray[counterSize-1]&&counterSize-1>=0){
     648           0 :       counterSize--;
     649           0 :     }
     650             :     else{
     651           0 :       fDataSignals[d]=-1;
     652             :     }
     653             :   }
     654           0 :   if(fDataSignals[beginTime+1]<1){
     655           0 :     fDataSignals[beginTime]=0;
     656           0 :   }
     657           0 : }
     658             : 
     659             : void AliHLTTPCPad::AddClusterCandidate(const AliHLTTPCClusters& candidate){
     660           0 :   fClusterCandidates.push_back(candidate);
     661           0 :   fUsedClusterCandidates.push_back(0);
     662           0 : }
     663             : 
     664             : void AliHLTTPCPad::AddCandidateDigits(const vector<AliHLTTPCDigitData>& candidateDigits){
     665           0 :   fCandidateDigitsVector.push_back(candidateDigits); 
     666           0 : }
     667             : 
     668             : vector<AliHLTTPCDigitData> *AliHLTTPCPad::GetCandidateDigits(Int_t candidateIndex){
     669           0 :   return (size_t(candidateIndex) < fCandidateDigitsVector.size()) ? &fCandidateDigitsVector.at(candidateIndex) :0;
     670             : }

Generated by: LCOV version 1.11