From 4e2384103b44e04cfd6fe7c9521d3be7db6d0408 Mon Sep 17 00:00:00 2001 From: richterm Date: Tue, 6 Dec 2011 22:04:28 +0000 Subject: [PATCH] implementing association of cluster MC labels and cluster ids to the unpacked clusters (code copied in large parts from AliHLTTPCClusterAccessHLTOUT::AliTPCclusterMIContainer and going to be obsolete there) --- .../comp/AliHLTTPCDataCompressionDecoder.cxx | 114 ++++++++++++++++++ .../comp/AliHLTTPCDataCompressionDecoder.h | 42 +++++-- 2 files changed, 148 insertions(+), 8 deletions(-) diff --git a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx index 6e6fdda9671..2c14dc8eb08 100644 --- a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx +++ b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx @@ -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 (index0) + 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()fSize(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(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()(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 +} diff --git a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h index 7febea2646e..0a8f69c0bb4 100644 --- a/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h +++ b/HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.h @@ -22,6 +22,7 @@ #include "AliHLTTPCTrackGeometry.h" #include "AliHLTDataInflater.h" #include "AliHLTTPCHWClusterMerger.h" +#include /** * @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 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 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& rawTrackPoints=pTrackPoints->GetRawPoints(); vector::const_iterator currentTrackPoint=rawTrackPoints.begin(); -- 2.43.0