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.
30 #include "AliHLTStdIncludes.h"
31 #include "AliHLTSystem.h"
32 #include "AliHLTComponentHandler.h"
33 #include "AliHLTComponent.h"
34 #include "AliHLTConfiguration.h"
35 #include "AliHLTConfigurationHandler.h"
36 #include "AliHLTTask.h"
37 #include "AliHLTModuleAgent.h"
38 #include "AliHLTOfflineInterface.h"
39 #include <TObjArray.h>
40 #include <TObjString.h>
41 #include <TStopwatch.h>
42 //#include <TSystem.h>
44 #include <TInterpreter.h>
46 /** HLT default component libraries */
47 const char* kHLTDefaultLibs[]= {
50 // "libAliHLTSample.so",
57 /** ROOT macro for the implementation of ROOT specific class methods */
58 ClassImp(AliHLTSystem)
60 AliHLTSystem::AliHLTSystem()
62 fpComponentHandler(new AliHLTComponentHandler()),
63 fpConfigurationHandler(new AliHLTConfigurationHandler()),
67 fStopwatches(new TObjArray),
71 // see header file for class documentation
73 // refer to README to build package
75 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
77 if (fgNofInstances++>0)
78 HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
80 SetGlobalLoggingLevel(kHLTLogDefault);
81 SetFrameworkLog(kHLTLogDefault);
82 if (fpComponentHandler) {
83 AliHLTComponentEnvironment env;
84 memset(&env, 0, sizeof(AliHLTComponentEnvironment));
85 env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
86 env.fLoggingFunc=NULL;
87 fpComponentHandler->SetEnvironment(&env);
88 InitAliLogFunc(fpComponentHandler);
89 fpComponentHandler->AnnounceVersion();
91 HLTFatal("can not create Component Handler");
93 if (fpConfigurationHandler) {
94 AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
96 HLTFatal("can not create Configuration Handler");
100 AliHLTSystem::~AliHLTSystem()
102 // see header file for class documentation
105 AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
106 if (fpConfigurationHandler) {
107 delete fpConfigurationHandler;
109 fpConfigurationHandler=NULL;
111 if (fpComponentHandler) {
112 delete fpComponentHandler;
114 fpComponentHandler=NULL;
117 int AliHLTSystem::fgNofInstances=0;
119 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
121 // see header file for class documentation
130 int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
132 // see header file for class documentation
144 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
146 // see header file for class documentation
155 int AliHLTSystem::BuildTaskList(const char* id)
157 // see header file for class documentation
160 if (fpConfigurationHandler) {
161 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
163 iResult=BuildTaskList(pConf);
165 HLTError("unknown configuration \"%s\"", id);
177 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
179 // see header file for class documentation
182 AliHLTTask* pTask=NULL;
183 if ((pTask=FindTask(pConf->GetName()))!=NULL) {
184 if (pTask->GetConf()!=pConf) {
185 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);
188 // task for this configuration exists, terminate
190 } else if (pConf->SourcesResolved(1)!=1) {
191 HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
194 pTask=new AliHLTTask(pConf);
198 pTask->SetLocalLoggingLevel(GetLocalLoggingLevel());
201 static int iterationLevel=0;
202 if (pTask && iResult>=0) {
203 // check for circular dependencies
204 if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
205 HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
206 pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
207 HLTError("aborted ...");
211 // check whether all dependencies are already in the task list
212 // create the missing ones
213 // this step is an iterative process which calls this function again for the missing
214 // configurations, in order to avoid the currently processed task to be created
215 // again it is added to the list temporarily and removed afterwards
216 // This is of high importance to preserve the order of the tasks. Furthermore, the
217 // InsertTask method has to be used in order to set all the cross links right
218 fTaskList.Add(pTask);
219 AliHLTConfiguration* pDep=pConf->GetFirstSource();
220 while (pDep!=NULL && iResult>=0) {
221 HLTDebug("iteration %d: checking dependency %s (%p)", iterationLevel, pDep->GetName(), pDep);
222 if (FindTask(pDep->GetName())==NULL) {
223 HLTDebug("iteration %d: building task list for configuration %s (%p)", iterationLevel, pDep->GetName(), pDep);
225 iResult=BuildTaskList(pDep);
228 pDep=pConf->GetNextSource();
230 // remove the temporarily added task
231 fTaskList.Remove(pTask);
233 // insert the task and set the cross-links
235 HLTDebug("iteration %d: inserting task %s (%p)", iterationLevel, pTask->GetName(), pTask);
236 iResult=InsertTask(pTask);
249 int AliHLTSystem::CleanTaskList()
251 // see header file for class documentation
254 while ((lnk=fTaskList.LastLink())!=NULL) {
255 delete (lnk->GetObject());
256 fTaskList.Remove(lnk);
261 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
263 // see header file for class documentation
265 TObjLink *lnk = NULL;
266 if ((iResult=pTask->CheckDependencies())>0)
267 lnk=fTaskList.FirstLink();
268 while (lnk && iResult>0) {
269 AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
270 //HLTDebug("checking \"%s\"", pCurr->GetName());
271 iResult=pTask->Depends(pCurr);
273 iResult=pTask->SetDependency(pCurr);
274 pCurr->SetTarget(pTask);
275 HLTDebug("set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
277 if (pCurr->Depends(pTask)) {
278 // circular dependency
279 HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
281 } else if ((iResult=pTask->CheckDependencies())>0) {
287 fTaskList.AddAfter(lnk, pTask);
289 fTaskList.AddFirst(pTask);
291 HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
292 } else if (iResult>0) {
293 HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
299 AliHLTTask* AliHLTSystem::FindTask(const char* id)
301 // see header file for class documentation
302 AliHLTTask* pTask=NULL;
304 pTask=dynamic_cast<AliHLTTask*>(fTaskList.FindObject(id));
309 void AliHLTSystem::PrintTaskList()
311 // see header file for class documentation
312 HLTLogKeyword("task list");
313 TObjLink *lnk = NULL;
314 HLTMessage("Task List");
315 lnk=fTaskList.FirstLink();
317 TObject* obj=lnk->GetObject();
319 HLTMessage(" %s - status:", obj->GetName());
320 AliHLTTask* pTask=(AliHLTTask*)obj;
321 pTask->PrintStatus();
328 int AliHLTSystem::Run(Int_t iNofEvents, int bStop)
330 // see header file for class documentation
333 SetStatusFlags(kRunning);
334 if (fEventCount>=0 || (iResult=InitTasks())>=0) {
335 if (fEventCount>=0 || (iResult=StartTasks())>=0) {
336 if (fEventCount==0) {
337 InitBenchmarking(fStopwatches);
339 //ResumeBenchmarking(fStopwatches);
341 for (int i=fEventCount; i<fEventCount+iNofEvents && iResult>=0; i++) {
342 if ((iResult=ProcessTasks(i))>=0) {
346 // TODO: define different running modes to either ignore errors in
347 // event processing or not
352 fEventCount+=iNofEvents;
353 if (bStop) StopTasks();
354 //else PauseBenchmarking(fStopwatches);
356 if (bStop) DeinitTasks();
360 } else if (iResult==-126 /*ENOKEY*/) {
361 iResult=0; // do not propagate the error
363 ClearStatusFlags(kRunning);
367 int AliHLTSystem::InitTasks()
369 // see header file for class documentation
371 TObjLink *lnk=fTaskList.FirstLink();
374 HLTWarning("Task list is empty, aborting ...");
375 return -126 /*ENOKEY*/;
377 while (lnk && iResult>=0) {
378 TObject* obj=lnk->GetObject();
380 AliHLTTask* pTask=(AliHLTTask*)obj;
381 iResult=pTask->Init(NULL, fpComponentHandler);
382 // ProcInfo_t ProcInfo;
383 // gSystem->GetProcInfo(&ProcInfo);
384 // HLTInfo("task %s initialized (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
390 HLTError("can not initialize task list, error %d", iResult);
396 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
398 // see header file for class documentation
400 if (pStopwatches==NULL) return 0;
402 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
403 TStopwatch* pStopwatch= new TStopwatch;
406 pStopwatches->AddAt(pStopwatch, i);
413 TObjLink *lnk=fTaskList.FirstLink();
414 while (lnk && iResult>=0) {
415 TObject* obj=lnk->GetObject();
417 AliHLTTask* pTask=(AliHLTTask*)obj;
418 AliHLTComponent* pComp=NULL;
419 if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) {
420 switch (pComp->GetComponentType()) {
421 case AliHLTComponent::kProcessor:
422 pComp->SetStopwatches(pStopwatches);
424 case AliHLTComponent::kSource:
426 // this switch determines whether the time consumption of the
427 // AliHLTComponent base methods should be counted to the input
428 // stopwatch or base stopwatch.
429 //int inputBase=(int)AliHLTComponent::kSWBase;
430 int inputBase=(int)AliHLTComponent::kSWInput;
431 pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase);
432 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA);
435 case AliHLTComponent::kSink:
437 // this switch determines whether the time consumption of the
438 // AliHLTComponent base methods should be counted to the output
439 // stopwatch or base stopwatch.
440 //int outputBase=(int)AliHLTComponent::kSWBase;
441 int outputBase=(int)AliHLTComponent::kSWOutput;
442 pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase);
443 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA);
447 HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
457 int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean)
459 // see header file for class documentation
461 if (pStopwatches==NULL) return 0;
463 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
464 if (!dynamic_cast<TStopwatch*>(pStopwatches->At(i))) {
470 if (iInitialized!=0) {
471 HLTInfo("HLT statistics:\n"
472 " base: R:%.3fs C:%.3fs\n"
473 " input: R:%.3fs C:%.3fs\n"
474 " output: R:%.3fs C:%.3fs\n"
475 " event processing : R:%.3fs C:%.3fs"
476 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->RealTime()
477 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->CpuTime()
478 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->RealTime()
479 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->CpuTime()
480 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->RealTime()
481 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->CpuTime()
482 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->RealTime()
483 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->CpuTime()
488 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
489 TObject* pObj=pStopwatches->RemoveAt(i);
490 if (pObj) delete pObj;
496 int AliHLTSystem::StartTasks()
498 // see header file for class documentation
500 TObjLink *lnk=fTaskList.FirstLink();
501 while (lnk && iResult>=0) {
502 TObject* obj=lnk->GetObject();
504 AliHLTTask* pTask=(AliHLTTask*)obj;
505 iResult=pTask->StartRun();
506 // ProcInfo_t ProcInfo;
507 // gSystem->GetProcInfo(&ProcInfo);
508 // HLTInfo("task %s started (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
514 HLTError("can not start task list, error %d", iResult);
522 int AliHLTSystem::ProcessTasks(Int_t eventNo)
524 // see header file for class documentation
526 HLTDebug("processing event no %d", eventNo);
527 TObjLink *lnk=fTaskList.FirstLink();
528 while (lnk && iResult>=0) {
529 TObject* obj=lnk->GetObject();
531 AliHLTTask* pTask=(AliHLTTask*)obj;
532 iResult=pTask->ProcessTask(eventNo);
533 // ProcInfo_t ProcInfo;
534 // gSystem->GetProcInfo(&ProcInfo);
535 // HLTInfo("task %s processed (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
542 HLTInfo("Event %d successfully finished (%d)", eventNo, iResult);
545 HLTError("Processing of event %d failed (%d)", eventNo, iResult);
551 int AliHLTSystem::StopTasks()
553 // see header file for class documentation
555 TObjLink *lnk=fTaskList.FirstLink();
556 while (lnk && iResult>=0) {
557 TObject* obj=lnk->GetObject();
559 AliHLTTask* pTask=(AliHLTTask*)obj;
560 iResult=pTask->EndRun();
561 // ProcInfo_t ProcInfo;
562 // gSystem->GetProcInfo(&ProcInfo);
563 // HLTInfo("task %s stopped (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
568 PrintBenchmarking(fStopwatches, 1 /*clean*/);
572 int AliHLTSystem::DeinitTasks()
574 // see header file for class documentation
576 TObjLink *lnk=fTaskList.FirstLink();
577 while (lnk && iResult>=0) {
578 TObject* obj=lnk->GetObject();
580 AliHLTTask* pTask=(AliHLTTask*)obj;
581 iResult=pTask->Deinit();
582 // ProcInfo_t ProcInfo;
583 // gSystem->GetProcInfo(&ProcInfo);
584 // HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
595 void* AliHLTSystem::AllocMemory( void* /*param*/, unsigned long size )
597 // see header file for class documentation
600 p=(void*)new char[size];
604 log.LoggingVarargs(kHLTLogError, "AliHLTSystem" , "AllocMemory" , __FILE__ , __LINE__ , "exeption during memory allocation" );
609 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
610 AliRawReader* rawReader)
612 // see header file for class documentation
614 if (runLoader || rawReader || nofEvents==0) {
615 if (nofEvents>0) {HLTInfo("Run Loader %p, Raw Reader %p , %d event(s)", runLoader, rawReader, nofEvents);}
616 if (CheckStatus(kReady)) {
618 // special case to close the reconstruction
619 if (!CheckStatus(kError)) {
624 if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
625 // the system always remains started after event processing, a specific
626 // call with nofEvents==0 is needed to execute the stop sequence
627 if ((iResult=Run(nofEvents, 0))<0) SetStatusFlags(kError);
631 HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
634 HLTError("missing RunLoader (%p)/RawReader (%p) instance", runLoader, rawReader);
640 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
642 // see header file for class documentation
644 if (runLoader || esd) {
645 HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
646 iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
648 HLTError("missing run loader/ESD instance(s)");
654 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
656 // see header file for class documentation
659 if (fpComponentHandler) {
660 TString libs(libraries);
661 TObjArray* pTokens=libs.Tokenize(" ");
663 int iEntries=pTokens->GetEntries();
664 for (int i=0; i<iEntries && iResult>=0; i++) {
665 iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
670 SetStatusFlags(kLibrariesLoaded);
672 // lets see if we need this, probably not
673 //fpComponentHandler->UnloadLibraries();
674 ClearStatusFlags(kLibrariesLoaded);
678 HLTFatal("no component handler available");
686 int AliHLTSystem::Configure(AliRunLoader* runloader)
688 // see header file for class documentation
689 return Configure(NULL, runloader);
692 int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader)
694 // see header file for class documentation
696 if (CheckStatus(kRunning)) {
697 HLTError("HLT system in running state, can not configure");
700 ClearStatusFlags(kConfigurationLoaded|kTaskListCreated);
701 if (CheckFilter(kHLTLogDebug))
702 AliHLTModuleAgent::PrintStatus();
703 if (CheckStatus(kConfigurationLoaded)==0) {
704 iResult=LoadConfigurations(rawReader, runloader);
706 if (fChains.Length()==0) {
707 HLTError("custom configuration(s) specified, but no configuration to run in local reconstruction, use \'localrec=<conf>\' option");
712 SetStatusFlags(kConfigurationLoaded);
713 if (CheckFilter(kHLTLogDebug))
714 fpConfigurationHandler->PrintConfigurations();
715 iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader);
717 SetStatusFlags(kTaskListCreated);
720 if (iResult<0) SetStatusFlags(kError);
725 int AliHLTSystem::ScanOptions(const char* options)
727 // see header file for class documentation
730 AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
732 TString alloptions(options);
733 TObjArray* pTokens=alloptions.Tokenize(" ");
735 int iEntries=pTokens->GetEntries();
736 for (int i=0; i<iEntries; i++) {
737 TString token=(((TObjString*)pTokens->At(i))->GetString());
738 if (token.Contains("loglevel=")) {
739 TString param=token.ReplaceAll("loglevel=", "");
740 if (param.IsDigit()) {
741 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
742 } else if (param.BeginsWith("0x") &&
743 param.Replace(0,2,"",0).IsHex()) {
745 sscanf(param.Data(),"%x", &severity);
746 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
748 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
750 } else if (token.Contains("frameworklog=")) {
751 TString param=token.ReplaceAll("frameworklog=", "");
752 if (param.IsDigit()) {
753 SetFrameworkLog((AliHLTComponentLogSeverity)param.Atoi());
754 } else if (param.BeginsWith("0x") &&
755 param.Replace(0,2,"",0).IsHex()) {
757 sscanf(param.Data(),"%x", &severity);
758 SetFrameworkLog((AliHLTComponentLogSeverity)severity);
760 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
762 } else if (token.Contains("alilog=off")) {
764 } else if (token.Contains("config=")) {
765 TString param=token.ReplaceAll("config=", "");
767 gROOT->Macro(param.Data(), &error);
769 SetStatusFlags(kConfigurationLoaded);
771 HLTError("can not execute macro \'%s\'", param.Data());
774 } else if (token.Contains("chains=")) {
775 TString param=token.ReplaceAll("chains=", "");
776 fChains=param.ReplaceAll(",", " ");
777 } else if (token.Contains("libmode=")) {
778 TString param=token.ReplaceAll("libmode=", "");
779 param.ReplaceAll(",", " ");
780 if (fpComponentHandler) {
781 if (param.CompareTo("static")==0) {
782 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kStatic);
783 } else if (param.CompareTo("dynamic")==0) {
784 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kDynamic);
786 HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
789 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
793 HLTWarning("unknown option \'%s\'", token.Data());
801 const char** deflib=kHLTDefaultLibs;
807 if ((!CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
808 (LoadComponentLibraries(libs.Data())<0)) {
809 HLTError("error while loading HLT libraries");
817 int AliHLTSystem::Reset(int bForce)
819 // see header file for class documentation
821 if (!bForce && CheckStatus(kRunning)) {
822 HLTError("HLT system in running state, can not configure");
826 ClearStatusFlags(~kUninitialized);
830 int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader)
832 // see header file for class documentation
833 if (CheckStatus(kRunning)) {
834 HLTError("HLT system in running state, can not configure");
838 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
839 while (pAgent && iResult>=0) {
840 const char* deplibs=pAgent->GetRequiredComponentLibraries();
842 HLTDebug("load libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
843 iResult=LoadComponentLibraries(deplibs);
846 HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
847 pAgent->CreateConfigurations(fpConfigurationHandler, rawReader, runloader);
848 pAgent=AliHLTModuleAgent::GetNextAgent();
854 int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader)
856 // see header file for class documentation
857 if (CheckStatus(kRunning)) {
858 HLTError("HLT system in running state, can not configure");
861 if (!CheckStatus(kConfigurationLoaded)) {
862 HLTWarning("configurations not yet loaded");
871 if (fChains.Length()>0) {
873 HLTInfo("custom reconstruction chain: %s", chains.Data());
875 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
876 while ((pAgent || fChains.Length()>0) && iResult>=0) {
877 const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
879 if (!chains.IsNull()) chains+="";
881 HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
883 pAgent=AliHLTModuleAgent::GetNextAgent();
887 // build task list for chains
888 TObjArray* pTokens=chains.Tokenize(" ");
890 int iEntries=pTokens->GetEntries();
891 for (int i=0; i<iEntries && iResult>=0; i++) {
892 const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
893 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
895 iResult=BuildTaskList(pConf);
897 assert(fpComponentHandler!=NULL);
898 TString cid=pConf->GetComponentID();
899 if (cid.CompareTo("HLTOUT")==0) {
900 // remove from the input of a global HLTOUT configuration
901 chains.ReplaceAll(pCID, "");
902 } else if (bHaveOutput==0) {
903 // check whether this configuration produces data output
904 if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) {
906 chains.ReplaceAll(pCID, "");
911 HLTWarning("can not find configuration %s", pCID);
917 // build HLTOUT for simulation
918 if (iResult>=0 && runloader) {
920 // there are components in the chain which produce data which need to be
921 // piped to an HLTOUT
922 if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
923 LoadComponentLibraries("libHLTsim.so")>=0) {
924 AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
925 iResult=BuildTaskList("_globalout_");
927 HLTError("can not load libHLTsim.so and HLTOUT component");
933 if (iResult>=0) SetStatusFlags(kTaskListCreated);
938 int AliHLTSystem::CheckStatus(int flag)
940 // see header file for class documentation
941 if (flag==kUninitialized && flag==fState) return 1;
942 if ((fState&flag)==flag) return 1;
946 int AliHLTSystem::GetStatusFlags()
948 // see header file for class documentation
952 int AliHLTSystem::SetStatusFlags(int flags)
954 // see header file for class documentation
959 int AliHLTSystem::ClearStatusFlags(int flags)
961 // see header file for class documentation
966 void* AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol)
968 // see header file for class documentation
969 if (fpComponentHandler==NULL) return NULL;
970 return fpComponentHandler->FindSymbol(library, symbol);
973 void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
975 SetLocalLoggingLevel(level);
976 if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
977 if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);