implementing reading of uncompressed HLT TPC raw clusters
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Oct 2011 09:37:58 +0000 (09:37 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Oct 2011 09:37:58 +0000 (09:37 +0000)
HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h
HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.cxx

index d98e090..0c8005c 100644 (file)
@@ -44,6 +44,9 @@ class AliHLTTPCDataCompressionDecoder : public AliHLTLogging {
   template<typename T>
   int ReadTrackClustersCompressed(T& c, AliHLTDataInflater* pInflater, AliHLTTPCTrackGeometry* pTrackPoints);
 
+  template<typename T>
+  int ReadClustersPartition(T& c, const AliHLTUInt8_t* pData, unsigned dataSize, AliHLTUInt32_t specification);
+
   AliHLTDataInflater* CreateInflater(int deflater, int mode) const;
 
  protected:
@@ -362,4 +365,33 @@ int AliHLTTPCDataCompressionDecoder::ReadTrackClustersCompressed(T& c, AliHLTDat
   }
   return iResult;
 }
+
+template<typename T>
+int AliHLTTPCDataCompressionDecoder::ReadClustersPartition(T& c, const AliHLTUInt8_t* pData, unsigned dataSize, AliHLTUInt32_t specification)
+{
+  // read raw cluster data
+  if (!pData) return -EINVAL;
+  if (dataSize<sizeof(AliHLTTPCRawClusterData)) return -ENODATA;
+  const AliHLTTPCRawClusterData* clusterData = reinterpret_cast<const AliHLTTPCRawClusterData*>(pData);
+  Int_t nCount = (Int_t) clusterData->fCount;
+  if (clusterData->fVersion!=0) {
+    return ReadRemainingClustersCompressed(c, pData, dataSize, specification);
+  }
+  if (nCount*sizeof(AliHLTTPCRawCluster) + sizeof(AliHLTTPCRawClusterData) != dataSize) return -EBADF;
+  AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(specification);
+  AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(specification);
+
+  const AliHLTTPCRawCluster *clusters = clusterData->fClusters;
+  for (int i=0; i<nCount; i++) {
+    c.Next(slice, partition);
+    c.SetPadRow(clusters[i].GetPadRow());
+    c.SetPad(clusters[i].GetPad());
+    c.SetTime(clusters[i].GetTime());
+    c.SetSigmaY2(clusters[i].GetSigmaY2());
+    c.SetSigmaZ2(clusters[i].GetSigmaZ2());
+    c.SetCharge(clusters[i].GetCharge());
+    c.SetQMax(clusters[i].GetQMax());
+  }
+  return 0;
+}
 #endif
index 2423630..0f3fbe0 100644 (file)
@@ -32,8 +32,7 @@
 #include "AliHLTTPCTransform.h"
 #include "AliHLTTPCTrackGeometry.h"
 #include "AliHLTTPCHWCFSpacePointContainer.h"
-#include "AliHLTDataInflaterSimple.h"
-#include "AliHLTDataInflaterHuffman.h"
+#include "AliHLTErrorGuard.h"
 #include "AliRawDataHeader.h"
 #include "AliTPCclusterMI.h"
 #include "TH1I.h"
@@ -125,12 +124,15 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
   unsigned rawDataSize=0;
   unsigned hwclustersDataSize=0;
   unsigned nofClusters=0;
+
+  // check size of TPC raw data
   for (pDesc=GetFirstInputBlock(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
        pDesc!=NULL; pDesc=GetNextInputBlock()) {
     fFlags|=kHaveRawData;
     rawDataSize+=pDesc->fSize;
   }
 
+  // check size of HWCF data and add to the MonitoringContainer
   for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkHWClustersDataType);
        pDesc!=NULL; pDesc=GetNextInputBlock()) {
     fFlags|=kHaveHWClusters;
@@ -166,12 +168,29 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
 
     // read data
     AliHLTTPCDataCompressionDecoder decoder;
+    bool bHaveRawClusters=false;
+    for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RawClustersDataType());
+        pDesc!=NULL; pDesc=GetNextInputBlock()) {
+      // Note: until r51411 and v5-01-Rev-03 the compressed cluster format was sent with data
+      // type {CLUSTRAW,TPC }, the version member indicated the actual type of data
+      // transparently handled in the decoder
+      bHaveRawClusters=true;
+      iResult=decoder.ReadClustersPartition(fMonitoringContainer->BeginRemainingClusterBlock(0, pDesc->fSpecification),
+                                           reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr),
+                                           pDesc->fSize,
+                                           pDesc->fSpecification);
+      if (iResult<0) {
+       HLTError("reading of partition clusters failed with error %d", iResult);
+      }
+    }
+
+    if (!bHaveRawClusters) {
     for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
         pDesc!=NULL; pDesc=GetNextInputBlock()) {
-      iResult=decoder.ReadRemainingClustersCompressed(fMonitoringContainer->BeginRemainingClusterBlock(0, pDesc->fSpecification),
-                                             reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr),
-                                             pDesc->fSize,
-                                             pDesc->fSpecification);
+      iResult=decoder.ReadClustersPartition(fMonitoringContainer->BeginRemainingClusterBlock(0, pDesc->fSpecification),
+                                           reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr),
+                                           pDesc->fSize,
+                                           pDesc->fSpecification);
     }
 
     for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType());
@@ -181,6 +200,12 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
                                               pDesc->fSize,
                                               pDesc->fSpecification);
     }
+    } else {
+      if (GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType()) ||
+         GetFirstInputBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType())) {
+       ALIHLTERRORGUARD(5, "conflicting data blocks, monitoring histograms already filled from raw cluster data, ignoring blocks of compressed partition and track clusters");
+      }                     
+    }
 
     fMonitoringContainer->Clear();
   }