2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 //* for The ALICE HLT Project. *
9 //* Permission to use, copy, modify and distribute this software and its *
10 //* documentation strictly for non-commercial purposes is hereby granted *
11 //* without fee, provided that the above copyright notice appears in all *
12 //* copies and that both the copyright notice and this permission notice *
13 //* appear in the supporting documentation. The authors make no claims *
14 //* about the suitability of this software for any purpose. It is *
15 //* provided "as is" without express or implied warranty. *
16 //**************************************************************************
18 /** @file AliHLTSystem.cxx
19 @author Matthias Richter
21 @brief Implementation of HLT module management.
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 "AliHLTDataSource.h"
39 #include "AliHLTOUT.h"
40 #include "AliHLTOUTHandler.h"
41 #include "AliHLTOUTTask.h"
42 #include "AliHLTControlTask.h"
43 #include "AliHLTDataBuffer.h"
44 #include "AliHLTMisc.h"
45 #include <TObjArray.h>
46 #include <TObjString.h>
47 #include <TStopwatch.h>
49 //#include <TSystem.h>
51 //#include <TInterpreter.h>
53 /** HLT default component libraries */
54 const char* AliHLTSystem::fgkHLTDefaultLibs[]= {
58 // "libAliHLTSample.so",
59 // "libAliHLTPHOS.so",
64 "libAliHLTTrigger.so",
68 /** ROOT macro for the implementation of ROOT specific class methods */
69 ClassImp(AliHLTSystem)
71 AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name)
73 fpComponentHandler(AliHLTComponentHandler::CreateHandler()),
74 fpConfigurationHandler(AliHLTConfigurationHandler::CreateHandler()),
78 fStopwatches(new TObjArray),
81 fpChainHandlers(NULL),
83 fpProprietaryHandlers(NULL),
89 // see header file for class documentation
91 // refer to README to build package
93 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
95 if (fgNofInstances++>0) {
96 // July 2008: multiple instances are now allowed
97 // AliHLTSystem is used in multiple instances for the kChain HLTOUT handler
98 //HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
101 SetGlobalLoggingLevel(loglevel);
102 SetFrameworkLog(loglevel);
103 if (fpComponentHandler) {
104 AliHLTAnalysisEnvironment env;
105 memset(&env, 0, sizeof(AliHLTAnalysisEnvironment));
106 env.fStructSize=sizeof(AliHLTAnalysisEnvironment);
107 env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
108 env.fGetEventDoneDataFunc=AliHLTSystem::AllocEventDoneData;
109 env.fLoggingFunc=NULL;
110 fpComponentHandler->SetEnvironment(&env);
111 InitAliLogFunc(fpComponentHandler);
112 if (fgNofInstances==1) {
113 fpComponentHandler->AnnounceVersion();
116 HLTFatal("can not create Component Handler");
118 if (fpConfigurationHandler) {
119 AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
121 HLTFatal("can not create Configuration Handler");
125 AliHLTSystem::~AliHLTSystem()
127 // see header file for class documentation
131 AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
132 if (fpConfigurationHandler) {
133 fpConfigurationHandler->Destroy();
135 fpConfigurationHandler=NULL;
137 if (fpComponentHandler) {
138 fpComponentHandler->Destroy();
140 fpComponentHandler=NULL;
142 // note: fpHLTOUTTask and fpControlTask are deleted by
146 int AliHLTSystem::fgNofInstances=0;
148 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
150 // see header file for class documentation
151 HLTLogKeyword("configuration handling");
154 HLTError("function not yet implemented");
162 int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
164 // see header file for class documentation
165 HLTLogKeyword("configuration handling");
170 HLTError("function not yet implemented");
179 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
181 // see header file for class documentation
182 HLTLogKeyword("configuration handling");
185 HLTError("function not yet implemented");
193 int AliHLTSystem::BuildTaskList(const char* id)
195 // see header file for class documentation
198 if (fpConfigurationHandler) {
199 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
201 iResult=BuildTaskList(pConf);
203 HLTError("unknown configuration \"%s\"", id);
215 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
217 // see header file for class documentation
220 AliHLTTask* pTask=NULL;
221 if ((pTask=FindTask(pConf->GetName()))!=NULL) {
222 if (pTask->GetConf()!=pConf) {
223 HLTError("configuration mismatch, there is already a task with configuration name \"%s\", but it is different. Most likely configuration %p is not registered properly", pConf->GetName(), pConf);
226 // task for this configuration exists, terminate
228 } else if (pConf->SourcesResolved(1)!=1) {
229 HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
232 pTask=new AliHLTTask(pConf);
236 pTask->SetLocalLoggingLevel(GetLocalLoggingLevel());
239 static int iterationLevel=0;
240 if (pTask && iResult>=0) {
241 // check for circular dependencies
242 if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
243 HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
244 pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
245 HLTError("aborted ...");
249 // check whether all dependencies are already in the task list
250 // create the missing ones
251 // this step is an iterative process which calls this function again for the missing
252 // configurations, in order to avoid the currently processed task to be created
253 // again it is added to the list temporarily and removed afterwards
254 // This is of high importance to preserve the order of the tasks. Furthermore, the
255 // InsertTask method has to be used in order to set all the cross links right
256 fTaskList.Add(pTask);
257 AliHLTConfiguration* pDep=pConf->GetFirstSource();
258 while (pDep!=NULL && iResult>=0) {
259 HLTDebug("iteration %d: checking dependency %s (%p)", iterationLevel, pDep->GetName(), pDep);
260 if (FindTask(pDep->GetName())==NULL) {
261 HLTDebug("iteration %d: building task list for configuration %s (%p)", iterationLevel, pDep->GetName(), pDep);
263 iResult=BuildTaskList(pDep);
266 pDep=pConf->GetNextSource();
268 // remove the temporarily added task
269 fTaskList.Remove(pTask);
271 // insert the task and set the cross-links
273 HLTDebug("iteration %d: inserting task %s (%p)", iterationLevel, pTask->GetName(), pTask);
274 iResult=InsertTask(pTask);
287 int AliHLTSystem::CleanTaskList()
289 // see header file for class documentation
294 while ((lnk=fTaskList.LastLink())!=NULL) {
295 delete (lnk->GetObject());
296 fTaskList.Remove(lnk);
302 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
304 // see header file for class documentation
306 if (fpControlTask==NULL) {
307 fpControlTask=new AliHLTControlTask;
308 if (!fpControlTask) return -ENOMEM;
309 fTaskList.AddFirst(fpControlTask);
311 TObjLink *controlLnk=NULL;
312 TObjLink *lnk = fTaskList.FirstLink();
313 assert(!lnk || lnk->GetObject()==fpControlTask || fpControlTask==NULL);
314 if (lnk && lnk->GetObject()==fpControlTask) {
315 if (pTask->GetConf() && pTask->GetConf()->GetFirstSource()==NULL) {
316 pTask->SetDependency(fpControlTask);
317 fpControlTask->SetTarget(pTask);
322 if ((iResult=pTask->CheckDependencies())<=0)
324 while (lnk && iResult>0) {
325 AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
326 //HLTDebug("checking \"%s\"", pCurr->GetName());
327 iResult=pTask->Depends(pCurr);
329 iResult=pTask->SetDependency(pCurr);
330 pCurr->SetTarget(pTask);
331 HLTDebug("set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
333 if (pCurr->Depends(pTask)) {
334 // circular dependency
335 HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
337 } else if ((iResult=pTask->CheckDependencies())>0) {
343 fTaskList.AddAfter(lnk, pTask);
344 } else if (controlLnk) {
345 fTaskList.AddAfter(controlLnk, pTask);
347 fTaskList.AddFirst(pTask);
349 HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
350 } else if (iResult>0) {
351 HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
357 AliHLTTask* AliHLTSystem::FindTask(const char* id)
359 // see header file for class documentation
360 AliHLTTask* pTask=NULL;
362 pTask=dynamic_cast<AliHLTTask*>(fTaskList.FindObject(id));
367 void AliHLTSystem::PrintTaskList()
369 // see header file for class documentation
370 HLTLogKeyword("task list");
371 TObjLink *lnk = NULL;
372 HLTMessage("Task List");
373 lnk=fTaskList.FirstLink();
375 TObject* obj=lnk->GetObject();
377 HLTMessage(" %s - status:", obj->GetName());
378 AliHLTTask* pTask=(AliHLTTask*)obj;
379 pTask->PrintStatus();
386 int AliHLTSystem::Run(Int_t iNofEvents, int bStop, AliHLTUInt64_t trgMask)
388 // see header file for class documentation
391 SetStatusFlags(kRunning);
392 if (fEventCount>=0 || (iResult=InitTasks())>=0) {
393 if (fEventCount>=0 || (iResult=StartTasks())>=0) {
394 if (fEventCount==0) {
395 InitBenchmarking(fStopwatches);
397 // Matthias Oct 11 2008 this is a bug
398 // By resuming the stopwatches at this point, all continued counting, but the
399 // starting and stopping is controlled by the AliHLTStopwatchGuard
400 //ResumeBenchmarking(fStopwatches);
402 for (int i=fEventCount; i<fEventCount+iNofEvents && iResult>=0; i++) {
404 if (iNofEvents>1 && i==fEventCount) {
405 HLTWarning("can not add more than one event to the HLTOUT, skipping all but last block");
407 // reset and prepare for new data
408 fpHLTOUTTask->Reset();
410 if ((iResult=ProcessTasks(i, trgMask))>=0) {
414 // TODO: define different running modes to either ignore errors in
415 // event processing or not
419 AliHLTDataBuffer::SetGlobalEventCount(iCount);
421 fEventCount+=iNofEvents;
422 if (bStop) StopTasks();
423 else PauseBenchmarking(fStopwatches);
425 if (bStop) DeinitTasks();
429 } else if (iResult==-126 /*ENOKEY*/) {
430 iResult=0; // do not propagate the error
432 ClearStatusFlags(kRunning);
433 AliHLTDataBuffer::PrintStatistics();
437 int AliHLTSystem::InitTasks()
439 // see header file for class documentation
441 TObjLink *lnk=fTaskList.FirstLink();
444 HLTInfo("Task list is empty, skipping HLT");
445 return -126 /*ENOKEY*/;
447 while (lnk && iResult>=0) {
448 TObject* obj=lnk->GetObject();
450 AliHLTTask* pTask=(AliHLTTask*)obj;
451 iResult=pTask->Init(NULL, fpComponentHandler);
452 // ProcInfo_t ProcInfo;
453 // gSystem->GetProcInfo(&ProcInfo);
454 // HLTInfo("task %s initialized (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
460 HLTError("can not initialize task list, error %d", iResult);
466 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
468 // see header file for class documentation
470 if (pStopwatches==NULL) return 0;
472 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
473 TStopwatch* pStopwatch= new TStopwatch;
476 pStopwatches->AddAt(pStopwatch, i);
483 TObjLink *lnk=fTaskList.FirstLink();
484 while (lnk && iResult>=0) {
485 TObject* obj=lnk->GetObject();
487 AliHLTTask* pTask=(AliHLTTask*)obj;
488 AliHLTComponent* pComp=NULL;
489 if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) {
490 switch (pComp->GetComponentType()) {
491 case AliHLTComponent::kProcessor:
492 pComp->SetStopwatches(pStopwatches);
494 case AliHLTComponent::kSource:
496 // this switch determines whether the time consumption of the
497 // AliHLTComponent base methods should be counted to the input
498 // stopwatch or base stopwatch.
499 //int inputBase=(int)AliHLTComponent::kSWBase;
500 int inputBase=(int)AliHLTComponent::kSWInput;
501 pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase);
502 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA);
505 case AliHLTComponent::kSink:
507 // this switch determines whether the time consumption of the
508 // AliHLTComponent base methods should be counted to the output
509 // stopwatch or base stopwatch.
510 //int outputBase=(int)AliHLTComponent::kSWBase;
511 int outputBase=(int)AliHLTComponent::kSWOutput;
512 pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase);
513 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA);
517 HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
527 int AliHLTSystem::PauseBenchmarking(TObjArray* pStopwatches) const
529 // see header file for class documentation
530 if (pStopwatches==NULL) return 0;
532 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
533 if (!pStopwatches->At(i)) continue;
534 TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
535 if (pSw) pSw->Stop();
540 int AliHLTSystem::ResumeBenchmarking(TObjArray* pStopwatches) const
542 // see header file for class documentation
543 if (pStopwatches==NULL) return 0;
545 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
546 if (!pStopwatches->At(i)) continue;
547 TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
548 if (pSw) pSw->Continue();
553 int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean) const
555 // see header file for class documentation
557 if (pStopwatches==NULL) return 0;
559 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
560 if (!dynamic_cast<TStopwatch*>(pStopwatches->At(i))) {
566 if (iInitialized!=0) {
567 HLTImportant("HLT statistics:\n"
568 " base: R:%.3fs C:%.3fs\n"
569 " input: R:%.3fs C:%.3fs\n"
570 " output: R:%.3fs C:%.3fs\n"
571 " event processing : R:%.3fs C:%.3fs"
572 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->RealTime()
573 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->CpuTime()
574 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->RealTime()
575 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->CpuTime()
576 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->RealTime()
577 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->CpuTime()
578 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->RealTime()
579 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->CpuTime()
584 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
585 TObject* pObj=pStopwatches->RemoveAt(i);
586 if (pObj) delete pObj;
592 int AliHLTSystem::StartTasks()
594 // see header file for class documentation
596 TObjLink *lnk=fTaskList.FirstLink();
597 while (lnk && iResult>=0) {
598 TObject* obj=lnk->GetObject();
600 AliHLTTask* pTask=(AliHLTTask*)obj;
601 iResult=pTask->StartRun();
602 // ProcInfo_t ProcInfo;
603 // gSystem->GetProcInfo(&ProcInfo);
604 // HLTInfo("task %s started (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
610 HLTError("can not start task list, error %d", iResult);
612 SetStatusFlags(kStarted);
615 if ((iResult=SendControlEvent(kAliHLTDataTypeSOR))<0) {
616 HLTError("can not send SOR event: error %d", iResult);
622 int AliHLTSystem::ProcessTasks(Int_t eventNo, AliHLTUInt64_t trgMask)
624 // see header file for class documentation
626 HLTDebug("processing event no %d", eventNo);
627 TObjLink *lnk=fTaskList.FirstLink();
628 while (lnk && iResult>=0) {
629 TObject* obj=lnk->GetObject();
631 AliHLTTask* pTask=(AliHLTTask*)obj;
632 iResult=pTask->ProcessTask(eventNo, gkAliEventTypeData, trgMask);
633 // ProcInfo_t ProcInfo;
634 // gSystem->GetProcInfo(&ProcInfo);
635 // HLTInfo("task %s processed (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
642 HLTImportant("Event %d successfully finished (%d)", eventNo, iResult);
645 HLTError("Processing of event %d failed (%d)", eventNo, iResult);
651 int AliHLTSystem::StopTasks()
653 // see header file for class documentation
655 if ((iResult=SendControlEvent(kAliHLTDataTypeEOR))<0) {
656 HLTError("can not send EOR event");
659 // cleanup blocks from the last event. This is a bit awkward. All output
660 // blocks from the chains need to be stored in the HLTOUT task. Though,
661 // we do not know, whether HLTOUT is going to be processed or not.
663 fpHLTOUTTask->Reset();
665 TObjLink *lnk=fTaskList.FirstLink();
667 TObject* obj=lnk->GetObject();
669 AliHLTTask* pTask=(AliHLTTask*)obj;
670 int locResult=pTask->EndRun();
671 if (iResult>=0 && locResult<0) iResult=locResult;
672 // ProcInfo_t ProcInfo;
673 // gSystem->GetProcInfo(&ProcInfo);
674 // HLTInfo("task %s stopped (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
679 PrintBenchmarking(fStopwatches, 1 /*clean*/);
680 ClearStatusFlags(kStarted);
684 int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt)
686 // see header file for class documentation
689 AliHLTComponentBlockDataList controlBlocks;
690 AliHLTComponentBlockData bd;
692 // run decriptor block of type kAliHLTDataTypeSOR/kAliHLTDataTypeEOR
693 AliHLTComponent::FillBlockData(bd);
694 AliHLTRunDesc runDesc;
695 memset(&runDesc, 0, sizeof(AliHLTRunDesc));
696 runDesc.fStructSize=sizeof(AliHLTRunDesc);
698 bd.fSize=sizeof(AliHLTRunDesc);
700 bd.fSpecification=kAliHLTVoidDataSpec;
701 controlBlocks.push_back(bd);
703 // ECS parameter of type kAliHLTDataTypeECSParam
704 if (fECSParams.IsNull())
705 fECSParams="CTP_TRIGGER_CLASS=00:DUMMY-TRIGGER-ALL:00-01-02-03-04-05-06-07-08-09-10-11-12-13-14-15-16-17";
706 AliHLTComponent::FillBlockData(bd);
707 bd.fPtr=(void*)fECSParams.Data();
708 bd.fSize=fECSParams.Length()+1;
709 bd.fDataType=kAliHLTDataTypeECSParam;
710 bd.fSpecification=kAliHLTVoidDataSpec;
711 controlBlocks.push_back(bd);
713 AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
714 HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
715 TObjLink *lnk=fTaskList.FirstLink();
716 while (lnk && iResult>=0) {
717 TObject* obj=lnk->GetObject();
719 AliHLTTask* pTask=(AliHLTTask*)obj;
720 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
721 if (dt==kAliHLTDataTypeSOR) eventType=gkAliEventTypeStartOfRun;
722 else if (dt==kAliHLTDataTypeEOR) eventType=gkAliEventTypeEndOfRun;
723 else HLTWarning("unknown control event %s", AliHLTComponent::DataType2Text(dt).c_str());
724 iResult=pTask->ProcessTask(-1, eventType);
730 // control events are not supposed to go into the HLTOUT
732 fpHLTOUTTask->Reset();
734 HLTDebug("event %s done (%d)", AliHLTComponent::DataType2Text(dt).c_str(), iResult);
738 int AliHLTSystem::DeinitTasks()
740 // see header file for class documentation
742 TObjLink *lnk=fTaskList.LastLink();
744 TObject* obj=lnk->GetObject();
746 AliHLTTask* pTask=(AliHLTTask*)obj;
747 int localRes=pTask->Deinit();
748 if (iResult>=0) iResult=localRes;
749 // ProcInfo_t ProcInfo;
750 // gSystem->GetProcInfo(&ProcInfo);
751 // HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
762 int AliHLTSystem::CleanHLTOUT()
764 // see header file for class documentation
765 if (fpChainHandlers) {
766 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
767 fpChainHandlers=NULL;
769 AliHLTOUT::InvalidateBlocks(*pHandlers);
770 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
772 assert(pHandlers->size()==0);
777 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
780 AliHLTOUT::InvalidateBlocks(*pHandlers);
781 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
783 assert(pHandlers->size()==0);
787 if (fpProprietaryHandlers) {
788 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
789 fpProprietaryHandlers=NULL;
791 AliHLTOUT::InvalidateBlocks(*pHandlers);
792 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
794 assert(pHandlers->size()==0);
800 void* AliHLTSystem::AllocMemory( void* /*param*/, unsigned long size )
802 // see header file for class documentation
805 p=(void*)new char[size];
809 log.LoggingVarargs(kHLTLogError, "AliHLTSystem" , "AllocMemory" , __FILE__ , __LINE__ , "exeption during memory allocation" );
814 int AliHLTSystem::AllocEventDoneData( void* /*param*/, AliHLTEventID_t /*eventID*/, unsigned long size, AliHLTComponentEventDoneData** edd )
816 // see header file for class documentation
817 unsigned long blocksize=sizeof(AliHLTComponentEventDoneData)+size;
818 void* block=AllocMemory(NULL, blocksize);
819 if (!block) return -ENOMEM;
820 memset(block, 0, blocksize);
821 *edd=reinterpret_cast<AliHLTComponentEventDoneData*>(block);
822 (*edd)->fStructSize=sizeof(AliHLTComponentEventDoneData);
823 (*edd)->fDataSize=size;
824 (*edd)->fData=reinterpret_cast<AliHLTUInt8_t*>(block)+sizeof(AliHLTComponentEventDoneData);
829 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
830 AliRawReader* rawReader)
832 // see header file for class documentation
834 if (runLoader || rawReader || nofEvents==0) {
835 if (nofEvents>0) {HLTInfo("Run Loader %p, Raw Reader %p , %d event(s)", runLoader, rawReader, nofEvents);}
836 if (CheckStatus(kReady)) {
838 // special case to close the reconstruction
839 if (!CheckStatus(kError)) {
845 if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
846 AliHLTUInt64_t trgMask=0x1;
847 if (runLoader==NULL) {
848 // this is a quick workaround for the case of simulation
849 // the trigger framework is still under development, secondly, AliHLTSimulation
850 // does not yet add the emulated ECS parameters, so no CTP trigger is known in the HLT
851 // AliHLTTask will initialize one dummy CTP trigger class with bit 0, that's why the
852 // default trigger mask is 0x1
853 trgMask=AliHLTMisc::Instance().GetTriggerMask(rawReader);
855 // the system always remains started after event processing, a specific
856 // call with nofEvents==0 is needed to execute the stop sequence
857 if ((iResult=Run(nofEvents, 0, trgMask))<0) SetStatusFlags(kError);
861 HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
864 HLTError("missing RunLoader (%p)/RawReader (%p) instance", runLoader, rawReader);
870 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
872 // see header file for class documentation
874 if (runLoader || esd) {
875 HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
876 iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
878 HLTError("missing run loader/ESD instance(s)");
884 int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd)
886 // see header file for class documentation
888 if (!pHLTOUT) return -EINVAL;
889 HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
891 // add the current HLTOUT task to the collection
893 AliHLTOUT* pTask=dynamic_cast<AliHLTOUT*>(fpHLTOUTTask);
894 if (pTask && (iResult=pTask->Init())>=0) {
895 if (pTask->GetNofDataBlocks()>0) {
896 pHLTOUT->AddSubCollection(pTask);
899 HLTWarning("can not initialize HLTOUT sub collection %s for reconstruction chain (%d), data blocks are lost", pTask?fpHLTOUTTask->GetName():"nil", iResult);
906 // process all kChain handlers first
908 if ((iResult=ProcessHLTOUTkChain(pHLTOUT))<0) {
909 HLTWarning("Processing of kChain-type data blocks failed with error code %d", iResult);
914 fpEsdHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
915 if (!fpProprietaryHandlers)
916 fpProprietaryHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
918 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pEsdHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
919 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pProprietaryHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
920 if (!pEsdHandlers || !pProprietaryHandlers) return -ENOMEM;
922 // invalidate all blocks
923 AliHLTOUT::InvalidateBlocks(*pEsdHandlers);
924 AliHLTOUT::InvalidateBlocks(*pProprietaryHandlers);
926 AliHLTComponentDataTypeList esdBlocks;
928 for (iResult=pHLTOUT->SelectFirstDataBlock();
930 iResult=pHLTOUT->SelectNextDataBlock()) {
931 AliHLTComponentDataType dt=kAliHLTVoidDataType;
932 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
933 pHLTOUT->GetDataBlockDescription(dt, spec);
934 AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
935 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
937 // default handling for ESD data blocks does not require an explicite handler
938 if (!pHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
939 handlerType=AliHLTModuleAgent::kEsd;
941 const char* pMsg="invalid";
942 switch (handlerType) {
943 case AliHLTModuleAgent::kEsd:
946 // schedule for later processing
947 pHLTOUT->InsertHandler(*pEsdHandlers, pHLTOUT->GetDataBlockHandlerDesc());
949 AliHLTComponentDataTypeList::iterator element=esdBlocks.begin();
950 for (; element!=esdBlocks.end(); element++) {
952 HLTWarning("multiple ESDs of identical data type %s, please add appropriate handler to merge ESDs", AliHLTComponent::DataType2Text(dt).c_str());
956 if (element==esdBlocks.end()) esdBlocks.push_back(dt);
959 const AliHLTUInt8_t* pBuffer=NULL;
960 AliHLTUInt32_t size=0;
961 if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) {
962 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
963 pHLTOUT->ReleaseDataBuffer(pBuffer);
965 pHLTOUT->MarkDataBlockProcessed();
969 case AliHLTModuleAgent::kRawReader:
970 // handled in the AliRawReaderHLT
972 case AliHLTModuleAgent::kRawStream:
973 HLTWarning("HLTOUT handler type 'kRawStream' not yet implemented: agent %s, data type %s, specification %#x",
974 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
975 AliHLTComponent::DataType2Text(dt).c_str(), spec);
977 case AliHLTModuleAgent::kChain:
978 HLTWarning("HLTOUT handler type 'kChain' has already been processed: agent %s, data type %s, specification %#x\n"
979 "New block of this type added by the chain? Skipping data block ...",
980 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
981 AliHLTComponent::DataType2Text(dt).c_str(), spec);
983 case AliHLTModuleAgent::kProprietary:
984 HLTDebug("processing proprietary data: agent %s, data type %s, specification %#x",
985 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
986 AliHLTComponent::DataType2Text(dt).c_str(), spec);
988 AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
989 int res=pHandler->ProcessData(pHLTOUT);
991 HLTWarning("processing proprietary data failed (%d): agent %s, data type %s, specification %#x",
992 res, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
993 AliHLTComponent::DataType2Text(dt).c_str(), spec);
997 case AliHLTModuleAgent::kUnknownOutput:
999 // fall trough intended
1001 HLTWarning("%s handler type: agent %s, data type %s, specification %#x, ... skipping data block",
1002 pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
1003 AliHLTComponent::DataType2Text(dt).c_str(), spec);
1006 // TODO: the return value of SelectFirst/NextDataBlock must be
1007 // changed in order to avoid this check
1008 if (iResult==-ENOENT) iResult=0;
1010 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator handler;
1012 // process and write all esd data blocks
1013 for (handler=pEsdHandlers->begin(); handler!=pEsdHandlers->end() && iResult>=0; handler++) {
1014 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1015 AliHLTOUTHandler* pHandler=*handler;
1016 const AliHLTUInt8_t* pBuffer=NULL;
1017 AliHLTUInt32_t size=0;
1018 pHandler->ProcessData(pHLTOUT);
1019 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1020 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*handler;
1021 AliHLTComponentDataType dt=desc;
1022 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
1023 pHandler->ReleaseProcessedData(pBuffer, size);
1025 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1028 // process all kProprietary data blocks
1029 for (handler=pProprietaryHandlers->begin(); handler!=pProprietaryHandlers->end() && iResult>=0; handler++) {
1030 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1031 AliHLTOUTHandler* pHandler=*handler;
1032 const AliHLTUInt8_t* pBuffer=NULL;
1033 AliHLTUInt32_t size=0;
1034 pHandler->ProcessData(pHLTOUT);
1035 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1036 HLTWarning("data produced by kProprietary handler ignored");
1037 pHandler->ReleaseProcessedData(pBuffer, size);
1039 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1042 // remove all empty handlers form the list (handlers which did not get a block this time)
1043 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pEsdHandlers);
1044 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pProprietaryHandlers);
1049 int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT)
1051 // see header file for class documentation
1053 if (!pHLTOUT) return -EINVAL;
1055 if (!fpChainHandlers)
1056 fpChainHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
1058 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pChainHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
1059 if (!pChainHandlers) return -ENOMEM;
1061 // invalidate all blocks
1062 AliHLTOUT::InvalidateBlocks(*pChainHandlers);
1065 pHLTOUT->FillHandlerList(*pChainHandlers, AliHLTModuleAgent::kChain);
1067 // process all defined chain handlers
1068 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator chainHandler;
1069 for (chainHandler=pChainHandlers->begin(); chainHandler!=pChainHandlers->end() && iResult>=0; chainHandler++) {
1070 if (chainHandler->IsEmpty()) continue;
1071 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*chainHandler));
1072 AliHLTOUTHandler* pHandler=*chainHandler;
1073 const AliHLTUInt8_t* pBuffer=NULL;
1074 AliHLTUInt32_t size=0;
1075 pHandler->ProcessData(pHLTOUT);
1076 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1077 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler;
1078 AliHLTComponentDataType dt=desc;
1080 pHandler->ReleaseProcessedData(pBuffer, size);
1082 pHLTOUT->MarkDataBlocksProcessed(&(*chainHandler));
1085 // remove all empty handlers form the list (handlers which did not get a block this time)
1086 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pChainHandlers);
1091 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
1093 // see header file for class documentation
1096 if (fpComponentHandler) {
1097 TString libs(libraries);
1098 TObjArray* pTokens=libs.Tokenize(" ");
1100 int iEntries=pTokens->GetEntriesFast();
1101 for (int i=0; i<iEntries && iResult>=0; i++) {
1102 iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
1107 SetStatusFlags(kLibrariesLoaded);
1109 // lets see if we need this, probably not
1110 //fpComponentHandler->UnloadLibraries();
1111 ClearStatusFlags(kLibrariesLoaded);
1115 HLTFatal("no component handler available");
1123 int AliHLTSystem::Configure(AliRunLoader* runloader)
1125 // see header file for class documentation
1126 return Configure(NULL, runloader);
1129 int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader)
1131 // see header file for class documentation
1133 if (CheckStatus(kRunning)) {
1134 HLTError("HLT system in running state, can not configure");
1137 ClearStatusFlags(kTaskListCreated);
1138 if (CheckFilter(kHLTLogDebug))
1139 AliHLTModuleAgent::PrintStatus();
1140 if (CheckStatus(kConfigurationLoaded)==0) {
1141 iResult=LoadConfigurations(rawReader, runloader);
1143 if (fChains.Length()==0) {
1144 HLTError("custom configuration(s) specified, but no configuration to run in local reconstruction, use \'chains=<chain,...>\' option");
1149 SetStatusFlags(kConfigurationLoaded);
1150 if (CheckFilter(kHLTLogDebug))
1151 fpConfigurationHandler->PrintConfigurations();
1152 iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader);
1154 SetStatusFlags(kTaskListCreated);
1157 if (iResult<0) SetStatusFlags(kError);
1162 int AliHLTSystem::ScanOptions(const char* options)
1164 // see header file for class documentation
1167 //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
1169 TString alloptions(options);
1170 TObjArray* pTokens=alloptions.Tokenize(" ");
1172 int iEntries=pTokens->GetEntriesFast();
1173 for (int i=0; i<iEntries; i++) {
1174 TString token=(((TObjString*)pTokens->At(i))->GetString());
1175 if (token.Contains("loglevel=")) {
1176 TString param=token.ReplaceAll("loglevel=", "");
1177 if (param.IsDigit()) {
1178 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
1179 } else if (param.BeginsWith("0x") &&
1180 param.Replace(0,2,"",0).IsHex()) {
1182 sscanf(param.Data(),"%x", &severity);
1183 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
1185 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1187 } else if (token.Contains("frameworklog=")) {
1188 TString param=token.ReplaceAll("frameworklog=", "");
1189 if (param.IsDigit()) {
1190 SetFrameworkLog((AliHLTComponentLogSeverity)param.Atoi());
1191 } else if (param.BeginsWith("0x") &&
1192 param.Replace(0,2,"",0).IsHex()) {
1194 sscanf(param.Data(),"%x", &severity);
1195 SetFrameworkLog((AliHLTComponentLogSeverity)severity);
1197 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1199 } else if (token.Contains("alilog=off")) {
1201 } else if (token.Contains("config=")) {
1202 TString param=token.ReplaceAll("config=", "");
1204 gROOT->Macro(param.Data(), &error);
1206 SetStatusFlags(kConfigurationLoaded);
1208 HLTError("can not execute macro \'%s\'", param.Data());
1211 } else if (token.Contains("chains=")) {
1212 TString param=token.ReplaceAll("chains=", "");
1213 fChains=param.ReplaceAll(",", " ");
1214 if (fChains.IsNull()) fChains=" "; // disable all chains
1215 } else if (token.Contains("libmode=")) {
1216 TString param=token.ReplaceAll("libmode=", "");
1217 param.ReplaceAll(",", " ");
1218 if (fpComponentHandler) {
1219 if (param.CompareTo("static")==0) {
1220 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kStatic);
1221 } else if (param.CompareTo("dynamic")==0) {
1222 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kDynamic);
1224 HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
1227 } else if (token.BeginsWith("ECS=")) {
1228 fECSParams=token.ReplaceAll("ECS=", "");
1229 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
1233 HLTWarning("unknown option \'%s\'", token.Data());
1240 if (libs.IsNull()) {
1241 const char** deflib=fgkHLTDefaultLibs;
1247 if ((!CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
1248 (LoadComponentLibraries(libs.Data())<0)) {
1249 HLTError("error while loading HLT libraries");
1257 int AliHLTSystem::Reset(int bForce)
1259 // see header file for class documentation
1261 if (!bForce && CheckStatus(kRunning)) {
1262 HLTError("HLT system in running state, can not configure");
1266 ClearStatusFlags(~kUninitialized);
1270 int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader)
1272 // see header file for class documentation
1273 if (CheckStatus(kRunning)) {
1274 HLTError("HLT system in running state, can not configure");
1278 AliHLTModuleAgent* pAgent=NULL;
1280 // first check for the required libraries and load those
1282 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1283 pAgent && iResult>=0;
1284 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1285 const char* deplibs=pAgent->GetRequiredComponentLibraries();
1287 HLTDebug("required libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
1293 iResult=LoadComponentLibraries(extralibs.Data());
1296 // in order to register the configurations in the correct sequence
1297 // all agents need to be ordered with respect to the required
1298 // libraries. Ordering relies on the naming convention
1299 // libAliHLT<Module>.so
1301 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1302 pAgent && iResult>=0;
1303 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1304 AliHLTModuleAgent* pPrevDep=NULL;
1305 TString dependencies=pAgent->GetRequiredComponentLibraries();
1306 TObjArray* pTokens=dependencies.Tokenize(" ");
1308 for (int n=0; n<pTokens->GetEntriesFast(); n++) {
1309 TString module=((TObjString*)pTokens->At(n))->GetString();
1310 HLTDebug(" checking %s", module.Data());
1311 module.ReplaceAll("libAliHLT", "");
1312 module.ReplaceAll(".so", "");
1314 for (AliHLTModuleAgent* pCurrent=dynamic_cast<AliHLTModuleAgent*>(pPrevDep==NULL?agents.First():agents.After(pPrevDep));
1315 pCurrent!=NULL; pCurrent=dynamic_cast<AliHLTModuleAgent*>(agents.After(pCurrent))) {
1316 HLTDebug(" checking %s == %s", module.Data(), pCurrent->GetModuleId());
1318 if (module.CompareTo(pCurrent->GetModuleId())==0) {
1328 // insert right after the last dependency
1329 agents.AddAfter(pPrevDep, pAgent);
1330 HLTDebug("insert %s after %s", pAgent->GetModuleId(), pPrevDep->GetModuleId());
1332 // insert at the beginning
1333 agents.AddFirst(pAgent);
1334 HLTDebug("insert %s at beginning", pAgent->GetModuleId());
1338 // now we load the configurations
1339 if (agents.GetEntries()) {
1340 TIter next(&agents);
1341 while ((pAgent = dynamic_cast<AliHLTModuleAgent*>(next()))) {
1342 HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
1343 pAgent->CreateConfigurations(fpConfigurationHandler, rawReader, runloader);
1350 int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader)
1352 // see header file for class documentation
1353 if (CheckStatus(kRunning)) {
1354 HLTError("HLT system in running state, can not configure");
1357 if (!CheckStatus(kConfigurationLoaded)) {
1358 HLTWarning("configurations not yet loaded");
1367 if (fChains.Length()>0) {
1369 HLTImportant("custom reconstruction chain: %s", chains.Data());
1371 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
1372 while ((pAgent || fChains.Length()>0) && iResult>=0) {
1373 const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
1375 if (!chains.IsNull()) chains+=" ";
1376 chains+=agentchains;
1377 HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
1379 pAgent=AliHLTModuleAgent::GetNextAgent();
1383 // build task list for chains
1384 TObjArray* pTokens=chains.Tokenize(" ");
1386 int iEntries=pTokens->GetEntriesFast();
1387 for (int i=0; i<iEntries && iResult>=0; i++) {
1388 const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
1389 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
1391 iResult=BuildTaskList(pConf);
1392 if (true) { // condition was deprecated but kept for sake of svn diff
1393 // bHaveOutput variable has to be set for both running modes
1394 // AliHLTSimulation and AliHLTReconstruction
1395 assert(fpComponentHandler!=NULL);
1396 TString cid=pConf->GetComponentID();
1397 if (runloader!=NULL && cid.CompareTo("HLTOUT")==0) {
1398 // remove from the input of a global HLTOUT configuration
1399 chains.ReplaceAll(pCID, "");
1400 } else if (bHaveOutput==0) {
1401 // check whether this configuration produces data output
1402 if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) {
1404 chains.ReplaceAll(pCID, "");
1409 HLTWarning("can not find configuration %s", pCID);
1415 // build HLTOUT for simulation
1416 if (iResult>=0 && runloader) {
1418 // there are components in the chain which produce data which need to be
1419 // piped to an HLTOUT
1420 if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
1421 fpComponentHandler->LoadLibrary("libHLTsim.so")>=0) {
1422 AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
1423 iResult=BuildTaskList("_globalout_");
1425 HLTError("can not load libHLTsim.so and HLTOUT component");
1431 // build HLTOUT task for reconstruction
1432 // Matthias 08.07.2008 the rawReader is never set when running embedded into
1433 // AliReconstruction. The system is configured during AliHLTReconstructor::Init
1434 // where the RawReader is not available. It is available in the first invocation
1437 // That means that policy is slightly changed:
1438 // - if the run loader is available -> AliSimulation
1439 // - no run loader available -> AliReconstruction
1440 if (iResult>=0 && !runloader) {
1442 // there are components in the chain which produce data which need to be
1443 // piped to an HLTOUT sub-collection
1444 if (!fpHLTOUTTask) {
1445 iResult=AddHLTOUTTask(chains.Data());
1450 if (iResult>=0) SetStatusFlags(kTaskListCreated);
1455 int AliHLTSystem::AddHLTOUTTask(const char* hltoutchains)
1457 // see header file for class documentation
1459 if (!hltoutchains || hltoutchains[0]==0) return 0;
1461 // check chains for output
1462 TString chains=hltoutchains;
1463 TObjArray* pTokens=chains.Tokenize(" ");
1465 int iEntries=pTokens->GetEntriesFast();
1466 for (int i=0; i<iEntries && iResult>=0; i++) {
1467 const char* token=((TObjString*)pTokens->At(i))->GetString().Data();
1468 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(token);
1470 TString cid=pConf->GetComponentID();
1471 if (fpComponentHandler->HasOutputData(cid.Data())) {
1475 HLTWarning("can not find configuration %s", token);
1477 // remove from the list of hltout chains
1478 chains.ReplaceAll(token, "");
1483 // do not create the HLTOUT task if none of the chains have output
1484 if (chains.IsNull()) return 0;
1486 // indicate the task to be available
1490 if (strcmp(chains.Data(), fpHLTOUTTask->GetSourceChains())==0) {
1491 HLTWarning("HLTOUT task already added for chains \"%s\" %p", chains.Data(), fpHLTOUTTask);
1493 HLTError("HLTOUT task already added for chains \"%s\" %p, ignoring new chains \"%s\"",
1494 fpHLTOUTTask->GetSourceChains(), fpHLTOUTTask, chains.Data());
1499 fpHLTOUTTask=new AliHLTOUTTask(chains);
1501 if (fpHLTOUTTask->GetConf() && fpHLTOUTTask->GetConf()->SourcesResolved()>=0) {
1502 iResult=InsertTask(fpHLTOUTTask);
1504 HLTError("HLTOUT task (%s) sources not resolved", fpHLTOUTTask->GetName());
1509 delete fpHLTOUTTask;
1518 int AliHLTSystem::CheckStatus(int flag)
1520 // see header file for class documentation
1521 if (flag==kUninitialized && flag==fState) return 1;
1522 if ((fState&flag)==flag) return 1;
1526 int AliHLTSystem::GetStatusFlags()
1528 // see header file for class documentation
1532 int AliHLTSystem::SetStatusFlags(int flags)
1534 // see header file for class documentation
1539 int AliHLTSystem::ClearStatusFlags(int flags)
1541 // see header file for class documentation
1546 void (*AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol))()
1548 // see header file for class documentation
1549 if (fpComponentHandler==NULL) return NULL;
1550 return fpComponentHandler->FindSymbol(library, symbol);
1553 void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
1555 // see header file for class documentation
1556 SetLocalLoggingLevel(level);
1557 if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
1558 if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);
1561 int AliHLTSystem::LoggingVarargs(AliHLTComponentLogSeverity severity,
1562 const char* originClass, const char* originFunc,
1563 const char* file, int line, ... ) const
1565 // see header file for function documentation
1569 va_start(args, line);
1571 if (!fName.IsNull())
1572 AliHLTLogging::SetLogString(this, " (%p)", "%s_pfmt_: ", fName.Data());
1573 iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, !fName.IsNull() /*append if non empty*/));