From: richterm Date: Fri, 11 Jan 2008 09:12:50 +0000 (+0000) Subject: scanning of handlers for HLTOUT blocks added X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=5db0e774fdf0dcd25f422fb1d1296564579cf03a scanning of handlers for HLTOUT blocks added --- diff --git a/HLT/BASE/AliHLTOUT.cxx b/HLT/BASE/AliHLTOUT.cxx index 0f3f381e435..2653dcb540c 100644 --- a/HLT/BASE/AliHLTOUT.cxx +++ b/HLT/BASE/AliHLTOUT.cxx @@ -28,6 +28,7 @@ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt #include +#include #include "AliHLTOUT.h" /** ROOT macro for the implementation of ROOT specific class methods */ @@ -40,7 +41,8 @@ AliHLTOUT::AliHLTOUT() fFlags(0), fBlockDescList(), fCurrent(fBlockDescList.begin()), - fpBuffer(NULL) + fpBuffer(NULL), + fDataHandlers() { // see header file for class documentation // or @@ -62,19 +64,32 @@ AliHLTOUT::~AliHLTOUT() // see header file for class documentation } +int AliHLTOUT::Init() +{ + // see header file for class documentation + int iResult=0; + if ((iResult=GenerateIndex())>=0) { + if ((iResult=InitHandlers())>=0) { + } + } + return iResult; +} + int AliHLTOUT::GetNofDataBlocks() { // see header file for class documentation return fBlockDescList.size(); } -int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec) +int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec, + AliHLTModuleAgent::AliHLTOUTHandlerType handlerType) { // see header file for class documentation if (CheckStatusFlag(kLocked)) return -EPERM; fCurrent=fBlockDescList.begin(); fSearchDataType=dt; fSearchSpecification=spec; + //fSearchHandlerType=handlerType; return FindAndSelectDataBlock(); } @@ -93,7 +108,8 @@ int AliHLTOUT::FindAndSelectDataBlock() int iResult=-ENOENT; while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) { if ((fSearchDataType==kAliHLTAnyDataType || (*fCurrent)==fSearchDataType) && - fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) { + fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification && + 1/*fSearchHandlerType==AliHLTModuleAgent::kUnknownOutput*/) { iResult=0; // TODO: check the byte order on the current system and the byte order of the // data block, print warning when missmatch and user did not check @@ -128,6 +144,13 @@ int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32 return iResult; } +AliHLTUInt32_t AliHLTOUT::GetDataBlockIndex() +{ + // see header file for class documentation + assert(0); // not implemented + return AliHLTOUTInvalidIndex; +} + int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) { // see header file for class documentation @@ -165,6 +188,7 @@ int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc) AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder() { + // see header file for class documentation if (fCurrent!=fBlockDescList.end()) { SetStatusFlag(kByteOrderChecked); AliHLTOUT::AliHLTOUTByteOrder_t order=CheckBlockByteOrder((*fCurrent).GetIndex()); @@ -175,6 +199,7 @@ AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder() int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type) { + // see header file for class documentation if (fCurrent!=fBlockDescList.end()) { SetStatusFlag(kAlignmentChecked); int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type); @@ -182,3 +207,106 @@ int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type) } return -ENOENT; } + +int AliHLTOUT::InitHandlers() +{ + // see header file for class documentation + int iResult=0; + AliHLTOUTIndexList remnants; + for (iResult=SelectFirstDataBlock(kAliHLTAnyDataType, kAliHLTVoidDataSpec); iResult>0; iResult=SelectNextDataBlock()) { + remnants.push_back(GetDataBlockIndex()); + AliHLTComponentDataType dt=kAliHLTVoidDataType; + AliHLTUInt32_t spec=kAliHLTVoidDataSpec; + if ((iResult=GetDataBlockDescription(dt, spec))<0) break; + for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); pAgent && iResult>=0; pAgent=AliHLTModuleAgent::GetNextAgent()) { + AliHLTModuleAgent::AliHLTOUTHandlerDesc handlerDesc; + if (pAgent->GetHandlerDescription(dt, spec, &handlerDesc)>0) { + AliHLTOUTHandlerListEntry entry(pAgent->GetOutputHandler(dt, spec), handlerDesc, pAgent, GetDataBlockIndex()); + iResult=InsertHandler(entry); + remnants.pop_back(); + break; + } + } + } + if (remnants.size()>0) { + HLTWarning("no handlers found for %d data blocks out of %d", remnants.size(), GetNofDataBlocks()); + vector::iterator block=fBlockDescList.begin(); + for (AliHLTOUTIndexList::iterator element=remnants.begin(); element!=remnants.end(); element++) { + for (int trials=0; trials<2; trials++) { + do { + // we start searching the index from the current position in the block list + if ((*block).GetIndex()==*element) break; + } while ((++block)!=fBlockDescList.end()); + if (block==fBlockDescList.end()) { + // rewind and try again + block=fBlockDescList.begin(); + } + } + assert(block!=fBlockDescList.end()); + if (block!=fBlockDescList.end()) { + HLTDebug(" %s", AliHLTComponent::DataType2Text((AliHLTComponentDataType)*block).c_str()); + } + } + } + return iResult; +} + +int AliHLTOUT::InsertHandler(const AliHLTOUTHandlerListEntry &entry) +{ + // see header file for class documentation + int iResult=0; + vector::iterator element=fDataHandlers.begin(); + while (element!=fDataHandlers.end()) { + if (entry==(*element)) break; + element++; + } + if (element==fDataHandlers.end()) { + fDataHandlers.push_back(entry); + } else { + + } + return iResult; +} + +AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler, + AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc, + AliHLTModuleAgent* pAgent, + AliHLTUInt32_t index) + : + fpHandler(pHandler), + fHandlerDesc(handlerDesc), + fpAgent(pAgent), + fBlocks() +{ + // see header file for class documentation + fBlocks.push_back(index); +} + +AliHLTOUT::AliHLTOUTHandlerListEntry::AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src) + : + fpHandler(src.fpHandler), + fHandlerDesc(src.fHandlerDesc), + fpAgent(src.fpAgent), + fBlocks() +{ + // see header file for class documentation + fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end()); +} + +AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTHandlerListEntry::operator=(const AliHLTOUTHandlerListEntry& src) +{ + // see header file for class documentation + fpHandler=src.fpHandler; + fHandlerDesc=src.fHandlerDesc; + fpAgent=src.fpAgent; + fBlocks.assign(src.fBlocks.begin(), src.fBlocks.end()); + return *this; +} + +AliHLTUInt32_t AliHLTOUT::AliHLTOUTHandlerListEntry::operator[](int i) const { + return fBlocks.size()>i?fBlocks[i]:AliHLTOUTInvalidIndex; +} + +void AliHLTOUT::AliHLTOUTHandlerListEntry::AddIndex(AliHLTUInt32_t index) { + fBlocks.push_back(index); +} diff --git a/HLT/BASE/AliHLTOUT.h b/HLT/BASE/AliHLTOUT.h index 4586b44b67d..3d59bc3ed5f 100644 --- a/HLT/BASE/AliHLTOUT.h +++ b/HLT/BASE/AliHLTOUT.h @@ -3,24 +3,26 @@ #ifndef ALIHLTOUT_H #define ALIHLTOUT_H -/* This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* See cxx source for full Copyright notice * /** @file AliHLTOUT.h @author Matthias Richter @date @brief The control class for HLTOUT data. +*/ -// see below for class documentation -// or -// refer to README to build package -// or -// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt - - */ #include #include "AliHLTLogging.h" +#include "AliHLTModuleAgent.h" + +class AliHLTOUTHandler; +class AliHLTOUTHandlerDesc; + +#define AliHLTOUTInvalidIndex (~(AliHLTUInt32_t)0) + +typedef vector AliHLTOUTIndexList; /** * @class AliHLTOUT @@ -38,6 +40,14 @@ class AliHLTOUT : public AliHLTLogging { /** standard destructor */ virtual ~AliHLTOUT(); + /** + * Init for processing. + * The HLTOUT is scanned for all available data blocks and the + * AliHLTOUTHandler objects for the data blocks are created according + * to the module agents (see AliHLTModuleAgent). + */ + int Init(); + /** * Get number of data blocks in the HLTOUT data */ @@ -47,19 +57,23 @@ class AliHLTOUT : public AliHLTLogging { * Select the first data block of a certain data type and specification. * The selection criteria can be of kAliHLTAnyDataType and/or * kAliHLTVoidDataSpec in order to be ignored and just match any data block. + * + * The search criteria can be combined with a handler type (e.g. kRawReader) * @param dt [in] data type to match
* @param spec [in] data specification to match
- * @return identifier >=0 if success, neg. error code if failed
- * -ENOENT if no block found
+ * @param handlerType [in] type of the handler + * @return identifier >0 if success, 0 if no block found
+ * neg. error code if failed
* -EPERM if access denied (object locked) */ - int SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec); + int SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec, + AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=AliHLTModuleAgent::kUnknownOutput); /** * Select the next data block of data type and specification of the previous * call to @ref SelectFirstDataBlock. - * @return identifier >=0 if success, neg. error code if failed
- * -ENOENT if no block found
+ * @return identifier >0 if success, 0 if no block found
+ * neg. error code if failed
* -EPERM if access denied (object locked) */ int SelectNextDataBlock(); @@ -71,6 +85,12 @@ class AliHLTOUT : public AliHLTLogging { */ int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec); + /** + * Get the index of the current data block. + * @return index, AliHLTOUTInvalidIndex if no block selected + */ + AliHLTUInt32_t GetDataBlockIndex(); + /** * Get buffer of the selected data block. * @param pBuffer [out] buffer of the selected data block @@ -218,12 +238,61 @@ class AliHLTOUT : public AliHLTLogging { kAlignmentWarning = 0x20 }; + class AliHLTOUTHandlerListEntry { + public: + AliHLTOUTHandlerListEntry(AliHLTOUTHandler* pHandler, + AliHLTModuleAgent::AliHLTOUTHandlerDesc& handlerDesc, + AliHLTModuleAgent* pAgent, + AliHLTUInt32_t index); + + /** copy constructor for vector handling */ + AliHLTOUTHandlerListEntry(const AliHLTOUTHandlerListEntry& src); + + /** assignment operator for vector handling */ + AliHLTOUTHandlerListEntry& operator=(const AliHLTOUTHandlerListEntry& src); + + ~AliHLTOUTHandlerListEntry(); + + operator AliHLTOUTHandler*() const {return fpHandler;} + operator AliHLTModuleAgent::AliHLTOUTHandlerDesc&() {return fHandlerDesc;} + operator AliHLTModuleAgent*() const {return fpAgent;} + + bool operator==(const AliHLTOUTHandlerListEntry& entry) const; + + AliHLTUInt32_t operator[](int i) const; + + void AddIndex(AliHLTUInt32_t index); + + private: + /** standard constructor prohibited */ + AliHLTOUTHandlerListEntry(); + + /** pointer to the handler */ + AliHLTOUTHandler* fpHandler; //! transient + + /** pointer to handler description */ + AliHLTModuleAgent::AliHLTOUTHandlerDesc fHandlerDesc; //! transient + + /** pointer to module agent */ + AliHLTModuleAgent* fpAgent; //! transient + + /** list of block indexes */ + AliHLTOUTIndexList fBlocks; //!transient + }; + /** * Generate the index of the HLTOUT data. * Must be implemented by the child classes. */ virtual int GenerateIndex()=0; + /** + * Find AliHLTOUTHandler objects for the data blocks. + * The available AliHLTModuleAgents are probed whether they provide + * handlers for data processing. + */ + int InitHandlers(); + /** * Get the data buffer * @param index [in] index of the block @@ -275,6 +344,17 @@ class AliHLTOUT : public AliHLTLogging { */ int CheckStatusFlag(unsigned int flag) const {return (fFlags&flag)==flag;} + /** + * Insert a handler item. + * The current list entries are checked if the handler is already in + * the list. It is added if not in the list, otherwise the block index + * is added to the existing entry. + * @param entry handler list entry + * @return 0 if added, EEXIST (non negative!) if merged with existing entry
+ * neg. error code if failed + */ + int InsertHandler(const AliHLTOUTHandlerListEntry &entry); + /** data type for the current block search, set from @ref SelectFirstDataBlock */ AliHLTComponentDataType fSearchDataType; //!transient @@ -293,6 +373,9 @@ class AliHLTOUT : public AliHLTLogging { /** data buffer under processing */ const AliHLTUInt8_t* fpBuffer; //!transient - ClassDef(AliHLTOUT, 0) + /** list of AliHLTOUTHandlers */ + vector fDataHandlers; // !transient + + ClassDef(AliHLTOUT, 1) }; #endif diff --git a/HLT/sim/AliHLTOUTComponent.cxx b/HLT/sim/AliHLTOUTComponent.cxx index f0655d5d8d9..6b93d253d37 100644 --- a/HLT/sim/AliHLTOUTComponent.cxx +++ b/HLT/sim/AliHLTOUTComponent.cxx @@ -125,7 +125,8 @@ int AliHLTOUTComponent::DoInit( int argc, const char** argv ) if (pWriter) { fWriters.push_back(pWriter); } else { - iResult=-ENOMEM; + HLTError("can nor open HOMER writer"); + iResult=-ENODEV; break; } } @@ -178,6 +179,7 @@ int AliHLTOUTComponent::DumpEvent( const AliHLTComponentEventData& evtData, } } + HLTInfo("added blocks to HOMER writer"); return iResult; } @@ -186,6 +188,7 @@ int AliHLTOUTComponent::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEven // see header file for class documentation int iResult=0; if (fWriters.size()==0) return 0; + HLTInfo("writing files"); // search for the writer with the biggest data volume in order to allocate the // output buffer of sufficient size