]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Small data block AliHLTTPCDataCompressionDescriptor with general description of the...
authorsgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Jun 2013 11:24:27 +0000 (11:24 +0000)
committersgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Jun 2013 11:24:27 +0000 (11:24 +0000)
to keep backward compatibility for the cluster merger.
At the moment the descriptor only says if the clusters should be merged  during  unpacking, or they were already merged in the HLT,

HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx
HLT/TPCLib/AliHLTTPCDataPublisherComponent.cxx
HLT/TPCLib/AliHLTTPCDefinitions.cxx
HLT/TPCLib/AliHLTTPCDefinitions.h
HLT/TPCLib/comp/AliHLTTPCDataCompressionComponent.cxx
HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx
HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h
HLT/TPCLib/comp/AliHLTTPCDataCompressionDescriptor.h [new file with mode: 0644]

index 0490f9662c190623fd4be6f5f81795242f60b6c0..446cd8270bee2a5a1341a2601b02a860af45dd95 100644 (file)
@@ -237,7 +237,6 @@ int AliHLTTPCClusterAccessHLTOUT::ProcessClusters(const char* params)
   AliHLTTPCDataCompressionDecoder& decoder=*fpDecoder;
   decoder.Clear();
   decoder.SetVerbosity(fVerbosity);
-  //decoder.EnableClusterMerger();
 
   bool bNextBlock=false;
   // add cluster id and mc information data blocks
@@ -253,6 +252,12 @@ int AliHLTTPCClusterAccessHLTOUT::ProcessClusters(const char* params)
     if (pHLTOUT->GetDataBlockDescription(desc.fDataType, desc.fSpecification)<0) {
       continue;
     }
+    if (desc.fDataType==AliHLTTPCDefinitions::DataCompressionDescriptorDataType()) {
+      // header      
+      if ((iResult=decoder.AddCompressionDescriptor(&desc))<0) {
+       return iResult;
+      }
+    }
     if (desc.fDataType==AliHLTTPCDefinitions::AliHLTDataTypeClusterMCInfo()) {
       // add mc information
       if ((iResult=decoder.AddClusterMCData(&desc))<0) {
index 03e34bad755eb902ebf8c8a4d8269c079764d521..f62522f4f50ea9e393246d7633b054ba724bd6d2 100644 (file)
@@ -190,8 +190,7 @@ int AliHLTTPCDataPublisherComponent::ReadClusterFromHLTOUT(AliHLTTPCDataPublishe
 
   AliHLTTPCDataCompressionDecoder& decoder=*fpDecoder;
   decoder.Clear();
-  decoder.SetVerbosity(GetVerbosity());
-  decoder.EnableClusterMerger();
+  decoder.SetVerbosity(GetVerbosity());  
 
   bool bNextBlock=false;
   // add cluster id and mc information data blocks
@@ -201,6 +200,12 @@ int AliHLTTPCDataPublisherComponent::ReadClusterFromHLTOUT(AliHLTTPCDataPublishe
     if ((iResult=pHLTOUT->GetDataBuffer(desc))<0) {
       continue;
     }
+    if (desc.fDataType==AliHLTTPCDefinitions::DataCompressionDescriptorDataType()) {
+      // header      
+      if ((iResult=decoder.AddCompressionDescriptor(&desc))<0) {
+       return iResult;
+      }
+    }
     if (desc.fDataType==AliHLTTPCDefinitions::AliHLTDataTypeClusterMCInfo()) {
       // add mc information
       if ((iResult=decoder.AddClusterMCData(&desc))<0) {
index c698835dd62ef9bf7b84926f453227166acb3051..683d3608985f489bf960b9bd7bb4407716588a2d 100644 (file)
@@ -42,7 +42,8 @@ const AliHLTComponentDataType AliHLTTPCDefinitions::fgkVertexDataType = AliHLTCo
 const AliHLTComponentDataType AliHLTTPCDefinitions::fgkTrackSegmentsDataType = AliHLTComponentDataTypeInitializer("TRAKSEGS", kAliHLTDataOriginTPC);
 const AliHLTComponentDataType AliHLTTPCDefinitions::fgkTracksDataType = AliHLTComponentDataTypeInitializer("TRACKS  ", kAliHLTDataOriginTPC);
 
-const AliHLTComponentDataType AliHLTTPCDefinitions::fgkClusterTracksModelDataType = AliHLTComponentDataTypeInitializer("CLSTRKMD", kAliHLTDataOriginTPC);
+const AliHLTComponentDataType AliHLTTPCDefinitions::fgkDataCompressionDescriptorDataType = AliHLTComponentDataTypeInitializer("COMPDESC", kAliHLTDataOriginTPC);
+const AliHLTComponentDataType AliHLTTPCDefinitions::fgkClusterTracksModelDataType = AliHLTComponentDataTypeInitializer("CLSTRKMD", kAliHLTDataOriginTPC); 
 const AliHLTComponentDataType AliHLTTPCDefinitions::fgkRemainingClustersModelDataType = AliHLTComponentDataTypeInitializer("REMCLSMD", kAliHLTDataOriginTPC);
 const AliHLTComponentDataType AliHLTTPCDefinitions::fgkClusterTracksCompressedDataType = AliHLTComponentDataTypeInitializer("CLSTRKCM", kAliHLTDataOriginTPC);
 const AliHLTComponentDataType AliHLTTPCDefinitions::fgkRemainingClustersCompressedDataType = AliHLTComponentDataTypeInitializer("REMCLSCM", kAliHLTDataOriginTPC);
@@ -87,7 +88,10 @@ const AliHLTComponentDataType& AliHLTTPCDefinitions::TracksDataType() {
   static AliHLTComponentDataType dt = AliHLTComponentDataTypeInitializer("TRACKS  ", kAliHLTDataOriginTPC);
   return dt;
 }
-
+const AliHLTComponentDataType& AliHLTTPCDefinitions::DataCompressionDescriptorDataType() {
+  static AliHLTComponentDataType dt = AliHLTComponentDataTypeInitializer("COMPDESC", kAliHLTDataOriginTPC);
+  return dt;
+}
 const AliHLTComponentDataType& AliHLTTPCDefinitions::ClusterTracksModelDataType() {
   static AliHLTComponentDataType dt = AliHLTComponentDataTypeInitializer("CLSTRKMD", kAliHLTDataOriginTPC);
   return dt;
index 983b9513022f48cc80a4d1cbcc26093e95cb66dc..7d9bf23406ce9f7bcb98a27e0b808c80f185bc56 100644 (file)
@@ -126,6 +126,9 @@ public:
   static const AliHLTComponentDataType& VertexDataType();
 
   // Cluster & Tracks model data
+  /** data compression descriptor*/
+  static const AliHLTComponentDataType fgkDataCompressionDescriptorDataType;          // see above
+  static const AliHLTComponentDataType& DataCompressionDescriptorDataType();
   /** cluster tracks model data type */
   static const AliHLTComponentDataType fgkClusterTracksModelDataType;          // see above
   static const AliHLTComponentDataType& ClusterTracksModelDataType();
index fbb41dfb76b5f0fabffa5a34501d9b2db9a2200b..9dd24adb91f9bb1db6966b2c33bf0c6379f0ab50 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "AliHLTTPCDataCompressionComponent.h"
 #include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCDataCompressionDescriptor.h"
 #include "AliHLTTPCTrackGeometry.h"
 #include "AliHLTTPCSpacePointContainer.h"
 #include "AliHLTTPCRawSpacePointContainer.h"
@@ -109,6 +110,7 @@ int AliHLTTPCDataCompressionComponent::GetOutputDataTypes(AliHLTComponentDataTyp
 {
   /// inherited from AliHLTComponent: multiple output data types of the component.
   tgtList.clear();
+  tgtList.push_back(AliHLTTPCDefinitions::DataCompressionDescriptorDataType());
   tgtList.push_back(AliHLTTPCDefinitions::RawClustersDataType());
   tgtList.push_back(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
   tgtList.push_back(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
@@ -169,6 +171,7 @@ int AliHLTTPCDataCompressionComponent::DoEvent( const AliHLTComponentEventData&
   }
 
   // Process an event
+
   // Loop over all input blocks in the event
   bool bHaveMC=(GetFirstInputBlock(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo | kAliHLTDataOriginTPC))!=NULL;
   if ((bHaveMC || fVerificationMode>0) && fpWrittenAssociatedClusterIds==NULL) {
@@ -190,6 +193,26 @@ int AliHLTTPCDataCompressionComponent::DoEvent( const AliHLTComponentEventData&
   if (GetBenchmarkInstance()) {
     GetBenchmarkInstance()->Start(2);
   }
+  // Write header block
+  {
+    AliHLTComponent_BlockData bd;
+    FillBlockData(bd);
+    bd.fOffset        = size;
+    bd.fSize          = sizeof(AliHLTTPCDataCompressionDescriptor);
+    bd.fDataType      = AliHLTTPCDefinitions::DataCompressionDescriptorDataType();
+    if( capacity < size + bd.fSize ){
+      iResult = -ENOMEM;
+      return iResult;
+    }    
+    AliHLTTPCDataCompressionDescriptor desc; 
+    desc.SetMergedClustersFlag(1);
+    *(AliHLTTPCDataCompressionDescriptor*)(outputPtr + bd.fOffset ) = desc;
+    outputBlocks.push_back(bd);
+    size += bd.fSize;
+    outputDataSize+=bd.fSize;
+    HLTBenchmark("header data block of size %d", bd.fSize);
+  }
 
   // transformed clusters
   // the transformed clusters have not been used yet
index ec85d05c5f68762bc371f7ed850418890d68879e..7205659bd5b83f65da51d1e6ed08258832369268 100644 (file)
@@ -21,6 +21,7 @@
 ///         class implementation which fills the actual target data struct
 
 #include "AliHLTTPCDataCompressionDecoder.h"
+#include "AliHLTTPCDataCompressionDescriptor.h"
 #include "AliHLTDataInflaterSimple.h"
 #include "AliHLTDataInflaterHuffman.h"
 #include "TList.h"
@@ -31,6 +32,7 @@ ClassImp(AliHLTTPCDataCompressionDecoder)
 AliHLTTPCDataCompressionDecoder::AliHLTTPCDataCompressionDecoder()
   : fPadShift(0.)
   , fVerbosity(0)
+  , fUseClusterMerger(kTRUE)
   , fpDataInflaterPartition(NULL)
   , fpDataInflaterTrack(NULL)
   , fpClusterMerger(NULL)
@@ -153,6 +155,21 @@ int AliHLTTPCDataCompressionDecoder::InitTrackModelClusterClusterDecoding()
   return 0;
 }
 
+int AliHLTTPCDataCompressionDecoder::AddCompressionDescriptor(const AliHLTComponentBlockData* pDesc)
+{
+  /// read descriptor
+  if (!pDesc) return -EINVAL;
+  if (pDesc->fDataType!=AliHLTTPCDefinitions::DataCompressionDescriptorDataType()) return -ENODATA;
+  const AliHLTTPCDataCompressionDescriptor* pHeader=reinterpret_cast<const AliHLTTPCDataCompressionDescriptor*>(pDesc->fPtr);
+  if (! pHeader->CheckSize( pDesc->fSize ) ) return -EINVAL;
+  if( pHeader->GetMergedClustersFlag() == 0 ){
+    fUseClusterMerger = kTRUE;
+  } else if( pHeader->GetMergedClustersFlag() == 1 ){
+    fUseClusterMerger = kFALSE;
+  } else return -EINVAL;
+  return 0;
+}
+
 int AliHLTTPCDataCompressionDecoder::AddClusterMCData(const AliHLTComponentBlockData* pDesc)
 {
   /// add cluster mc data block
@@ -249,4 +266,5 @@ void AliHLTTPCDataCompressionDecoder::Clear(const char* option)
   fPartitionClusterIds.clear();
   fTrackModelClusterIds.Clear();
   fClusterMCData.clear();
+  fUseClusterMerger = kTRUE;
 }
index 1c8838721225693821a3033d4c7b0a6118c1df04..e4d01438e3a38b7e133d4000f8ce04472074403d 100644 (file)
@@ -54,10 +54,10 @@ class AliHLTTPCDataCompressionDecoder : public AliHLTLogging {
   void SetPadShift(float padShift) {fPadShift=padShift;}
   float PadShift() const {return fPadShift;}
   void SetVerbosity(int verbosity) {fVerbosity=verbosity;}
-  void EnableClusterMerger() {if (!fpClusterMerger) fpClusterMerger=new AliHLTTPCHWClusterMerger;}
 
   int InitPartitionClusterDecoding(AliHLTUInt32_t specification);
   int InitTrackModelClusterClusterDecoding();
+  int AddCompressionDescriptor(const AliHLTComponentBlockData* pDesc);
   int AddClusterMCData(const AliHLTComponentBlockData* pDesc);
   int AddClusterIds(const AliHLTComponentBlockData* pDesc);
   AliHLTUInt32_t GetClusterId(int clusterNo) const;
@@ -80,6 +80,7 @@ class AliHLTTPCDataCompressionDecoder : public AliHLTLogging {
 
   float fPadShift; //! pad shift
   int fVerbosity; //! verbosity level
+  Bool_t fUseClusterMerger; // flag to run the cluster merger
   AliHLTDataInflater* fpDataInflaterPartition; //! instance of inflater for partition clusters
   AliHLTDataInflater* fpDataInflaterTrack; //! instance of inflater for track clusters
   AliHLTTPCHWClusterMerger* fpClusterMerger; //! merger instance
@@ -173,6 +174,11 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
   bool bNextCluster=true;
   bool bReadSuccess=true;
   AliHLTTPCRawCluster rawCluster;
+
+  if( fUseClusterMerger && !fpClusterMerger ){
+    fpClusterMerger = new AliHLTTPCHWClusterMerger;
+  }
+
   if (fpClusterMerger)
     fpClusterMerger->Clear();
 
@@ -239,7 +245,7 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
     if (parameterId>=AliHLTTPCDefinitions::kLast) {
       AliHLTUInt32_t id=GetClusterId(decodedClusterCnt);
       const AliHLTTPCClusterMCLabel* pMC=GetMCLabel(id);
-      if (fpClusterMerger && fpClusterMerger->CheckCandidate(slice, partition, rawCluster)) {
+      if (fUseClusterMerger && fpClusterMerger && fpClusterMerger->CheckCandidate(slice, partition, rawCluster)) {
        fpClusterMerger->AddCandidate(slice, partition, id, rawCluster, pMC);
       } else {
       c.Next(slice, partition);
@@ -271,7 +277,7 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
   }
   pInflater->CloseBitDataInput();
   int mergedClusterCnt=0;
-  if (fpClusterMerger) {
+  if (fUseClusterMerger && fpClusterMerger) {
     mergedClusterCnt=fpClusterMerger->Merge();
     int remainingCnt=0;
     if (mergedClusterCnt>=0) {
diff --git a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDescriptor.h b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDescriptor.h
new file mode 100644 (file)
index 0000000..a7e7a36
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef ALIHLTTPCDATACOMPRESSIONDESCRIPTOR_H
+#define ALIHLTTPCDATACOMPRESSIONDESCRIPTOR_H
+
+#include "Rtypes.h"
+
+/**
+ * @struct AliHLTTPCDataCompressionDescriptor
+ * The class describes properties of the compressed data
+ * @ingroup alihlt_tpc_datastructs
+ */
+class AliHLTTPCDataCompressionDescriptor
+{
+ public:
+
+  AliHLTTPCDataCompressionDescriptor(): fVersion(0), fMergedClustersFlag(1){}
+  ~AliHLTTPCDataCompressionDescriptor(){}
+  AliHLTTPCDataCompressionDescriptor(const AliHLTTPCDataCompressionDescriptor& other)
+    : fVersion(other.fVersion)
+    , fMergedClustersFlag(other.fMergedClustersFlag)
+  {}
+
+  AliHLTTPCDataCompressionDescriptor& operator=(const AliHLTTPCDataCompressionDescriptor& other){ 
+    fVersion = other.fVersion;
+    fMergedClustersFlag = other.fMergedClustersFlag;
+    return *this;
+  }
+
+  Bool_t CheckSize( UInt_t size ) const {
+    if( size<sizeof(UInt_t) ) return 0;
+    if( fVersion==0 ) return ( size==sizeof(AliHLTTPCDataCompressionDescriptor));
+    return 0;
+  }
+  
+  UInt_t GetVersion() const { return fVersion; }
+  Int_t GetMergedClustersFlag() const { return fMergedClustersFlag; }
+  
+  void SetMergedClustersFlag( Int_t flag ){ fMergedClustersFlag=flag; }
+
+ private:
+
+  UInt_t fVersion; // version number
+  Int_t fMergedClustersFlag; // flag tells if the clusters were merged at the branch borders
+};
+
+#endif