From f3506ea2d2fd9e5b16da047a239b790a77a12e13 Mon Sep 17 00:00:00 2001 From: richterm Date: Tue, 16 Oct 2007 09:39:41 +0000 Subject: [PATCH] - implemented component registration via agents - added HLTOUT component as default data sink for simulation - added AliHLTAgentSim for libHLTsim.so - AliHLTComponentHandler: more robust library handling --- HLT/BASE/AliHLTComponentHandler.cxx | 124 ++++++++++++++---- HLT/BASE/AliHLTComponentHandler.h | 59 +++++++-- HLT/BASE/AliHLTModuleAgent.cxx | 30 ++++- HLT/BASE/AliHLTModuleAgent.h | 35 +++-- HLT/BASE/AliHLTSystem.cxx | 105 ++++++++++----- HLT/BASE/AliHLTSystem.h | 4 +- HLT/BASE/util/AliHLTAgentUtil.cxx | 27 ++++ HLT/BASE/util/AliHLTAgentUtil.h | 5 + HLT/BASE/util/AliHLTDataGenerator.cxx | 3 - HLT/BASE/util/AliHLTFilePublisher.cxx | 13 +- HLT/BASE/util/AliHLTFileWriter.cxx | 3 - .../util/AliHLTLoaderPublisherComponent.cxx | 6 +- .../AliHLTRawReaderPublisherComponent.cxx | 6 +- .../util/AliHLTRootFilePublisherComponent.cxx | 4 +- .../util/AliHLTRootFileStreamerComponent.cxx | 3 - .../util/AliHLTRootFileWriterComponent.cxx | 3 - HLT/ChangeLog | 6 + HLT/SampleLib/AliHLTAgentSample.cxx | 13 ++ HLT/SampleLib/AliHLTAgentSample.h | 5 + HLT/SampleLib/AliHLTDummyComponent.cxx | 8 +- HLT/TPCLib/AliHLTTPCAgent.cxx | 5 + HLT/TPCLib/AliHLTTPCAgent.h | 5 + HLT/libHLTsim.pkg | 4 +- 23 files changed, 364 insertions(+), 112 deletions(-) diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index f95574a1be1..b8e0da4fdb8 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -36,15 +36,9 @@ using namespace std; #include "AliHLTComponentHandler.h" #include "AliHLTComponent.h" #include "AliHLTDataTypes.h" -//#include "AliHLTSystem.h" +#include "AliHLTModuleAgent.h" #include "TString.h" -// the standard components -// #include "AliHLTFilePublisher.h" -// #include "AliHLTFileWriter.h" -// #include "AliHLTRootFilePublisherComponent.h" -// #include "AliHLTRootFileWriterComponent.h" - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTComponentHandler) @@ -54,7 +48,7 @@ AliHLTComponentHandler::AliHLTComponentHandler() fScheduleList(), fLibraryList(), fEnvironment(), - fStandardList() + fOwnedComponents() { // see header file for class documentation // or @@ -72,7 +66,7 @@ AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv) fScheduleList(), fLibraryList(), fEnvironment(), - fStandardList() + fOwnedComponents() { // see header file for class documentation if (pEnv) { @@ -84,8 +78,15 @@ AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv) // for redirection AliHLTLogging::Init(pEnv->fLoggingFunc); } - } else + } else { memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment)); + } + //#ifndef __DEBUG + //SetLocalLoggingLevel(kHLTLogError); + //#else + //SetLocalLoggingLevel(kHLTLogInfo); + //#endif + AddStandardComponents(); } @@ -114,6 +115,16 @@ int AliHLTComponentHandler::AnnounceVersion() return iResult; } +Int_t AliHLTComponentHandler::AddComponent(AliHLTComponent* pSample) +{ + // see header file for class documentation + Int_t iResult=0; + if ((iResult=RegisterComponent(pSample))>=0) { + fOwnedComponents.push_back(pSample); + } + return iResult; +} + Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample) { // see header file for class documentation @@ -242,6 +253,21 @@ void AliHLTComponentHandler::List() } } +int AliHLTComponentHandler::HasOutputData( const char* componentID) +{ + // see header file for class documentation + int iResult=0; + AliHLTComponent* pSample=FindComponent(componentID); + if (pSample) { + AliHLTComponent::TComponentType ct=AliHLTComponent::kUnknown; + ct=pSample->GetComponentType(); + iResult=(ct==AliHLTComponent::kSource || ct==AliHLTComponent::kProcessor); + } else { + iResult=-ENOENT; + } + return iResult; +} + void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) { // see header file for class documentation @@ -257,22 +283,34 @@ void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) } } -int AliHLTComponentHandler::LoadLibrary( const char* libraryPath ) +int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateAgents) { // see header file for class documentation int iResult=0; if (libraryPath) { + // first activate all agents which are already loaded + if (bActivateAgents) ActivateAgents(); + + // set the global component handler for static component registration AliHLTComponent::SetGlobalComponentHandler(this); + AliHLTLibHandle hLib; const char* loadtype=""; #ifdef HAVE_DLFCN_H // use interface to the dynamic linking loader - hLib.fHandle=dlopen(libraryPath, RTLD_NOW); - loadtype="dlopen"; + try { + hLib.fHandle=dlopen(libraryPath, RTLD_NOW); + loadtype="dlopen"; + } + catch (...) { + // error message printed further down + loadtype="dlopen exeption"; + } #else // use ROOT dynamic loader // check if the library was already loaded, as Load returns // 'failure' if the library was already loaded + try { AliHLTLibHandle* pLib=FindLibrary(libraryPath); if (pLib) { int* pRootHandle=reinterpret_cast(pLib->fHandle); @@ -288,6 +326,11 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath ) //HLTDebug("library %s loaded via gSystem", libraryPath); } loadtype="gSystem"; + } + catch (...) { + // error message printed further down + loadtype="gSystem exeption"; + } #endif //HAVE_DLFCN_H if (hLib.fHandle!=NULL) { // create TString object to store library path and use pointer as handle @@ -306,9 +349,12 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath ) } else { HLTInfo("no build info available (possible AliRoot embedded build)"); } + + // static registration of components when library is loaded iResult=RegisterScheduledComponents(); + } else { - HLTError("can not load library %s", libraryPath); + HLTError("can not load library %s (%s)", libraryPath, loadtype); #ifdef HAVE_DLFCN_H HLTError("dlopen error: %s", dlerror()); #endif //HAVE_DLFCN_H @@ -319,6 +365,13 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath ) #endif } AliHLTComponent::UnsetGlobalComponentHandler(); + + if (iResult>=0) { + // alternative dynamic registration by library agents + // !!! has to be done after UnsetGlobalComponentHandler + if (bActivateAgents) ActivateAgents(); + } + } else { iResult=-EINVAL; } @@ -353,7 +406,12 @@ int AliHLTComponentHandler::UnloadLibrary(AliHLTComponentHandler::AliHLTLibHandl fgAliLoggingFunc=NULL; TString* pName=reinterpret_cast(handle.fName); #ifdef HAVE_DLFCN_H - dlclose(handle.fHandle); + try { + dlclose(handle.fHandle); + } + catch (...) { + HLTError("exeption caught during dlclose of library %s", pName!=NULL?pName->Data():""); + } #else int* pCount=reinterpret_cast(handle.fHandle); if (--(*pCount)==0) { @@ -444,10 +502,6 @@ int AliHLTComponentHandler::AddStandardComponents() // see header file for class documentation int iResult=0; AliHLTComponent::SetGlobalComponentHandler(this); -// fStandardList.push_back(new AliHLTFilePublisher); -// fStandardList.push_back(new AliHLTFileWriter); -// fStandardList.push_back(new AliHLTRootFilePublisherComponent); -// fStandardList.push_back(new AliHLTRootFileWriterComponent); AliHLTComponent::UnsetGlobalComponentHandler(); iResult=RegisterScheduledComponents(); return iResult; @@ -468,16 +522,40 @@ int AliHLTComponentHandler::RegisterScheduledComponents() return iResult; } +int AliHLTComponentHandler::ActivateAgents(const AliHLTModuleAgent** blackList, int size) +{ + // see header file for class documentation + int iResult=0; + AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); + while (pAgent && iResult>=0) { + if (blackList) { + int i=0; + for (; iActivateComponentHandler(this); + pAgent=AliHLTModuleAgent::GetNextAgent(); + } + return iResult; +} + int AliHLTComponentHandler::DeleteStandardComponents() { // see header file for class documentation int iResult=0; - vector::iterator element=fStandardList.begin(); - while (element!=fStandardList.end()) { + vector::iterator element=fOwnedComponents.begin(); + while (element!=fOwnedComponents.end()) { //DeregisterComponent((*element)->GetComponentID()); delete(*element); - fStandardList.erase(element); - element=fStandardList.begin(); + fOwnedComponents.erase(element); + element=fOwnedComponents.begin(); } return iResult; } diff --git a/HLT/BASE/AliHLTComponentHandler.h b/HLT/BASE/AliHLTComponentHandler.h index d75a7e97440..01d54ee5058 100644 --- a/HLT/BASE/AliHLTComponentHandler.h +++ b/HLT/BASE/AliHLTComponentHandler.h @@ -26,6 +26,7 @@ #include "AliHLTLogging.h" class AliHLTComponent; +class AliHLTModuleAgent; struct AliHLTComponentEnvironment; struct AliHLTComponentDataType; @@ -62,10 +63,11 @@ class AliHLTComponentHandler : public AliHLTLogging { * handler. The object has to be valid during the whole runtime and should * thus be a global object which is ONLY used for the purpose of registration. * This also ensures automatically registration at library load time. - * @param libraryPath const char string containing the library name/path + * @param libraryPath const char string containing the library name/path + * @param bActivateAgents activate agents after loading (@ref ActivateAgents) * @return 0 if succeeded, neg. error code if failed */ - int LoadLibrary( const char* libraryPath ); + int LoadLibrary( const char* libraryPath, int bActivateAgents=1 ); /** * Find a symbol in a dynamically loaded library. @@ -98,10 +100,19 @@ class AliHLTComponentHandler : public AliHLTLogging { * Registration is done by passing a sample object of the component to the * handler. The object has to be valid during the whole runtime and should * thus be a global object which is ONLY used for the purpose of registration. - * @param pSample a sample object of the component + * @param pSample a sample object of the component * @return neg. error code if failed */ - int RegisterComponent(AliHLTComponent* pSample ); + int RegisterComponent(AliHLTComponent* pSample); + + /** + * Add a component and leave control of the sample object to the handler. + * Exactly the same functionality as @ref RegisterComponent but deletes + * the sample object at clean-up of the handler. + * @param pSample a sample object of the component + * @return neg. error code if failed + */ + int AddComponent(AliHLTComponent* pSample); /** * Registers all scheduled components. @@ -171,6 +182,15 @@ class AliHLTComponentHandler : public AliHLTLogging { return CreateComponent( componentID, pEnvParam, 0, NULL, component ); } + /** + * Check if a registered component has output data, e.g. is of type + * kSource or kProcessor (see @ref AliHLTComponent::TComponentType). + * @param componentID ID of the component to create + * @return 1 if component has output data, 0 if not
+ * -ENOENT if component does not exist + */ + int HasOutputData( const char* componentID); + /** * Print registered components to stdout. * @return none @@ -182,6 +202,13 @@ class AliHLTComponentHandler : public AliHLTLogging { */ int AnnounceVersion(); + /** + * Find a component. + * @param componentID ID of the component to find + * @return index, neg. error code if failed + */ + int FindComponentIndex(const char* componentID); + protected: private: @@ -190,13 +217,6 @@ class AliHLTComponentHandler : public AliHLTLogging { /** assignment operator prohibited */ AliHLTComponentHandler& operator=(const AliHLTComponentHandler&); - /** - * Find a component. - * @param componentID ID of the component to find - * @return index, neg. error code if failed - */ - int FindComponentIndex(const char* componentID); - /** * Find a component. * @param componentID ID of the component to find @@ -218,7 +238,18 @@ class AliHLTComponentHandler : public AliHLTLogging { int UnloadLibraries(); /** - * Compount descriptor for component libraries + * Activate all module agents with this component handler. + * The function loops over all available module agents and activates + * each agent with this component handler. During activation, the + * dynamic component registration is carried out by the agents version + * of @ref AliHLTModuleAgent::RegisterComponents + * @param blackList array of agents which should be excluded + * @param size array size + */ + int ActivateAgents(const AliHLTModuleAgent** blackList=NULL, int size=0); + + /** + * Compound descriptor for component libraries */ struct AliHLTLibHandle { AliHLTLibHandle() : fHandle(NULL), fName(NULL) {} @@ -252,8 +283,8 @@ class AliHLTComponentHandler : public AliHLTLogging { vector fLibraryList; // see above /** running environment for the component */ AliHLTComponentEnvironment fEnvironment; // see above - /** list of standard components */ - vector fStandardList; // see above + /** list of owned components, deleted at termination of the handler */ + vector fOwnedComponents; // see above ClassDef(AliHLTComponentHandler, 0); diff --git a/HLT/BASE/AliHLTModuleAgent.cxx b/HLT/BASE/AliHLTModuleAgent.cxx index f8d284e9efe..086de37c2de 100644 --- a/HLT/BASE/AliHLTModuleAgent.cxx +++ b/HLT/BASE/AliHLTModuleAgent.cxx @@ -30,7 +30,8 @@ ClassImp(AliHLTModuleAgent) AliHLTModuleAgent::AliHLTModuleAgent() : - fpNext(NULL) + fpNext(NULL), + fpComponentHandler(NULL) { // see header file for class documentation // or @@ -97,8 +98,31 @@ const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const return NULL; } -int AliHLTModuleAgent::RegisterComponents(AliRawReader* /*rawReader*/, - AliRunLoader* /*runloader*/) const +int AliHLTModuleAgent::ActivateComponentHandler(AliHLTComponentHandler* pHandler) +{ + int iResult=0; + if (pHandler==NULL) { + if (fpComponentHandler!=NULL) { + // reset and think about deregistration + fpComponentHandler=NULL; + HLTWarning("deregistration of components not yet implemented"); + } + return 0; + } + if (fpComponentHandler!=NULL) { + if (pHandler!=fpComponentHandler) { + HLTError("only one component handler can be activated per agent"); + return -EINVAL; + } + return 0; + } + if ((iResult=RegisterComponents(pHandler))>=0) { + fpComponentHandler=pHandler; + } + return iResult; +} + +int AliHLTModuleAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const { // default method, nothing to be done, child classes can overload return 0; diff --git a/HLT/BASE/AliHLTModuleAgent.h b/HLT/BASE/AliHLTModuleAgent.h index d9dda5b6771..25bfa088d2b 100644 --- a/HLT/BASE/AliHLTModuleAgent.h +++ b/HLT/BASE/AliHLTModuleAgent.h @@ -25,6 +25,7 @@ #include "AliHLTLogging.h" #include "AliHLTConfiguration.h" #include "AliHLTConfigurationHandler.h" +#include "AliHLTComponentHandler.h" class AliRunLoader; class AliRawReader; @@ -117,6 +118,18 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { */ static AliHLTModuleAgent* GetNextAgent(); + /** + * Activate a component handler for this agent. + * The @ref RegisterComponents method will be called in order to allow + * the agent to register components. Once activated, the function can + * be called repeatedly with the same handler and gently ignores the + * invocation. In the current stage of development, only one handler + * can be activated per agent. This is sufficient for the current + * operation, but can be extended. + * @param pHandler [in] the component handler instance + */ + int ActivateComponentHandler(AliHLTComponentHandler* pHandler); + /** * Register all configurations belonging to this module with the * AliHLTConfigurationHandler. The agent can adapt the configurations @@ -158,15 +171,18 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { virtual const char* GetRequiredComponentLibraries() const; /** - * Register componets. + * Register components. * This method can be used to register components for the module instead - * of the 'static object approach'. Registration is don by passing a - * sample object to @ref AliHLTComponentHandler::RegisterComponent
- * \em Note: The sample object is owned by the agent, make sure to delete - * it. + * of the 'static object approach'. Registration is done by passing a + * sample object to the AliHLTComponentHandler via + * - @ref AliHLTComponentHandler::RegisterComponent
+ * The sample object is owned by the agent, make sure to delete it. + * - @ref AliHLTComponentHandler::AddComponent
+ * Same functionality but handler deletes the object at the end. + * + * @param pHandler [in] instance of the component handler */ - virtual int RegisterComponents(AliRawReader* rawReader=NULL, - AliRunLoader* runloader=NULL) const; + virtual int RegisterComponents(AliHLTComponentHandler* pHandler) const; /** * Old method kept for backward compatibility, redirected to @ref @@ -208,7 +224,10 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { /** number of agents */ static int fCount; //! transient - ClassDef(AliHLTModuleAgent, 1); + /* instance of the active component handler */ + AliHLTComponentHandler* fpComponentHandler; //! transient + + ClassDef(AliHLTModuleAgent, 2); }; #endif diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index aa7aed257fd..823e502a02f 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -26,6 +26,7 @@ using namespace std; #endif +#include #include "AliHLTStdIncludes.h" #include "AliHLTSystem.h" #include "AliHLTComponentHandler.h" @@ -84,7 +85,7 @@ AliHLTSystem::AliHLTSystem() AliHLTComponentLogSeverity loglevel=fpComponentHandler->GetLocalLoggingLevel(); fpComponentHandler->SetLocalLoggingLevel(kHLTLogError); fpComponentHandler->SetEnvironment(&env); - fpComponentHandler->LoadLibrary("libAliHLTUtil.so"); + fpComponentHandler->LoadLibrary("libAliHLTUtil.so", 0/* do not activate agents */); fgAliLoggingFunc=(AliHLTLogging::AliHLTDynamicMessage)fpComponentHandler->FindSymbol("libAliHLTUtil.so", "AliDynamicMessage"); fpComponentHandler->SetLocalLoggingLevel(loglevel); if (fgAliLoggingFunc==NULL) { @@ -303,7 +304,7 @@ AliHLTTask* AliHLTSystem::FindTask(const char* id) // see header file for class documentation AliHLTTask* pTask=NULL; if (id) { - pTask=(AliHLTTask*)fTaskList.FindObject(id); + pTask=dynamic_cast(fTaskList.FindObject(id)); } return pTask; } @@ -359,7 +360,7 @@ int AliHLTSystem::Run(Int_t iNofEvents, int bStop) } if (iResult>=0) { iResult=iCount; - } else if (iResult==-ENOENT) { + } else if (iResult==-ENOKEY) { iResult=0; // do not propagate the error } ClearStatusFlags(kRunning); @@ -374,7 +375,7 @@ int AliHLTSystem::InitTasks() if (lnk==NULL) { HLTWarning("Task list is empty, aborting ..."); - return -ENOENT; + return -ENOKEY; } while (lnk && iResult>=0) { TObject* obj=lnk->GetObject(); @@ -604,13 +605,15 @@ int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader, if (CheckStatus(kReady)) { if (nofEvents==0) { // special case to close the reconstruction + if (!CheckStatus(kError)) { StopTasks(); DeinitTasks(); + } } else { if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) { // the system always remains started after event processing, a specific - // call with nofEvents==0 is neede to execute the stop sequence - iResult=Run(nofEvents, 0); + // call with nofEvents==0 is needed to execute the stop sequence + if ((iResult=Run(nofEvents, 0))<0) SetStatusFlags(kError); } } } else { @@ -672,7 +675,7 @@ int AliHLTSystem::LoadComponentLibraries(const char* libraries) int AliHLTSystem::Configure(AliRunLoader* runloader) { // see header file for class documentation - Configure(NULL, runloader); + return Configure(NULL, runloader); } int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader) @@ -698,7 +701,7 @@ int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader) SetStatusFlags(kConfigurationLoaded); if (CheckFilter(kHLTLogDebug)) fpConfigurationHandler->PrintConfigurations(); - iResult=BuildTaskListsFromTopConfigurations(rawReader, runloader); + iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader); if (iResult>=0) { SetStatusFlags(kTaskListCreated); } @@ -812,7 +815,7 @@ int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runl return iResult; } -int AliHLTSystem::BuildTaskListsFromTopConfigurations(AliRawReader* rawReader, AliRunLoader* runloader) +int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader) { // see header file for class documentation if (CheckStatus(kRunning)) { @@ -825,36 +828,72 @@ int AliHLTSystem::BuildTaskListsFromTopConfigurations(AliRawReader* rawReader, A } int iResult=0; - AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); - while ((pAgent || fChains.Length()>0) && iResult>=0) { - TString tops; - if (fChains.Length()>0) { - tops=fChains; - HLTInfo("custom local reconstruction configurations: %s", tops.Data()); - } else { - tops=pAgent->GetReconstructionChains(rawReader, runloader); - HLTInfo("local reconstruction configurations for agent %s (%p): %s", pAgent->GetName(), pAgent, tops.Data()); + int bHaveOutput=0; + + // query chains + TString chains; + if (fChains.Length()>0) { + chains=fChains; + HLTInfo("custom reconstruction chain: %s", chains.Data()); + } else { + AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); + while ((pAgent || fChains.Length()>0) && iResult>=0) { + const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader); + if (agentchains) { + if (!chains.IsNull()) chains+=""; + chains+=agentchains; + HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains); + } + pAgent=AliHLTModuleAgent::GetNextAgent(); } - TObjArray* pTokens=tops.Tokenize(" "); - if (pTokens) { - int iEntries=pTokens->GetEntries(); - for (int i=0; i=0; i++) { - const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data(); - AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID); - if (pConf) { - iResult=BuildTaskList(pConf); - } else { - HLTWarning("can not find top configuration %s", pCID); + } + + // build task list for chains + TObjArray* pTokens=chains.Tokenize(" "); + if (pTokens) { + int iEntries=pTokens->GetEntries(); + for (int i=0; i=0; i++) { + const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data(); + AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID); + if (pConf) { + iResult=BuildTaskList(pConf); + if (runloader) { + assert(fpComponentHandler!=NULL); + TString cid=pConf->GetComponentID(); + if (cid.CompareTo("HLTOUT")==0) { + // remove from the input of a global HLTOUT configuration + chains.ReplaceAll(pCID, ""); + } else if (bHaveOutput==0) { + // check whether this configuration produces data output + if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) { + bHaveOutput=0; + chains.ReplaceAll(pCID, ""); + } + } } + } else { + HLTWarning("can not find configuration %s", pCID); } - delete pTokens; } - - if (fChains.Length()>0) { - break; // ignore the agents + delete pTokens; + } + + // build HLTOUT for simulation + if (iResult>=0 && runloader) { + if (bHaveOutput) { + // there are components in the chain which produce data which need to be + // piped to an HLTOUT + if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 || + LoadComponentLibraries("libHLTsim.so")>=0) { + AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL); + iResult=BuildTaskList("_globalout_"); + } else { + HLTError("can not load libHLTsim.so and HLTOUT component"); + iResult=-EFAULT; + } } - pAgent=AliHLTModuleAgent::GetNextAgent(); } + if (iResult>=0) SetStatusFlags(kTaskListCreated); return iResult; diff --git a/HLT/BASE/AliHLTSystem.h b/HLT/BASE/AliHLTSystem.h index ab6a686bdde..57319f2d7cc 100644 --- a/HLT/BASE/AliHLTSystem.h +++ b/HLT/BASE/AliHLTSystem.h @@ -332,8 +332,8 @@ class AliHLTSystem : public AliHLTLogging { * @param runloader optional instance of the run loader * @return neg. error code if failed */ - int BuildTaskListsFromTopConfigurations(AliRawReader* rawReader, - AliRunLoader* runloader=NULL); + int BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, + AliRunLoader* runloader=NULL); enum AliHLTSystemState_t { kUninitialized = 0x0, diff --git a/HLT/BASE/util/AliHLTAgentUtil.cxx b/HLT/BASE/util/AliHLTAgentUtil.cxx index 1949ccd7d9a..85ef9099fc1 100644 --- a/HLT/BASE/util/AliHLTAgentUtil.cxx +++ b/HLT/BASE/util/AliHLTAgentUtil.cxx @@ -22,9 +22,20 @@ @brief Agent of the libAliHLTUtil library */ +#include #include "AliHLTAgentUtil.h" #include "AliHLTConfiguration.h" +// header files of library components +#include "AliHLTDataGenerator.h" +#include "AliHLTRawReaderPublisherComponent.h" +#include "AliHLTLoaderPublisherComponent.h" +#include "AliHLTRootFileStreamerComponent.h" +#include "AliHLTRootFileWriterComponent.h" +#include "AliHLTRootFilePublisherComponent.h" +#include "AliHLTFileWriter.h" +#include "AliHLTFilePublisher.h" + /** global instance for agent registration */ AliHLTAgentUtil gAliHLTAgentUtil; @@ -65,3 +76,19 @@ const char* AliHLTAgentUtil::GetRequiredComponentLibraries() const // see header file for class documentation return NULL; } + +int AliHLTAgentUtil::RegisterComponents(AliHLTComponentHandler* pHandler) const +{ + // see header file for class documentation + assert(pHandler); + if (!pHandler) return -EINVAL; + pHandler->AddComponent(new AliHLTDataGenerator); + pHandler->AddComponent(new AliHLTRawReaderPublisherComponent); + pHandler->AddComponent(new AliHLTLoaderPublisherComponent); + pHandler->AddComponent(new AliHLTRootFileStreamerComponent); + pHandler->AddComponent(new AliHLTRootFileWriterComponent); + pHandler->AddComponent(new AliHLTRootFilePublisherComponent); + pHandler->AddComponent(new AliHLTFileWriter); + pHandler->AddComponent(new AliHLTFilePublisher); + return 0; +} diff --git a/HLT/BASE/util/AliHLTAgentUtil.h b/HLT/BASE/util/AliHLTAgentUtil.h index b83a769da05..f75f9045eb1 100644 --- a/HLT/BASE/util/AliHLTAgentUtil.h +++ b/HLT/BASE/util/AliHLTAgentUtil.h @@ -61,6 +61,11 @@ class AliHLTAgentUtil : public AliHLTModuleAgent { */ const char* GetRequiredComponentLibraries() const; + /** + * Register components for the AliHLTUtil library. + * @param pHandler [in] instance of the component handler + */ + int RegisterComponents(AliHLTComponentHandler* pHandler) const; protected: private: diff --git a/HLT/BASE/util/AliHLTDataGenerator.cxx b/HLT/BASE/util/AliHLTDataGenerator.cxx index 063ad5ffffe..cfcced7acec 100644 --- a/HLT/BASE/util/AliHLTDataGenerator.cxx +++ b/HLT/BASE/util/AliHLTDataGenerator.cxx @@ -34,9 +34,6 @@ using namespace std; #include "AliHLTDataGenerator.h" #include "TString.h" -/** the global object for component registration */ -AliHLTDataGenerator gAliHLTDataGenerator; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTDataGenerator) diff --git a/HLT/BASE/util/AliHLTFilePublisher.cxx b/HLT/BASE/util/AliHLTFilePublisher.cxx index b2bfa4d3b28..38ae8e4e449 100644 --- a/HLT/BASE/util/AliHLTFilePublisher.cxx +++ b/HLT/BASE/util/AliHLTFilePublisher.cxx @@ -31,8 +31,6 @@ using namespace std; #include #include -/** the global object for component registration */ -AliHLTFilePublisher gAliHLTFilePublisher; /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTFilePublisher) @@ -211,6 +209,7 @@ int AliHLTFilePublisher::DoInit( int argc, const char** argv ) int AliHLTFilePublisher::InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc) { + // see header file for class documentation int iResult=0; if (pDesc) { if (pCurrEvent==NULL) { @@ -232,6 +231,7 @@ int AliHLTFilePublisher::InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc) int AliHLTFilePublisher::InsertEvent(EventFiles* &pEvent) { + // see header file for class documentation int iResult=0; if (pEvent) { HLTDebug("Inserted event %p", pEvent); @@ -303,6 +303,7 @@ int AliHLTFilePublisher::GetEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTUInt32_t& size, vector& outputBlocks ) { + // see header file for class documentation int iResult=0; TObjLink *lnk=fpCurrent; if (lnk==NULL) lnk=fEvents.FirstLink(); @@ -379,15 +380,22 @@ AliHLTFilePublisher::FileDesc::FileDesc(const char* name, AliHLTComponentDataTyp fDataType(dt), fSpecification(spec) { + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt } AliHLTFilePublisher::FileDesc::~FileDesc() { + // see header file for class documentation CloseFile(); } void AliHLTFilePublisher::FileDesc::CloseFile() { + // see header file for class documentation if (fpInstance) { // Unfortunately had to use AliLog mechanisms rather that AliHLTLogging because @@ -405,6 +413,7 @@ void AliHLTFilePublisher::FileDesc::CloseFile() int AliHLTFilePublisher::FileDesc::OpenFile() { + // see header file for class documentation int iResult=0; TString fullFN= fName + "?filetype=raw"; fpInstance = new TFile(fullFN); diff --git a/HLT/BASE/util/AliHLTFileWriter.cxx b/HLT/BASE/util/AliHLTFileWriter.cxx index 5871f55790a..ca75880f72f 100644 --- a/HLT/BASE/util/AliHLTFileWriter.cxx +++ b/HLT/BASE/util/AliHLTFileWriter.cxx @@ -32,9 +32,6 @@ using namespace std; //#include //#include -/** the global object for component registration */ -AliHLTFileWriter gAliHLTFileWriter; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTFileWriter) diff --git a/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx b/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx index 8b1da04b821..a61a66fd4c2 100644 --- a/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx +++ b/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx @@ -34,9 +34,6 @@ #include "AliLog.h" #include "TTree.h" -/** global instance for agent registration */ -AliHLTLoaderPublisherComponent gAliHLTLoaderPublisherComponent; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTLoaderPublisherComponent) @@ -70,11 +67,13 @@ const char* AliHLTLoaderPublisherComponent::GetComponentID() AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType() { + // see header file for class documentation return fDataType; } void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { + // see header file for class documentation constBase=fMaxSize; inputMultiplier=1; } @@ -221,6 +220,7 @@ int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& /*e TTree* AliHLTLoaderPublisherComponent::GetTree() { + // see header file for class documentation TTree* pTree=NULL; if (fpLoader) { if (fTreeType.CompareTo("digits")==0) diff --git a/HLT/BASE/util/AliHLTRawReaderPublisherComponent.cxx b/HLT/BASE/util/AliHLTRawReaderPublisherComponent.cxx index 01e26e67c1a..53d9860050e 100644 --- a/HLT/BASE/util/AliHLTRawReaderPublisherComponent.cxx +++ b/HLT/BASE/util/AliHLTRawReaderPublisherComponent.cxx @@ -34,9 +34,6 @@ #include #include -/** global instance for agent registration */ -AliHLTRawReaderPublisherComponent gAliHLTRawReaderPublisherComponent; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTRawReaderPublisherComponent) @@ -70,11 +67,13 @@ const char* AliHLTRawReaderPublisherComponent::GetComponentID() AliHLTComponentDataType AliHLTRawReaderPublisherComponent::GetOutputDataType() { + // see header file for class documentation return fDataType; } void AliHLTRawReaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { + // see header file for class documentation constBase=fMaxSize; inputMultiplier=1; } @@ -266,5 +265,6 @@ int AliHLTRawReaderPublisherComponent::GetEvent(const AliHLTComponentEventData& } int AliHLTRawReaderPublisherComponent::GetSpecificationFromEquipmentId(int id, AliHLTUInt32_t& specification) const { + // see header file for class documentation return specification=id; } diff --git a/HLT/BASE/util/AliHLTRootFilePublisherComponent.cxx b/HLT/BASE/util/AliHLTRootFilePublisherComponent.cxx index 7d15fc44d9e..9cf757c05eb 100644 --- a/HLT/BASE/util/AliHLTRootFilePublisherComponent.cxx +++ b/HLT/BASE/util/AliHLTRootFilePublisherComponent.cxx @@ -29,9 +29,6 @@ // temporary #include "TH1F.h" -/** the global object for component registration */ -AliHLTRootFilePublisherComponent gAliHLTRootFilePublisherComponent; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTRootFilePublisherComponent) @@ -109,6 +106,7 @@ int AliHLTRootFilePublisherComponent::GetEvent( const AliHLTComponentEventData& AliHLTUInt32_t& /*size*/, vector& /*outputBlocks*/ ) { + // see header file for class documentation int iResult=0; if (GetEventCount()%2==0) { TH1F *hpx = new TH1F("hpx","px distribution",100,-4,4); diff --git a/HLT/BASE/util/AliHLTRootFileStreamerComponent.cxx b/HLT/BASE/util/AliHLTRootFileStreamerComponent.cxx index 09b1551cdc9..165e6862fdb 100644 --- a/HLT/BASE/util/AliHLTRootFileStreamerComponent.cxx +++ b/HLT/BASE/util/AliHLTRootFileStreamerComponent.cxx @@ -26,9 +26,6 @@ #include "AliHLTRootFileStreamerComponent.h" #include "TString.h" -/** the global object for component registration */ -AliHLTRootFileStreamerComponent gAliHLTRootFileStreamerComponent; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTRootFileStreamerComponent) diff --git a/HLT/BASE/util/AliHLTRootFileWriterComponent.cxx b/HLT/BASE/util/AliHLTRootFileWriterComponent.cxx index 38d6dfd0f20..f0076ec526e 100644 --- a/HLT/BASE/util/AliHLTRootFileWriterComponent.cxx +++ b/HLT/BASE/util/AliHLTRootFileWriterComponent.cxx @@ -27,9 +27,6 @@ #include "TFile.h" #include "TString.h" -/** the global object for component registration */ -AliHLTRootFileWriterComponent gAliHLTRootFileWriterComponent; - /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTRootFileWriterComponent) diff --git a/HLT/ChangeLog b/HLT/ChangeLog index 5888f3ba231..7f54e5e9f27 100644 --- a/HLT/ChangeLog +++ b/HLT/ChangeLog @@ -1,3 +1,9 @@ +2007-10-16 + - implemented component registration via agents + - added HLTOUT component as default data sink for simulation + - added AliHLTAgentSim for libHLTsim.so + - AliHLTComponentHandler: more robust library handling + 2007-08-17 version HLT-v0-7 tagged - corresponds to AliRoot v4-06-Rev-00 - calibration framework diff --git a/HLT/SampleLib/AliHLTAgentSample.cxx b/HLT/SampleLib/AliHLTAgentSample.cxx index 3f9b041d7cd..c0a10578c8a 100644 --- a/HLT/SampleLib/AliHLTAgentSample.cxx +++ b/HLT/SampleLib/AliHLTAgentSample.cxx @@ -22,10 +22,14 @@ @brief Agent of the libAliHLTSample library */ +#include #include "AliHLTAgentSample.h" #include "AliHLTConfiguration.h" #include "TSystem.h" +// header files of library components +#include "AliHLTDummyComponent.h" + /** global instance for agent registration */ AliHLTAgentSample gAliHLTAgentSample; @@ -104,3 +108,12 @@ const char* AliHLTAgentSample::GetRequiredComponentLibraries() const // see header file for class documentation return "libAliHLTUtil.so libAliHLTSample.so"; } + +int AliHLTAgentSample::RegisterComponents(AliHLTComponentHandler* pHandler) const +{ + // see header file for class documentation + assert(pHandler); + if (!pHandler) return -EINVAL; + pHandler->AddComponent(new AliHLTDummyComponent); + return 0; +} diff --git a/HLT/SampleLib/AliHLTAgentSample.h b/HLT/SampleLib/AliHLTAgentSample.h index 382620cbdd6..eafd2adc653 100644 --- a/HLT/SampleLib/AliHLTAgentSample.h +++ b/HLT/SampleLib/AliHLTAgentSample.h @@ -94,6 +94,11 @@ class AliHLTAgentSample : public AliHLTModuleAgent { */ const char* GetRequiredComponentLibraries() const; + /** + * Register components for the AliHLTSample library. + * @param pHandler [in] instance of the component handler + */ + int RegisterComponents(AliHLTComponentHandler* pHandler) const; protected: private: diff --git a/HLT/SampleLib/AliHLTDummyComponent.cxx b/HLT/SampleLib/AliHLTDummyComponent.cxx index 41dbf709e9a..f663dded0fe 100644 --- a/HLT/SampleLib/AliHLTDummyComponent.cxx +++ b/HLT/SampleLib/AliHLTDummyComponent.cxx @@ -29,12 +29,10 @@ using namespace std; #include "AliHLTSystem.h" #include "AliHLTDummyComponent.h" #include "AliHLTDefinitions.h" -#include -#include - -// this is a global object used for automatic component registration, do not use this -AliHLTDummyComponent gAliHLTDummyComponent; +#include +#include +/** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTDummyComponent) AliHLTDummyComponent::AliHLTDummyComponent() diff --git a/HLT/TPCLib/AliHLTTPCAgent.cxx b/HLT/TPCLib/AliHLTTPCAgent.cxx index ce2c7cdb628..d0d2e4dc969 100644 --- a/HLT/TPCLib/AliHLTTPCAgent.cxx +++ b/HLT/TPCLib/AliHLTTPCAgent.cxx @@ -109,3 +109,8 @@ const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const // see header file for class documentation return NULL; } + +int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const +{ + return 0; +} diff --git a/HLT/TPCLib/AliHLTTPCAgent.h b/HLT/TPCLib/AliHLTTPCAgent.h index 02b370d7684..98e134cd35f 100644 --- a/HLT/TPCLib/AliHLTTPCAgent.h +++ b/HLT/TPCLib/AliHLTTPCAgent.h @@ -62,6 +62,11 @@ class AliHLTTPCAgent : public AliHLTModuleAgent { */ const char* GetRequiredComponentLibraries() const; + /** + * Register components for the AliHLTTPC library. + * @param pHandler [in] instance of the component handler + */ + int RegisterComponents(AliHLTComponentHandler* pHandler) const; protected: private: diff --git a/HLT/libHLTsim.pkg b/HLT/libHLTsim.pkg index 7f0c6a3a3f9..85c78ffbf6c 100644 --- a/HLT/libHLTsim.pkg +++ b/HLT/libHLTsim.pkg @@ -5,7 +5,9 @@ include $(MODDIR)/hlt.conf LIBHLTSIM_VERSION := 0 -MODULE_SRCS= AliHLTSimulation.cxx +MODULE_SRCS= AliHLTSimulation.cxx \ + AliHLTAgentSim.cxx \ + AliHLTOUTComponent.cxx CLASS_HDRS:= $(MODULE_SRCS:.cxx=.h) -- 2.43.0