X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FBASE%2FAliHLTOUTHomerBuffer.cxx;h=a2d1fc75ebf0cf7271fdc4c452cb3eef870b0c22;hb=1dbbd625307b070a91f7d16c50f3409aa20dd3fe;hp=0f95b3ca4ba67eb1ea227e9ea13a59e856ffa293;hpb=4de7334f2d94b0375e7f1726eef6f8d5184c1ec1;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/BASE/AliHLTOUTHomerBuffer.cxx b/HLT/BASE/AliHLTOUTHomerBuffer.cxx index 0f95b3ca4ba..a2d1fc75ebf 100644 --- a/HLT/BASE/AliHLTOUTHomerBuffer.cxx +++ b/HLT/BASE/AliHLTOUTHomerBuffer.cxx @@ -19,7 +19,7 @@ /** @file AliHLTOUTHomerBuffer.cxx @author Matthias Richter @date - @brief HLTOUT data wrapper for AliRawReader. */ + @brief HLTOUT data wrapper for buffer in HOMER format. */ // see header file for class documentation // or @@ -28,16 +28,20 @@ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt #include +#include #include "AliHLTOUTHomerBuffer.h" #include "AliHLTHOMERReader.h" +#include "AliHLTHOMERLibManager.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTOUTHomerBuffer) -AliHLTOUTHomerBuffer::AliHLTOUTHomerBuffer(const AliHLTUInt8_t* pBuffer) +AliHLTOUTHomerBuffer::AliHLTOUTHomerBuffer(const AliHLTUInt8_t* pBuffer, int size) : AliHLTOUT(), + fpManager(new AliHLTHOMERLibManager), fpBuffer(pBuffer), + fSize(size), fpReader(NULL) { // see header file for class documentation @@ -45,17 +49,36 @@ AliHLTOUTHomerBuffer::AliHLTOUTHomerBuffer(const AliHLTUInt8_t* pBuffer) // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + assert(sizeof(homer_uint64)==kAliHLTComponentDataTypefIDsize); + assert(sizeof(homer_uint32)==kAliHLTComponentDataTypefOriginSize); + assert(fpManager); } AliHLTOUTHomerBuffer::~AliHLTOUTHomerBuffer() { // see header file for class documentation + if (fpManager) { + if (fpReader) fpManager->DeleteReader(fpReader); + delete fpManager; + fpManager=NULL; + fpReader=NULL; + } } int AliHLTOUTHomerBuffer::GenerateIndex() { // see header file for class documentation int iResult=0; + if (!fpReader) { + if (fpManager) { + fpReader=fpManager->OpenReaderBuffer(fpBuffer, fSize); + } + } + if (fpReader) { + iResult=ScanReader(fpReader); + } else { + iResult=-ENODEV; + } return iResult; } @@ -75,3 +98,66 @@ int AliHLTOUTHomerBuffer::GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_ } return iResult; } + +AliHLTOUT::AliHLTOUTByteOrder AliHLTOUTHomerBuffer::CheckBlockByteOrder(AliHLTUInt32_t index) +{ + if (fpReader) { + return static_cast(fpReader->GetBlockByteOrder(index)); + } + return kInvalidByteOrder; +} + +int AliHLTOUTHomerBuffer::CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type) +{ + if (fpReader) { + return fpReader->GetBlockTypeAlignment(index, static_cast(type)); + } + return -ENODATA; +} + +int AliHLTOUTHomerBuffer::ScanReader(AliHLTMonitoringReader* pReader, AliHLTUInt32_t offset) +{ + // see header file for class documentation + int iResult=0; + if (pReader && (iResult=pReader->ReadNextEvent())==0) { + AliHLTUInt32_t nofBlocks=pReader->GetBlockCnt(); + AliHLTUInt32_t tmp1=0x1; + AliHLTUInt32_t tmp2=offset; + + // first check if the offset allows to add all data blocks without exceeding the + // range + while (nofBlocks>tmp1 && tmp2>0) { + if (tmp2&0x1) { + HLTError("index range %#x exceeded for %d data blocks", nofBlocks, offset); + iResult=-ERANGE; + } + tmp2>>=1; + tmp1<<=1; + } + + // loop over data blocks + HLTDebug("generating index for %d data blocks of reader with offset %#x", nofBlocks, offset); + for (AliHLTUInt32_t i=0; i=0; i++) { + homer_uint64 id=pReader->GetBlockDataType( i ); + homer_uint32 origin=pReader->GetBlockDataOrigin( i ); + homer_uint32 spec=pReader->GetBlockDataSpec( i ); + AliHLTComponentDataType dt; + AliHLTComponent::SetDataType(dt, ByteSwap64(id), ByteSwap32(origin)); + AliHLTOUTBlockDescriptor desc(dt, spec, offset|i, this); + HLTDebug("adding block %d: %s %#x", i, AliHLTComponent::DataType2Text(dt).c_str(), spec); + iResult=AddBlockDescriptor(desc); + } + } else { + if (iResult==EBADMSG) { + HLTWarning("Format error in data block"); + iResult*=-1; + } else if (iResult==126/*ENOKEY*/) { + HLTWarning("Format error in data block: can not find HOMER block descriptor id"); + iResult*=-1; + } else { + iResult=-ENODEV; + } + } + return iResult; +} +