3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTSystem.cxx
20 @author Matthias Richter
22 @brief Implementation of HLT module management.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
36 #include "AliHLTStdIncludes.h"
37 #include "AliHLTSystem.h"
38 #include "AliHLTComponentHandler.h"
39 #include "AliHLTComponent.h"
40 #include "AliHLTConfiguration.h"
41 #include "AliHLTConfigurationHandler.h"
42 #include "AliHLTTask.h"
43 #include "AliHLTModuleAgent.h"
44 #include "AliHLTOfflineInterface.h"
45 #include <TObjArray.h>
46 #include <TObjString.h>
47 #include <TStopwatch.h>
48 //#include <TSystem.h>
50 //#include <TInterpreter.h>
52 /** HLT default component libraries */
53 const char* AliHLTSystem::fgkHLTDefaultLibs[]= {
56 // "libAliHLTSample.so",
63 /** ROOT macro for the implementation of ROOT specific class methods */
64 ClassImp(AliHLTSystem)
66 AliHLTSystem::AliHLTSystem()
68 fpComponentHandler(new AliHLTComponentHandler()),
69 fpConfigurationHandler(new AliHLTConfigurationHandler()),
73 fStopwatches(new TObjArray),
77 // see header file for class documentation
79 // refer to README to build package
81 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
83 if (fgNofInstances++>0)
84 HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
86 SetGlobalLoggingLevel(kHLTLogDefault);
87 SetFrameworkLog(kHLTLogDefault);
88 if (fpComponentHandler) {
89 AliHLTComponentEnvironment env;
90 memset(&env, 0, sizeof(AliHLTComponentEnvironment));
91 env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
92 env.fLoggingFunc=NULL;
93 fpComponentHandler->SetEnvironment(&env);
94 InitAliLogFunc(fpComponentHandler);
95 fpComponentHandler->AnnounceVersion();
97 HLTFatal("can not create Component Handler");
99 if (fpConfigurationHandler) {
100 AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
102 HLTFatal("can not create Configuration Handler");
106 AliHLTSystem::~AliHLTSystem()
108 // see header file for class documentation
111 AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
112 if (fpConfigurationHandler) {
113 delete fpConfigurationHandler;
115 fpConfigurationHandler=NULL;
117 if (fpComponentHandler) {
118 delete fpComponentHandler;
120 fpComponentHandler=NULL;
123 int AliHLTSystem::fgNofInstances=0;
125 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
127 // see header file for class documentation
128 HLTLogKeyword("configuration handling");
131 HLTError("function not yet implemented");
139 int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
141 // see header file for class documentation
142 HLTLogKeyword("configuration handling");
147 HLTError("function not yet implemented");
156 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
158 // see header file for class documentation
159 HLTLogKeyword("configuration handling");
162 HLTError("function not yet implemented");
170 int AliHLTSystem::BuildTaskList(const char* id)
172 // see header file for class documentation
175 if (fpConfigurationHandler) {
176 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
178 iResult=BuildTaskList(pConf);
180 HLTError("unknown configuration \"%s\"", id);
192 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
194 // see header file for class documentation
197 AliHLTTask* pTask=NULL;
198 if ((pTask=FindTask(pConf->GetName()))!=NULL) {
199 if (pTask->GetConf()!=pConf) {
200 HLTError("configuration missmatch, there is already a task with configuration name \"%s\", but it is different. Most likely configuration %p is not registered properly", pConf->GetName(), pConf);
203 // task for this configuration exists, terminate
205 } else if (pConf->SourcesResolved(1)!=1) {
206 HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
209 pTask=new AliHLTTask(pConf);
213 pTask->SetLocalLoggingLevel(GetLocalLoggingLevel());
216 static int iterationLevel=0;
217 if (pTask && iResult>=0) {
218 // check for circular dependencies
219 if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
220 HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
221 pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
222 HLTError("aborted ...");
226 // check whether all dependencies are already in the task list
227 // create the missing ones
228 // this step is an iterative process which calls this function again for the missing
229 // configurations, in order to avoid the currently processed task to be created
230 // again it is added to the list temporarily and removed afterwards
231 // This is of high importance to preserve the order of the tasks. Furthermore, the
232 // InsertTask method has to be used in order to set all the cross links right
233 fTaskList.Add(pTask);
234 AliHLTConfiguration* pDep=pConf->GetFirstSource();
235 while (pDep!=NULL && iResult>=0) {
236 HLTDebug("iteration %d: checking dependency %s (%p)", iterationLevel, pDep->GetName(), pDep);
237 if (FindTask(pDep->GetName())==NULL) {
238 HLTDebug("iteration %d: building task list for configuration %s (%p)", iterationLevel, pDep->GetName(), pDep);
240 iResult=BuildTaskList(pDep);
243 pDep=pConf->GetNextSource();
245 // remove the temporarily added task
246 fTaskList.Remove(pTask);
248 // insert the task and set the cross-links
250 HLTDebug("iteration %d: inserting task %s (%p)", iterationLevel, pTask->GetName(), pTask);
251 iResult=InsertTask(pTask);
264 int AliHLTSystem::CleanTaskList()
266 // see header file for class documentation
269 while ((lnk=fTaskList.LastLink())!=NULL) {
270 delete (lnk->GetObject());
271 fTaskList.Remove(lnk);
276 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
278 // see header file for class documentation
280 TObjLink *lnk = NULL;
281 if ((iResult=pTask->CheckDependencies())>0)
282 lnk=fTaskList.FirstLink();
283 while (lnk && iResult>0) {
284 AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
285 //HLTDebug("checking \"%s\"", pCurr->GetName());
286 iResult=pTask->Depends(pCurr);
288 iResult=pTask->SetDependency(pCurr);
289 pCurr->SetTarget(pTask);
290 HLTDebug("set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
292 if (pCurr->Depends(pTask)) {
293 // circular dependency
294 HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
296 } else if ((iResult=pTask->CheckDependencies())>0) {
302 fTaskList.AddAfter(lnk, pTask);
304 fTaskList.AddFirst(pTask);
306 HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
307 } else if (iResult>0) {
308 HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
314 AliHLTTask* AliHLTSystem::FindTask(const char* id)
316 // see header file for class documentation
317 AliHLTTask* pTask=NULL;
319 pTask=dynamic_cast<AliHLTTask*>(fTaskList.FindObject(id));
324 void AliHLTSystem::PrintTaskList()
326 // see header file for class documentation
327 HLTLogKeyword("task list");
328 TObjLink *lnk = NULL;
329 HLTMessage("Task List");
330 lnk=fTaskList.FirstLink();
332 TObject* obj=lnk->GetObject();
334 HLTMessage(" %s - status:", obj->GetName());
335 AliHLTTask* pTask=(AliHLTTask*)obj;
336 pTask->PrintStatus();
343 int AliHLTSystem::Run(Int_t iNofEvents, int bStop)
345 // see header file for class documentation
348 SetStatusFlags(kRunning);
349 if (fEventCount>=0 || (iResult=InitTasks())>=0) {
350 if (fEventCount>=0 || (iResult=StartTasks())>=0) {
351 if (fEventCount==0) {
352 InitBenchmarking(fStopwatches);
354 //ResumeBenchmarking(fStopwatches);
356 for (int i=fEventCount; i<fEventCount+iNofEvents && iResult>=0; i++) {
357 if ((iResult=ProcessTasks(i))>=0) {
361 // TODO: define different running modes to either ignore errors in
362 // event processing or not
367 fEventCount+=iNofEvents;
368 if (bStop) StopTasks();
369 //else PauseBenchmarking(fStopwatches);
371 if (bStop) DeinitTasks();
375 } else if (iResult==-126 /*ENOKEY*/) {
376 iResult=0; // do not propagate the error
378 ClearStatusFlags(kRunning);
382 int AliHLTSystem::InitTasks()
384 // see header file for class documentation
386 TObjLink *lnk=fTaskList.FirstLink();
389 HLTWarning("Task list is empty, aborting ...");
390 return -126 /*ENOKEY*/;
392 while (lnk && iResult>=0) {
393 TObject* obj=lnk->GetObject();
395 AliHLTTask* pTask=(AliHLTTask*)obj;
396 iResult=pTask->Init(NULL, fpComponentHandler);
397 // ProcInfo_t ProcInfo;
398 // gSystem->GetProcInfo(&ProcInfo);
399 // HLTInfo("task %s initialized (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
405 HLTError("can not initialize task list, error %d", iResult);
411 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
413 // see header file for class documentation
415 if (pStopwatches==NULL) return 0;
417 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
418 TStopwatch* pStopwatch= new TStopwatch;
421 pStopwatches->AddAt(pStopwatch, i);
428 TObjLink *lnk=fTaskList.FirstLink();
429 while (lnk && iResult>=0) {
430 TObject* obj=lnk->GetObject();
432 AliHLTTask* pTask=(AliHLTTask*)obj;
433 AliHLTComponent* pComp=NULL;
434 if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) {
435 switch (pComp->GetComponentType()) {
436 case AliHLTComponent::kProcessor:
437 pComp->SetStopwatches(pStopwatches);
439 case AliHLTComponent::kSource:
441 // this switch determines whether the time consumption of the
442 // AliHLTComponent base methods should be counted to the input
443 // stopwatch or base stopwatch.
444 //int inputBase=(int)AliHLTComponent::kSWBase;
445 int inputBase=(int)AliHLTComponent::kSWInput;
446 pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase);
447 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA);
450 case AliHLTComponent::kSink:
452 // this switch determines whether the time consumption of the
453 // AliHLTComponent base methods should be counted to the output
454 // stopwatch or base stopwatch.
455 //int outputBase=(int)AliHLTComponent::kSWBase;
456 int outputBase=(int)AliHLTComponent::kSWOutput;
457 pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase);
458 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA);
462 HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
472 int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean)
474 // see header file for class documentation
476 if (pStopwatches==NULL) return 0;
478 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
479 if (!dynamic_cast<TStopwatch*>(pStopwatches->At(i))) {
485 if (iInitialized!=0) {
486 HLTInfo("HLT statistics:\n"
487 " base: R:%.3fs C:%.3fs\n"
488 " input: R:%.3fs C:%.3fs\n"
489 " output: R:%.3fs C:%.3fs\n"
490 " event processing : R:%.3fs C:%.3fs"
491 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->RealTime()
492 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->CpuTime()
493 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->RealTime()
494 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->CpuTime()
495 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->RealTime()
496 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->CpuTime()
497 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->RealTime()
498 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->CpuTime()
503 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
504 TObject* pObj=pStopwatches->RemoveAt(i);
505 if (pObj) delete pObj;
511 int AliHLTSystem::StartTasks()
513 // see header file for class documentation
515 TObjLink *lnk=fTaskList.FirstLink();
516 while (lnk && iResult>=0) {
517 TObject* obj=lnk->GetObject();
519 AliHLTTask* pTask=(AliHLTTask*)obj;
520 iResult=pTask->StartRun();
521 // ProcInfo_t ProcInfo;
522 // gSystem->GetProcInfo(&ProcInfo);
523 // HLTInfo("task %s started (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
529 HLTError("can not start task list, error %d", iResult);
537 int AliHLTSystem::ProcessTasks(Int_t eventNo)
539 // see header file for class documentation
541 HLTDebug("processing event no %d", eventNo);
542 TObjLink *lnk=fTaskList.FirstLink();
543 while (lnk && iResult>=0) {
544 TObject* obj=lnk->GetObject();
546 AliHLTTask* pTask=(AliHLTTask*)obj;
547 iResult=pTask->ProcessTask(eventNo);
548 // ProcInfo_t ProcInfo;
549 // gSystem->GetProcInfo(&ProcInfo);
550 // HLTInfo("task %s processed (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
557 HLTInfo("Event %d successfully finished (%d)", eventNo, iResult);
560 HLTError("Processing of event %d failed (%d)", eventNo, iResult);
566 int AliHLTSystem::StopTasks()
568 // see header file for class documentation
570 TObjLink *lnk=fTaskList.FirstLink();
571 while (lnk && iResult>=0) {
572 TObject* obj=lnk->GetObject();
574 AliHLTTask* pTask=(AliHLTTask*)obj;
575 iResult=pTask->EndRun();
576 // ProcInfo_t ProcInfo;
577 // gSystem->GetProcInfo(&ProcInfo);
578 // HLTInfo("task %s stopped (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
583 PrintBenchmarking(fStopwatches, 1 /*clean*/);
587 int AliHLTSystem::DeinitTasks()
589 // see header file for class documentation
591 TObjLink *lnk=fTaskList.FirstLink();
592 while (lnk && iResult>=0) {
593 TObject* obj=lnk->GetObject();
595 AliHLTTask* pTask=(AliHLTTask*)obj;
596 iResult=pTask->Deinit();
597 // ProcInfo_t ProcInfo;
598 // gSystem->GetProcInfo(&ProcInfo);
599 // HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
610 void* AliHLTSystem::AllocMemory( void* /*param*/, unsigned long size )
612 // see header file for class documentation
615 p=(void*)new char[size];
619 log.LoggingVarargs(kHLTLogError, "AliHLTSystem" , "AllocMemory" , __FILE__ , __LINE__ , "exeption during memory allocation" );
624 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
625 AliRawReader* rawReader)
627 // see header file for class documentation
629 if (runLoader || rawReader || nofEvents==0) {
630 if (nofEvents>0) {HLTInfo("Run Loader %p, Raw Reader %p , %d event(s)", runLoader, rawReader, nofEvents);}
631 if (CheckStatus(kReady)) {
633 // special case to close the reconstruction
634 if (!CheckStatus(kError)) {
639 if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
640 // the system always remains started after event processing, a specific
641 // call with nofEvents==0 is needed to execute the stop sequence
642 if ((iResult=Run(nofEvents, 0))<0) SetStatusFlags(kError);
646 HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
649 HLTError("missing RunLoader (%p)/RawReader (%p) instance", runLoader, rawReader);
655 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
657 // see header file for class documentation
659 if (runLoader || esd) {
660 HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
661 iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
663 HLTError("missing run loader/ESD instance(s)");
669 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
671 // see header file for class documentation
674 if (fpComponentHandler) {
675 TString libs(libraries);
676 TObjArray* pTokens=libs.Tokenize(" ");
678 int iEntries=pTokens->GetEntries();
679 for (int i=0; i<iEntries && iResult>=0; i++) {
680 iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
685 SetStatusFlags(kLibrariesLoaded);
687 // lets see if we need this, probably not
688 //fpComponentHandler->UnloadLibraries();
689 ClearStatusFlags(kLibrariesLoaded);
693 HLTFatal("no component handler available");
701 int AliHLTSystem::Configure(AliRunLoader* runloader)
703 // see header file for class documentation
704 return Configure(NULL, runloader);
707 int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader)
709 // see header file for class documentation
711 if (CheckStatus(kRunning)) {
712 HLTError("HLT system in running state, can not configure");
715 ClearStatusFlags(kTaskListCreated);
716 if (CheckFilter(kHLTLogDebug))
717 AliHLTModuleAgent::PrintStatus();
718 if (CheckStatus(kConfigurationLoaded)==0) {
719 iResult=LoadConfigurations(rawReader, runloader);
721 if (fChains.Length()==0) {
722 HLTError("custom configuration(s) specified, but no configuration to run in local reconstruction, use \'localrec=<conf>\' option");
727 SetStatusFlags(kConfigurationLoaded);
728 if (CheckFilter(kHLTLogDebug))
729 fpConfigurationHandler->PrintConfigurations();
730 iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader);
732 SetStatusFlags(kTaskListCreated);
735 if (iResult<0) SetStatusFlags(kError);
740 int AliHLTSystem::ScanOptions(const char* options)
742 // see header file for class documentation
745 //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
747 TString alloptions(options);
748 TObjArray* pTokens=alloptions.Tokenize(" ");
750 int iEntries=pTokens->GetEntries();
751 for (int i=0; i<iEntries; i++) {
752 TString token=(((TObjString*)pTokens->At(i))->GetString());
753 if (token.Contains("loglevel=")) {
754 TString param=token.ReplaceAll("loglevel=", "");
755 if (param.IsDigit()) {
756 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
757 } else if (param.BeginsWith("0x") &&
758 param.Replace(0,2,"",0).IsHex()) {
760 sscanf(param.Data(),"%x", &severity);
761 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
763 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
765 } else if (token.Contains("frameworklog=")) {
766 TString param=token.ReplaceAll("frameworklog=", "");
767 if (param.IsDigit()) {
768 SetFrameworkLog((AliHLTComponentLogSeverity)param.Atoi());
769 } else if (param.BeginsWith("0x") &&
770 param.Replace(0,2,"",0).IsHex()) {
772 sscanf(param.Data(),"%x", &severity);
773 SetFrameworkLog((AliHLTComponentLogSeverity)severity);
775 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
777 } else if (token.Contains("alilog=off")) {
779 } else if (token.Contains("config=")) {
780 TString param=token.ReplaceAll("config=", "");
782 gROOT->Macro(param.Data(), &error);
784 SetStatusFlags(kConfigurationLoaded);
786 HLTError("can not execute macro \'%s\'", param.Data());
789 } else if (token.Contains("chains=")) {
790 TString param=token.ReplaceAll("chains=", "");
791 fChains=param.ReplaceAll(",", " ");
792 } else if (token.Contains("libmode=")) {
793 TString param=token.ReplaceAll("libmode=", "");
794 param.ReplaceAll(",", " ");
795 if (fpComponentHandler) {
796 if (param.CompareTo("static")==0) {
797 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kStatic);
798 } else if (param.CompareTo("dynamic")==0) {
799 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kDynamic);
801 HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
804 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
808 HLTWarning("unknown option \'%s\'", token.Data());
816 const char** deflib=fgkHLTDefaultLibs;
822 if ((!CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
823 (LoadComponentLibraries(libs.Data())<0)) {
824 HLTError("error while loading HLT libraries");
832 int AliHLTSystem::Reset(int bForce)
834 // see header file for class documentation
836 if (!bForce && CheckStatus(kRunning)) {
837 HLTError("HLT system in running state, can not configure");
841 ClearStatusFlags(~kUninitialized);
845 int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader)
847 // see header file for class documentation
848 if (CheckStatus(kRunning)) {
849 HLTError("HLT system in running state, can not configure");
853 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
854 while (pAgent && iResult>=0) {
855 const char* deplibs=pAgent->GetRequiredComponentLibraries();
857 HLTDebug("load libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
858 iResult=LoadComponentLibraries(deplibs);
861 HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
862 pAgent->CreateConfigurations(fpConfigurationHandler, rawReader, runloader);
863 pAgent=AliHLTModuleAgent::GetNextAgent();
869 int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader)
871 // see header file for class documentation
872 if (CheckStatus(kRunning)) {
873 HLTError("HLT system in running state, can not configure");
876 if (!CheckStatus(kConfigurationLoaded)) {
877 HLTWarning("configurations not yet loaded");
886 if (fChains.Length()>0) {
888 HLTInfo("custom reconstruction chain: %s", chains.Data());
890 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
891 while ((pAgent || fChains.Length()>0) && iResult>=0) {
892 const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
894 if (!chains.IsNull()) chains+="";
896 HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
898 pAgent=AliHLTModuleAgent::GetNextAgent();
902 // build task list for chains
903 TObjArray* pTokens=chains.Tokenize(" ");
905 int iEntries=pTokens->GetEntries();
906 for (int i=0; i<iEntries && iResult>=0; i++) {
907 const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
908 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
910 iResult=BuildTaskList(pConf);
912 assert(fpComponentHandler!=NULL);
913 TString cid=pConf->GetComponentID();
914 if (cid.CompareTo("HLTOUT")==0) {
915 // remove from the input of a global HLTOUT configuration
916 chains.ReplaceAll(pCID, "");
917 } else if (bHaveOutput==0) {
918 // check whether this configuration produces data output
919 if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) {
921 chains.ReplaceAll(pCID, "");
926 HLTWarning("can not find configuration %s", pCID);
932 // build HLTOUT for simulation
933 if (iResult>=0 && runloader) {
935 // there are components in the chain which produce data which need to be
936 // piped to an HLTOUT
937 if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
938 LoadComponentLibraries("libHLTsim.so")>=0) {
939 AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
940 iResult=BuildTaskList("_globalout_");
942 HLTError("can not load libHLTsim.so and HLTOUT component");
948 if (iResult>=0) SetStatusFlags(kTaskListCreated);
953 int AliHLTSystem::CheckStatus(int flag)
955 // see header file for class documentation
956 if (flag==kUninitialized && flag==fState) return 1;
957 if ((fState&flag)==flag) return 1;
961 int AliHLTSystem::GetStatusFlags()
963 // see header file for class documentation
967 int AliHLTSystem::SetStatusFlags(int flags)
969 // see header file for class documentation
974 int AliHLTSystem::ClearStatusFlags(int flags)
976 // see header file for class documentation
981 void* AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol)
983 // see header file for class documentation
984 if (fpComponentHandler==NULL) return NULL;
985 return fpComponentHandler->FindSymbol(library, symbol);
988 void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
990 // see header file for class documentation
991 SetLocalLoggingLevel(level);
992 if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
993 if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);