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;
143 // note: fpHLTOUTTask and fpControlTask are deleted by
147 int AliHLTSystem::fgNofInstances=0;
149 int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
151 // see header file for class documentation
152 HLTLogKeyword("configuration handling");
155 HLTError("function not yet implemented");
163 int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
165 // see header file for class documentation
166 HLTLogKeyword("configuration handling");
171 HLTError("function not yet implemented");
180 int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
182 // see header file for class documentation
183 HLTLogKeyword("configuration handling");
186 HLTError("function not yet implemented");
194 int AliHLTSystem::BuildTaskList(const char* id)
196 // see header file for class documentation
199 if (fpConfigurationHandler) {
200 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
202 iResult=BuildTaskList(pConf);
204 HLTError("unknown configuration \"%s\"", id);
216 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
218 // see header file for class documentation
221 AliHLTTask* pTask=NULL;
222 if ((pTask=FindTask(pConf->GetName()))!=NULL) {
223 if (pTask->GetConf()!=pConf) {
224 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);
227 // task for this configuration exists, terminate
229 } else if (pConf->SourcesResolved(1)!=1) {
230 HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
233 pTask=new AliHLTTask(pConf);
237 pTask->SetLocalLoggingLevel(GetLocalLoggingLevel());
240 static int iterationLevel=0;
241 if (pTask && iResult>=0) {
242 // check for circular dependencies
243 if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
244 HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
245 pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
246 HLTError("aborted ...");
250 // check whether all dependencies are already in the task list
251 // create the missing ones
252 // this step is an iterative process which calls this function again for the missing
253 // configurations, in order to avoid the currently processed task to be created
254 // again it is added to the list temporarily and removed afterwards
255 // This is of high importance to preserve the order of the tasks. Furthermore, the
256 // InsertTask method has to be used in order to set all the cross links right
257 fTaskList.Add(pTask);
258 AliHLTConfiguration* pDep=pConf->GetFirstSource();
259 while (pDep!=NULL && iResult>=0) {
260 HLTDebug("iteration %d: checking dependency %s (%p)", iterationLevel, pDep->GetName(), pDep);
261 if (FindTask(pDep->GetName())==NULL) {
262 HLTDebug("iteration %d: building task list for configuration %s (%p)", iterationLevel, pDep->GetName(), pDep);
264 iResult=BuildTaskList(pDep);
267 pDep=pConf->GetNextSource();
269 // remove the temporarily added task
270 fTaskList.Remove(pTask);
272 // insert the task and set the cross-links
274 HLTDebug("iteration %d: inserting task %s (%p)", iterationLevel, pTask->GetName(), pTask);
275 iResult=InsertTask(pTask);
288 int AliHLTSystem::CleanTaskList()
290 // see header file for class documentation
295 while ((lnk=fTaskList.LastLink())!=NULL) {
296 delete (lnk->GetObject());
297 fTaskList.Remove(lnk);
303 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
305 // see header file for class documentation
307 if (fpControlTask==NULL) {
308 fpControlTask=new AliHLTControlTask;
309 if (!fpControlTask) return -ENOMEM;
310 fTaskList.AddFirst(fpControlTask);
312 TObjLink *controlLnk=NULL;
313 TObjLink *lnk = fTaskList.FirstLink();
314 assert(!lnk || lnk->GetObject()==fpControlTask || fpControlTask==NULL);
315 if (lnk && lnk->GetObject()==fpControlTask) {
316 if (pTask->GetConf() && pTask->GetConf()->GetFirstSource()==NULL) {
317 pTask->SetDependency(fpControlTask);
318 fpControlTask->SetTarget(pTask);
323 if ((iResult=pTask->CheckDependencies())<=0)
325 while (lnk && iResult>0) {
326 AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
327 //HLTDebug("checking \"%s\"", pCurr->GetName());
328 iResult=pTask->Depends(pCurr);
330 iResult=pTask->SetDependency(pCurr);
331 pCurr->SetTarget(pTask);
332 HLTDebug("set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
334 if (pCurr->Depends(pTask)) {
335 // circular dependency
336 HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
338 } else if ((iResult=pTask->CheckDependencies())>0) {
344 fTaskList.AddAfter(lnk, pTask);
345 } else if (controlLnk) {
346 fTaskList.AddAfter(controlLnk, pTask);
348 fTaskList.AddFirst(pTask);
350 HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
351 } else if (iResult>0) {
352 HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
358 AliHLTTask* AliHLTSystem::FindTask(const char* id)
360 // see header file for class documentation
361 AliHLTTask* pTask=NULL;
363 pTask=dynamic_cast<AliHLTTask*>(fTaskList.FindObject(id));
368 void AliHLTSystem::PrintTaskList()
370 // see header file for class documentation
371 HLTLogKeyword("task list");
372 TObjLink *lnk = NULL;
373 HLTMessage("Task List");
374 lnk=fTaskList.FirstLink();
376 TObject* obj=lnk->GetObject();
378 HLTMessage(" %s - status:", obj->GetName());
379 AliHLTTask* pTask=(AliHLTTask*)obj;
380 pTask->PrintStatus();
387 int AliHLTSystem::Run(Int_t iNofEvents, int bStop, AliHLTUInt64_t trgMask)
389 // see header file for class documentation
392 SetStatusFlags(kRunning);
393 if (fEventCount>=0 || (iResult=InitTasks())>=0) {
394 if (fEventCount>=0 || (iResult=StartTasks())>=0) {
395 if (fEventCount==0) {
396 InitBenchmarking(fStopwatches);
398 // Matthias Oct 11 2008 this is a bug
399 // By resuming the stopwatches at this point, all continued counting, but the
400 // starting and stopping is controlled by the AliHLTStopwatchGuard
401 //ResumeBenchmarking(fStopwatches);
403 for (int i=fEventCount; i<fEventCount+iNofEvents && iResult>=0; i++) {
405 if (iNofEvents>1 && i==fEventCount) {
406 HLTWarning("can not add more than one event to the HLTOUT, skipping all but last block");
408 // reset and prepare for new data
409 fpHLTOUTTask->Reset();
411 if ((iResult=ProcessTasks(i, trgMask))>=0) {
415 // TODO: define different running modes to either ignore errors in
416 // event processing or not
420 AliHLTDataBuffer::SetGlobalEventCount(iCount);
422 fEventCount+=iNofEvents;
423 if (bStop) StopTasks();
424 else PauseBenchmarking(fStopwatches);
426 if (bStop) DeinitTasks();
430 } else if (iResult==-126 /*ENOKEY*/) {
431 iResult=0; // do not propagate the error
433 ClearStatusFlags(kRunning);
434 AliHLTDataBuffer::PrintStatistics();
438 int AliHLTSystem::InitTasks()
440 // see header file for class documentation
442 TObjLink *lnk=fTaskList.FirstLink();
445 HLTInfo("Task list is empty, skipping HLT");
446 return -126 /*ENOKEY*/;
448 while (lnk && iResult>=0) {
449 TObject* obj=lnk->GetObject();
451 AliHLTTask* pTask=(AliHLTTask*)obj;
452 iResult=pTask->Init(NULL, fpComponentHandler);
453 // ProcInfo_t ProcInfo;
454 // gSystem->GetProcInfo(&ProcInfo);
455 // HLTInfo("task %s initialized (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
461 HLTError("can not initialize task list, error %d", iResult);
467 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
469 // see header file for class documentation
471 if (pStopwatches==NULL) return 0;
473 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
474 TStopwatch* pStopwatch= new TStopwatch;
477 pStopwatches->AddAt(pStopwatch, i);
484 TObjLink *lnk=fTaskList.FirstLink();
485 while (lnk && iResult>=0) {
486 TObject* obj=lnk->GetObject();
488 AliHLTTask* pTask=(AliHLTTask*)obj;
489 AliHLTComponent* pComp=NULL;
490 if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) {
491 switch (pComp->GetComponentType()) {
492 case AliHLTComponent::kProcessor:
493 pComp->SetStopwatches(pStopwatches);
495 case AliHLTComponent::kSource:
497 // this switch determines whether the time consumption of the
498 // AliHLTComponent base methods should be counted to the input
499 // stopwatch or base stopwatch.
500 //int inputBase=(int)AliHLTComponent::kSWBase;
501 int inputBase=(int)AliHLTComponent::kSWInput;
502 pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase);
503 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA);
506 case AliHLTComponent::kSink:
508 // this switch determines whether the time consumption of the
509 // AliHLTComponent base methods should be counted to the output
510 // stopwatch or base stopwatch.
511 //int outputBase=(int)AliHLTComponent::kSWBase;
512 int outputBase=(int)AliHLTComponent::kSWOutput;
513 pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase);
514 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA);
518 HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
528 int AliHLTSystem::PauseBenchmarking(TObjArray* pStopwatches) const
530 // see header file for class documentation
531 if (pStopwatches==NULL) return 0;
533 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
534 if (!pStopwatches->At(i)) continue;
535 TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
536 if (pSw) pSw->Stop();
541 int AliHLTSystem::ResumeBenchmarking(TObjArray* pStopwatches) const
543 // see header file for class documentation
544 if (pStopwatches==NULL) return 0;
546 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
547 if (!pStopwatches->At(i)) continue;
548 TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
549 if (pSw) pSw->Continue();
554 int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean) const
556 // see header file for class documentation
558 if (pStopwatches==NULL) return 0;
560 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
561 if (!dynamic_cast<TStopwatch*>(pStopwatches->At(i))) {
567 if (iInitialized!=0) {
568 HLTImportant("HLT statistics:\n"
569 " base: R:%.3fs C:%.3fs\n"
570 " input: R:%.3fs C:%.3fs\n"
571 " output: R:%.3fs C:%.3fs\n"
572 " event processing : R:%.3fs C:%.3fs"
573 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->RealTime()
574 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->CpuTime()
575 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->RealTime()
576 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->CpuTime()
577 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->RealTime()
578 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->CpuTime()
579 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->RealTime()
580 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->CpuTime()
585 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
586 TObject* pObj=pStopwatches->RemoveAt(i);
587 if (pObj) delete pObj;
593 int AliHLTSystem::StartTasks()
595 // see header file for class documentation
597 TObjLink *lnk=fTaskList.FirstLink();
598 while (lnk && iResult>=0) {
599 TObject* obj=lnk->GetObject();
601 AliHLTTask* pTask=(AliHLTTask*)obj;
602 iResult=pTask->StartRun();
603 // ProcInfo_t ProcInfo;
604 // gSystem->GetProcInfo(&ProcInfo);
605 // HLTInfo("task %s started (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
611 HLTError("can not start task list, error %d", iResult);
613 SetStatusFlags(kStarted);
616 if ((iResult=SendControlEvent(kAliHLTDataTypeSOR))<0) {
617 HLTError("can not send SOR event: error %d", iResult);
623 int AliHLTSystem::ProcessTasks(Int_t eventNo, AliHLTUInt64_t trgMask)
625 // see header file for class documentation
627 HLTDebug("processing event no %d", eventNo);
628 TObjLink *lnk=fTaskList.FirstLink();
629 while (lnk && iResult>=0) {
630 TObject* obj=lnk->GetObject();
632 AliHLTTask* pTask=(AliHLTTask*)obj;
633 iResult=pTask->ProcessTask(eventNo, gkAliEventTypeData, trgMask);
634 // ProcInfo_t ProcInfo;
635 // gSystem->GetProcInfo(&ProcInfo);
636 // HLTInfo("task %s processed (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
643 HLTImportant("Event %d successfully finished (%d)", eventNo, iResult);
646 HLTError("Processing of event %d failed (%d)", eventNo, iResult);
652 int AliHLTSystem::StopTasks()
654 // see header file for class documentation
656 if ((iResult=SendControlEvent(kAliHLTDataTypeEOR))<0) {
657 HLTError("can not send EOR event");
660 // cleanup blocks from the last event. This is a bit awkward. All output
661 // blocks from the chains need to be stored in the HLTOUT task. Though,
662 // we do not know, whether HLTOUT is going to be processed or not.
664 fpHLTOUTTask->Reset();
666 TObjLink *lnk=fTaskList.FirstLink();
668 TObject* obj=lnk->GetObject();
670 AliHLTTask* pTask=(AliHLTTask*)obj;
671 int locResult=pTask->EndRun();
672 if (iResult>=0 && locResult<0) iResult=locResult;
673 // ProcInfo_t ProcInfo;
674 // gSystem->GetProcInfo(&ProcInfo);
675 // HLTInfo("task %s stopped (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
680 PrintBenchmarking(fStopwatches, 1 /*clean*/);
681 ClearStatusFlags(kStarted);
685 int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt)
687 // see header file for class documentation
690 AliHLTComponentBlockDataList controlBlocks;
691 AliHLTComponentBlockData bd;
693 // run decriptor block of type kAliHLTDataTypeSOR/kAliHLTDataTypeEOR
694 AliHLTComponent::FillBlockData(bd);
695 AliHLTRunDesc runDesc;
696 memset(&runDesc, 0, sizeof(AliHLTRunDesc));
697 runDesc.fStructSize=sizeof(AliHLTRunDesc);
699 bd.fSize=sizeof(AliHLTRunDesc);
701 bd.fSpecification=kAliHLTVoidDataSpec;
702 controlBlocks.push_back(bd);
704 // ECS parameter of type kAliHLTDataTypeECSParam
705 if (fECSParams.IsNull())
706 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";
707 AliHLTComponent::FillBlockData(bd);
708 bd.fPtr=(void*)fECSParams.Data();
709 bd.fSize=fECSParams.Length()+1;
710 bd.fDataType=kAliHLTDataTypeECSParam;
711 bd.fSpecification=kAliHLTVoidDataSpec;
712 controlBlocks.push_back(bd);
714 AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
715 HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
716 TObjLink *lnk=fTaskList.FirstLink();
717 while (lnk && iResult>=0) {
718 TObject* obj=lnk->GetObject();
720 AliHLTTask* pTask=(AliHLTTask*)obj;
721 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
722 if (dt==kAliHLTDataTypeSOR) eventType=gkAliEventTypeStartOfRun;
723 else if (dt==kAliHLTDataTypeEOR) eventType=gkAliEventTypeEndOfRun;
724 else HLTWarning("unknown control event %s", AliHLTComponent::DataType2Text(dt).c_str());
725 iResult=pTask->ProcessTask(-1, eventType);
731 // control events are not supposed to go into the HLTOUT
733 fpHLTOUTTask->Reset();
735 HLTDebug("event %s done (%d)", AliHLTComponent::DataType2Text(dt).c_str(), iResult);
739 int AliHLTSystem::DeinitTasks()
741 // see header file for class documentation
743 TObjLink *lnk=fTaskList.LastLink();
745 TObject* obj=lnk->GetObject();
747 AliHLTTask* pTask=(AliHLTTask*)obj;
748 int localRes=pTask->Deinit();
749 if (iResult>=0) iResult=localRes;
750 // ProcInfo_t ProcInfo;
751 // gSystem->GetProcInfo(&ProcInfo);
752 // HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
763 int AliHLTSystem::CleanHLTOUT()
765 // see header file for class documentation
766 if (fpChainHandlers) {
767 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
768 fpChainHandlers=NULL;
770 AliHLTOUT::InvalidateBlocks(*pHandlers);
771 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
773 assert(pHandlers->size()==0);
778 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
781 AliHLTOUT::InvalidateBlocks(*pHandlers);
782 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
784 assert(pHandlers->size()==0);
788 if (fpProprietaryHandlers) {
789 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
790 fpProprietaryHandlers=NULL;
792 AliHLTOUT::InvalidateBlocks(*pHandlers);
793 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
795 assert(pHandlers->size()==0);
801 void* AliHLTSystem::AllocMemory( void* /*param*/, unsigned long size )
803 // see header file for class documentation
806 p=(void*)new char[size];
810 log.LoggingVarargs(kHLTLogError, "AliHLTSystem" , "AllocMemory" , __FILE__ , __LINE__ , "exeption during memory allocation" );
815 int AliHLTSystem::AllocEventDoneData( void* /*param*/, AliHLTEventID_t /*eventID*/, unsigned long size, AliHLTComponentEventDoneData** edd )
817 // see header file for class documentation
818 unsigned long blocksize=sizeof(AliHLTComponentEventDoneData)+size;
819 void* block=AllocMemory(NULL, blocksize);
820 if (!block) return -ENOMEM;
821 memset(block, 0, blocksize);
822 *edd=reinterpret_cast<AliHLTComponentEventDoneData*>(block);
823 (*edd)->fStructSize=sizeof(AliHLTComponentEventDoneData);
824 (*edd)->fDataSize=size;
825 (*edd)->fData=reinterpret_cast<AliHLTUInt8_t*>(block)+sizeof(AliHLTComponentEventDoneData);
830 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
831 AliRawReader* rawReader)
833 // see header file for class documentation
835 if (runLoader || rawReader || nofEvents==0) {
836 if (nofEvents>0) {HLTInfo("Run Loader %p, Raw Reader %p , %d event(s)", runLoader, rawReader, nofEvents);}
837 if (CheckStatus(kReady)) {
839 // special case to close the reconstruction
840 if (!CheckStatus(kError)) {
846 if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
847 AliHLTUInt64_t trgMask=0x1;
848 if (runLoader==NULL) {
849 // this is a quick workaround for the case of simulation
850 // the trigger framework is still under development, secondly, AliHLTSimulation
851 // does not yet add the emulated ECS parameters, so no CTP trigger is known in the HLT
852 // AliHLTTask will initialize one dummy CTP trigger class with bit 0, that's why the
853 // default trigger mask is 0x1
854 trgMask=AliHLTMisc::Instance().GetTriggerMask(rawReader);
856 // the system always remains started after event processing, a specific
857 // call with nofEvents==0 is needed to execute the stop sequence
858 if ((iResult=Run(nofEvents, 0, trgMask))<0) SetStatusFlags(kError);
862 HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
865 HLTError("missing RunLoader (%p)/RawReader (%p) instance", runLoader, rawReader);
871 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
873 // see header file for class documentation
875 if (runLoader || esd) {
876 HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
877 iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
879 HLTError("missing run loader/ESD instance(s)");
885 int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd)
887 // see header file for class documentation
889 if (!pHLTOUT) return -EINVAL;
890 HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
892 // add the current HLTOUT task to the collection
894 AliHLTOUT* pTask=dynamic_cast<AliHLTOUT*>(fpHLTOUTTask);
895 if (pTask && (iResult=pTask->Init())>=0) {
896 if (pTask->GetNofDataBlocks()>0) {
897 pHLTOUT->AddSubCollection(pTask);
900 HLTWarning("can not initialize HLTOUT sub collection %s for reconstruction chain (%d), data blocks are lost", pTask?fpHLTOUTTask->GetName():"nil", iResult);
907 // process all kChain handlers first
909 if ((iResult=ProcessHLTOUTkChain(pHLTOUT))<0) {
910 HLTWarning("Processing of kChain-type data blocks failed with error code %d", iResult);
915 fpEsdHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
916 if (!fpProprietaryHandlers)
917 fpProprietaryHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
919 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pEsdHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
920 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pProprietaryHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
921 if (!pEsdHandlers || !pProprietaryHandlers) return -ENOMEM;
923 // invalidate all blocks
924 AliHLTOUT::InvalidateBlocks(*pEsdHandlers);
925 AliHLTOUT::InvalidateBlocks(*pProprietaryHandlers);
927 AliHLTComponentDataTypeList esdBlocks;
929 for (iResult=pHLTOUT->SelectFirstDataBlock();
931 iResult=pHLTOUT->SelectNextDataBlock()) {
932 AliHLTComponentDataType dt=kAliHLTVoidDataType;
933 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
934 pHLTOUT->GetDataBlockDescription(dt, spec);
935 AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
936 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
938 // default handling for ESD data blocks does not require an explicite handler
939 if (!pHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
940 handlerType=AliHLTModuleAgent::kEsd;
942 const char* pMsg="invalid";
943 switch (handlerType) {
944 case AliHLTModuleAgent::kEsd:
947 // schedule for later processing
948 pHLTOUT->InsertHandler(*pEsdHandlers, pHLTOUT->GetDataBlockHandlerDesc());
950 AliHLTComponentDataTypeList::iterator element=esdBlocks.begin();
951 for (; element!=esdBlocks.end(); element++) {
953 HLTWarning("multiple ESDs of identical data type %s, please add appropriate handler to merge ESDs", AliHLTComponent::DataType2Text(dt).c_str());
957 if (element==esdBlocks.end()) esdBlocks.push_back(dt);
960 const AliHLTUInt8_t* pBuffer=NULL;
961 AliHLTUInt32_t size=0;
962 if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) {
963 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
964 pHLTOUT->ReleaseDataBuffer(pBuffer);
966 pHLTOUT->MarkDataBlockProcessed();
970 case AliHLTModuleAgent::kRawReader:
971 // handled in the AliRawReaderHLT
973 case AliHLTModuleAgent::kRawStream:
974 HLTWarning("HLTOUT handler type 'kRawStream' not yet implemented: agent %s, data type %s, specification %#x",
975 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
976 AliHLTComponent::DataType2Text(dt).c_str(), spec);
978 case AliHLTModuleAgent::kChain:
979 HLTWarning("HLTOUT handler type 'kChain' has already been processed: agent %s, data type %s, specification %#x\n"
980 "New block of this type added by the chain? Skipping data block ...",
981 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
982 AliHLTComponent::DataType2Text(dt).c_str(), spec);
984 case AliHLTModuleAgent::kProprietary:
985 HLTDebug("processing proprietary data: agent %s, data type %s, specification %#x",
986 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
987 AliHLTComponent::DataType2Text(dt).c_str(), spec);
989 AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
990 int res=pHandler->ProcessData(pHLTOUT);
992 HLTWarning("processing proprietary data failed (%d): agent %s, data type %s, specification %#x",
993 res, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
994 AliHLTComponent::DataType2Text(dt).c_str(), spec);
998 case AliHLTModuleAgent::kUnknownOutput:
1000 // fall trough intended
1002 HLTWarning("%s handler type: agent %s, data type %s, specification %#x, ... skipping data block",
1003 pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
1004 AliHLTComponent::DataType2Text(dt).c_str(), spec);
1007 // TODO: the return value of SelectFirst/NextDataBlock must be
1008 // changed in order to avoid this check
1009 if (iResult==-ENOENT) iResult=0;
1011 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator handler;
1013 // process and write all esd data blocks
1014 for (handler=pEsdHandlers->begin(); handler!=pEsdHandlers->end() && iResult>=0; handler++) {
1015 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1016 AliHLTOUTHandler* pHandler=*handler;
1017 const AliHLTUInt8_t* pBuffer=NULL;
1018 AliHLTUInt32_t size=0;
1019 pHandler->ProcessData(pHLTOUT);
1020 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1021 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*handler;
1022 AliHLTComponentDataType dt=desc;
1023 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
1024 pHandler->ReleaseProcessedData(pBuffer, size);
1026 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1029 // process all kProprietary data blocks
1030 for (handler=pProprietaryHandlers->begin(); handler!=pProprietaryHandlers->end() && iResult>=0; handler++) {
1031 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1032 AliHLTOUTHandler* pHandler=*handler;
1033 const AliHLTUInt8_t* pBuffer=NULL;
1034 AliHLTUInt32_t size=0;
1035 pHandler->ProcessData(pHLTOUT);
1036 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1037 HLTWarning("data produced by kProprietary handler ignored");
1038 pHandler->ReleaseProcessedData(pBuffer, size);
1040 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1043 // remove all empty handlers form the list (handlers which did not get a block this time)
1044 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pEsdHandlers);
1045 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pProprietaryHandlers);
1050 int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT)
1052 // see header file for class documentation
1054 if (!pHLTOUT) return -EINVAL;
1056 if (!fpChainHandlers)
1057 fpChainHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
1059 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pChainHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
1060 if (!pChainHandlers) return -ENOMEM;
1062 // invalidate all blocks
1063 AliHLTOUT::InvalidateBlocks(*pChainHandlers);
1066 pHLTOUT->FillHandlerList(*pChainHandlers, AliHLTModuleAgent::kChain);
1068 // process all defined chain handlers
1069 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator chainHandler;
1070 for (chainHandler=pChainHandlers->begin(); chainHandler!=pChainHandlers->end() && iResult>=0; chainHandler++) {
1071 if (chainHandler->IsEmpty()) continue;
1072 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*chainHandler));
1073 AliHLTOUTHandler* pHandler=*chainHandler;
1074 const AliHLTUInt8_t* pBuffer=NULL;
1075 AliHLTUInt32_t size=0;
1076 pHandler->ProcessData(pHLTOUT);
1077 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1078 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler;
1079 AliHLTComponentDataType dt=desc;
1081 pHandler->ReleaseProcessedData(pBuffer, size);
1083 pHLTOUT->MarkDataBlocksProcessed(&(*chainHandler));
1086 // remove all empty handlers form the list (handlers which did not get a block this time)
1087 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pChainHandlers);
1092 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
1094 // see header file for class documentation
1097 if (fpComponentHandler) {
1098 TString libs(libraries);
1099 TObjArray* pTokens=libs.Tokenize(" ");
1101 int iEntries=pTokens->GetEntriesFast();
1102 for (int i=0; i<iEntries && iResult>=0; i++) {
1103 iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
1108 SetStatusFlags(kLibrariesLoaded);
1110 // lets see if we need this, probably not
1111 //fpComponentHandler->UnloadLibraries();
1112 ClearStatusFlags(kLibrariesLoaded);
1116 HLTFatal("no component handler available");
1124 int AliHLTSystem::Configure(AliRunLoader* runloader)
1126 // see header file for class documentation
1127 return Configure(NULL, runloader);
1130 int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader)
1132 // see header file for class documentation
1134 if (CheckStatus(kRunning)) {
1135 HLTError("HLT system in running state, can not configure");
1138 ClearStatusFlags(kTaskListCreated);
1139 if (CheckFilter(kHLTLogDebug))
1140 AliHLTModuleAgent::PrintStatus();
1141 if (CheckStatus(kConfigurationLoaded)==0) {
1142 iResult=LoadConfigurations(rawReader, runloader);
1144 if (fChains.Length()==0) {
1145 HLTError("custom configuration(s) specified, but no configuration to run in local reconstruction, use \'chains=<chain,...>\' option");
1150 SetStatusFlags(kConfigurationLoaded);
1151 if (CheckFilter(kHLTLogDebug))
1152 fpConfigurationHandler->PrintConfigurations();
1153 iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader);
1155 SetStatusFlags(kTaskListCreated);
1158 if (iResult<0) SetStatusFlags(kError);
1163 int AliHLTSystem::ScanOptions(const char* options)
1165 // see header file for class documentation
1168 //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
1170 TString alloptions(options);
1171 TObjArray* pTokens=alloptions.Tokenize(" ");
1173 int iEntries=pTokens->GetEntriesFast();
1174 for (int i=0; i<iEntries; i++) {
1175 TString token=(((TObjString*)pTokens->At(i))->GetString());
1176 if (token.Contains("loglevel=")) {
1177 TString param=token.ReplaceAll("loglevel=", "");
1178 if (param.IsDigit()) {
1179 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
1180 } else if (param.BeginsWith("0x") &&
1181 param.Replace(0,2,"",0).IsHex()) {
1183 sscanf(param.Data(),"%x", &severity);
1184 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
1186 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1188 } else if (token.Contains("frameworklog=")) {
1189 TString param=token.ReplaceAll("frameworklog=", "");
1190 if (param.IsDigit()) {
1191 SetFrameworkLog((AliHLTComponentLogSeverity)param.Atoi());
1192 } else if (param.BeginsWith("0x") &&
1193 param.Replace(0,2,"",0).IsHex()) {
1195 sscanf(param.Data(),"%x", &severity);
1196 SetFrameworkLog((AliHLTComponentLogSeverity)severity);
1198 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1200 } else if (token.Contains("alilog=off")) {
1202 } else if (token.Contains("config=")) {
1203 TString param=token.ReplaceAll("config=", "");
1205 gROOT->Macro(param.Data(), &error);
1207 SetStatusFlags(kConfigurationLoaded);
1209 HLTError("can not execute macro \'%s\'", param.Data());
1212 } else if (token.Contains("chains=")) {
1213 TString param=token.ReplaceAll("chains=", "");
1214 fChains=param.ReplaceAll(",", " ");
1215 if (fChains.IsNull()) fChains=" "; // disable all chains
1216 } else if (token.Contains("libmode=")) {
1217 TString param=token.ReplaceAll("libmode=", "");
1218 param.ReplaceAll(",", " ");
1219 if (fpComponentHandler) {
1220 if (param.CompareTo("static")==0) {
1221 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kStatic);
1222 } else if (param.CompareTo("dynamic")==0) {
1223 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kDynamic);
1225 HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
1228 } else if (token.BeginsWith("ECS=")) {
1229 fECSParams=token.ReplaceAll("ECS=", "");
1230 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
1234 HLTWarning("unknown option \'%s\'", token.Data());
1241 if (libs.IsNull()) {
1242 const char** deflib=fgkHLTDefaultLibs;
1248 if ((!CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
1249 (LoadComponentLibraries(libs.Data())<0)) {
1250 HLTError("error while loading HLT libraries");
1258 int AliHLTSystem::Reset(int bForce)
1260 // see header file for class documentation
1262 if (!bForce && CheckStatus(kRunning)) {
1263 HLTError("HLT system in running state, can not configure");
1267 ClearStatusFlags(~kUninitialized);
1271 int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader)
1273 // see header file for class documentation
1274 if (CheckStatus(kRunning)) {
1275 HLTError("HLT system in running state, can not configure");
1279 AliHLTModuleAgent* pAgent=NULL;
1281 // first check for the required libraries and load those
1283 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1284 pAgent && iResult>=0;
1285 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1286 const char* deplibs=pAgent->GetRequiredComponentLibraries();
1288 HLTDebug("required libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
1294 iResult=LoadComponentLibraries(extralibs.Data());
1297 // in order to register the configurations in the correct sequence
1298 // all agents need to be ordered with respect to the required
1299 // libraries. Ordering relies on the naming convention
1300 // libAliHLT<Module>.so
1302 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1303 pAgent && iResult>=0;
1304 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1305 AliHLTModuleAgent* pPrevDep=NULL;
1306 TString dependencies=pAgent->GetRequiredComponentLibraries();
1307 TObjArray* pTokens=dependencies.Tokenize(" ");
1309 for (int n=0; n<pTokens->GetEntriesFast(); n++) {
1310 TString module=((TObjString*)pTokens->At(n))->GetString();
1311 HLTDebug(" checking %s", module.Data());
1312 module.ReplaceAll("libAliHLT", "");
1313 module.ReplaceAll(".so", "");
1315 for (AliHLTModuleAgent* pCurrent=dynamic_cast<AliHLTModuleAgent*>(pPrevDep==NULL?agents.First():agents.After(pPrevDep));
1316 pCurrent!=NULL; pCurrent=dynamic_cast<AliHLTModuleAgent*>(agents.After(pCurrent))) {
1317 HLTDebug(" checking %s == %s", module.Data(), pCurrent->GetModuleId());
1319 if (module.CompareTo(pCurrent->GetModuleId())==0) {
1329 // insert right after the last dependency
1330 agents.AddAfter(pPrevDep, pAgent);
1331 HLTDebug("insert %s after %s", pAgent->GetModuleId(), pPrevDep->GetModuleId());
1333 // insert at the beginning
1334 agents.AddFirst(pAgent);
1335 HLTDebug("insert %s at beginning", pAgent->GetModuleId());
1339 // now we load the configurations
1340 if (agents.GetEntries()) {
1341 TIter next(&agents);
1342 while ((pAgent = dynamic_cast<AliHLTModuleAgent*>(next()))) {
1343 HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
1344 pAgent->CreateConfigurations(fpConfigurationHandler, rawReader, runloader);
1351 int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader)
1353 // see header file for class documentation
1354 if (CheckStatus(kRunning)) {
1355 HLTError("HLT system in running state, can not configure");
1358 if (!CheckStatus(kConfigurationLoaded)) {
1359 HLTWarning("configurations not yet loaded");
1368 if (fChains.Length()>0) {
1370 HLTImportant("custom reconstruction chain: %s", chains.Data());
1372 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
1373 while ((pAgent || fChains.Length()>0) && iResult>=0) {
1374 const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
1376 if (!chains.IsNull()) chains+=" ";
1377 chains+=agentchains;
1378 HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
1380 pAgent=AliHLTModuleAgent::GetNextAgent();
1384 // build task list for chains
1385 TObjArray* pTokens=chains.Tokenize(" ");
1387 int iEntries=pTokens->GetEntriesFast();
1388 for (int i=0; i<iEntries && iResult>=0; i++) {
1389 const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
1390 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
1392 iResult=BuildTaskList(pConf);
1393 if (true) { // condition was deprecated but kept for sake of svn diff
1394 // bHaveOutput variable has to be set for both running modes
1395 // AliHLTSimulation and AliHLTReconstruction
1396 assert(fpComponentHandler!=NULL);
1397 TString cid=pConf->GetComponentID();
1398 if (runloader!=NULL && cid.CompareTo("HLTOUT")==0) {
1399 // remove from the input of a global HLTOUT configuration
1400 chains.ReplaceAll(pCID, "");
1401 } else if (bHaveOutput==0) {
1402 // check whether this configuration produces data output
1403 if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) {
1405 chains.ReplaceAll(pCID, "");
1410 HLTWarning("can not find configuration %s", pCID);
1416 // build HLTOUT for simulation
1417 if (iResult>=0 && runloader) {
1419 // there are components in the chain which produce data which need to be
1420 // piped to an HLTOUT
1422 // add the SchemaEvolutionComponent which analyzes the ROOT objects in
1423 // the output stream
1424 if (fpComponentHandler->FindComponentIndex("ROOTSchemaEvolutionComponent")>=0 ||
1425 fpComponentHandler->LoadLibrary("libAliHLTUtil.so")>=0) {
1426 AliHLTConfiguration schemaevo("_schemaevolution_", "ROOTSchemaEvolutionComponent",
1427 chains.Data(), "-file=HLT.StreamerInfo.root");
1428 iResult=BuildTaskList("_schemaevolution_");
1430 HLTWarning("can not load libAliHLTUtil.so and ROOTSchemaEvolutionComponent");
1433 // add the HLTOUT component
1434 if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
1435 fpComponentHandler->LoadLibrary("libHLTsim.so")>=0) {
1436 AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
1437 iResult=BuildTaskList("_globalout_");
1439 HLTError("can not load libHLTsim.so and HLTOUT component");
1445 // build HLTOUT task for reconstruction
1446 // Matthias 08.07.2008 the rawReader is never set when running embedded into
1447 // AliReconstruction. The system is configured during AliHLTReconstructor::Init
1448 // where the RawReader is not available. It is available in the first invocation
1451 // That means that policy is slightly changed:
1452 // - if the run loader is available -> AliSimulation
1453 // - no run loader available -> AliReconstruction
1454 if (iResult>=0 && !runloader) {
1456 // there are components in the chain which produce data which need to be
1457 // piped to an HLTOUT sub-collection
1458 if (!fpHLTOUTTask) {
1459 iResult=AddHLTOUTTask(chains.Data());
1464 if (iResult>=0) SetStatusFlags(kTaskListCreated);
1469 int AliHLTSystem::AddHLTOUTTask(const char* hltoutchains)
1471 // see header file for class documentation
1473 if (!hltoutchains || hltoutchains[0]==0) return 0;
1475 // check chains for output
1476 TString chains=hltoutchains;
1477 TObjArray* pTokens=chains.Tokenize(" ");
1479 int iEntries=pTokens->GetEntriesFast();
1480 for (int i=0; i<iEntries && iResult>=0; i++) {
1481 const char* token=((TObjString*)pTokens->At(i))->GetString().Data();
1482 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(token);
1484 TString cid=pConf->GetComponentID();
1485 if (fpComponentHandler->HasOutputData(cid.Data())) {
1489 HLTWarning("can not find configuration %s", token);
1491 // remove from the list of hltout chains
1492 chains.ReplaceAll(token, "");
1497 // do not create the HLTOUT task if none of the chains have output
1498 if (chains.IsNull()) return 0;
1500 // indicate the task to be available
1504 if (strcmp(chains.Data(), fpHLTOUTTask->GetSourceChains())==0) {
1505 HLTWarning("HLTOUT task already added for chains \"%s\" %p", chains.Data(), fpHLTOUTTask);
1507 HLTError("HLTOUT task already added for chains \"%s\" %p, ignoring new chains \"%s\"",
1508 fpHLTOUTTask->GetSourceChains(), fpHLTOUTTask, chains.Data());
1513 fpHLTOUTTask=new AliHLTOUTTask(chains);
1515 if (fpHLTOUTTask->GetConf() && fpHLTOUTTask->GetConf()->SourcesResolved()>=0) {
1516 iResult=InsertTask(fpHLTOUTTask);
1518 HLTError("HLTOUT task (%s) sources not resolved", fpHLTOUTTask->GetName());
1523 delete fpHLTOUTTask;
1532 int AliHLTSystem::CheckStatus(int flag)
1534 // see header file for class documentation
1535 if (flag==kUninitialized && flag==fState) return 1;
1536 if ((fState&flag)==flag) return 1;
1540 int AliHLTSystem::GetStatusFlags()
1542 // see header file for class documentation
1546 int AliHLTSystem::SetStatusFlags(int flags)
1548 // see header file for class documentation
1553 int AliHLTSystem::ClearStatusFlags(int flags)
1555 // see header file for class documentation
1560 void (*AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol))()
1562 // see header file for class documentation
1563 if (fpComponentHandler==NULL) return NULL;
1564 return fpComponentHandler->FindSymbol(library, symbol);
1567 void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
1569 // see header file for class documentation
1570 SetLocalLoggingLevel(level);
1571 if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
1572 if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);
1575 int AliHLTSystem::LoggingVarargs(AliHLTComponentLogSeverity severity,
1576 const char* originClass, const char* originFunc,
1577 const char* file, int line, ... ) const
1579 // see header file for function documentation
1583 va_start(args, line);
1585 if (!fName.IsNull())
1586 AliHLTLogging::SetLogString(this, " (%p)", "%s_pfmt_: ", fName.Data());
1587 iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, !fName.IsNull() /*append if non empty*/));