HWCF emulator update according to the new hardware clusterfinder
authorsgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 31 Aug 2011 15:51:13 +0000 (15:51 +0000)
committersgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 31 Aug 2011 15:51:13 +0000 (15:51 +0000)
14 files changed:
HLT/CMakelibAliHLTTPC.pkg
HLT/TPCLib/AliHLTTPCClusterMCData.h
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFDataTypes.h
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFDivisionUnit.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFEmulator.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFEmulator.h
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFEmulatorComponent.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFEmulatorComponent.h
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFExtractorUnit.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFExtractorUnit.h
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.cxx [new file with mode: 0644]
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.h [new file with mode: 0644]
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFProcessorUnit.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFProcessorUnit.h

index 19e3dcd..deca1b0 100644 (file)
@@ -133,6 +133,7 @@ set ( CLASS_HDRS
     AliHLTTPCdEdxComponent.h
     AliHLTTPCdEdxMonitoringComponent.h
     HWCFemulator/AliHLTTPCHWCFExtractorUnit.h
+    HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.h
     HWCFemulator/AliHLTTPCHWCFProcessorUnit.h
     HWCFemulator/AliHLTTPCHWCFMergerUnit.h
     HWCFemulator/AliHLTTPCHWCFDivisionUnit.h
index 72cfd15..e517c27 100644 (file)
  */
 struct AliHLTTPCClusterMCWeight
 {
+  //* constructor **/
+  AliHLTTPCClusterMCWeight(): fMCID(-1), fWeight(0)
+  {}
+
   AliHLTInt32_t  fMCID;     // MC track ID
   AliHLTFloat32_t fWeight; // weight of the track ID
 };  
index aa97dd5..ad094df 100644 (file)
@@ -26,11 +26,24 @@ struct AliHLTTPCHWCFDefinitions
 
 typedef struct AliHLTTPCHWCFDefinitions AliHLTTPCHWCFDefinitions;
 
+struct AliHLTTPCHWCFDigit
+{
+  //* constructor **/
+  AliHLTTPCHWCFDigit(): fQ(0), fTime(0), fPeak(0), fMC()
+  {}
+
+  AliHLTUInt32_t fQ;    // charge
+  AliHLTUInt32_t fTime; // timebin
+  AliHLTUInt32_t fPeak;  // peak flag: 0:flat, 1:peak, 2: local minimum
+  AliHLTTPCClusterMCLabel fMC; // mc label
+};
+typedef struct AliHLTTPCHWCFDigit AliHLTTPCHWCFDigit;
+
 struct AliHLTTPCHWCFBunch
 {
   //* constructor **/
   AliHLTTPCHWCFBunch(): fFlag(0), fRow(0), fPad(0), fBranch(0), fBorder(0),
-       fTime(0),fGain(0), fData(), fMC()
+                       fGain(0), fData()
   {}
 
   AliHLTUInt32_t fFlag; // 0 - Off, 1 - data, 2 - RCU trailer, 3 - end of data
@@ -38,11 +51,9 @@ struct AliHLTTPCHWCFBunch
   AliHLTUInt32_t fPad;  // pad number
   bool fBranch;         // 0  - pad belongs to branch A, 1 - pad belongs to branch B
   bool fBorder;         // is the pad at the border of its branch
-  AliHLTUInt32_t fTime; // time of the first signal
   AliHLTUInt64_t fGain; // gain correction factor 
                         //   (fixed point integer with kFixedPoint bits after the point)
-  std::vector<AliHLTUInt32_t> fData;      // signals
-  std::vector<AliHLTTPCClusterMCLabel> fMC; // mc labels
+  std::vector<AliHLTTPCHWCFDigit> fData;      // signals
 };
 typedef struct AliHLTTPCHWCFBunch AliHLTTPCHWCFBunch;
 
index 393cacb..399978d 100644 (file)
@@ -120,7 +120,7 @@ const AliHLTTPCHWCFCluster *AliHLTTPCHWCFDivisionUnit::OutputStream()
  
   // MC part
 
-  AliHLTTPCClusterMCWeight emptyWeight = {-1,0};
+  AliHLTTPCClusterMCWeight emptyWeight;
 
   fOutput.fMC.fClusterID[0] = emptyWeight;
   fOutput.fMC.fClusterID[1] = emptyWeight;
index d4a24b7..80faa79 100644 (file)
@@ -41,6 +41,7 @@ AliHLTTPCHWCFEmulator::AliHLTTPCHWCFEmulator()
   fDebug(0),
   fkMapping(0),
   fChannelExtractor(),
+  fPeakFinderUnit(),
   fChannelProcessor(),
   fChannelMerger(),
   fDivisionUnit()
@@ -58,6 +59,7 @@ AliHLTTPCHWCFEmulator::AliHLTTPCHWCFEmulator(const AliHLTTPCHWCFEmulator&)
   fDebug(0),
   fkMapping(0),
   fChannelExtractor(),
+  fPeakFinderUnit(),
   fChannelProcessor(),
   fChannelMerger(),
   fDivisionUnit()
@@ -76,16 +78,21 @@ void AliHLTTPCHWCFEmulator::Init( const AliHLTUInt32_t *mapping, AliHLTUInt32_t
   // Initialisation
   fkMapping = mapping;
   
+  fPeakFinderUnit.SetChargeFluctuation( (config2>>4) & 0xF );
+
+  fChannelProcessor.SetSingleSeqLimit( (config1) & 0xFF );
+  fChannelProcessor.SetDeconvolutionTime( (config1>>24) & 0x1 );
+  fChannelProcessor.SetUseTimeBinWindow( (config2>>4) & 0x1 );
+
   fChannelMerger.SetByPassMerger( (config1>>27) & 0x1 );
-  fDivisionUnit.SetSinglePadSuppression( (config1>>26) & 0x1 );
   fChannelMerger.SetDeconvolution( (config1>>25) & 0x1 );
-  fChannelProcessor.SetDeconvolution( (config1>>24) & 0x1 );
-  fDivisionUnit.SetClusterLowerLimit( (config1>>8) & 0xFFFF );
-  fChannelProcessor.SetSingleSeqLimit( (config1) & 0xFF );
   fChannelMerger.SetMatchDistance( (config2) & 0xF );
-  fChannelProcessor.SetTimeBinWindow( (config2>>4) & 0xFF );
-  fChannelProcessor.SetChargeFluctuation( (config2>>12) & 0xF );
 
+  fDivisionUnit.SetClusterLowerLimit( (config1>>8) & 0xFFFF );
+  fDivisionUnit.SetSinglePadSuppression( (config1>>26) & 0x1 );
+
+  fPeakFinderUnit.SetDebugLevel(fDebug);
   fChannelProcessor.SetDebugLevel(fDebug);
   fChannelMerger.SetDebugLevel(fDebug);
   fDivisionUnit.SetDebugLevel(fDebug);
@@ -112,8 +119,9 @@ int AliHLTTPCHWCFEmulator::FindClusters( const AliHLTUInt32_t *rawEvent,
   // Initialise 
 
   int ret = 0;
-
+  
   fChannelExtractor.Init( fkMapping, mcLabels, 3*rawEventSize32 );
+  fPeakFinderUnit.Init();
   fChannelProcessor.Init();
   fChannelMerger.Init();
   fDivisionUnit.Init();
@@ -122,7 +130,8 @@ int AliHLTTPCHWCFEmulator::FindClusters( const AliHLTUInt32_t *rawEvent,
   
   for( AliHLTUInt32_t  iWord=0; iWord<=rawEventSize32; iWord++ ){
 
-    const AliHLTTPCHWCFBunch *bunch=0;
+    const AliHLTTPCHWCFBunch *bunch1=0;
+    const AliHLTTPCHWCFBunch *bunch2=0;
     const AliHLTTPCHWCFClusterFragment *fragment=0;
     const AliHLTTPCHWCFClusterFragment *candidate=0;
     const AliHLTTPCHWCFCluster *cluster = 0;
@@ -130,37 +139,40 @@ int AliHLTTPCHWCFEmulator::FindClusters( const AliHLTUInt32_t *rawEvent,
     if( iWord<rawEventSize32 ) fChannelExtractor.InputStream(ReadBigEndian(rawEvent[iWord]));
     else fChannelExtractor.InputEndOfData();
 
-    while( (bunch = fChannelExtractor.OutputStream()) ){ 
-      fChannelProcessor.InputStream(bunch);
-      while( (fragment = fChannelProcessor.OutputStream() )){  
-       fChannelMerger.InputStream( fragment );
-       while( (candidate = fChannelMerger.OutputStream()) ){             
-         fDivisionUnit.InputStream(candidate);
-         while( (cluster = fDivisionUnit.OutputStream()) ){        
-           if( cluster->fFlag==1 ){
-             if( outputSize32+AliHLTTPCHWCFData::fgkAliHLTTPCHWClusterSize > maxOutputSize32 ){ // No space in the output buffer
-               ret = -2;
-               break;
-             }       
-             AliHLTUInt32_t *co = &output[outputSize32];
-             int i=0;
-             co[i++] = WriteBigEndian(cluster->fRowQ);
-             co[i++] = WriteBigEndian(cluster->fQ);
-             co[i++] = cluster->fP;
-             co[i++] = cluster->fT;
-             co[i++] = cluster->fP2;
-             co[i++] = cluster->fT2;
-             outputSize32+=AliHLTTPCHWCFData::fgkAliHLTTPCHWClusterSize;
-             if( mcLabels && outputMC && outputMC->fCount < maxNMCLabels){
-               outputMC->fLabels[outputMC->fCount++] = cluster->fMC;
+    while( (bunch1 = fChannelExtractor.OutputStream()) ){ 
+      fPeakFinderUnit.InputStream(bunch1);
+      while( (bunch2 = fPeakFinderUnit.OutputStream() )){      
+       fChannelProcessor.InputStream(bunch2);
+       while( (fragment = fChannelProcessor.OutputStream() )){ 
+         fChannelMerger.InputStream( fragment );
+         while( (candidate = fChannelMerger.OutputStream()) ){           
+           fDivisionUnit.InputStream(candidate);
+           while( (cluster = fDivisionUnit.OutputStream()) ){      
+             if( cluster->fFlag==1 ){
+               if( outputSize32+AliHLTTPCHWCFData::fgkAliHLTTPCHWClusterSize > maxOutputSize32 ){ // No space in the output buffer
+                 ret = -2;
+                 break;
+               }             
+               AliHLTUInt32_t *co = &output[outputSize32];
+               int i=0;
+               co[i++] = WriteBigEndian(cluster->fRowQ);
+               co[i++] = WriteBigEndian(cluster->fQ);
+               co[i++] = cluster->fP;
+               co[i++] = cluster->fT;
+               co[i++] = cluster->fP2;
+               co[i++] = cluster->fT2;
+               outputSize32+=AliHLTTPCHWCFData::fgkAliHLTTPCHWClusterSize;
+               if( mcLabels && outputMC && outputMC->fCount < maxNMCLabels){
+                 outputMC->fLabels[outputMC->fCount++] = cluster->fMC;
+               }
              }
-           }
-           else if( cluster->fFlag==2 ){
-             if( outputSize32+1 > maxOutputSize32 ){ // No space in the output buffer
-               ret = -2;
-               break;
+             else if( cluster->fFlag==2 ){
+               if( outputSize32+1 > maxOutputSize32 ){ // No space in the output buffer
+                 ret = -2;
+                 break;
+               }
+               output[outputSize32++] = cluster->fRowQ;
              }
-             output[outputSize32++] = cluster->fRowQ;
            }
          }
        }
@@ -198,7 +210,7 @@ void AliHLTTPCHWCFEmulator::CreateConfiguration
  bool doDeconvTime, bool doDeconvPad, bool doFlowControl, 
  bool doSinglePadSuppression, bool bypassMerger, 
  AliHLTUInt32_t clusterLowerLimit, AliHLTUInt32_t singleSeqLimit, 
- AliHLTUInt32_t mergerDistance, AliHLTUInt32_t timeBinWindow, AliHLTUInt32_t chargeFluctuation,
+ AliHLTUInt32_t mergerDistance, bool useTimeBinWindow, AliHLTUInt32_t chargeFluctuation,
  AliHLTUInt32_t &configWord1, AliHLTUInt32_t &configWord2 
  )
 {
@@ -216,6 +228,6 @@ void AliHLTTPCHWCFEmulator::CreateConfiguration
   configWord1 |= ( (AliHLTUInt32_t)singleSeqLimit & 0xFF );
 
   configWord2 |= ( (AliHLTUInt32_t)mergerDistance & 0xF );
-  configWord2 |= ( (AliHLTUInt32_t)timeBinWindow  & 0xFF )<<4;
-  configWord2 |= ( (AliHLTUInt32_t)chargeFluctuation  & 0xF )<<12;
+  configWord2 |= ( (AliHLTUInt32_t)chargeFluctuation  & 0xF )<<4;
+  configWord2 |= ( (AliHLTUInt32_t)useTimeBinWindow  & 0x1 )<<8;
 }
index 65faf58..6dfe4c0 100644 (file)
@@ -8,6 +8,7 @@
 //* See cxx source for full Copyright notice                               *
 
 #include "AliHLTTPCHWCFExtractorUnit.h"
+#include "AliHLTTPCHWCFPeakFinderUnit.h"
 #include "AliHLTTPCHWCFProcessorUnit.h"
 #include "AliHLTTPCHWCFMergerUnit.h"
 #include "AliHLTTPCHWCFDivisionUnit.h"
@@ -65,13 +66,13 @@ class AliHLTTPCHWCFEmulator
     ( bool doDeconvTime, bool doDeconvPad, bool doFlowControl,  
       bool doSinglePadSuppression, bool bypassMerger, 
       AliHLTUInt32_t clusterLowerLimit,AliHLTUInt32_t singleSeqLimit, 
-      AliHLTUInt32_t mergerDistance, AliHLTUInt32_t timeBinWindow, AliHLTUInt32_t chargeFluctuation,
+      AliHLTUInt32_t mergerDistance, bool useTimeBinWindow, AliHLTUInt32_t chargeFluctuation,
       AliHLTUInt32_t &configWord1, AliHLTUInt32_t &configWord2  );
  
   /** create default configuration word 
    **/
   static void CreateDefaultConfiguration( AliHLTUInt32_t &configWord1, AliHLTUInt32_t &configWord2 ){
-    CreateConfiguration(0,0,0,1,0,0,0, 3, 5, 0, configWord1, configWord2 );
+    CreateConfiguration(0,0,0,1,0,0,0, 3, 1, 0, configWord1, configWord2 );
   }
   
  private: 
@@ -84,6 +85,7 @@ class AliHLTTPCHWCFEmulator
   int  fDebug; // debug level
   const AliHLTUInt32_t *fkMapping; //! mapping array
   AliHLTTPCHWCFExtractorUnit fChannelExtractor; //! transient
+  AliHLTTPCHWCFPeakFinderUnit fPeakFinderUnit; //! transient
   AliHLTTPCHWCFProcessorUnit fChannelProcessor; //! transient
   AliHLTTPCHWCFMergerUnit    fChannelMerger; //! transient
   AliHLTTPCHWCFDivisionUnit  fDivisionUnit;   //! transient
index 6b3b998..f5fb854 100644 (file)
@@ -62,7 +62,7 @@ AliHLTTPCHWCFEmulatorComponent::AliHLTTPCHWCFEmulatorComponent()
   fClusterLowerLimit(0),
   fSingleSeqLimit(0),
   fMergerDistance(3),
-  fTimeBinWindow(5),
+  fUseTimeBinWindow(1),
   fChargeFluctuation(0),
   fDebug(0),
   fCFSupport(),
@@ -89,7 +89,7 @@ AliHLTTPCHWCFEmulatorComponent::AliHLTTPCHWCFEmulatorComponent(const AliHLTTPCHW
   fClusterLowerLimit(0),
   fSingleSeqLimit(0),
   fMergerDistance(3),
-  fTimeBinWindow(5),
+  fUseTimeBinWindow(1),
   fChargeFluctuation(0),
   fDebug(0),
   fCFSupport(),
@@ -215,7 +215,7 @@ void AliHLTTPCHWCFEmulatorComponent::SetDefaultConfiguration()
   fClusterLowerLimit = 0;
   fSingleSeqLimit = 0;
   fMergerDistance = 3;
-  fTimeBinWindow = 5;
+  fUseTimeBinWindow = 1;
   fChargeFluctuation = 0;
   fDebug = 0;
   fBenchmark.Reset();
@@ -314,10 +314,10 @@ int AliHLTTPCHWCFEmulatorComponent::ReadConfigurationString(  const char* argume
       continue;
     }
  
-    if ( argument.CompareTo( "-timebin-window" ) == 0 ) {
+    if ( argument.CompareTo( "-use-timebin-window" ) == 0 ) {
       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
-      fTimeBinWindow  = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
-      HLTInfo( "TimeBin window is set to: %d", fTimeBinWindow );
+      fUseTimeBinWindow  = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
+      HLTInfo( "Using TimeBin window is set to: %d", fUseTimeBinWindow );
       continue;
     }
    
@@ -444,7 +444,7 @@ int AliHLTTPCHWCFEmulatorComponent::DoEvent( const AliHLTComponentEventData& evt
 
   AliHLTUInt32_t configWord1=0, configWord2=0; 
   AliHLTTPCHWCFEmulator::CreateConfiguration
-    ( fDoDeconvTime, fDoDeconvPad, fDoFlowControl, fDoSinglePadSuppression, fBypassMerger, fClusterLowerLimit, fSingleSeqLimit, fMergerDistance, fTimeBinWindow, fChargeFluctuation, configWord1, configWord2 );
+    ( fDoDeconvTime, fDoDeconvPad, fDoFlowControl, fDoSinglePadSuppression, fBypassMerger, fClusterLowerLimit, fSingleSeqLimit, fMergerDistance, fUseTimeBinWindow, fChargeFluctuation, configWord1, configWord2 );
 
   for ( unsigned long ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
index 4ba4a8b..2b1fcde 100644 (file)
@@ -148,7 +148,7 @@ class AliHLTTPCHWCFEmulatorComponent : public AliHLTProcessor
   AliHLTUInt32_t fClusterLowerLimit; // cut clusters at this charge value
   AliHLTUInt32_t fSingleSeqLimit;    // cut sequences at this charge value
   AliHLTUInt32_t fMergerDistance; // max. distance in mean time between two pads to be merged
-  AliHLTUInt32_t fTimeBinWindow; // timebin window
+  bool           fUseTimeBinWindow; // use timebin window
   AliHLTUInt32_t fChargeFluctuation; // allowed charge fluctuation for peak finding 
   Int_t fDebug; // debug level
   AliHLTTPCHWCFSupport fCFSupport;     // !transient
index 08c40f2..147cb4f 100644 (file)
@@ -26,6 +26,7 @@
 //  @note 
 
 #include "AliHLTTPCHWCFExtractorUnit.h"
+#include <iostream>
 
 AliHLTTPCHWCFExtractorUnit::AliHLTTPCHWCFExtractorUnit()
   :
@@ -37,6 +38,7 @@ AliHLTTPCHWCFExtractorUnit::AliHLTTPCHWCFExtractorUnit()
   fPendingOutput(0),
   fChannelNumWordsLeft(0),
   fBunchNumWordsLeft(0),  
+  fBunchCurrentTime(-2),
   fkMCLabels(0),
   fNMCLabels(0),
   fCurrentMCLabel(0)
@@ -61,6 +63,7 @@ AliHLTTPCHWCFExtractorUnit::AliHLTTPCHWCFExtractorUnit(const AliHLTTPCHWCFExtrac
   fPendingOutput(0),
   fChannelNumWordsLeft(0),
   fBunchNumWordsLeft(0),  
+  fBunchCurrentTime(-2),
   fkMCLabels(0),
   fNMCLabels(0),
   fCurrentMCLabel(0)
@@ -83,12 +86,12 @@ int AliHLTTPCHWCFExtractorUnit::Init( const AliHLTUInt32_t *mapping, const AliHL
   fInputStatus = kEmpty;
   fkMapping = mapping;
   fBunch->fFlag = 0; // wait for the next channel
-  fBunch->fData.clear();
-  fBunch->fMC.clear();
+  fBunch->fData.clear();  
   fPendingOutput = 0;  
   fkMCLabels = mcLabels;
   fNMCLabels = nMCLables;
   fCurrentMCLabel = 0;
+  fBunchCurrentTime = -2;
   if( !fkMapping ) return  -1;
   return 0;
 }
@@ -138,8 +141,7 @@ const AliHLTTPCHWCFBunch *AliHLTTPCHWCFExtractorUnit::OutputStream()
       fBunch = newBunch;
       fPendingOutput = 1;
     }
-    fBunch->fData.clear();
-    fBunch->fMC.clear();
+    fBunch->fData.clear();    
     fBunch->fFlag = 3; // end of data
     fStatus = kStop;    
     return oldBunch;   
@@ -154,10 +156,11 @@ const AliHLTTPCHWCFBunch *AliHLTTPCHWCFExtractorUnit::OutputStream()
       fBunch = newBunch;
       fPendingOutput = 1;
     }
-    fBunch->fData.clear();
-    fBunch->fMC.clear();
+    fBunch->fData.clear();    
     fBunch->fFlag = 2; // rcu
-    fBunch->fData.push_back(fInput);
+    AliHLTTPCHWCFDigit d;
+    d.fQ = fInput;     
+    fBunch->fData.push_back(d);
     fStatus = ( flag == 0x2 ) ?kReadingRCU :kFinishing;
     return oldBunch;   
   }
@@ -184,12 +187,11 @@ const AliHLTTPCHWCFBunch *AliHLTTPCHWCFExtractorUnit::OutputStream()
       if( !( (configWord>>15) & 0x1 ) ) fBunch->fFlag = 0;// channel not active
       fBunch->fGain = (configWord>>16 ) & 0x1FFF;
     }
-    fBunch->fData.clear();
-    fBunch->fMC.clear();
-    fBunch->fTime = 0xFFFFFFFF;
+    fBunch->fData.clear(); 
     fChannelNumWordsLeft= (fInput >> 16) & 0x3FF; // payload size in 10-bit words
     fBunchNumWordsLeft = 0;
-   
+    fBunchCurrentTime = -2;
+
     if( (fInput >> 29) & 0x1 ) fBunch->fFlag = 0; // there were readout errors
 
     //cout<<"Extractor: Header of new channel F "<<fBunch->fFlag
@@ -217,21 +219,27 @@ const AliHLTTPCHWCFBunch *AliHLTTPCHWCFExtractorUnit::OutputStream()
          fBunch->fBranch = oldBunch->fBranch;
          fBunch->fBorder = oldBunch->fBorder;
          fBunch->fGain = oldBunch->fGain;
-         fBunch->fData.clear();
-         fBunch->fMC.clear();    
-         fBunch->fTime = 0xFFFFFFFF;
+         fBunch->fData.clear();          
          fBunchNumWordsLeft = word10;
+         fBunchCurrentTime = -2;
        }
-      } else { // continue the brunch
-       if( fBunch->fTime > AliHLTTPCHWCFDefinitions::kMaxNTimeBins ){ // time has not been read so far
-         fBunch->fTime = word10;
+      } else { // continue the bunch
+       if( fBunchCurrentTime <-1 ){ // time has not been read so far
+         fBunchCurrentTime = word10;
          //cout<<"Extractor: Bunch time: "<<fBunch->fTime<<endl;
        } else { // read the signal
-         fBunch->fData.push_back(word10);
-         if( fkMCLabels && fCurrentMCLabel<=fNMCLabels ){
-           fBunch->fMC.push_back( fkMCLabels[fCurrentMCLabel] );
+         AliHLTTPCHWCFDigit d;
+         d.fQ = word10;
+         d.fPeak = 0;
+         if( fkMCLabels && fCurrentMCLabel<fNMCLabels ){
+           d.fMC = fkMCLabels[fCurrentMCLabel];
            fCurrentMCLabel++;
          }
+         if( fBunchCurrentTime >= 0 ){
+           d.fTime = (AliHLTUInt32_t) fBunchCurrentTime;
+           fBunch->fData.push_back(d);
+           fBunchCurrentTime--;
+         }
          //cout<<"Extractor: Bunch signal["<<fBunch->fNSignals<<"]: "<<word10<<endl;
        }
       }
index 49f28e6..f1c5f5c 100644 (file)
@@ -59,6 +59,7 @@ class AliHLTTPCHWCFExtractorUnit
 
   AliHLTInt32_t fChannelNumWordsLeft; // n 10-bit words left in the channel
   AliHLTInt32_t fBunchNumWordsLeft;// n 10-bit words left in the bunch
+  AliHLTInt32_t fBunchCurrentTime; // timebin of the curent signal
 
   const AliHLTTPCClusterMCLabel *fkMCLabels; // pointer to mc labels
   AliHLTUInt32_t fNMCLabels;                 // N mc labels
diff --git a/HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.cxx b/HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.cxx
new file mode 100644 (file)
index 0000000..899047a
--- /dev/null
@@ -0,0 +1,138 @@
+// $Id: AliHLTTPCHWCFPeakFinderUnit.cxx 51236 2011-08-22 16:01:48Z sgorbuno $
+//****************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project          * 
+//* ALICE Experiment at CERN, All rights reserved.                           *
+//*                                                                          *
+//* Primary Authors: Sergey Gorbunov, Torsten Alt                            *
+//* Developers:      Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de> *
+//*                  Torsten Alt <talt@cern.ch>                              *
+//*                  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   AliHLTTPCHWCFPeakFinderUnit.cxx
+//  @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
+//  @author Torsten Alt <talt@cern.ch> 
+//  @date   
+//  @brief  Channel Processor unit of FPGA ClusterFinder Emulator for TPC
+//  @brief  ( see AliHLTTPCHWCFEmulator class )
+//  @note 
+
+#include "AliHLTTPCHWCFPeakFinderUnit.h"
+#include <iostream>
+#include <cstdio>
+
+
+AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit()
+  :
+  fOutput(),
+  fkBunch(0),
+  fChargeFluctuation(0),
+  fDebug(0)
+{
+  //constructor 
+  Init();
+}
+
+
+AliHLTTPCHWCFPeakFinderUnit::~AliHLTTPCHWCFPeakFinderUnit()
+{   
+  //destructor 
+}
+
+AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit(const AliHLTTPCHWCFPeakFinderUnit&)
+  :
+  fOutput(),
+  fkBunch(0),
+  fChargeFluctuation(0),
+  fDebug(0)
+{
+  // dummy
+  Init();
+}
+
+AliHLTTPCHWCFPeakFinderUnit& AliHLTTPCHWCFPeakFinderUnit::operator=(const AliHLTTPCHWCFPeakFinderUnit&)
+{
+  // dummy  
+  return *this;
+}
+
+int AliHLTTPCHWCFPeakFinderUnit::Init()
+{
+  // initialise  
+
+  fkBunch = 0;
+  return 0;
+}
+
+int AliHLTTPCHWCFPeakFinderUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
+{
+  // input stream of data 
+  
+  if( bunch && fDebug ){
+    printf("\nHWCF Processor: input bunch F %1d R %3d P %3d  NS %2ld:\n",
+          bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fData.size());
+    for( unsigned int i=0; i<bunch->fData.size(); i++ ){
+      const AliHLTTPCHWCFDigit &d = bunch->fData[i];
+      printf("   q %2d t %3d ", d.fQ, d.fTime);
+      printf("(");
+      for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",d.fMC.fClusterID[j].fMCID, d.fMC.fClusterID[j].fWeight );
+      printf(" )\n");      
+    }
+  }
+
+  fkBunch = bunch;
+  return 0;
+}
+
+const AliHLTTPCHWCFBunch *AliHLTTPCHWCFPeakFinderUnit::OutputStream()
+{ 
+  // output stream of data 
+
+  if( !fkBunch ) return 0;
+
+  fOutput.fFlag = fkBunch->fFlag;
+  fOutput.fRow = fkBunch->fRow;
+  fOutput.fPad = fkBunch->fPad;
+  fOutput.fBranch = fkBunch->fBranch;
+  fOutput.fBorder = fkBunch->fBorder;
+  fOutput.fGain = fkBunch->fGain;
+  fOutput.fData.clear();
+  fOutput.fData.insert(fOutput.fData.end(),fkBunch->fData.begin(), fkBunch->fData.end());
+  fkBunch = 0;
+
+  if( fOutput.fFlag !=1 ){ // rcu trailer word, forward it 
+    return &fOutput;
+  }
+
+  bool slope = 0;
+  AliHLTUInt32_t qLast = 0;
+  AliHLTUInt32_t n = fOutput.fData.size();
+  
+  for( AliHLTUInt32_t i=0; i<n; i++ ){
+    AliHLTUInt32_t q = fOutput.fData[i].fQ;
+    if( !slope && q + fChargeFluctuation < qLast   ){ // peak
+      slope = 1;
+      if( i>0 ) fOutput.fData[i-1].fPeak = 1;
+    }
+    if( slope && q > qLast + fChargeFluctuation ){ // minimum
+      slope = 0;
+      if( i>0 ) fOutput.fData[i-1].fPeak = 2;
+    }
+    qLast = q;
+  }
+  
+  if( n>0 ){
+    if( !slope ) fOutput.fData[n-1].fPeak = 1;
+    else fOutput.fData[n-1].fPeak = 2;
+  }
+  
+  return &fOutput;
+}
diff --git a/HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.h b/HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.h
new file mode 100644 (file)
index 0000000..7b1f571
--- /dev/null
@@ -0,0 +1,65 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTTPCHWCFProcessorUnit.h 51142 2011-08-18 13:43:40Z sgorbuno $
+#ifndef ALIHLTTPCHWCFPEAKFINDERUNIT_H
+#define ALIHLTTPCHWCFPEAKFINDERUNIT_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                               *
+
+
+#include "AliHLTDataTypes.h"
+#include "AliHLTTPCHWCFDataTypes.h"
+
+
+//  @class AliHLTTPCHWCFPeakFinderUnit
+//  @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
+//  @author Torsten Alt <talt@cern.ch> 
+//  @brief  Channel Processor unit of FPGA ClusterFinder Emulator for TPC
+//  @brief  ( see AliHLTTPCHWCFEmulator class )
+//  @note
+//
+class AliHLTTPCHWCFPeakFinderUnit
+{
+ public:
+
+  /** standard constructor */
+  AliHLTTPCHWCFPeakFinderUnit();
+  
+  /** destructor */
+  ~AliHLTTPCHWCFPeakFinderUnit();
+
+  /** set debug level */
+  void SetDebugLevel( int val ){ fDebug = val; }
+
+  /** set allowed charge fluctuation for peak finding
+   */
+  void SetChargeFluctuation( AliHLTUInt32_t val ){ 
+    fChargeFluctuation = val;
+  }
+
+
+  /** initialise */
+  int Init();
+  
+  /** input stream of data */
+  int InputStream( const AliHLTTPCHWCFBunch *bunch );
+
+  /** output stream of data */
+  const AliHLTTPCHWCFBunch *OutputStream();
+  
+ private: 
+
+  /** copy constructor prohibited */
+  AliHLTTPCHWCFPeakFinderUnit(const AliHLTTPCHWCFPeakFinderUnit&);
+  /** assignment operator prohibited */
+  AliHLTTPCHWCFPeakFinderUnit& operator=(const AliHLTTPCHWCFPeakFinderUnit&);  
+  
+
+  AliHLTTPCHWCFBunch fOutput; // current output
+  const AliHLTTPCHWCFBunch *fkBunch; // current input
+  AliHLTUInt32_t fChargeFluctuation; // allowed charge fluctuation for peak finding 
+  int fDebug; // debug level
+};
+
+#endif
index 2d577c1..e0d9a03 100644 (file)
@@ -37,8 +37,7 @@ AliHLTTPCHWCFProcessorUnit::AliHLTTPCHWCFProcessorUnit()
   fBunchIndex(0),
   fDeconvolute(0),
   fSingleSeqLimit(0),
-  fHalfTimeBinWindow(2),
-  fChargeFluctuation(0),
+  fUseTimeBinWindow(1),
   fDebug(0)
 {
   //constructor 
@@ -58,8 +57,7 @@ AliHLTTPCHWCFProcessorUnit::AliHLTTPCHWCFProcessorUnit(const AliHLTTPCHWCFProces
   fBunchIndex(0),
   fDeconvolute(0),
   fSingleSeqLimit(0),
-  fHalfTimeBinWindow(2),
-  fChargeFluctuation(0),
+  fUseTimeBinWindow(1),
   fDebug(0)
 {
   // dummy
@@ -77,6 +75,7 @@ int AliHLTTPCHWCFProcessorUnit::Init()
   // initialise  
 
   fkBunch = 0;
+  fBunchIndex = 0;
   return 0;
 }
 
@@ -85,15 +84,14 @@ int AliHLTTPCHWCFProcessorUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
   // input stream of data 
   
   if( bunch && fDebug ){
-    printf("\nHWCF Processor: input bunch F %1d R %3d P %3d T %3d NS %2ld:\n",
-          bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fTime, bunch->fData.size());
+    printf("\nHWCF Processor: input bunch F %1d R %3d P %3d  NS %2ld:\n",
+          bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fData.size());
     for( unsigned int i=0; i<bunch->fData.size(); i++ ){
-      printf("   %2d ", bunch->fData[i]);
-      if( i < bunch->fMC.size() ){
-       printf("(");
-       for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",bunch->fMC[i].fClusterID[j].fMCID, bunch->fMC[i].fClusterID[j].fWeight );
-       printf(" )\n");
-      }
+      AliHLTTPCHWCFDigit d =  bunch->fData[i];
+      printf("   q %2d t %3d ", d.fQ, d.fTime);      
+       printf("(");
+      for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",d.fMC.fClusterID[j].fMCID, d.fMC.fClusterID[j].fWeight );
+      printf(" )\n");    
     }
   }
 
@@ -106,6 +104,9 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
 { 
   // output stream of data 
 
+  //const AliHLTUInt32_t kTimeBinWindow = 5;
+  const AliHLTUInt32_t kHalfTimeBinWindow = 2;
   if( !fkBunch ) return 0;
   
   fOutput.fFlag = fkBunch->fFlag;
@@ -119,111 +120,85 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
   fOutput.fT2 = 0;
   fOutput.fP = 0;
   fOutput.fP2 = 0;
-  fOutput.fTMean =  fkBunch->fTime;  
+  fOutput.fTMean = 0;
   fOutput.fMC.clear();
   
   if( fkBunch->fFlag==2 && fkBunch->fData.size()==1 ){ // rcu trailer word, forward it 
-    fOutput.fRow = fkBunch->fData[0];
-  }    
+    fOutput.fRow = fkBunch->fData[0].fQ;
+  }
   
   if( fkBunch->fFlag >1 ){
-    fkBunch = 0;
-    fBunchIndex = 0;
+    fkBunch = 0;    
     return &fOutput;
   }
 
   if( fkBunch->fFlag < 1 ) return 0;
+  
+  while( fBunchIndex<fkBunch->fData.size() ){
 
-  if( fBunchIndex >= fkBunch->fData.size() || fkBunch->fTime < fBunchIndex ) return 0;  
-
-  AliHLTUInt32_t qMax = 0;  
-  AliHLTInt32_t iQMax = fBunchIndex;
-  AliHLTInt32_t clusterEnd = fBunchIndex+1;
-
-  {
-    AliHLTUInt32_t i=fBunchIndex;
+    AliHLTUInt32_t iStart = fBunchIndex;
+    AliHLTUInt32_t iPeak = fBunchIndex;
+    AliHLTUInt32_t qPeak = 0;
 
-    // find a maximum
+    // find next/best peak
     
-    for( ; i<fkBunch->fData.size(); i++ ){
-      AliHLTUInt32_t q = fkBunch->fData[i];
-      if( q>qMax ){
-       qMax = q;
-       iQMax = i;
-      } else {
-       if( fDeconvolute && q + fChargeFluctuation < qMax ) break;      
+    for( ; fBunchIndex<fkBunch->fData.size(); fBunchIndex++ ){
+      const AliHLTTPCHWCFDigit &d = fkBunch->fData[fBunchIndex];            
+      if( d.fPeak != 1 ) continue;
+      if( fDeconvolute ){
+       iPeak = fBunchIndex;
+       fBunchIndex++;
+       break;
+      } else { 
+       if( d.fQ>qPeak ){
+         qPeak = d.fQ;
+         iPeak = fBunchIndex;
+       }
       }
     }
   
-    // find last minimum and the end of the cluster
-  
-    AliHLTUInt32_t iQMin = i;
-    if( i<fkBunch->fData.size() ){
-      AliHLTUInt32_t qMin = fkBunch->fData[i];  
-
-      for(; i<fkBunch->fData.size(); i++ ){
-       AliHLTUInt32_t q = fkBunch->fData[i];
-       if( q <= qMin ){
-         qMin = q;
-         iQMin = i;
-       } else {
-         if( q > qMin + fChargeFluctuation ){
-           break;
-         }
+    // find next minimum
+
+    for( ; fBunchIndex<fkBunch->fData.size(); fBunchIndex++ ){
+      if( fDeconvolute ){
+       if( fkBunch->fData[fBunchIndex].fPeak != 0 ){
+         fBunchIndex++;
+         break;
        }
       }
     }
+
+    AliHLTUInt32_t iEnd = fBunchIndex;
     
-    clusterEnd = iQMin+1;
-    if( i>= fkBunch->fData.size() ) clusterEnd = fkBunch->fData.size();
-    
-    // find the center of the peak
-    AliHLTUInt32_t iMaxFirst = iQMax, iMaxLast = iQMax;
-    
-    for( i=fBunchIndex; i<iQMax; i++ ){
-      AliHLTUInt32_t q = fkBunch->fData[i];
-      if( q + fChargeFluctuation >= qMax ){
-       iMaxFirst = i;
-       break;
-      }
+    if( fUseTimeBinWindow ){
+      if( iPeak > iStart + kHalfTimeBinWindow ) iStart = iPeak - kHalfTimeBinWindow;
+      if( iEnd  > iPeak + kHalfTimeBinWindow ) iEnd = iPeak + kHalfTimeBinWindow;
     }
-    
-    for( i=clusterEnd-1; i>iQMax; i-- ){
-      AliHLTUInt32_t q = fkBunch->fData[i];
-      if( q + fChargeFluctuation >= qMax ){
-       iMaxLast = i;     
-       break;
-      }
+
+    fOutput.fQmax = 0;
+    fOutput.fQ = 0;
+    fOutput.fT = 0;
+    fOutput.fT2 = 0;
+    fOutput.fP = 0;
+    fOutput.fP2 = 0;
+    fOutput.fTMean = fkBunch->fData[iPeak].fTime;
+    fOutput.fMC.clear();
+
+    for( AliHLTUInt32_t i=iStart; i<iEnd; i++ ){
+      const AliHLTTPCHWCFDigit &d = fkBunch->fData[i];
+      AliHLTUInt64_t q = d.fQ*fkBunch->fGain;
+      if (fOutput.fQmax < q) fOutput.fQmax = q;
+      fOutput.fQ += q;
+      fOutput.fT += q*d.fTime;
+      fOutput.fT2+= q*d.fTime*d.fTime;
+      fOutput.fP += q*fkBunch->fPad;
+      fOutput.fP2+= q*fkBunch->fPad*fkBunch->fPad;
+      fOutput.fMC.push_back(d.fMC);
     }
     
-    iQMax = ( iMaxFirst + iMaxLast )/ 2;
-  }
+    if( fkBunch->fData.size()==1 && fOutput.fQ < fSingleSeqLimit ) continue;  
   
-  AliHLTUInt32_t clusterStart = fBunchIndex;
-  if( (int)clusterStart < iQMax - fHalfTimeBinWindow ) clusterStart = iQMax - fHalfTimeBinWindow ;
-  if( clusterEnd > iQMax + fHalfTimeBinWindow +1 ) clusterEnd = iQMax + fHalfTimeBinWindow +1;  
-
-  fBunchIndex = clusterStart;  
-  AliHLTInt32_t bunchTime = fkBunch->fTime - clusterStart;
-
-  for( ; fBunchIndex < clusterEnd && bunchTime>=0; fBunchIndex++, bunchTime-- ){
-    AliHLTUInt64_t q = fkBunch->fData[fBunchIndex]*fkBunch->fGain;
-    if (fOutput.fQmax < q) fOutput.fQmax = q;
-    fOutput.fQ += q;
-    fOutput.fT += q*bunchTime;
-    fOutput.fT2+= q*bunchTime*bunchTime;
-    fOutput.fP += q*fkBunch->fPad;
-    fOutput.fP2+= q*fkBunch->fPad*fkBunch->fPad;
-    if( fBunchIndex<fkBunch->fMC.size() ){
-      fOutput.fMC.push_back(fkBunch->fMC[fBunchIndex]);
-    }
-  }  
-
-  fOutput.fTMean = (AliHLTUInt64_t)( fkBunch->fTime - iQMax );
-
-  AliHLTInt32_t length = clusterEnd - clusterStart;
-
-  if( length<=1 && fOutput.fQ < fSingleSeqLimit ) return 0;  
-
-  return &fOutput;
+    return &fOutput;
+  }
+  return 0;
 }
index 60f4711..bbe4f8c 100644 (file)
@@ -33,7 +33,7 @@ class AliHLTTPCHWCFProcessorUnit
   void SetDebugLevel( int val ){ fDebug = val; }
 
   /** do cluster deconvolution in time direction */
-  void SetDeconvolution( bool val ){ fDeconvolute = val; }
+  void SetDeconvolutionTime( bool val ){ fDeconvolute = val; }
 
   /** lower charge limit for isolated signals
    */
@@ -41,19 +41,12 @@ class AliHLTTPCHWCFProcessorUnit
     fSingleSeqLimit = val << AliHLTTPCHWCFDefinitions::kFixedPoint; 
   }
 
-  /** max. size of the cluster in time bins
+  /** limit size of the cluster in time bins to 5
    */
-  void SetTimeBinWindow( AliHLTUInt32_t val ){ 
-    fHalfTimeBinWindow = val/2;
+  void SetUseTimeBinWindow( bool val ){ 
+    fUseTimeBinWindow = val;
   }
 
-  /** set allowed charge fluctuation for peak finding
-   */
-  void SetChargeFluctuation( AliHLTUInt32_t val ){ 
-    fChargeFluctuation = val;
-  }
-
-
   /** initialise */
   int Init();
   
@@ -76,8 +69,7 @@ class AliHLTTPCHWCFProcessorUnit
   AliHLTUInt32_t fBunchIndex; // index in bunch
   bool fDeconvolute;    // do deconvolution in time direction
   AliHLTUInt64_t fSingleSeqLimit; // lower charge limit for isolated signals
-  AliHLTInt32_t fHalfTimeBinWindow; // 1/2 of max. size of the cluster in time bins 
-  AliHLTInt32_t fChargeFluctuation; // allowed charge fluctuation for peak finding 
+  bool fUseTimeBinWindow; // set max. size of the cluster to 5 time bins 
   int fDebug; // debug level
 };