From 124b5fc83ea16be85716d5ac89ab762c47c70ee6 Mon Sep 17 00:00:00 2001 From: sgorbuno Date: Thu, 27 Jun 2013 11:24:27 +0000 Subject: [PATCH] Small data block AliHLTTPCDataCompressionDescriptor with general description of the compressed data is introduced, 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 | 7 ++- .../AliHLTTPCDataPublisherComponent.cxx | 9 +++- HLT/TPCLib/AliHLTTPCDefinitions.cxx | 8 +++- HLT/TPCLib/AliHLTTPCDefinitions.h | 3 ++ .../AliHLTTPCDataCompressionComponent.cxx | 23 ++++++++++ .../comp/AliHLTTPCDataCompressionDecoder.cxx | 18 ++++++++ .../comp/AliHLTTPCDataCompressionDecoder.h | 12 +++-- .../comp/AliHLTTPCDataCompressionDescriptor.h | 45 +++++++++++++++++++ 8 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 HLT/TPCLib/comp/AliHLTTPCDataCompressionDescriptor.h diff --git a/HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx b/HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx index 0490f9662c1..446cd8270be 100644 --- a/HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx +++ b/HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx @@ -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) { diff --git a/HLT/TPCLib/AliHLTTPCDataPublisherComponent.cxx b/HLT/TPCLib/AliHLTTPCDataPublisherComponent.cxx index 03e34bad755..f62522f4f50 100644 --- a/HLT/TPCLib/AliHLTTPCDataPublisherComponent.cxx +++ b/HLT/TPCLib/AliHLTTPCDataPublisherComponent.cxx @@ -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) { diff --git a/HLT/TPCLib/AliHLTTPCDefinitions.cxx b/HLT/TPCLib/AliHLTTPCDefinitions.cxx index c698835dd62..683d3608985 100644 --- a/HLT/TPCLib/AliHLTTPCDefinitions.cxx +++ b/HLT/TPCLib/AliHLTTPCDefinitions.cxx @@ -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; diff --git a/HLT/TPCLib/AliHLTTPCDefinitions.h b/HLT/TPCLib/AliHLTTPCDefinitions.h index 983b9513022..7d9bf23406c 100644 --- a/HLT/TPCLib/AliHLTTPCDefinitions.h +++ b/HLT/TPCLib/AliHLTTPCDefinitions.h @@ -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(); diff --git a/HLT/TPCLib/comp/AliHLTTPCDataCompressionComponent.cxx b/HLT/TPCLib/comp/AliHLTTPCDataCompressionComponent.cxx index fbb41dfb76b..9dd24adb91f 100644 --- a/HLT/TPCLib/comp/AliHLTTPCDataCompressionComponent.cxx +++ b/HLT/TPCLib/comp/AliHLTTPCDataCompressionComponent.cxx @@ -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 diff --git a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx index ec85d05c5f6..7205659bd5b 100644 --- a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx +++ b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx @@ -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(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; } diff --git a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h index 1c883872122..e4d01438e3a 100644 --- a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h +++ b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h @@ -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 index 00000000000..a7e7a365c70 --- /dev/null +++ b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDescriptor.h @@ -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