implementing component benchmark and persistent decoder
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 18 Dec 2012 08:47:16 +0000 (08:47 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 18 Dec 2012 08:47:16 +0000 (08:47 +0000)
HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.cxx
HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.h

index 053a233..5a94b0d 100644 (file)
@@ -33,6 +33,7 @@
 #include "AliHLTTPCTrackGeometry.h"
 #include "AliHLTTPCHWCFSpacePointContainer.h"
 #include "AliHLTErrorGuard.h"
+#include "AliHLTComponentBenchmark.h"
 #include "AliRawDataHeader.h"
 #include "AliTPCclusterMI.h"
 #include "AliTPCROC.h"
@@ -55,6 +56,8 @@ ClassImp(AliHLTTPCDataCompressionMonitorComponent)
 
 AliHLTTPCDataCompressionMonitorComponent::AliHLTTPCDataCompressionMonitorComponent()
   : AliHLTProcessor()
+  , fpBenchmark(NULL)
+  , fpDecoder(NULL)
   , fpHWClusterDecoder(NULL)
   , fHistoHWCFDataSize(NULL)
   , fHistoHWCFReductionFactor(NULL)
@@ -138,6 +141,11 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
     return iResult;
   }
 
+  if (GetBenchmarkInstance()) {
+    GetBenchmarkInstance()->StartNewEvent();
+    GetBenchmarkInstance()->Start(0);
+  }
+
   const AliHLTComponentBlockData* pDesc=NULL;
   unsigned rawDataSize=0;
   unsigned rawEventSizeFromRCUtrailer=0;
@@ -184,6 +192,10 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
   }
 
   if (fMonitoringContainer) {
+    if (GetBenchmarkInstance()) {
+      GetBenchmarkInstance()->Start(1);
+    }
+
     for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
         pDesc!=NULL; pDesc=GetNextInputBlock()) {
       iResult=fMonitoringContainer->AddClusterIds(pDesc);
@@ -195,7 +207,8 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
     }
 
     // read data
-    AliHLTTPCDataCompressionDecoder decoder;
+    AliHLTTPCDataCompressionDecoder& decoder=*fpDecoder;
+    decoder.Clear();
     bool bHaveRawClusters=false;
     for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RawClustersDataType());
         pDesc!=NULL; pDesc=GetNextInputBlock()) {
@@ -251,6 +264,9 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
        ALIHLTERRORGUARD(5, "conflicting data blocks, monitoring histograms already filled from raw cluster data, ignoring blocks of compressed partition and track clusters");
       }                     
     }
+    if (GetBenchmarkInstance()) {
+      GetBenchmarkInstance()->Stop(1);
+    }
 
     fMonitoringContainer->Clear();
   }
@@ -282,6 +298,11 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
     iResult=Publish(fPublishingMode);
   }
 
+  if (GetBenchmarkInstance()) {
+    GetBenchmarkInstance()->Stop(0);
+    HLTBenchmark("%s", GetBenchmarkInstance()->GetStatistics());
+  }
+
   return iResult;
 }
 
@@ -462,6 +483,20 @@ int AliHLTTPCDataCompressionMonitorComponent::DoInit( int argc, const char** arg
     if (yaxis) yaxis->SetTitle("reduction factor");
   }
 
+  std::auto_ptr<AliHLTComponentBenchmark> benchmark(new AliHLTComponentBenchmark);
+  if (benchmark.get()) {
+    benchmark->SetTimer(0,"total");
+    benchmark->SetTimer(1,"clusterdecoding");
+  } else {
+    return -ENOMEM;
+  }
+
+  auto_ptr<AliHLTTPCDataCompressionDecoder> decoder(new AliHLTTPCDataCompressionDecoder);
+  if (!decoder.get()) {
+    return -ENOMEM;
+  }
+
+
   fHistoHWCFDataSize=histoHWCFDataSize.release();
   fHistoHWCFReductionFactor=histoHWCFReductionFactor.release();
   fHistoTotalReductionFactor=histoTotalReductionFactor.release();
@@ -470,6 +505,8 @@ int AliHLTTPCDataCompressionMonitorComponent::DoInit( int argc, const char** arg
 
   fpHWClusterDecoder=hwClusterDecoder.release();
   fMonitoringContainer=dataContainer.release();
+  fpBenchmark=benchmark.release();
+  fpDecoder=decoder.release();
 
   return iResult;
 }
@@ -479,6 +516,9 @@ int AliHLTTPCDataCompressionMonitorComponent::DoDeinit()
   /// inherited from AliHLTComponent: component cleanup
   int iResult=0;
 
+  if (fpBenchmark) delete fpBenchmark; fpBenchmark=NULL;
+  if (fpDecoder) delete fpDecoder;
+  fpDecoder=NULL;
   if (fpHWClusterDecoder) delete fpHWClusterDecoder;
   fpHWClusterDecoder=NULL;
 
@@ -689,7 +729,7 @@ AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::~AliDataContainer()
   if (fHistograms3D) delete fHistograms3D;
 }
 
-AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::iterator& AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::BeginRemainingClusterBlock(int /*count*/, AliHLTUInt32_t specification)
+AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::iterator& AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::BeginPartitionClusterBlock(int /*count*/, AliHLTUInt32_t specification)
 {
   /// iterator of remaining clusters block of specification
   AliHLTUInt8_t slice=AliHLTTPCDefinitions::GetMinSliceNr(specification);
@@ -869,6 +909,7 @@ void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillPad(float p
     fHistogram3DPointers[index]->Fill(fSector,pad,currentRow);
   
   AliTPCROC *roc=AliTPCROC::Instance();
+  if (roc) {
   Float_t pos[3]={0.,0.,0.};
   roc->GetPositionGlobal(fSector, fSector>35?currentRow-63:currentRow, (int)pad, pos); 
   if (fSector<=17 || (fSector>=36&&fSector<=53))
@@ -882,6 +923,7 @@ void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillPad(float p
     if (index<fHistogram2DPointers.size() && fHistogram2DPointers[index]!=NULL)
       fHistogram2DPointers[index]->Fill(pos[0],pos[1]);
   }
+  }
 
 }
 
index f3432d7..981f1d6 100644 (file)
@@ -21,6 +21,8 @@ class AliHLTTPCHWCFData;
 class AliHLTDataInflater;
 class AliHLTTPCTrackGeometry;
 class AliHLTTPCHWCFSpacePointContainer;
+class AliHLTComponentBenchmark;
+class AliHLTTPCDataCompressionDecoder;
 class TH1;
 class TH2;
 class TH3;
@@ -197,6 +199,16 @@ public:
       void SetSigmaZ2(float sigmaZ2)      {if (fData) fData->FillSigmaZ2(sigmaZ2, fClusterId);}
       void SetCharge(unsigned charge)     {if (fData) fData->FillCharge(charge, fClusterId);}
       void SetQMax(unsigned qmax)         {if (fData) {fData->FillQMax(qmax, fClusterId);fData->Fill(fSlice, fPartition, fClusterId);}}
+      iterator& operator=(const AliHLTTPCRawCluster& cluster) {if (fData) {
+         fData->FillPadRow(cluster.GetPadRow(), fSlice, fClusterId);
+         fData->FillPad(cluster.GetPad(), fClusterId);
+         fData->FillTime(cluster.GetTime(), fClusterId);
+         fData->FillSigmaY2(cluster.GetSigmaY2(), fClusterId, fPartition);
+         fData->FillSigmaZ2(cluster.GetSigmaZ2(), fClusterId);
+         fData->FillCharge(cluster.GetCharge(), fClusterId);
+         fData->FillQMax(cluster.GetQMax(), fClusterId);
+         fData->Fill(fSlice, fPartition, fClusterId);
+       } return *this;}
       void SetMC(const AliHLTTPCClusterMCLabel* /*pMC*/) {/* nop */}
 
       // switch to next cluster
@@ -221,8 +233,12 @@ public:
       int fPartition; //! current partition
     };
 
-    /// iterator of remaining clusters block of specification
-    iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
+    /// legacy, to be removed later
+    iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification) {
+      return BeginPartitionClusterBlock(count, specification);
+    }
+    /// iterator of partition clusters block of specification
+    iterator& BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification);
     /// iterator of track model clusters
     iterator& BeginTrackModelClusterBlock(int count);
 
@@ -292,11 +308,16 @@ protected:
 
   /// publish to output
   int Publish(int mode);
+
+  AliHLTComponentBenchmark* GetBenchmarkInstance() const {return fpBenchmark;}
     
 private:
   AliHLTTPCDataCompressionMonitorComponent(const AliHLTTPCDataCompressionMonitorComponent&);
   AliHLTTPCDataCompressionMonitorComponent& operator=(const AliHLTTPCDataCompressionMonitorComponent&);
 
+  /// benchmark
+  AliHLTComponentBenchmark* fpBenchmark; //! benchmark instance
+  AliHLTTPCDataCompressionDecoder* fpDecoder; //! cluster decoder instance
   AliHLTTPCHWCFData* fpHWClusterDecoder; //! data decoder for HW clusters
 
   TH2* fHistoHWCFDataSize;         //! hwcf data size vs. event size