From 48abe484c5b83b9a29c58ef691c8246fc074e8a2 Mon Sep 17 00:00:00 2001 From: richterm Date: Thu, 7 Aug 2008 11:55:17 +0000 Subject: [PATCH] - adding event type data block {EVENTTYP:PRIV} to component input blocks to be consistent with PubSub - AliHLTComponent: calculating id for component statistics entry from chain id using a crc algorithm - removing the SOR/EOR event publishing from the AliHLTDataSource - AliHLTTask: make component initialization a virtual fuction to be re-implemnted by child classes --- HLT/BASE/AliHLTComponent.cxx | 122 +++++++++++++++++++++++++++------- HLT/BASE/AliHLTComponent.h | 38 +++++++++-- HLT/BASE/AliHLTDataBuffer.cxx | 2 +- HLT/BASE/AliHLTDataSource.cxx | 57 +++++----------- HLT/BASE/AliHLTDataSource.h | 28 +------- HLT/BASE/AliHLTSystem.cxx | 1 - HLT/BASE/AliHLTTask.cxx | 63 +++++++++++++----- HLT/BASE/AliHLTTask.h | 10 ++- 8 files changed, 204 insertions(+), 117 deletions(-) diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index df76ad341af..8f138354b7d 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -74,8 +74,10 @@ AliHLTComponent::AliHLTComponent() fpDDLList(NULL), fCDBSetRunNoFunc(false), fChainId(), + fChainIdCrc(0), fpBenchmark(NULL), - fRequireSteeringBlocks(false) + fRequireSteeringBlocks(false), + fEventType(gkAliEventTypeUnknown) { // see header file for class documentation // or @@ -306,7 +308,7 @@ int AliHLTComponent::SetRunDescription(const AliHLTRunDesc* desc, const char* /* int AliHLTComponent::SetComponentDescription(const char* desc) { - // default implementation, childs can overload + // see header file for function documentation int iResult=0; if (!desc) return 0; @@ -322,11 +324,13 @@ int AliHLTComponent::SetComponentDescription(const char* desc) argument.ReplaceAll("chainid", ""); if (argument.BeginsWith("=")) { fChainId=argument.Replace(0,1,""); + fChainIdCrc=CalculateChecksum((const AliHLTUInt8_t*)fChainId.c_str(), fChainId.length()); + HLTDebug("setting component description: chain id %s crc 0x%8x", fChainId.c_str(), fChainIdCrc); } else { fChainId=""; } } else { - HLTWarning("unknown component discription %s", argument.Data()); + HLTWarning("unknown component description %s", argument.Data()); } } } @@ -523,17 +527,22 @@ int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTCom } } ((AliHLTComponent*)pConsumer)->GetInputDataTypes(itypes); - AliHLTComponentDataTypeList::iterator itype=itypes.begin(); - while (itype!=itypes.end()) { - //PrintDataTypeContent((*itype), "consumer \'%s\'"); - AliHLTComponentDataTypeList::iterator otype=otypes.begin(); - while (otype!=otypes.end() && (*itype)!=(*otype)) otype++; - //if (otype!=otypes.end()) PrintDataTypeContent(*otype, "publisher \'%s\'"); - if (otype!=otypes.end()) { - if (tgtList) tgtList->push_back(*itype); + AliHLTComponentDataTypeList::iterator otype=otypes.begin(); + for (;otype!=otypes.end();otype++) { + //PrintDataTypeContent((*otype), "publisher \'%s\'"); + if ((*otype)==(kAliHLTAnyDataType|kAliHLTDataOriginPrivate)) { + if (tgtList) tgtList->push_back(*otype); + iResult++; + continue; + } + + AliHLTComponentDataTypeList::iterator itype=itypes.begin(); + for (;itype!=itypes.end() && (*itype)!=(*otype); itype++); + //if (itype!=itypes.end()) PrintDataTypeContent(*itype, "consumer \'%s\'"); + if (itype!=itypes.end()) { + if (tgtList) tgtList->push_back(*otype); iResult++; } - itype++; } } else { iResult=-EINVAL; @@ -625,6 +634,7 @@ void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData) // see header file for function documentation memset(&evtData, 0, sizeof(AliHLTComponentEventData)); evtData.fStructSize=sizeof(AliHLTComponentEventData); + evtData.fEventID=kAliHLTVoidEventID; } void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt) @@ -1249,6 +1259,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, #if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS) AliHLTComponentStatistics outputStat; memset(&outputStat, 0, sizeof(AliHLTComponentStatistics)); + outputStat.fId=fChainIdCrc; compStats.push_back(outputStat); if (fpBenchmark) { fpBenchmark->Reset(); @@ -1256,12 +1267,14 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, } #endif - // data processing is skipped if there are only steering events - // in the block list. It is not skipped if there is no block list - // at all for the sake of data source components. Data processing - // is always skipped if the event is of type - // - gkAliEventTypeConfiguration - // - gkAliEventTypeReadPreprocessor + // data processing is skipped + // - if there are only steering events in the block list. + // For the sake of data source components data processing + // is not skipped if there is no block list at all or if it + // just contains the eventType block + // - always skipped if the event is of type + // - gkAliEventTypeConfiguration + // - gkAliEventTypeReadPreprocessor const unsigned int skipModeDefault=0x1; const unsigned int skipModeForce=0x2; unsigned int bSkipDataProcessing=skipModeDefault; @@ -1270,7 +1283,6 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, if (fpInputBlocks && evtData.fBlockCnt>0) { // first look for all special events and execute in the appropriate // sequence afterwords - AliHLTUInt32_t eventType=gkAliEventTypeUnknown; int indexComConfEvent=-1; int indexUpdtDCSEvent=-1; int indexSOREvent=-1; @@ -1298,9 +1310,17 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeUpdtDCS) { indexUpdtDCSEvent=i; } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) { - eventType=fpInputBlocks[i].fSpecification; + fEventType=fpInputBlocks[i].fSpecification; + + // skip always in case of gkAliEventTypeConfiguration if (fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration) bSkipDataProcessing|=skipModeForce; + + // skip always in case of gkAliEventTypeReadPreprocessor if (fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor) bSkipDataProcessing|=skipModeForce; + + // never skip if the event type block is the only block + if (evtData.fBlockCnt==1) bSkipDataProcessing&=~skipModeDefault; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentStatistics) { if (compStats.size()>0) { AliHLTUInt8_t* pData=reinterpret_cast(fpInputBlocks[i].fPtr); @@ -1330,6 +1350,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, // start of run if (fpRunDesc==NULL) { fpRunDesc=new AliHLTRunDesc; + if (fpRunDesc) *fpRunDesc=kAliHLTVoidRunDesc; } if (fpRunDesc) { AliHLTRunDesc rundesc; @@ -1365,7 +1386,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, HLTWarning("did not receive SOR, ignoring EOR"); } } - if (indexComConfEvent>=0 || eventType==gkAliEventTypeConfiguration) { + if (indexComConfEvent>=0 || fEventType==gkAliEventTypeConfiguration) { TString cdbEntry; if (indexComConfEvent>=0 && fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) { cdbEntry.Append(reinterpret_cast(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize); @@ -1376,7 +1397,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult); } } - if (indexUpdtDCSEvent>=0 || eventType==gkAliEventTypeReadPreprocessor) { + if (indexUpdtDCSEvent>=0 || fEventType==gkAliEventTypeReadPreprocessor) { TString modules; if (fpInputBlocks[indexUpdtDCSEvent].fPtr!=NULL && fpInputBlocks[indexUpdtDCSEvent].fSize>0) { modules.Append(reinterpret_cast(fpInputBlocks[indexUpdtDCSEvent].fPtr), fpInputBlocks[indexUpdtDCSEvent].fSize); @@ -1454,7 +1475,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, outputBlocks=NULL; } CleanupInputObjects(); - if (iResult>=0 && !bSkipDataProcessing) { + if (iResult>=0 && IsDataEvent()) { IncrementEventCounter(); } if (outputBlockCnt==0) { @@ -1636,6 +1657,15 @@ AliHLTUInt32_t AliHLTComponent::GetRunType() const return fpRunDesc->fRunType; } +bool AliHLTComponent::IsDataEvent(AliHLTUInt32_t* pTgt) +{ + // see header file for function documentation + if (pTgt) *pTgt=fEventType; + return (fEventType==gkAliEventTypeData || + fEventType==gkAliEventTypeDataReplay || + fEventType==gkAliEventTypeCalibration); +} + int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo, const char* structname, const char* eventname) { @@ -1740,3 +1770,49 @@ Int_t AliHLTComponent::GetFirstUsedDDLWord(AliHLTEventDDL &list) const return iResult; } + +AliHLTUInt32_t AliHLTComponent::CalculateChecksum(const AliHLTUInt8_t* buffer, int size) +{ + // see header file for function documentation + AliHLTUInt32_t remainder = 0; + const AliHLTUInt8_t crcwidth=(8*sizeof(AliHLTUInt32_t)); + const AliHLTUInt32_t topbit=1 << (crcwidth-1); + const AliHLTUInt32_t polynomial=0xD8; /* 11011 followed by 0's */ + + // code from + // http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code + + /* + * Perform modulo-2 division, a byte at a time. + */ + for (int byte = 0; byte < size; ++byte) + { + /* + * Bring the next byte into the remainder. + */ + remainder ^= (buffer[byte] << (crcwidth - 8)); + + /* + * Perform modulo-2 division, a bit at a time. + */ + for (uint8_t bit = 8; bit > 0; --bit) + { + /* + * Try to divide the current data bit. + */ + if (remainder & topbit) + { + remainder = (remainder << 1) ^ polynomial; + } + else + { + remainder = (remainder << 1); + } + } + } + + /* + * The final remainder is the CRC result. + */ + return (remainder); +} diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h index 933985e3797..3fdb811a107 100644 --- a/HLT/BASE/AliHLTComponent.h +++ b/HLT/BASE/AliHLTComponent.h @@ -143,11 +143,11 @@ typedef vector AliHLTMemoryFilePList; * also implements a standard method for @ref GetInputDataTypes. * * - AliHLTProcessor for components of type @ref kProcessor
- * All types of data processors can inherit from AliHLTDataSource and must + * All types of data processors can inherit from AliHLTProcessor and must * implement the @ref AliHLTProcessor::DoEvent method. * * - AliHLTDataSink for components of type @ref kSink
- * All types of data processors can inherit from AliHLTDataSource and must + * All types of data processors can inherit from AliHLTDataSink and must * implement the @ref AliHLTDataSink::DumpEvent method. The class * also implements a standard method for @ref GetOutputDataType and @ref * GetOutputDataSize. @@ -165,7 +165,7 @@ typedef vector AliHLTMemoryFilePList; * and AliHLTDataSink provides it's own processing method (see * @ref alihltcomponent-type-std), which splits into a high and a low-level * method. For the @ref alihltcomponent-low-level-interface, all parameters are - * shipped as function arguments, the component is supposed to dump data to the + * shipped as function arguments, the component is supposed to write data to the * output buffer and handle all block descriptors. * The @ref alihltcomponent-high-level-interface is the standard processing * method and will be used whenever the low-level method is not overloaded. @@ -176,7 +176,7 @@ typedef vector AliHLTMemoryFilePList; * For that reason the @ref GetOutputDataSize function should return a rough * estimatian of the data to be produced by the component. The component is * responsible for checking the memory size and must return -ENOSPC if the - * available buffer is to small, and update the estimator respectively. The + * available buffer is too small, and update the estimator respectively. The * framework will allocate a buffer of appropriate size and call the processing * again. * @@ -504,6 +504,12 @@ class AliHLTComponent : public AliHLTLogging { */ static string DataType2Text( const AliHLTComponentDataType& type, int mode=0); + /** + * Calculate a CRC checksum of a data buffer. + * Polynomial for the calculation is 0xD8. + */ + static AliHLTUInt32_t CalculateChecksum(const AliHLTUInt8_t* buffer, int size); + /** * Helper function to print content of data type. */ @@ -737,6 +743,15 @@ class AliHLTComponent : public AliHLTLogging { */ virtual int EndOfRun(); + /** + * Check whether a component requires all steering blocks. + * Childs can overload in order to indicate that they want to + * receive also the steering data blocks. There is also the + * possibility to add the required data types to the input + * data type list in GetInputDataTypes(). + */ + virtual bool RequireSteeringBlocks() const {return false;} + /** * General memory allocation method. * All memory which is going to be used 'outside' of the interface must @@ -1125,6 +1140,13 @@ class AliHLTComponent : public AliHLTLogging { */ const char* GetChainId() const {return fChainId.c_str();} + /** + * Check whether the current event is a valid data event. + * @param pTgt optional pointer to get the event type + * @return true if the current event is a real data event + */ + bool IsDataEvent(AliHLTUInt32_t* pTgt=NULL); + /** * Set a bit to 1 in a readout list ( = AliHLTEventDDL ) * -> enable DDL for readout @@ -1349,12 +1371,18 @@ class AliHLTComponent : public AliHLTLogging { /** id of the component in the analysis chain */ string fChainId; //! transient + /** crc value of the chainid, used as a 32bit id */ + AliHLTUInt32_t fChainIdCrc; //! transient + /** optional benchmarking for the component statistics */ TStopwatch* fpBenchmark; //! transient /** component requires steering data blocks */ bool fRequireSteeringBlocks; //! transient - ClassDef(AliHLTComponent, 7) + /** current event type */ + AliHLTUInt32_t fEventType; //! transient + + ClassDef(AliHLTComponent, 8) }; #endif diff --git a/HLT/BASE/AliHLTDataBuffer.cxx b/HLT/BASE/AliHLTDataBuffer.cxx index bedcd9b2461..0e2d58b20bc 100644 --- a/HLT/BASE/AliHLTDataBuffer.cxx +++ b/HLT/BASE/AliHLTDataBuffer.cxx @@ -588,7 +588,7 @@ int AliHLTDataBuffer::ResetDataBuffer() desc=fActiveConsumers.begin(); while (desc!=fActiveConsumers.end()) { AliHLTConsumerDescriptor* pDesc=*desc; - HLTWarning("consumer %p was not released", pDesc); + HLTWarning("consumer %p (%s) was not released", pDesc, pDesc->GetComponent()?pDesc->GetComponent()->GetComponentID():"### invalid component ###"); fActiveConsumers.erase(desc); desc=fActiveConsumers.begin(); fConsumers.push_back(pDesc); diff --git a/HLT/BASE/AliHLTDataSource.cxx b/HLT/BASE/AliHLTDataSource.cxx index bca288bfc45..ea8418fc5ae 100644 --- a/HLT/BASE/AliHLTDataSource.cxx +++ b/HLT/BASE/AliHLTDataSource.cxx @@ -39,11 +39,6 @@ AliHLTDataSource::AliHLTDataSource() // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt } -void* AliHLTDataSource::fgpSpecialEvent=NULL; -int AliHLTDataSource::fgSpecialEventSize=0; -AliHLTComponentDataType AliHLTDataSource::fgSpecialEventDataType=kAliHLTVoidDataType; -AliHLTUInt32_t AliHLTDataSource::fgSpecialEventSpecification=kAliHLTVoidDataSpec; - AliHLTDataSource::~AliHLTDataSource() { // see header file for class documentation @@ -57,7 +52,7 @@ void AliHLTDataSource::GetInputDataTypes( vector& list) int AliHLTDataSource::DoProcessing( const AliHLTComponentEventData& evtData, - const AliHLTComponentBlockData* /*blocks*/, + const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, @@ -67,28 +62,22 @@ int AliHLTDataSource::DoProcessing( const AliHLTComponentEventData& evtData, // see header file for class documentation int iResult=0; if (evtData.fBlockCnt > 0) { - HLTWarning("Data source component skips input data blocks"); - } - if (fgpSpecialEvent==NULL || fgSpecialEventSize==0) { - // normal event publishing - iResult=GetEvent(evtData, trigData, outputPtr, size, outputBlocks); - HLTDebug("component %s (%p) GetEvent finished (%d)", GetComponentID(), this, iResult); - } else { - // publish special event - if (size>=(unsigned)fgSpecialEventSize) { - memcpy(outputPtr, fgpSpecialEvent, fgSpecialEventSize); - AliHLTComponentBlockData bd; - FillBlockData(bd); - bd.fOffset=0; - bd.fSize=fgSpecialEventSize; - bd.fDataType=fgSpecialEventDataType; - bd.fSpecification=fgSpecialEventSpecification; - outputBlocks.push_back(bd); - size=bd.fSize; - } else { - iResult=-ENOSPC; + int unknown=-1; + for (unsigned int block; block=0) { + HLTWarning("Data source component skips input data blocks: first unknown block %s", + DataType2Text(blocks[unknown].fDataType).c_str()); } } + iResult=GetEvent(evtData, trigData, outputPtr, size, outputBlocks); + HLTDebug("component %s (%p) GetEvent finished (%d)", GetComponentID(), this, iResult); edd = NULL; return iResult; } @@ -109,19 +98,3 @@ int AliHLTDataSource::GetEvent( const AliHLTComponentEventData& /*evtData*/, Ali HLTFatal("no processing method implemented"); return -ENOSYS; } - -AliHLTDataSource::AliSpecialEventGuard::AliSpecialEventGuard(AliHLTRunDesc* pDesc, AliHLTComponentDataType dt, AliHLTUInt32_t spec) -{ - AliHLTDataSource::fgpSpecialEvent=pDesc; - AliHLTDataSource::fgSpecialEventSize=sizeof(AliHLTRunDesc); - AliHLTDataSource::fgSpecialEventDataType=dt; - AliHLTDataSource::fgSpecialEventSpecification=spec; -} - -AliHLTDataSource::AliSpecialEventGuard::~AliSpecialEventGuard() -{ - AliHLTDataSource::fgpSpecialEvent=NULL; - AliHLTDataSource::fgSpecialEventSize=0; - AliHLTDataSource::fgSpecialEventDataType=kAliHLTVoidDataType; - AliHLTDataSource::fgSpecialEventSpecification=kAliHLTVoidDataSpec; -} diff --git a/HLT/BASE/AliHLTDataSource.h b/HLT/BASE/AliHLTDataSource.h index 3dc2ae26102..0f63f992bea 100644 --- a/HLT/BASE/AliHLTDataSource.h +++ b/HLT/BASE/AliHLTDataSource.h @@ -73,24 +73,6 @@ class AliHLTDataSource : public AliHLTComponent { */ void GetInputDataTypes( vector& list); - /** - * @class AliSpecialEventGuard - * Guard structure to set the data sources into 'special event publishing' - * mode. The SOR and EOR events are generated by all the data sources and - * perculated through the chain as normal events. The AliSpecialEventGuard - * is a back-door mechansim to trigger publishing of the special event - * described by the run descriptor instead of the publishing of real data. - * - * The descriptor has to be valid throughout the lifetime of the guard. - */ - class AliSpecialEventGuard { - public: - /** constructor, set run descriptor */ - AliSpecialEventGuard(AliHLTRunDesc* pDesc, AliHLTComponentDataType dt, AliHLTUInt32_t spec); - /** destructor, reset run descriptor */ - ~AliSpecialEventGuard(); - }; - protected: /** @@ -122,15 +104,7 @@ protected: virtual int GetEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData); private: - /** pointer to the special event going to be published */ - static void* fgpSpecialEvent; //! transient - /** data size of the special event going to be published */ - static int fgSpecialEventSize; //! transient - /** data type of the special event going to be published */ - static AliHLTComponentDataType fgSpecialEventDataType; //! transient - /** data specification of the special event going to be published */ - static AliHLTUInt32_t fgSpecialEventSpecification; //! transient - ClassDef(AliHLTDataSource, 2) + ClassDef(AliHLTDataSource, 3) }; #endif diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index ae4c318a1ec..6e4461e15e4 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -647,7 +647,6 @@ int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt) AliHLTRunDesc runDesc; memset(&runDesc, 0, sizeof(AliHLTRunDesc)); runDesc.fStructSize=sizeof(AliHLTRunDesc); - AliHLTDataSource::AliSpecialEventGuard g(&runDesc, dt, kAliHLTVoidDataSpec); HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc); TObjLink *lnk=fTaskList.FirstLink(); while (lnk && iResult>=0) { diff --git a/HLT/BASE/AliHLTTask.cxx b/HLT/BASE/AliHLTTask.cxx index 9ece514d359..1f3b91fd2d3 100644 --- a/HLT/BASE/AliHLTTask.cxx +++ b/HLT/BASE/AliHLTTask.cxx @@ -104,22 +104,41 @@ int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH) fpConfiguration, GetName(), pConf); } if (pConf!=NULL) fpConfiguration=pConf; - if (fpConfiguration) { + iResult=CreateComponent(fpConfiguration, pCH, fpComponent); + if (iResult>=0) { + iResult=CustomInit(pCH); + } + return iResult; +} + +int AliHLTTask::CreateComponent(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const +{ + // see header file for class documentation + int iResult=0; + if (pConf) { if (pCH) { int argc=0; const char** argv=NULL; - if ((iResult=fpConfiguration->GetArguments(&argv))>=0) { + if ((iResult=pConf->GetArguments(&argv))>=0) { argc=iResult; // just to make it clear // TODO: we have to think about the optional environment parameter, - // currently just set to NULL. - iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent); - if (fpComponent && iResult>=0) { - //HLTDebug("component %s (%p) created", fpComponent->GetComponentID(), fpComponent); + // currently just set to NULL. + iResult=pCH->CreateComponent(pConf->GetComponentID(), pComponent); + if (pComponent && iResult>=0) { + TString description; + description.Form("chainid=%s", GetName()); + pComponent->SetComponentDescription(description.Data()); + const AliHLTAnalysisEnvironment* pEnv=pCH->GetEnvironment(); + if ((iResult=pComponent->Init(pEnv, NULL, argc, argv))>=0) { + //HLTDebug("component %s (%p) created", pComponent->GetComponentID(), pComponent); + } else { + HLTError("Initialization of component \"%s\" failed with error %d", pComponent->GetComponentID(), iResult); + } } else { - //HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult); + //HLTError("can not find component \"%s\" (%d)", pConf->GetComponentID(), iResult); } } else { - HLTError("can not get argument list for configuration %s (%s)", fpConfiguration->GetName(), fpConfiguration->GetComponentID()); + HLTError("can not get argument list for configuration %s (%s)", pConf->GetName(), pConf->GetComponentID()); iResult=-EINVAL; } } else { @@ -130,9 +149,6 @@ int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH) HLTError("configuration object instance needed for task initialization"); iResult=-EINVAL; } - if (iResult>=0) { - iResult=CustomInit(pCH); - } return iResult; } @@ -428,7 +444,7 @@ int AliHLTTask::EndRun() return iResult; } -int AliHLTTask::ProcessTask(Int_t eventNo) +int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType) { // see header file for function documentation int iResult=0; @@ -504,7 +520,6 @@ int AliHLTTask::ProcessTask(Int_t eventNo) do { long unsigned int iOutputDataSize=0; AliHLTConfiguration* pConf=GetConf(); - assert(pConf); // check if there was a buffer size specified, query output size // estimator from component otherwize if (pConf && pConf->GetOutputBufferSize()>=0) { @@ -531,8 +546,8 @@ int AliHLTTask::ProcessTask(Int_t eventNo) //HLTDebug("provided raw buffer %p", pTgtBuffer); AliHLTComponentEventData evtData; AliHLTComponent::FillEventData(evtData); - evtData.fEventID=(AliHLTEventID_t)eventNo; - evtData.fBlockCnt=iSourceDataBlock; + if (eventNo>=0) + evtData.fEventID=(AliHLTEventID_t)eventNo; AliHLTComponentTriggerData trigData; trigData.fStructSize=sizeof(trigData); trigData.fDataSize=0; @@ -542,14 +557,28 @@ int AliHLTTask::ProcessTask(Int_t eventNo) AliHLTComponentBlockData* outputBlocks=NULL; AliHLTComponentEventDoneData* edd=NULL; if (pTgtBuffer!=NULL || iOutputDataSize==0) { + // add event type data block + AliHLTComponentBlockData eventTypeBlock; + AliHLTComponent::FillBlockData(eventTypeBlock); + // Note: no payload! + eventTypeBlock.fDataType=kAliHLTDataTypeEvent; + eventTypeBlock.fSpecification=eventType; + fBlockDataArray.push_back(eventTypeBlock); + + // process + evtData.fBlockCnt=fBlockDataArray.size(); iResult=pComponent->ProcessEvent(evtData, &fBlockDataArray[0], trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd); HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt); + + // remove event data block + fBlockDataArray.pop_back(); + if (iResult>=0 && outputBlocks) { if (fListTargets.First()!=NULL) { AliHLTComponentBlockDataList segments; for (AliHLTUInt32_t oblock=0; oblock0) { iResult=fpDataBuffer->SetSegments(pTgtBuffer, &segments[0], segments.size()); diff --git a/HLT/BASE/AliHLTTask.h b/HLT/BASE/AliHLTTask.h index e994c85b3e1..799f4901c62 100644 --- a/HLT/BASE/AliHLTTask.h +++ b/HLT/BASE/AliHLTTask.h @@ -77,6 +77,14 @@ class AliHLTTask : public TObject, public AliHLTLogging { */ int Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH); + /** + * Create the component. + * @param pConf configuration descritption + * @param pCH component handler + * @return component instance + */ + virtual int CreateComponent(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const; + /** * De-Initialize the task. * Final cleanup after the run. The @ref AliHLTComponent::Deinit method of @@ -197,7 +205,7 @@ class AliHLTTask : public TObject, public AliHLTLogging { * processing, the data blocks are released.
* The @ref StartRun method must be called before. */ - int ProcessTask(Int_t eventNo); + int ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType=gkAliEventTypeData); /** * Determine the number of matching data block between the component and the -- 2.43.0