]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTSystem.cxx
New class AliESDEvent, backward compatibility with the old AliESD (Christian)
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTSystem.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  for The ALICE HLT Project.                            *
9  *                                                                        *
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  **************************************************************************/
18
19 /** @file   AliHLTSystem.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Implementation of HLT module management.
23 */
24
25 #if __GNUC__>= 3
26 using namespace std;
27 #endif
28
29 #include "AliHLTStdIncludes.h"
30 #include "AliHLTSystem.h"
31 #include "AliHLTComponentHandler.h"
32 #include "AliHLTComponent.h"
33 #include "AliHLTConfiguration.h"
34 #include "AliHLTConfigurationHandler.h"
35 #include "AliHLTTask.h"
36 #include "AliHLTModuleAgent.h"
37 #include "AliHLTOfflineInterface.h"
38 #include <TObjArray.h>
39 #include <TObjString.h>
40 #include <TString.h>
41 #include <TStopwatch.h>
42
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTSystem)
45
46 AliHLTSystem::AliHLTSystem()
47   :
48   fpComponentHandler(new AliHLTComponentHandler()),
49   fpConfigurationHandler(new AliHLTConfigurationHandler()),
50   fTaskList(),
51   fState(0)
52 {
53   // see header file for class documentation
54   // or
55   // refer to README to build package
56   // or
57   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58
59   if (fgNofInstances++>0)
60     HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
61
62   SetGlobalLoggingLevel(kHLTLogDefault);
63   if (fpComponentHandler) {
64     AliHLTComponentEnvironment env;
65     memset(&env, 0, sizeof(AliHLTComponentEnvironment));
66     env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
67     env.fLoggingFunc=NULL;
68     AliHLTComponentLogSeverity loglevel=fpComponentHandler->GetLocalLoggingLevel();
69     fpComponentHandler->SetLocalLoggingLevel(kHLTLogError);
70     fpComponentHandler->SetEnvironment(&env);
71     fpComponentHandler->LoadLibrary("libAliHLTUtil.so");
72     fgAliLoggingFunc=(AliHLTLogging::AliHLTDynamicMessage)fpComponentHandler->FindSymbol("libAliHLTUtil.so", "AliDynamicMessage");
73     fpComponentHandler->SetLocalLoggingLevel(loglevel);
74     if (fgAliLoggingFunc==NULL) {
75       HLTError("symbol lookp failure: can not find AliDynamicMessage, switching to HLT logging system");
76     }
77     fpComponentHandler->AnnounceVersion();
78   } else {
79     HLTFatal("can not create Component Handler");
80   }
81   if (fpConfigurationHandler) {
82     AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
83   } else {
84     HLTFatal("can not create Configuration Handler");
85   }
86 }
87
88 AliHLTSystem::AliHLTSystem(const AliHLTSystem&)
89   :
90   AliHLTLogging(),
91   fpComponentHandler(NULL),
92   fpConfigurationHandler(NULL),
93   fTaskList(),
94   fState(0)
95 {
96   // see header file for class documentation
97   if (fgNofInstances++>0)
98     HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
99
100   HLTFatal("copy constructor untested");
101 }
102
103 AliHLTSystem& AliHLTSystem::operator=(const AliHLTSystem&)
104
105   // see header file for class documentation
106   HLTFatal("assignment operator untested");
107   return *this;
108 }
109
110 AliHLTSystem::~AliHLTSystem()
111 {
112   // see header file for class documentation
113   fgNofInstances--;
114   CleanTaskList();
115   AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
116   if (fpConfigurationHandler) {
117     delete fpConfigurationHandler;
118   }
119   fpConfigurationHandler=NULL;
120   
121   if (fpComponentHandler) {
122     delete fpComponentHandler;
123   }
124   fpComponentHandler=NULL;
125 }
126
127 int AliHLTSystem::fgNofInstances=0;
128
129 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
130 {
131   // see header file for class documentation
132   int iResult=0;
133   if (pConf) {
134   } else {
135     iResult=-EINVAL;
136   }
137   return iResult;
138 }
139
140 int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
141 {
142   // see header file for class documentation
143   int iResult=0;
144   if (pConf) {
145     if (pPrec) {
146       // find the position
147     }
148   } else {
149     iResult=-EINVAL;
150   }
151   return iResult;
152 }
153
154 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
155 {
156   // see header file for class documentation
157   int iResult=0;
158   if (pConf) {
159   } else {
160     iResult=-EINVAL;
161   }
162   return iResult;
163 }
164
165 int AliHLTSystem::BuildTaskList(const char* id)
166 {
167   // see header file for class documentation
168   int iResult=0;
169   if (id) {
170     if (fpConfigurationHandler) {
171       AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
172       if (pConf) {
173         iResult=BuildTaskList(pConf);
174       } else {
175         HLTError("unknown configuration \"%s\"", id);
176         iResult=-EEXIST;
177       }
178     } else {
179       iResult=-EFAULT;
180     }
181   } else {
182     iResult=-EINVAL;
183   }
184   return iResult;
185 }
186
187 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
188 {
189   // see header file for class documentation
190   int iResult=0;
191   if (pConf) {
192     AliHLTTask* pTask=NULL;
193     if ((pTask=FindTask(pConf->GetName()))!=NULL) {
194       if (pTask->GetConf()!=pConf) {
195         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);
196         iResult=-EEXIST;
197         pTask=NULL;
198       }
199     } else if (pConf->SourcesResolved(1)!=1) {
200         HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
201         iResult=-ENOLINK;
202     } else {
203       pTask=new AliHLTTask(pConf);
204       if (pTask==NULL) {
205         iResult=-ENOMEM;
206       }
207     }
208     if (pTask) {
209       // check for circular dependencies
210       if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
211         HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
212         pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
213         HLTError("aborted ...");
214         iResult=-ELOOP;
215       }
216       if (iResult>=0) {
217         // check whether all dependencies are already in the task list
218         // create the missing ones
219         // this step is an iterative process which calls this function again for the missing
220         // configurations, in order to avoid the currently processed task to be created
221         // again it is added to the list temporarily and removed afterwards
222         // This is of high importance to preserve the order of the tasks. Furthermore, the
223         // InsertTask method has to be used in order to set all the cross links right 
224         fTaskList.Add(pTask);
225         AliHLTConfiguration* pDep=pConf->GetFirstSource();
226         while (pDep!=NULL && iResult>=0) {
227           if (FindTask(pDep->GetName())==NULL) {
228             iResult=BuildTaskList(pDep);
229           }
230           pDep=pConf->GetNextSource();
231         }
232         // remove the temporarily added task
233         fTaskList.Remove(pTask);
234
235         // insert the task and set the cross-links
236         if (iResult>=0) {
237           iResult=InsertTask(pTask);
238         }
239       } else {
240         delete pTask;
241         pTask=NULL;
242       }
243     }
244   } else {
245     iResult=-EINVAL;
246   }
247   return iResult;
248 }
249
250 int AliHLTSystem::CleanTaskList()
251 {
252   // see header file for class documentation
253   int iResult=0;
254   TObjLink* lnk=NULL;
255   while ((lnk=fTaskList.LastLink())!=NULL) {
256     delete (lnk->GetObject());
257     fTaskList.Remove(lnk);
258   }
259   return iResult;
260 }
261
262 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
263 {
264   // see header file for class documentation
265   int iResult=0;
266   TObjLink *lnk = NULL;
267   if ((iResult=pTask->CheckDependencies())>0)
268     lnk=fTaskList.FirstLink();
269   while (lnk && iResult>0) {
270     AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
271     //HLTDebug("checking  \"%s\"", pCurr->GetName());
272     iResult=pTask->Depends(pCurr);
273     if (iResult>0) {
274       iResult=pTask->SetDependency(pCurr);
275       pCurr->SetTarget(pTask);
276       HLTDebug("set dependency  \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
277     }
278     if (pCurr->Depends(pTask)) {
279       // circular dependency
280       HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
281       iResult=-ELOOP;
282     } else if ((iResult=pTask->CheckDependencies())>0) {
283       lnk = lnk->Next();
284     }
285   }
286   if (iResult==0) {
287       if (lnk) {
288         fTaskList.AddAfter(lnk, pTask);
289       } else {
290         fTaskList.AddFirst(pTask);
291       }
292       HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
293   } else if (iResult>0) {
294     HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
295     iResult=-ENOLINK;
296   }
297   return iResult;
298 }
299
300 AliHLTTask* AliHLTSystem::FindTask(const char* id)
301 {
302   // see header file for class documentation
303   AliHLTTask* pTask=NULL;
304   if (id) {
305     pTask=(AliHLTTask*)fTaskList.FindObject(id); 
306   }
307   return pTask;
308 }
309
310 void AliHLTSystem::PrintTaskList()
311 {
312   // see header file for class documentation
313   HLTLogKeyword("task list");
314   TObjLink *lnk = NULL;
315   HLTMessage("Task List");
316   lnk=fTaskList.FirstLink();
317   while (lnk) {
318     TObject* obj=lnk->GetObject();
319     if (obj) {
320       HLTMessage("  %s - status:", obj->GetName());
321       AliHLTTask* pTask=(AliHLTTask*)obj;
322       pTask->PrintStatus();
323     } else {
324     }
325     lnk = lnk->Next();
326   }
327 }
328
329 int AliHLTSystem::Run(Int_t iNofEvents) 
330 {
331   // see header file for class documentation
332   int iResult=0;
333   int iCount=0;
334   SetStatusFlags(kRunning);
335   TStopwatch StopwatchBase; StopwatchBase.Reset();
336   TStopwatch StopwatchDA; StopwatchDA.Reset();
337   TStopwatch StopwatchInput; StopwatchInput.Reset();
338   TStopwatch StopwatchOutput; StopwatchOutput.Reset();
339   TObjArray Stopwatches;
340   Stopwatches.AddAt(&StopwatchBase, (int)AliHLTComponent::kSWBase);
341   Stopwatches.AddAt(&StopwatchDA, (int)AliHLTComponent::kSWDA);
342   Stopwatches.AddAt(&StopwatchInput, (int)AliHLTComponent::kSWInput);
343   Stopwatches.AddAt(&StopwatchOutput, (int)AliHLTComponent::kSWOutput);
344   if ((iResult=InitTasks())>=0 && (iResult=InitBenchmarking(&Stopwatches))>=0) {
345     if ((iResult=StartTasks())>=0) {
346       for (int i=0; i<iNofEvents && iResult>=0; i++) {
347         iResult=ProcessTasks(i);
348         if (iResult>=0) {
349           HLTInfo("Event %d successfully finished (%d)", i, iResult);
350           iResult=0;
351           iCount++;
352         } else {
353           HLTError("Processing of event %d failed (%d)", i, iResult);
354           // TODO: define different running modes to either ignore errors in
355           // event processing or not
356           // currently ignored 
357           //iResult=0;
358         }
359       }
360       StopTasks();
361     } else {
362       HLTError("can not start task list");
363     }
364     DeinitTasks();
365   } else if (iResult!=-ENOENT) {
366     HLTError("can not initialize task list");
367   }
368   if (iResult>=0) {
369     iResult=iCount;
370     HLTInfo("HLT statistics:\n"
371             "    base:              R:%.3fs C:%.3fs\n"
372             "    input:             R:%.3fs C:%.3fs\n"
373             "    output:            R:%.3fs C:%.3fs\n"
374             "    event processing : R:%.3fs C:%.3fs"
375             , StopwatchBase.RealTime(),StopwatchBase.CpuTime()
376             , StopwatchInput.RealTime(),StopwatchInput.CpuTime()
377             , StopwatchOutput.RealTime(),StopwatchOutput.CpuTime()
378             , StopwatchDA.RealTime(),StopwatchDA.CpuTime());
379   }
380   ClearStatusFlags(kRunning);
381   return iResult;
382 }
383
384 int AliHLTSystem::InitTasks()
385 {
386   // see header file for class documentation
387   int iResult=0;
388   TObjLink *lnk=fTaskList.FirstLink();
389   if (lnk==NULL) {
390     HLTWarning("Task list is empty, aborting ...");
391     return -ENOENT;
392   }
393   while (lnk && iResult>=0) {
394     TObject* obj=lnk->GetObject();
395     if (obj) {
396       AliHLTTask* pTask=(AliHLTTask*)obj;
397       iResult=pTask->Init(NULL, fpComponentHandler);
398     } else {
399     }
400     lnk = lnk->Next();
401   }
402   if (iResult<0) {
403   }
404   return iResult;
405 }
406
407 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
408 {
409   // see header file for class documentation
410   if (pStopwatches==NULL) return -EINVAL;
411
412   int iResult=0;
413   TObjLink *lnk=fTaskList.FirstLink();
414   while (lnk && iResult>=0) {
415     TObject* obj=lnk->GetObject();
416     if (obj) {
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);
423           break;
424         case AliHLTComponent::kSource:
425           {
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);
433           }
434           break;
435         case AliHLTComponent::kSink:
436           {
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);
444           }
445           break;
446         default:
447           HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
448         }
449       }
450     } else {
451     }
452     lnk = lnk->Next();
453   }
454   return iResult;
455 }
456
457 int AliHLTSystem::StartTasks()
458 {
459   // see header file for class documentation
460   int iResult=0;
461   TObjLink *lnk=fTaskList.FirstLink();
462   while (lnk && iResult>=0) {
463     TObject* obj=lnk->GetObject();
464     if (obj) {
465       AliHLTTask* pTask=(AliHLTTask*)obj;
466       iResult=pTask->StartRun();
467     } else {
468     }
469     lnk = lnk->Next();
470   }
471   if (iResult<0) {
472   }
473   return iResult;
474 }
475
476 int AliHLTSystem::ProcessTasks(Int_t eventNo)
477 {
478   // see header file for class documentation
479   int iResult=0;
480   HLTDebug("processing event no %d", eventNo);
481   TObjLink *lnk=fTaskList.FirstLink();
482   while (lnk && iResult>=0) {
483     TObject* obj=lnk->GetObject();
484     if (obj) {
485       AliHLTTask* pTask=(AliHLTTask*)obj;
486       iResult=pTask->ProcessTask(eventNo);
487       HLTDebug("task %s finnished (%d)", pTask->GetName(), iResult);
488     } else {
489     }
490     lnk = lnk->Next();
491   }
492   return iResult;
493 }
494
495 int AliHLTSystem::StopTasks()
496 {
497   // see header file for class documentation
498   int iResult=0;
499   TObjLink *lnk=fTaskList.FirstLink();
500   while (lnk && iResult>=0) {
501     TObject* obj=lnk->GetObject();
502     if (obj) {
503       AliHLTTask* pTask=(AliHLTTask*)obj;
504       iResult=pTask->EndRun();
505     } else {
506     }
507     lnk = lnk->Next();
508   }
509   return iResult;
510 }
511
512 int AliHLTSystem::DeinitTasks()
513 {
514   // see header file for class documentation
515   int iResult=0;
516   TObjLink *lnk=fTaskList.FirstLink();
517   while (lnk && iResult>=0) {
518     TObject* obj=lnk->GetObject();
519     if (obj) {
520       AliHLTTask* pTask=(AliHLTTask*)obj;
521       iResult=pTask->Deinit();
522     } else {
523     }
524     lnk = lnk->Next();
525   }
526   return iResult;
527 }
528
529 void* AliHLTSystem::AllocMemory( void* param, unsigned long size )
530 {
531   // see header file for class documentation
532   if (param==NULL) {
533     // get rid of 'unused parameter' warning
534   }
535   return (void*)new char[size];
536 }
537
538 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader, 
539                               AliRawReader* rawReader)
540 {
541   // see header file for class documentation
542   int iResult=0;
543   if (runLoader) {
544     HLTInfo("Run Loader %p, Raw Reader %p , %d events", runLoader, rawReader, nofEvents);
545     if (CheckStatus(kReady)) {
546       if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
547         iResult=Run(nofEvents);
548       }
549     } else {
550       HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
551     }
552   } else {
553     HLTError("missing run loader instance");
554     iResult=-EINVAL;
555   }
556   return iResult;
557 }
558
559 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
560 {
561   // see header file for class documentation
562   int iResult=0;
563   if (runLoader) {
564     HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
565     iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
566   } else {
567     HLTError("missing run loader/ESD instance(s)");
568     iResult=-EINVAL;
569   }
570   return iResult;
571 }
572
573 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
574 {
575   // see header file for class documentation
576   int iResult=0;
577   if (libraries) {
578     if (fpComponentHandler) {
579       TString libs(libraries);
580       TObjArray* pTokens=libs.Tokenize(" ");
581       if (pTokens) {
582         int iEntries=pTokens->GetEntries();
583         for (int i=0; i<iEntries && iResult>=0; i++) {
584           iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
585         }
586         delete pTokens;
587       }
588       if (iResult>=0) {
589         SetStatusFlags(kLibrariesLoaded);
590       } else {
591         // lets see if we need this, probably not
592         //fpComponentHandler->UnloadLibraries();
593         ClearStatusFlags(kLibrariesLoaded);
594       }
595     } else {
596       iResult=-EFAULT;
597       HLTFatal("no component handler available");
598     }
599   } else {
600     iResult=-EINVAL;
601   }
602   return iResult;
603 }
604
605 int AliHLTSystem::Configure(AliRunLoader* runloader)
606 {
607   // see header file for class documentation
608   int iResult=0;
609   if (CheckStatus(kRunning)) {
610     HLTError("HLT system in running state, can not configure");
611     return -EBUSY;
612   }
613   if (CheckFilter(kHLTLogDebug))
614     AliHLTModuleAgent::PrintStatus();
615   ClearStatusFlags(kConfigurationLoaded|kTaskListCreated);
616   iResult=LoadConfigurations(runloader);
617   if (iResult>=0) {
618     SetStatusFlags(kConfigurationLoaded);
619     iResult=BuildTaskListsFromTopConfigurations(runloader);
620     if (iResult>=0) {
621       SetStatusFlags(kTaskListCreated);
622     }
623   }
624   if (iResult<0) SetStatusFlags(kError);
625   
626   return iResult;
627 }
628
629 int AliHLTSystem::Reset(int bForce)
630 {
631   // see header file for class documentation
632   int iResult=0;
633   if (!bForce && CheckStatus(kRunning)) {
634     HLTError("HLT system in running state, can not configure");
635     return -EBUSY;
636   }
637   CleanTaskList();
638   ClearStatusFlags(~kUninitialized);
639   return iResult;
640 }
641
642 int AliHLTSystem::LoadConfigurations(AliRunLoader* runloader)
643 {
644   // see header file for class documentation
645   if (CheckStatus(kRunning)) {
646     HLTError("HLT system in running state, can not configure");
647     return -EBUSY;
648   }
649   int iResult=0;
650   AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
651   while (pAgent && iResult>=0) {
652     const char* deplibs=pAgent->GetRequiredComponentLibraries();
653     if (deplibs) {
654       HLTDebug("load libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
655       iResult=LoadComponentLibraries(deplibs);
656     }
657     if (iResult>=0) {
658       HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
659       pAgent->CreateConfigurations(fpConfigurationHandler, runloader);
660       pAgent=AliHLTModuleAgent::GetNextAgent();
661     }
662   }
663   return iResult;
664 }
665
666 int AliHLTSystem::BuildTaskListsFromTopConfigurations(AliRunLoader* runloader)
667 {
668   // see header file for class documentation
669   if (CheckStatus(kRunning)) {
670     HLTError("HLT system in running state, can not configure");
671     return -EBUSY;
672   }
673   if (!CheckStatus(kConfigurationLoaded)) {
674     HLTWarning("configurations not yet loaded");
675     return 0;
676   }
677
678   int iResult=0;
679   AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
680   while (pAgent && iResult>=0) {
681     TString tops=pAgent->GetLocalRecConfigurations(runloader);
682     HLTDebug("top configurations for agent %s (%p): %s", pAgent->GetName(), pAgent, tops.Data());
683     TObjArray* pTokens=tops.Tokenize(" ");
684     if (pTokens) {
685       int iEntries=pTokens->GetEntries();
686       for (int i=0; i<iEntries && iResult>=0; i++) {
687         const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
688         AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
689         if (pConf) {
690           iResult=BuildTaskList(pConf);
691         } else {
692           HLTWarning("can not find top configuration %s", pCID);
693         }
694       }
695       delete pTokens;
696     }
697     
698     pAgent=AliHLTModuleAgent::GetNextAgent();
699   }
700   if (iResult>=0) SetStatusFlags(kTaskListCreated);
701
702   return iResult;
703 }
704
705 int AliHLTSystem::CheckStatus(int flag)
706 {
707   // see header file for class documentation
708   if (flag==kUninitialized && flag==fState) return 1;
709   if ((fState&flag)==flag) return 1;
710   return 0;
711 }
712
713 int AliHLTSystem::GetStatusFlags()
714 {
715   // see header file for class documentation
716   return fState;
717 }
718
719 int AliHLTSystem::SetStatusFlags(int flags)
720 {
721   // see header file for class documentation
722   fState|=flags;
723   return fState;
724 }
725
726 int AliHLTSystem::ClearStatusFlags(int flags)
727 {
728   // see header file for class documentation
729   fState&=~flags;
730   return fState;
731 }
732
733 void* AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol)
734 {
735   if (fpComponentHandler==NULL) return NULL;
736   return fpComponentHandler->FindSymbol(library, symbol);
737 }