From 2f516e61ff457d99e9b961db640ac9ccaa7e04b2 Mon Sep 17 00:00:00 2001 From: sgorbuno Date: Fri, 19 Feb 2010 10:58:20 +0000 Subject: [PATCH] Now the TPC clusterfinder produces a special compressed input for the CA tracker, in order to reduce the network traffic. --- .../AliHLTTPCClusterFinderComponent.cxx | 35 +++++ ...liHLTTPCCAInputDataCompressorComponent.cxx | 147 ++++++++++-------- .../AliHLTTPCCAInputDataCompressorComponent.h | 7 + .../AliHLTTPCCATrackerComponent.cxx | 22 +-- 4 files changed, 140 insertions(+), 71 deletions(-) diff --git a/HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx b/HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx index a44fa788305..b860ad46de1 100644 --- a/HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx +++ b/HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx @@ -42,6 +42,8 @@ using namespace std; #include "AliTPCcalibDB.h" #include "AliTPCCalPad.h" #include "AliTPCParam.h" +#include "AliHLTTPCCAInputDataCompressorComponent.h" +#include "AliHLTTPCCADef.h" #include #include @@ -155,6 +157,7 @@ int AliHLTTPCClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeL tgtList.clear(); tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType); tgtList.push_back(kAliHLTDataTypeHwAddr16); + tgtList.push_back(AliHLTTPCCADefinitions::fgkCompressedInputDataType); return tgtList.size(); } @@ -498,6 +501,38 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev tSize+=nHWAdd*sizeof(AliHLTUInt16_t); } + { // compressed output for the CA tracker + + AliHLTUInt32_t dSize = 0; + + int ret = AliHLTTPCCAInputDataCompressorComponent::Compress( (AliHLTTPCClusterData*)( outputPtr + bd.fOffset ), + size - tSize, + outputPtr+tSize, + dSize ); + + if ( ret!=0 || tSize + dSize > size ) + { + Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data", + "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", + tSize + dSize, size ); + iResult=-ENOSPC; + break; + } + + AliHLTComponentBlockData bdCompressed; + FillBlockData( bdCompressed ); + bdCompressed.fOffset = tSize ; + bdCompressed.fSize = dSize; + bdCompressed.fSpecification = iter->fSpecification; + bdCompressed.fDataType = AliHLTTPCCADefinitions::fgkCompressedInputDataType; + outputBlocks.push_back( bdCompressed ); + + tSize += dSize; + outBPtr += dSize; + outPtr = (AliHLTTPCClusterData*)outBPtr; + } + + if(fDoMC){ Int_t maxNumberOfClusterMCInfo = (Int_t)((size-tSize)/sizeof(AliHLTTPCClusterFinder::ClusterMCInfo)-1); AliHLTTPCClusterFinder::ClusterMCInfo* outputMCInfo= (AliHLTTPCClusterFinder::ClusterMCInfo*)(outputPtr+tSize); diff --git a/HLT/TPCLib/tracking-ca/AliHLTTPCCAInputDataCompressorComponent.cxx b/HLT/TPCLib/tracking-ca/AliHLTTPCCAInputDataCompressorComponent.cxx index 6b64aa31800..d1cc1239f0d 100644 --- a/HLT/TPCLib/tracking-ca/AliHLTTPCCAInputDataCompressorComponent.cxx +++ b/HLT/TPCLib/tracking-ca/AliHLTTPCCAInputDataCompressorComponent.cxx @@ -188,71 +188,20 @@ int AliHLTTPCCAInputDataCompressorComponent::DoEvent if( minSlice>AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) minSlice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ; if( maxSlicefSize; - AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); - - AliHLTTPCCACompressedCluster *outCluster = (AliHLTTPCCACompressedCluster*)( outputPtr+outTotalSize ); - AliHLTTPCCACompressedClusterRow *outRow = 0; - - Int_t dSize = 0; - UShort_t oldId = 0; - for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ){ - AliHLTTPCSpacePointData *cluster = &( inPtrSP->fSpacePoints[i] ); - UInt_t origId = cluster->fID; - UInt_t patch = (origId>>22)&0x7; - UInt_t slice = origId>>25; - UInt_t row = cluster->fPadRow; - Double_t rowX = AliHLTTPCTransform::Row2X( row ); - row = row - AliHLTTPCTransform::GetFirstRow( patch ); - UShort_t id = (UShort_t)( (slice<<10) +(patch<<6) + row ); - if( i==0 || id!= oldId ){ - // fill new row header - outRow = (AliHLTTPCCACompressedClusterRow*) outCluster; - outCluster = outRow->fClusters; - dSize+= ( ( AliHLTUInt8_t * )outCluster ) - (( AliHLTUInt8_t * )outRow); - if ( outTotalSize + dSize > (int) maxBufferSize ) break; - outRow->fSlicePatchRowID = id; - outRow->fNClusters = 0; - oldId = id; - //cout<<"Fill row: s "<fX<<":"<fX - rowX )*1.e4 + 32768.; - Double_t y = (cluster->fY)*1.e4 + 8388608.; - Double_t z = (cluster->fZ)*1.e4 + 8388608.; - - // truncate if necessary - if( x<0 ) x = 0; else if( x > 0x0000FFFF ) x = 0x0000FFFF; - if( y<0 ) y = 0; else if( y > 0x00FFFFFF ) y = 0x00FFFFFF; - if( z<0 ) z = 0; else if( z > 0x00FFFFFF ) z = 0x00FFFFFF; - - UInt_t ix0 = ( (UInt_t) x )&0x000000FF; - UInt_t ix1 = (( (UInt_t) x )&0x0000FF00 )>>8; - UInt_t iy = ( (UInt_t) y )&0x00FFFFFF; - UInt_t iz = ( (UInt_t) z )&0x00FFFFFF; - - dSize+= sizeof( AliHLTTPCCACompressedCluster ); - if ( outTotalSize + dSize > (int) maxBufferSize ) break; - outCluster->fP0 = (ix0<<24) + iy; - outCluster->fP1 = (ix1<<24) + iz; - outCluster++; - outRow->fNClusters++; - //cout<<"clu "<fNClusters-1<<": "<fX<<" "<fY<<" "<fZ<<" "<fID<fPtr ), maxBufferSize - outTotalSize, + outputPtr+outTotalSize, + dSize ); - if ( outTotalSize + dSize > (int) maxBufferSize ) { - HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize, outTotalSize+ dSize ); - ret = -ENOSPC; + if ( ret!=0 ){ + HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize ); break; } + AliHLTComponentBlockData bd; FillBlockData( bd ); bd.fOffset = outTotalSize; @@ -260,7 +209,7 @@ int AliHLTTPCCAInputDataCompressorComponent::DoEvent bd.fSpecification = iter->fSpecification; bd.fDataType = GetOutputDataType(); outputBlocks.push_back( bd ); - outTotalSize+=dSize; + outTotalSize+=dSize; } size = outTotalSize; @@ -285,3 +234,79 @@ int AliHLTTPCCAInputDataCompressorComponent::DoEvent } + +int AliHLTTPCCAInputDataCompressorComponent::Compress( AliHLTTPCClusterData* inputPtr, + AliHLTUInt32_t maxBufferSize, + AliHLTUInt8_t* outputPtr, + AliHLTUInt32_t& outputSize + ) +{ + // Preprocess the data for CA Slice Tracker + + Int_t ret = 0; + outputSize = 0; + + AliHLTTPCCACompressedCluster *outCluster = (AliHLTTPCCACompressedCluster*)( outputPtr ); + AliHLTTPCCACompressedClusterRow *outRow = 0; + + UShort_t oldId = 0; + + for ( unsigned int i = 0; i < inputPtr->fSpacePointCnt; i++ ){ + AliHLTTPCSpacePointData *cluster = &( inputPtr->fSpacePoints[i] ); + UInt_t origId = cluster->fID; + UInt_t patch = (origId>>22)&0x7; + UInt_t slice = origId>>25; + UInt_t row = cluster->fPadRow; + Double_t rowX = AliHLTTPCTransform::Row2X( row ); + row = row - AliHLTTPCTransform::GetFirstRow( patch ); + UShort_t id = (UShort_t)( (slice<<10) +(patch<<6) + row ); + if( i==0 || id!= oldId ){ + // fill new row header + outRow = (AliHLTTPCCACompressedClusterRow*) outCluster; + outCluster = outRow->fClusters; + outputSize+= ( ( AliHLTUInt8_t * )outCluster ) - (( AliHLTUInt8_t * )outRow); + if ( outputSize > (int) maxBufferSize ){ + ret = -ENOSPC; + outputSize=0; + break; + } + outRow->fSlicePatchRowID = id; + outRow->fNClusters = 0; + oldId = id; + //cout<<"Fill row: s "<fX<<":"<fX - rowX )*1.e4 + 32768.; + Double_t y = (cluster->fY)*1.e4 + 8388608.; + Double_t z = (cluster->fZ)*1.e4 + 8388608.; + + // truncate if necessary + if( x<0 ) x = 0; else if( x > 0x0000FFFF ) x = 0x0000FFFF; + if( y<0 ) y = 0; else if( y > 0x00FFFFFF ) y = 0x00FFFFFF; + if( z<0 ) z = 0; else if( z > 0x00FFFFFF ) z = 0x00FFFFFF; + + UInt_t ix0 = ( (UInt_t) x )&0x000000FF; + UInt_t ix1 = (( (UInt_t) x )&0x0000FF00 )>>8; + UInt_t iy = ( (UInt_t) y )&0x00FFFFFF; + UInt_t iz = ( (UInt_t) z )&0x00FFFFFF; + + outputSize+= sizeof( AliHLTTPCCACompressedCluster ); + if ( outputSize > (int) maxBufferSize ){ + outputSize = 0; + ret = -ENOSPC; + break; + } + outCluster->fP0 = (ix0<<24) + iy; + outCluster->fP1 = (ix1<<24) + iz; + outCluster++; + outRow->fNClusters++; + //cout<<"clu "<fNClusters-1<<": "<fX<<" "<fY<<" "<fZ<<" "<fID<fDataType != AliHLTTPCDefinitions::fgkClustersDataType - && iter->fDataType != AliHLTTPCCADefinitions::fgkCompressedInputDataType + if ( // iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType && + iter->fDataType != AliHLTTPCCADefinitions::fgkCompressedInputDataType ) continue; slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); @@ -552,11 +552,11 @@ int AliHLTTPCCATrackerComponent::DoEvent for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) { iter = blocks + ndx; if ( slice != AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue; - if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){ - AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); - nClustersTotal += inPtrSP->fSpacePointCnt; - } - else if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){ + //if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){ + //AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); + //nClustersTotal += inPtrSP->fSpacePointCnt; + //} else + if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){ const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr; while( inPtr< ((const AliHLTUInt8_t *) iter->fPtr) + iter->fSize ){ AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr; @@ -597,6 +597,7 @@ int AliHLTTPCCATrackerComponent::DoEvent iter = blocks + ndx; int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); int nPatchClust = 0; + /* if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){ AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); nPatchClust = inPtrSP->fSpacePointCnt; @@ -609,8 +610,9 @@ int AliHLTTPCCATrackerComponent::DoEvent } clusterData[islice].ReadCluster( c->fID, c->fPadRow, c->fX, c->fY, c->fZ, c->fCharge ); } - } - else if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){ + } else + */ + if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){ const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr; nPatchClust=0; while( inPtr< ((const AliHLTUInt8_t *)iter->fPtr) + iter->fSize ){ -- 2.43.5