implementing association of cluster MC labels and cluster ids to the unpacked cluster...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Dec 2011 22:04:28 +0000 (22:04 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Dec 2011 22:04:28 +0000 (22:04 +0000)
HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx
HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h

index 6e6fdda..2c14dc8 100644 (file)
@@ -35,6 +35,10 @@ AliHLTTPCDataCompressionDecoder::AliHLTTPCDataCompressionDecoder()
   , fpDataInflaterPartition(NULL)
   , fpDataInflaterTrack(NULL)
   , fpClusterMerger(NULL)
+  , fRemainingClusterIds()
+  , fTrackModelClusterIds()
+  , fCurrentClusterIds(NULL)
+  , fClusterMCData()
 {
   /// constructor
 }
@@ -126,3 +130,113 @@ AliHLTDataInflater* AliHLTTPCDataCompressionDecoder::CreateInflater(int deflater
   }
   return NULL;
 }
+
+int AliHLTTPCDataCompressionDecoder::InitPartitionClusterDecoding(AliHLTUInt32_t specification)
+{
+  /// init the decoding of partition cluster block
+  AliHLTUInt8_t slice=AliHLTTPCDefinitions::GetMinSliceNr(specification);
+  AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(specification);
+  unsigned index=slice*AliHLTTPCTransform::GetNumberOfPatches()+partition;
+  if (index<fRemainingClusterIds.size())
+    fCurrentClusterIds=&fRemainingClusterIds[index];
+  else
+    fCurrentClusterIds=NULL;
+  return 0;
+}
+
+int AliHLTTPCDataCompressionDecoder::InitTrackModelClusterClusterDecoding()
+{
+  /// init the decoding of track model cluster block
+  if (fTrackModelClusterIds.fIds && fTrackModelClusterIds.fSize>0)
+    fCurrentClusterIds=&fTrackModelClusterIds;
+  else
+    fCurrentClusterIds=NULL;
+  return 0;
+}
+
+int AliHLTTPCDataCompressionDecoder::AddClusterMCData(const AliHLTComponentBlockData* pDesc)
+{
+  /// add cluster mc data block
+  if (!pDesc) return -EINVAL;
+  if (pDesc->fDataType==AliHLTTPCDefinitions::AliHLTDataTypeClusterMCInfo()) {
+    AliHLTUInt8_t slice=AliHLTTPCDefinitions::GetMinSliceNr(pDesc->fSpecification);
+    AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(pDesc->fSpecification);
+    unsigned index=slice*AliHLTTPCTransform::GetNumberOfPatches()+partition;
+    if (fClusterMCData.size()<=index) {
+      if ((int)fClusterMCData.size()<AliHLTTPCTransform::GetNSlice()*AliHLTTPCTransform::GetNumberOfPatches()) {
+       fClusterMCData.resize(AliHLTTPCTransform::GetNSlice()*AliHLTTPCTransform::GetNumberOfPatches(), NULL);
+      } else {
+       fClusterMCData.resize(index+1, NULL);
+      }
+    }
+    if (pDesc->fSize<sizeof(AliHLTTPCClusterMCData)) return -EINVAL;
+    const AliHLTTPCClusterMCData* pData=reinterpret_cast<const AliHLTTPCClusterMCData*>(pDesc->fPtr);
+    unsigned nLabels = pData->fCount;
+    if (nLabels*sizeof(AliHLTTPCClusterMCLabel) + sizeof(AliHLTTPCClusterMCData) != pDesc->fSize) {
+      return -EINVAL;
+    }
+    fClusterMCData[index]=pData;
+    return 0;
+  }
+  return -ENODATA;
+}
+
+int AliHLTTPCDataCompressionDecoder::AddClusterIds(const AliHLTComponentBlockData* pDesc)
+{
+  /// add cluster id block for remaining or track model clusters
+  if (!pDesc) return -EINVAL;
+  if (pDesc->fDataType==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
+    fTrackModelClusterIds.fIds=reinterpret_cast<AliHLTUInt32_t*>(pDesc->fPtr);
+    fTrackModelClusterIds.fSize=pDesc->fSize/sizeof(AliHLTUInt32_t);
+    return 0;
+  }
+  if (pDesc->fDataType==AliHLTTPCDefinitions::RemainingClusterIdsDataType()) {
+    AliHLTUInt8_t slice=AliHLTTPCDefinitions::GetMinSliceNr(pDesc->fSpecification);
+    AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(pDesc->fSpecification);
+    unsigned index=slice*AliHLTTPCTransform::GetNumberOfPatches()+partition;
+    if (fRemainingClusterIds.size()<=index) {
+      if ((int)fRemainingClusterIds.size()<AliHLTTPCTransform::GetNSlice()*AliHLTTPCTransform::GetNumberOfPatches()) {
+       fRemainingClusterIds.resize(AliHLTTPCTransform::GetNSlice()*AliHLTTPCTransform::GetNumberOfPatches());
+      } else {
+       fRemainingClusterIds.resize(index+1);
+      }
+    }
+    fRemainingClusterIds[index].fIds=reinterpret_cast<AliHLTUInt32_t*>(pDesc->fPtr);
+    fRemainingClusterIds[index].fSize=pDesc->fSize/sizeof(AliHLTUInt32_t);
+    return 0;
+  }
+  return -ENODATA;
+}
+
+AliHLTUInt32_t AliHLTTPCDataCompressionDecoder::GetClusterId(int clusterNo) const
+{
+  /// get the cluster id from the current cluster id block
+  if (!fCurrentClusterIds ||
+      (int)fCurrentClusterIds->fSize<=clusterNo ||
+      clusterNo<0)
+    return kAliHLTVoidDataSpec;
+  return fCurrentClusterIds->fIds[clusterNo];
+}
+
+const AliHLTTPCClusterMCLabel* AliHLTTPCDataCompressionDecoder::GetMCLabel(AliHLTUInt32_t clusterId) const
+{
+  /// get MC data for a cluster Id
+  if (clusterId==kAliHLTVoidDataSpec) return NULL;
+
+  unsigned slice=AliHLTTPCSpacePointData::GetSlice(clusterId);
+  unsigned partition=AliHLTTPCSpacePointData::GetPatch(clusterId);
+  unsigned number=AliHLTTPCSpacePointData::GetNumber(clusterId);
+  if ((int)slice>=AliHLTTPCTransform::GetNSlice() ||
+      (int)partition>=AliHLTTPCTransform::GetNumberOfPatches()) return NULL;
+  unsigned index=slice*AliHLTTPCTransform::GetNumberOfPatches()+partition;
+  if (fClusterMCData.size()<=index ||
+      fClusterMCData[index]==NULL ||
+      fClusterMCData[index]->fCount<=number) return NULL;
+
+  return &(fClusterMCData[index]->fLabels[number]);
+}
+
+void AliHLTTPCDataCompressionDecoder::Clear(const char* /*option*/)
+{
+  // cleanup
+}
index 7febea2..0a8f69c 100644 (file)
@@ -22,6 +22,7 @@
 #include "AliHLTTPCTrackGeometry.h"
 #include "AliHLTDataInflater.h"
 #include "AliHLTTPCHWClusterMerger.h"
+#include <vector>
 
 /**
  * @class AliHLTTPCDataCompressionDecoder
@@ -55,6 +56,21 @@ class AliHLTTPCDataCompressionDecoder : public AliHLTLogging {
   void SetVerbosity(int verbosity) {fVerbosity=verbosity;}
   void EnableClusterMerger() {if (!fpClusterMerger) fpClusterMerger=new AliHLTTPCHWClusterMerger;}
 
+  int InitPartitionClusterDecoding(AliHLTUInt32_t specification);
+  int InitTrackModelClusterClusterDecoding();
+  int AddClusterMCData(const AliHLTComponentBlockData* pDesc);
+  int AddClusterIds(const AliHLTComponentBlockData* pDesc);
+  AliHLTUInt32_t GetClusterId(int clusterNo) const;
+  const AliHLTTPCClusterMCLabel* GetMCLabel(AliHLTUInt32_t clusterId) const;
+
+  void Clear(const char* option);
+
+  struct AliClusterIdBlock {
+    AliClusterIdBlock() : fIds(NULL), fSize(0) {}
+    AliHLTUInt32_t* fIds; //!
+    AliHLTUInt32_t  fSize; //!
+  };
+
  protected:
  private:
   AliHLTTPCDataCompressionDecoder(const AliHLTTPCDataCompressionDecoder&);
@@ -66,6 +82,11 @@ class AliHLTTPCDataCompressionDecoder : public AliHLTLogging {
   AliHLTDataInflater* fpDataInflaterTrack; //! instance of inflater for track clusters
   AliHLTTPCHWClusterMerger* fpClusterMerger; //! merger instance
 
+  vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
+  AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
+  AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
+  vector<const AliHLTTPCClusterMCData*> fClusterMCData; //! references to MC data blocks
+
   ClassDef(AliHLTTPCDataCompressionDecoder, 0)
 };
 
@@ -115,6 +136,9 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
   int iResult=0;
   if (!pInflater) return -EINVAL;
 
+  if ((iResult= InitPartitionClusterDecoding(specification))<0)
+    return iResult;
+
   AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(specification);
   AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(specification);
   // the compressed format stores the difference of the local row number in
@@ -200,12 +224,11 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
       {rawCluster.SetQMax(value); break;}
     }
     if (parameterId>=AliHLTTPCDefinitions::kLast) {
+      AliHLTUInt32_t id=GetClusterId(decodedClusterCnt);
+      const AliHLTTPCClusterMCLabel* pMC=GetMCLabel(id);
       if (fpClusterMerger && fpClusterMerger->CheckCandidate(slice, partition, rawCluster)) {
-         fpClusterMerger->AddCandidate(slice, partition, ~AliHLTUInt32_t(0), rawCluster);
-     } else {
-       // FIXME: afetr introcucing the temporary rawCluster, the
-       // interface can be changed to set all properties in one
-       // call
+       fpClusterMerger->AddCandidate(slice, partition, id, rawCluster, pMC);
+      } else {
       c.Next(slice, partition);
       c.SetPadRow(rawCluster.GetPadRow()+rowOffset);
       c.SetPad(rawCluster.GetPad());
@@ -214,6 +237,7 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
       c.SetSigmaZ2(rawCluster.GetSigmaZ2());
       c.SetCharge(rawCluster.GetCharge());
       c.SetQMax(rawCluster.GetQMax());
+      if (pMC) c.SetMC(pMC);
       outClusterCnt++;
       }
       bNextCluster=true;
@@ -242,9 +266,7 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
           i!=fpClusterMerger->end(); i++) {
        c.Next((*i).GetSlice(), (*i).GetPartition());
        const AliHLTTPCRawCluster& mergedCluster=(*i).GetCluster();
-       // FIXME: afetr introcucing the temporary rawCluster, the
-       // interface can be changed to set all properties in one
-       // call
+       const AliHLTTPCClusterMCLabel& mc=(*i).MCLabel();
        c.SetPadRow(mergedCluster.GetPadRow()+rowOffset);
        c.SetPad(mergedCluster.GetPad());
        c.SetTime(mergedCluster.GetTime());
@@ -252,6 +274,7 @@ int AliHLTTPCDataCompressionDecoder::ReadRemainingClustersCompressed(T& c, AliHL
        c.SetSigmaZ2(mergedCluster.GetSigmaZ2());
        c.SetCharge(mergedCluster.GetCharge());
        c.SetQMax(mergedCluster.GetQMax());
+       c.SetMC(&mc);
        outClusterCnt++;
        remainingCnt++;
       }
@@ -361,6 +384,9 @@ int AliHLTTPCDataCompressionDecoder::ReadTrackClustersCompressed(T& c, AliHLTDat
   int iResult=0;
   if (!pInflater || !pTrackPoints) return -EINVAL;
 
+  if ((iResult= InitTrackModelClusterClusterDecoding())<0)
+    return iResult;
+
   const vector<AliHLTTrackGeometry::AliHLTTrackPoint>& rawTrackPoints=pTrackPoints->GetRawPoints();
   vector<AliHLTTrackGeometry::AliHLTTrackPoint>::const_iterator currentTrackPoint=rawTrackPoints.begin();