HWCFEmulator update
authorsgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Sep 2011 21:13:42 +0000 (21:13 +0000)
committersgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Sep 2011 21:13:42 +0000 (21:13 +0000)
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFConsistencyControlComponent.cxx
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/AliHLTTPCHWCFMergerUnit.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFPeakFinderUnit.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFProcessorUnit.cxx
HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFSupport.cxx

index fc4a1ce..2049d74 100644 (file)
@@ -151,10 +151,10 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoInit( int argc, const char** arg
 
   fHistHeaderAll = new TH1F("hHWCFHeaderAll", "fHistHeaderAll",6,0.,6.);
   fHistHeaderGood = new TH1F("hHWCFHeaderGood", "fHistHeaderGood",6,0.,6.);
-  fHistClusterAll = new TH1F("hHWCFClusterAll", "fHistClusterAll",7,0.,7.);
-  fHistClusterGood = new TH1F("hHWCFClusterGood", "fHistClusterGood",7,0.,7.);
+  fHistClusterAll = new TH1F("hHWCFClusterAll", "fHistClusterAll",8,0.,8.);
+  fHistClusterGood = new TH1F("hHWCFClusterGood", "fHistClusterGood",8,0.,8.);
   fProfHeader = new TH1F("pHWCFHeader", "HWCF: Consistency of header data", 6, 0., 6.);
-  fProfCluster = new TH1F("pHWCFClusters", "HWCF: Consisteny of cluster data", 7, 0., 7.);
+  fProfCluster = new TH1F("pHWCFClusters", "HWCF: Consisteny of cluster data", 8, 0., 8.);
 
   TString arguments = "";
   for ( int i = 0; i < argc; i++ ) {
@@ -346,12 +346,12 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
   for( unsigned long i=0; i<evtData.fBlockCnt; i++ ) checkedBlocks[i] = 0;
   
   for ( unsigned long ndx1 = 0; ndx1 < evtData.fBlockCnt; ndx1++ ){
-    
     const AliHLTComponentBlockData* iter1 = blocks+ndx1;
     fBenchmark.AddInput(iter1->fSize);
     
     if (  iter1->fDataType != (AliHLTTPCDefinitions::fgkHWClustersDataType | kAliHLTDataOriginTPC) 
          ) continue;
     if( checkedBlocks[ndx1] ) continue;// block already checked
 
     checkedBlocks[ndx1] = 1;
@@ -374,6 +374,7 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
     bool sameSize = 1;
    
     bool sameFlag = 1;
+    bool sameQMax = 1;
     bool sameCharge = 1;
     bool sameRow = 1;
     bool sameFloat[4] = {1,1,1,1};
@@ -423,20 +424,14 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
       
       int startRCU1 = nWordsHeader;
       int startRCU2 = nWordsHeader;
-      
-      for( AliHLTInt32_t i=nWordsHeader; i<nWords1; i+=5 ){
-       if( p1[i]>>30 == 0x2 ){
-         startRCU1 = i; 
-         break;
-       }
+
+      for( ; startRCU1<nWords1; startRCU1+=6 ){
+       if( p1[startRCU1]>>30 == 0x2 ) break;     
       }
-      
-      for( AliHLTInt32_t i=nWordsHeader; i<nWords2; i+=5 ){
-       if( p2[i]>>30 == 0x2 ){
-         startRCU2 = i; 
-         break;
-       }
-      }     
+
+      for( ; startRCU2<nWords2; startRCU2+=6 ){
+       if( p2[startRCU2]>>30 == 0x2 ) break;     
+      } 
       
 
       // compare RCU headers
@@ -458,19 +453,21 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
       if( sameSize ) fHistHeaderGood->Fill(5);
 
       // compare clusters
-                       
+
       if( startRCU1 == startRCU2 ){
-       for( AliHLTInt32_t i=nWordsHeader; i<startRCU1; i+=5){
+       for( AliHLTInt32_t i=nWordsHeader; i<startRCU1; i+=6){
          AliHLTUInt32_t header1 = p1[i];
+         AliHLTUInt32_t charge1 = p1[i+1];
          AliHLTUInt32_t header2 = p2[i];
+         AliHLTUInt32_t charge2 = p2[i+1];
 
 
          AliHLTUInt32_t flag1 = header1 >> 30;
-         AliHLTUInt32_t charge1 = ( header1 & 0xFFFFFF ) >> 6;
-         AliHLTUInt32_t row1 = header1 & 0x3f;
+         AliHLTUInt32_t qmax1 = ( header1 & 0xFFFFFF ) >> 6;
+         AliHLTUInt32_t row1 = (header1>>24) & 0x3f;
          AliHLTUInt32_t flag2 = header2 >> 30;
-         AliHLTUInt32_t charge2 = ( header2 & 0xFFFFFF ) >> 6;
-         AliHLTUInt32_t row2 = header2 & 0x3f;
+         AliHLTUInt32_t qmax2 = ( header2 & 0xFFFFFF ) >> 6;
+         AliHLTUInt32_t row2 = (header2>>24) & 0x3f;
          
          fHistClusterAll->Fill(0);
          if( flag1 == flag2 ) fHistClusterGood->Fill(0);
@@ -478,11 +475,11 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
          
          if( flag1!=0x3 || flag2!=0x3 ) continue;
          
-         // compare cluster charge
+         // compare cluster qMax
          
          fHistClusterAll->Fill(1);
-         if( charge1 == charge2 ) fHistClusterGood->Fill(1);
-         else sameCharge = 0;
+         if( qmax1 == qmax2 ) fHistClusterGood->Fill(1);
+         else sameQMax = 0;
          
          // compare cluster row index
          
@@ -490,15 +487,21 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
          if( row1 == row2 ) fHistClusterGood->Fill(2);
          else sameRow = 0;
          
+         // compare cluster charge
+         
+         fHistClusterAll->Fill(3);
+         if( charge1 == charge2 ) fHistClusterGood->Fill(3);
+         else sameCharge = 0;
+
          // compare floating point data
 
          for( int j=0; j<4; j++ ){
-           AliHLTFloat64_t f1     = *((AliHLTFloat32_t*)&p1[i+j]);
-           AliHLTFloat64_t f2     = *((AliHLTFloat32_t*)&p2[i+j]);
+           AliHLTFloat64_t f1     = *((AliHLTFloat32_t*)&p1[i+2+j]);
+           AliHLTFloat64_t f2     = *((AliHLTFloat32_t*)&p2[i+2+j]);
            double w = (fabs(f1) + fabs(f2))/2;
            if( w>1.e-20 ){
-             fHistClusterAll->Fill(3+j);
-             if( fabs(f1 - f2) < 1.e-6*w ) fHistClusterGood->Fill(3+j);
+             fHistClusterAll->Fill(4+j);
+             if( fabs(f1 - f2) < 1.e-6*w ) fHistClusterGood->Fill(4+j);
              else sameFloat[j] = 0;
            }
          }
@@ -523,6 +526,7 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
     if( !sameRCU ){ err=1; warn+=", RCU header";}
     if( !sameSize ){ err=1; warn+=", N Clusters";}
     if( !sameFlag ){ err=1; warn+=", Cluster Header";}
+    if( !sameQMax ){ err=1; warn+=", Cluster Qmax";}
     if( !sameCharge ){ err=1; warn+=", Cluster Charge";}
     if( !sameRow ){ err=1; warn+=", Cluster Row";}
     if( !sameFloat[0] ){ err=1; warn+=", Cluster Pad value";}
@@ -549,7 +553,7 @@ int AliHLTTPCHWCFConsistencyControlComponent::DoEvent( const AliHLTComponentEven
   delete[] checkedBlocks;
    
   HLTInfo("HWCF consistency check: %.10f %s of %ld data blocks are OK",
-         (double)(fNBlocks-fNDismatch)/(double)fNBlocks*100.,"%",fNBlocks);
+            (double)(fNBlocks-fNDismatch)/(double)fNBlocks*100.,"%",fNBlocks);
   
   //if( fNDismatch>0 ){
   //HLTWarning("HWCF inconsistency: %ld of %ld data blocks are not OK",
index 399978d..0298e50 100644 (file)
@@ -69,7 +69,7 @@ int AliHLTTPCHWCFDivisionUnit::InputStream( const AliHLTTPCHWCFClusterFragment *
   // input stream of data
   fkInput = fragment;
   if( fkInput && fDebug ){
-    std::cout<<"HWCF Division: input F: "<<fragment->fFlag<<" R: "<<fragment->fRow
+    std::cout<<"HWCF Division: input Br: "<<fragment->fBranch<<" F: "<<fragment->fFlag<<" R: "<<fragment->fRow
             <<" Q: "<<(fragment->fQ>>AliHLTTPCHWCFDefinitions::kFixedPoint)
             <<" P: "<<fragment->fPad<<" Tmean: "<<fragment->fTMean;            
     if( fragment->fFlag==1 && fragment->fQ > 0 ){
index 80faa79..9aaa453 100644 (file)
@@ -82,12 +82,13 @@ void AliHLTTPCHWCFEmulator::Init( const AliHLTUInt32_t *mapping, AliHLTUInt32_t
 
   fChannelProcessor.SetSingleSeqLimit( (config1) & 0xFF );
   fChannelProcessor.SetDeconvolutionTime( (config1>>24) & 0x1 );
-  fChannelProcessor.SetUseTimeBinWindow( (config2>>4) & 0x1 );
+  fChannelProcessor.SetUseTimeBinWindow( (config2>>8) & 0x1 );
 
  
   fChannelMerger.SetByPassMerger( (config1>>27) & 0x1 );
   fChannelMerger.SetDeconvolution( (config1>>25) & 0x1 );
   fChannelMerger.SetMatchDistance( (config2) & 0xF );
+  fChannelMerger.SetMatchTimeFollow( (config2>>9) & 0x1 );
 
   fDivisionUnit.SetClusterLowerLimit( (config1>>8) & 0xFFFF );
   fDivisionUnit.SetSinglePadSuppression( (config1>>26) & 0x1 );
@@ -210,7 +211,7 @@ void AliHLTTPCHWCFEmulator::CreateConfiguration
  bool doDeconvTime, bool doDeconvPad, bool doFlowControl, 
  bool doSinglePadSuppression, bool bypassMerger, 
  AliHLTUInt32_t clusterLowerLimit, AliHLTUInt32_t singleSeqLimit, 
- AliHLTUInt32_t mergerDistance, bool useTimeBinWindow, AliHLTUInt32_t chargeFluctuation,
+ AliHLTUInt32_t mergerDistance, bool useTimeBinWindow, AliHLTUInt32_t chargeFluctuation, bool useTimeFollow,
  AliHLTUInt32_t &configWord1, AliHLTUInt32_t &configWord2 
  )
 {
@@ -230,4 +231,5 @@ void AliHLTTPCHWCFEmulator::CreateConfiguration
   configWord2 |= ( (AliHLTUInt32_t)mergerDistance & 0xF );
   configWord2 |= ( (AliHLTUInt32_t)chargeFluctuation  & 0xF )<<4;
   configWord2 |= ( (AliHLTUInt32_t)useTimeBinWindow  & 0x1 )<<8;
+  configWord2 |= ( (AliHLTUInt32_t)useTimeFollow  & 0x1 )<<9;
 }
index 6dfe4c0..9c90a28 100644 (file)
@@ -66,13 +66,13 @@ class AliHLTTPCHWCFEmulator
     ( bool doDeconvTime, bool doDeconvPad, bool doFlowControl,  
       bool doSinglePadSuppression, bool bypassMerger, 
       AliHLTUInt32_t clusterLowerLimit,AliHLTUInt32_t singleSeqLimit, 
-      AliHLTUInt32_t mergerDistance, bool useTimeBinWindow, AliHLTUInt32_t chargeFluctuation,
+      AliHLTUInt32_t mergerDistance, bool useTimeBinWindow, AliHLTUInt32_t chargeFluctuation, bool useTimeFollow,
       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, 1, 0, configWord1, configWord2 );
+    CreateConfiguration(0,0,0,1,0,0,0, 3, 1, 0, 1, configWord1, configWord2 );
   }
   
  private: 
index f5fb854..98db2aa 100644 (file)
@@ -63,6 +63,7 @@ AliHLTTPCHWCFEmulatorComponent::AliHLTTPCHWCFEmulatorComponent()
   fSingleSeqLimit(0),
   fMergerDistance(3),
   fUseTimeBinWindow(1),
+  fUseTimeFollow(1),
   fChargeFluctuation(0),
   fDebug(0),
   fCFSupport(),
@@ -90,6 +91,7 @@ AliHLTTPCHWCFEmulatorComponent::AliHLTTPCHWCFEmulatorComponent(const AliHLTTPCHW
   fSingleSeqLimit(0),
   fMergerDistance(3),
   fUseTimeBinWindow(1),
+  fUseTimeFollow(1),
   fChargeFluctuation(0),
   fDebug(0),
   fCFSupport(),
@@ -216,6 +218,7 @@ void AliHLTTPCHWCFEmulatorComponent::SetDefaultConfiguration()
   fSingleSeqLimit = 0;
   fMergerDistance = 3;
   fUseTimeBinWindow = 1;
+  fUseTimeFollow = 1;
   fChargeFluctuation = 0;
   fDebug = 0;
   fBenchmark.Reset();
@@ -230,7 +233,7 @@ int AliHLTTPCHWCFEmulatorComponent::ReadConfigurationString(  const char* argume
 
   int iResult = 0;
   if ( !arguments ) return iResult;
-
+  cout<<"["<<arguments<<"]"<<endl;
   TString allArgs = arguments;
   TString argument;
   int bMissingParam = 0;
@@ -327,7 +330,14 @@ int AliHLTTPCHWCFEmulatorComponent::ReadConfigurationString(  const char* argume
       HLTInfo( "Charge fluctuation is set to: %d", fChargeFluctuation );
       continue;
     }
-
+    
+    if ( argument.CompareTo( "-use-time-follow" ) == 0 ) {
+      if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
+      fUseTimeFollow  = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
+      HLTInfo( "Use of time follow algorithm is set to: %d", fUseTimeFollow );
+      continue;
+    }
+   
     if ( argument.CompareTo( "-debug-level" ) == 0 ) {
       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
       fDebug  = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
@@ -444,7 +454,7 @@ int AliHLTTPCHWCFEmulatorComponent::DoEvent( const AliHLTComponentEventData& evt
 
   AliHLTUInt32_t configWord1=0, configWord2=0; 
   AliHLTTPCHWCFEmulator::CreateConfiguration
-    ( fDoDeconvTime, fDoDeconvPad, fDoFlowControl, fDoSinglePadSuppression, fBypassMerger, fClusterLowerLimit, fSingleSeqLimit, fMergerDistance, fUseTimeBinWindow, fChargeFluctuation, configWord1, configWord2 );
+    ( fDoDeconvTime, fDoDeconvPad, fDoFlowControl, fDoSinglePadSuppression, fBypassMerger, fClusterLowerLimit, fSingleSeqLimit, fMergerDistance, fUseTimeBinWindow, fChargeFluctuation, fUseTimeFollow, configWord1, configWord2 );
 
   for ( unsigned long ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
index 2b1fcde..0559f9c 100644 (file)
@@ -149,6 +149,7 @@ class AliHLTTPCHWCFEmulatorComponent : public AliHLTProcessor
   AliHLTUInt32_t fSingleSeqLimit;    // cut sequences at this charge value
   AliHLTUInt32_t fMergerDistance; // max. distance in mean time between two pads to be merged
   bool           fUseTimeBinWindow; // use timebin window
+  bool           fUseTimeFollow; // use time follow algorithm for merging pads  
   AliHLTUInt32_t fChargeFluctuation; // allowed charge fluctuation for peak finding 
   Int_t fDebug; // debug level
   AliHLTTPCHWCFSupport fCFSupport;     // !transient
index de91b19..4023bf0 100644 (file)
@@ -94,7 +94,7 @@ int AliHLTTPCHWCFMergerUnit::InputStream( const AliHLTTPCHWCFClusterFragment *fr
     fInput.fSlope = 0;
     fInput.fLastQ = fInput.fQ;
     if( fDebug ){
-      std::cout<<"Merger: input F: "<<fragment->fFlag<<" R: "<<fragment->fRow
+      std::cout<<"Merger: input Br: "<<fragment->fBranch<<" F: "<<fragment->fFlag<<" R: "<<fragment->fRow
               <<" Q: "<<(fragment->fQ>>AliHLTTPCHWCFDefinitions::kFixedPoint)
               <<" P: "<<fragment->fPad<<" Tmean: "<<fragment->fTMean;          
       if( fragment->fFlag==1 && fragment->fQ > 0 ){
@@ -201,28 +201,32 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFMergerUnit::OutputStream()
   }
 
   // merge 
-    
-  while( fSearchStart[ib]<fSearchEnd[ib]  && fSearchRange[ib][fSearchStart[ib]].fTMean+fMatchDistance>fInput.fTMean ){
+  
+  AliHLTTPCHWCFClusterFragment *ret = 0;
+  
+  if( fSearchStart[ib]<fSearchEnd[ib]  && fSearchRange[ib][fSearchStart[ib]].fTMean+fMatchDistance>fInput.fTMean ){
     AliHLTTPCHWCFClusterFragment &s = fSearchRange[ib][fSearchStart[ib]++];
     if( fDeconvolute && s.fSlope && s.fLastQ<fInput.fLastQ ){
       //cout<<"push from search range at "<<fSearchStart[ib]-1<<" of "<<fSearchEnd[ib]<<endl;
-      return &s;
+      ret = &s;
+    } else {
+      // cout<<"merge search range at "<<fSearchStart-1<<" of "<<fSearchEnd<<endl;
+      if( !fInput.fSlope && s.fLastQ > fInput.fQ ) fInput.fSlope = 1;
+      if (fInput.fQmax < s.fQmax) fInput.fQmax = s.fQmax;
+      fInput.fQ += s.fQ;
+      fInput.fT += s.fT;
+      fInput.fT2 += s.fT2;
+      fInput.fP += s.fP;
+      fInput.fP2 += s.fP2;
+      fInput.fMC.insert(fInput.fMC.end(), s.fMC.begin(), s.fMC.end());
+      if( !fMatchTimeFollow ) fInput.fTMean = s.fTMean;    
+      ret = 0;
     }
-    // cout<<"merge search range at "<<fSearchStart-1<<" of "<<fSearchEnd<<endl;
-    if( !fInput.fSlope && s.fLastQ > fInput.fQ ) fInput.fSlope = 1;
-    if (fInput.fQmax < s.fQmax) fInput.fQmax = s.fQmax;
-    fInput.fQ += s.fQ;
-    fInput.fT += s.fT;
-    fInput.fT2 += s.fT2;
-    fInput.fP += s.fP;
-    fInput.fP2 += s.fP2;
-    fInput.fMC.insert(fInput.fMC.end(), s.fMC.begin(), s.fMC.end());
-    if( !fMatchTimeFollow ) fInput.fTMean = s.fTMean;
   }
   
   // insert 
   
   fInsertRange[ib][fInsertEnd[ib]++] = fInput;
   fInput.fFlag = 0;
-  return 0;
+  return ret;
 }
index 899047a..f5e2a38 100644 (file)
@@ -75,9 +75,9 @@ int AliHLTTPCHWCFPeakFinderUnit::Init()
 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",
+    printf("\nHWCF Peak Finder: 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];
@@ -117,12 +117,13 @@ const AliHLTTPCHWCFBunch *AliHLTTPCHWCFPeakFinderUnit::OutputStream()
   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
+    AliHLTUInt32_t q = fOutput.fData[i].fQ;    
+    if( !slope ){
+      if(q + fChargeFluctuation < qLast   ){ // peak
+       slope = 1;
+       if( i>0 ) fOutput.fData[i-1].fPeak = 1;
+      }
+    }else if( q > qLast + fChargeFluctuation ){ // minimum
       slope = 0;
       if( i>0 ) fOutput.fData[i-1].fPeak = 2;
     }
index e0d9a03..624c402 100644 (file)
@@ -88,7 +88,7 @@ int AliHLTTPCHWCFProcessorUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
           bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fData.size());
     for( unsigned int i=0; i<bunch->fData.size(); i++ ){
       AliHLTTPCHWCFDigit d =  bunch->fData[i];
-      printf("   q %2d t %3d ", d.fQ, d.fTime);      
+      printf("   q %2d t %3d peak %2d ", d.fQ, d.fTime, d.fPeak);      
        printf("(");
       for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",d.fMC.fClusterID[j].fMCID, d.fMC.fClusterID[j].fWeight );
       printf(" )\n");    
@@ -135,11 +135,11 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
   if( fkBunch->fFlag < 1 ) return 0;
   
   while( fBunchIndex<fkBunch->fData.size() ){
-
+    
     AliHLTUInt32_t iStart = fBunchIndex;
     AliHLTUInt32_t iPeak = fBunchIndex;
     AliHLTUInt32_t qPeak = 0;
-
+        
     // find next/best peak
     
     for( ; fBunchIndex<fkBunch->fData.size(); fBunchIndex++ ){
@@ -147,6 +147,7 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
       if( d.fPeak != 1 ) continue;
       if( fDeconvolute ){
        iPeak = fBunchIndex;
+       qPeak = d.fQ;
        fBunchIndex++;
        break;
       } else { 
@@ -156,26 +157,47 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
        }
       }
     }
-  
-    // find next minimum
+    
+    if( qPeak == 0 ) return 0;
 
-    for( ; fBunchIndex<fkBunch->fData.size(); fBunchIndex++ ){
-      if( fDeconvolute ){
-       if( fkBunch->fData[fBunchIndex].fPeak != 0 ){
-         fBunchIndex++;
-         break;
+    // find next minimum !!! At the moment the minimum finder is on only when no timebin window set
+
+    if( !fUseTimeBinWindow ){
+      for( ; fBunchIndex<fkBunch->fData.size(); fBunchIndex++ ){
+       if( fDeconvolute ){
+         if( fkBunch->fData[fBunchIndex].fPeak != 0 ){
+           fBunchIndex++;
+           break;
+         }
+       }
+      }
+    } else{ 
+      if( !fDeconvolute ){
+       fBunchIndex = fkBunch->fData.size();
+      } else {
+       // find next peak
+       if( fBunchIndex+1<fkBunch->fData.size() && fkBunch->fData[fBunchIndex+1].fPeak==1 ){
+         fBunchIndex = fBunchIndex+1;
+       } else  if( fBunchIndex+2<fkBunch->fData.size() && fkBunch->fData[fBunchIndex+2].fPeak==1 ){
+         fBunchIndex = fBunchIndex+1;
+       } else  if( fBunchIndex+3<fkBunch->fData.size() && fkBunch->fData[fBunchIndex+3].fPeak==1 ){
+         fBunchIndex = fBunchIndex+2;
+       } else   if( fBunchIndex+1<fkBunch->fData.size() ){
+         fBunchIndex = fBunchIndex+2;
+       } else   if( fBunchIndex<fkBunch->fData.size() ){
+         fBunchIndex = fBunchIndex+1;
        }
       }
     }
-
-    AliHLTUInt32_t iEnd = fBunchIndex;
     
+    AliHLTUInt32_t iEnd = fBunchIndex;
+
     if( fUseTimeBinWindow ){
       if( iPeak > iStart + kHalfTimeBinWindow ) iStart = iPeak - kHalfTimeBinWindow;
-      if( iEnd  > iPeak + kHalfTimeBinWindow ) iEnd = iPeak + kHalfTimeBinWindow;
+      if( iEnd  > iPeak + kHalfTimeBinWindow + 1) iEnd = iPeak + kHalfTimeBinWindow + 1;
     }
 
-    fOutput.fQmax = 0;
+    fOutput.fQmax = qPeak*fkBunch->fGain;
     fOutput.fQ = 0;
     fOutput.fT = 0;
     fOutput.fT2 = 0;
@@ -186,8 +208,7 @@ const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
 
     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;
+      AliHLTUInt64_t q = d.fQ*fkBunch->fGain;      
       fOutput.fQ += q;
       fOutput.fT += q*d.fTime;
       fOutput.fT2+= q*d.fTime*d.fTime;
index fff57bb..1cd5077 100644 (file)
@@ -260,6 +260,7 @@ AliHLTUInt32_t *AliHLTTPCHWCFSupport::ReadMapping( int slice, int patch, const c
        
       AliHLTUInt32_t branch = (hwAdd >> 11) & 0x1;     
       rowBranchPadHw[nRead] = (row<<25) | (branch<<24) | (pad<<16) | hwAdd;
+
       nRead++;
       err = 0;
     }