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);
698 runDesc.fRunNo=AliHLTMisc::Instance().GetCDBRunNo();
700 bd.fSize=sizeof(AliHLTRunDesc);
702 bd.fSpecification=kAliHLTVoidDataSpec;
703 controlBlocks.push_back(bd);
705 // ECS parameter of type kAliHLTDataTypeECSParam
706 if (fECSParams.IsNull())
707 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";
708 AliHLTComponent::FillBlockData(bd);
709 bd.fPtr=(void*)fECSParams.Data();
710 bd.fSize=fECSParams.Length()+1;
711 bd.fDataType=kAliHLTDataTypeECSParam;
712 bd.fSpecification=kAliHLTVoidDataSpec;
713 controlBlocks.push_back(bd);
715 AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
716 HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
717 TObjLink *lnk=fTaskList.FirstLink();
718 while (lnk && iResult>=0) {
719 TObject* obj=lnk->GetObject();
721 AliHLTTask* pTask=(AliHLTTask*)obj;
722 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
723 if (dt==kAliHLTDataTypeSOR) eventType=gkAliEventTypeStartOfRun;
724 else if (dt==kAliHLTDataTypeEOR) eventType=gkAliEventTypeEndOfRun;
725 else HLTWarning("unknown control event %s", AliHLTComponent::DataType2Text(dt).c_str());
726 iResult=pTask->ProcessTask(-1, eventType);
732 // control events are not supposed to go into the HLTOUT
734 fpHLTOUTTask->Reset();
736 HLTDebug("event %s done (%d)", AliHLTComponent::DataType2Text(dt).c_str(), iResult);
740 int AliHLTSystem::DeinitTasks()
742 // see header file for class documentation
744 TObjLink *lnk=fTaskList.LastLink();
746 TObject* obj=lnk->GetObject();
748 AliHLTTask* pTask=(AliHLTTask*)obj;
749 int localRes=pTask->Deinit();
750 if (iResult>=0) iResult=localRes;
751 // ProcInfo_t ProcInfo;
752 // gSystem->GetProcInfo(&ProcInfo);
753 // HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
764 int AliHLTSystem::CleanHLTOUT()
766 // see header file for class documentation
767 if (fpChainHandlers) {
768 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
769 fpChainHandlers=NULL;
771 AliHLTOUT::InvalidateBlocks(*pHandlers);
772 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
774 assert(pHandlers->size()==0);
779 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
782 AliHLTOUT::InvalidateBlocks(*pHandlers);
783 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
785 assert(pHandlers->size()==0);
789 if (fpProprietaryHandlers) {
790 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
791 fpProprietaryHandlers=NULL;
793 AliHLTOUT::InvalidateBlocks(*pHandlers);
794 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
796 assert(pHandlers->size()==0);
802 void* AliHLTSystem::AllocMemory( void* /*param*/, unsigned long size )
804 // see header file for class documentation
807 p=(void*)new char[size];
811 log.LoggingVarargs(kHLTLogError, "AliHLTSystem" , "AllocMemory" , __FILE__ , __LINE__ , "exeption during memory allocation" );
816 int AliHLTSystem::AllocEventDoneData( void* /*param*/, AliHLTEventID_t /*eventID*/, unsigned long size, AliHLTComponentEventDoneData** edd )
818 // see header file for class documentation
819 unsigned long blocksize=sizeof(AliHLTComponentEventDoneData)+size;
820 void* block=AllocMemory(NULL, blocksize);
821 if (!block) return -ENOMEM;
822 memset(block, 0, blocksize);
823 *edd=reinterpret_cast<AliHLTComponentEventDoneData*>(block);
824 (*edd)->fStructSize=sizeof(AliHLTComponentEventDoneData);
825 (*edd)->fDataSize=size;
826 (*edd)->fData=reinterpret_cast<AliHLTUInt8_t*>(block)+sizeof(AliHLTComponentEventDoneData);
831 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
832 AliRawReader* rawReader)
834 // see header file for class documentation
836 if (runLoader || rawReader || nofEvents==0) {
837 if (nofEvents>0) {HLTInfo("Run Loader %p, Raw Reader %p , %d event(s)", runLoader, rawReader, nofEvents);}
838 if (CheckStatus(kReady)) {
840 // special case to close the reconstruction
841 if (!CheckStatus(kError)) {
847 if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
848 AliHLTUInt64_t trgMask=0x1;
849 if (runLoader==NULL) {
850 // this is a quick workaround for the case of simulation
851 // the trigger framework is still under development, secondly, AliHLTSimulation
852 // does not yet add the emulated ECS parameters, so no CTP trigger is known in the HLT
853 // AliHLTTask will initialize one dummy CTP trigger class with bit 0, that's why the
854 // default trigger mask is 0x1
855 trgMask=AliHLTMisc::Instance().GetTriggerMask(rawReader);
857 // the system always remains started after event processing, a specific
858 // call with nofEvents==0 is needed to execute the stop sequence
859 if ((iResult=Run(nofEvents, 0, trgMask))<0) SetStatusFlags(kError);
863 HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
866 HLTError("missing RunLoader (%p)/RawReader (%p) instance", runLoader, rawReader);
872 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
874 // see header file for class documentation
876 if (runLoader || esd) {
877 HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
878 iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
880 HLTError("missing run loader/ESD instance(s)");
886 int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd)
888 // see header file for class documentation
890 if (!pHLTOUT) return -EINVAL;
891 HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
893 // add the current HLTOUT task to the collection
895 AliHLTOUT* pTask=dynamic_cast<AliHLTOUT*>(fpHLTOUTTask);
896 if (pTask && (iResult=pTask->Init())>=0) {
897 if (pTask->GetNofDataBlocks()>0) {
898 pHLTOUT->AddSubCollection(pTask);
901 HLTWarning("can not initialize HLTOUT sub collection %s for reconstruction chain (%d), data blocks are lost", pTask?fpHLTOUTTask->GetName():"nil", iResult);
908 // process all kChain handlers first
910 if ((iResult=ProcessHLTOUTkChain(pHLTOUT))<0) {
911 HLTWarning("Processing of kChain-type data blocks failed with error code %d", iResult);
916 fpEsdHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
917 if (!fpProprietaryHandlers)
918 fpProprietaryHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
920 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pEsdHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
921 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pProprietaryHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
922 if (!pEsdHandlers || !pProprietaryHandlers) return -ENOMEM;
924 // invalidate all blocks
925 AliHLTOUT::InvalidateBlocks(*pEsdHandlers);
926 AliHLTOUT::InvalidateBlocks(*pProprietaryHandlers);
928 AliHLTComponentDataTypeList esdBlocks;
930 for (iResult=pHLTOUT->SelectFirstDataBlock();
932 iResult=pHLTOUT->SelectNextDataBlock()) {
933 AliHLTComponentDataType dt=kAliHLTVoidDataType;
934 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
935 pHLTOUT->GetDataBlockDescription(dt, spec);
936 AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
937 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
939 // default handling for ESD data blocks does not require an explicite handler
940 if (!pHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
941 handlerType=AliHLTModuleAgent::kEsd;
943 const char* pMsg="invalid";
944 switch (handlerType) {
945 case AliHLTModuleAgent::kEsd:
948 // schedule for later processing
949 pHLTOUT->InsertHandler(*pEsdHandlers, pHLTOUT->GetDataBlockHandlerDesc());
951 AliHLTComponentDataTypeList::iterator element=esdBlocks.begin();
952 for (; element!=esdBlocks.end(); element++) {
954 HLTWarning("multiple ESDs of identical data type %s, please add appropriate handler to merge ESDs", AliHLTComponent::DataType2Text(dt).c_str());
958 if (element==esdBlocks.end()) esdBlocks.push_back(dt);
961 const AliHLTUInt8_t* pBuffer=NULL;
962 AliHLTUInt32_t size=0;
963 if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) {
964 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
965 pHLTOUT->ReleaseDataBuffer(pBuffer);
967 pHLTOUT->MarkDataBlockProcessed();
971 case AliHLTModuleAgent::kRawReader:
972 // handled in the AliRawReaderHLT
974 case AliHLTModuleAgent::kRawStream:
975 HLTWarning("HLTOUT handler type 'kRawStream' not yet implemented: agent %s, data type %s, specification %#x",
976 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
977 AliHLTComponent::DataType2Text(dt).c_str(), spec);
979 case AliHLTModuleAgent::kChain:
980 HLTWarning("HLTOUT handler type 'kChain' has already been processed: agent %s, data type %s, specification %#x\n"
981 "New block of this type added by the chain? Skipping data block ...",
982 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
983 AliHLTComponent::DataType2Text(dt).c_str(), spec);
985 case AliHLTModuleAgent::kProprietary:
986 HLTDebug("processing proprietary data: agent %s, data type %s, specification %#x",
987 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
988 AliHLTComponent::DataType2Text(dt).c_str(), spec);
990 AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
991 int res=pHandler->ProcessData(pHLTOUT);
993 HLTWarning("processing proprietary data failed (%d): agent %s, data type %s, specification %#x",
994 res, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
995 AliHLTComponent::DataType2Text(dt).c_str(), spec);
999 case AliHLTModuleAgent::kUnknownOutput:
1001 // fall trough intended
1003 HLTWarning("%s handler type: agent %s, data type %s, specification %#x, ... skipping data block",
1004 pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
1005 AliHLTComponent::DataType2Text(dt).c_str(), spec);
1008 // TODO: the return value of SelectFirst/NextDataBlock must be
1009 // changed in order to avoid this check
1010 if (iResult==-ENOENT) iResult=0;
1012 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator handler;
1014 // process and write all esd data blocks
1015 for (handler=pEsdHandlers->begin(); handler!=pEsdHandlers->end() && iResult>=0; handler++) {
1016 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1017 AliHLTOUTHandler* pHandler=*handler;
1018 const AliHLTUInt8_t* pBuffer=NULL;
1019 AliHLTUInt32_t size=0;
1020 pHandler->ProcessData(pHLTOUT);
1021 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1022 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*handler;
1023 AliHLTComponentDataType dt=desc;
1024 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
1025 pHandler->ReleaseProcessedData(pBuffer, size);
1027 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1030 // process all kProprietary data blocks
1031 for (handler=pProprietaryHandlers->begin(); handler!=pProprietaryHandlers->end() && iResult>=0; handler++) {
1032 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1033 AliHLTOUTHandler* pHandler=*handler;
1034 const AliHLTUInt8_t* pBuffer=NULL;
1035 AliHLTUInt32_t size=0;
1036 pHandler->ProcessData(pHLTOUT);
1037 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1038 HLTWarning("data produced by kProprietary handler ignored");
1039 pHandler->ReleaseProcessedData(pBuffer, size);
1041 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1044 // remove all empty handlers form the list (handlers which did not get a block this time)
1045 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pEsdHandlers);
1046 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pProprietaryHandlers);
1051 int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT)
1053 // see header file for class documentation
1055 if (!pHLTOUT) return -EINVAL;
1057 if (!fpChainHandlers)
1058 fpChainHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
1060 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pChainHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
1061 if (!pChainHandlers) return -ENOMEM;
1063 // invalidate all blocks
1064 AliHLTOUT::InvalidateBlocks(*pChainHandlers);
1067 pHLTOUT->FillHandlerList(*pChainHandlers, AliHLTModuleAgent::kChain);
1069 // process all defined chain handlers
1070 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator chainHandler;
1071 for (chainHandler=pChainHandlers->begin(); chainHandler!=pChainHandlers->end() && iResult>=0; chainHandler++) {
1072 if (chainHandler->IsEmpty()) continue;
1073 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*chainHandler));
1074 AliHLTOUTHandler* pHandler=*chainHandler;
1075 const AliHLTUInt8_t* pBuffer=NULL;
1076 AliHLTUInt32_t size=0;
1077 pHandler->ProcessData(pHLTOUT);
1078 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1079 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler;
1080 AliHLTComponentDataType dt=desc;
1082 pHandler->ReleaseProcessedData(pBuffer, size);
1084 pHLTOUT->MarkDataBlocksProcessed(&(*chainHandler));
1087 // remove all empty handlers form the list (handlers which did not get a block this time)
1088 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pChainHandlers);
1093 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
1095 // see header file for class documentation
1098 if (fpComponentHandler) {
1099 TString libs(libraries);
1100 TObjArray* pTokens=libs.Tokenize(" ");
1102 int iEntries=pTokens->GetEntriesFast();
1103 for (int i=0; i<iEntries && iResult>=0; i++) {
1104 iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
1109 SetStatusFlags(kLibrariesLoaded);
1111 // lets see if we need this, probably not
1112 //fpComponentHandler->UnloadLibraries();
1113 ClearStatusFlags(kLibrariesLoaded);
1117 HLTFatal("no component handler available");
1125 int AliHLTSystem::Configure(AliRunLoader* runloader)
1127 // see header file for class documentation
1128 return Configure(NULL, runloader);
1131 int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader)
1133 // see header file for class documentation
1135 if (CheckStatus(kRunning)) {
1136 HLTError("HLT system in running state, can not configure");
1139 ClearStatusFlags(kTaskListCreated);
1140 if (CheckFilter(kHLTLogDebug))
1141 AliHLTModuleAgent::PrintStatus();
1142 if (CheckStatus(kConfigurationLoaded)==0) {
1143 iResult=LoadConfigurations(rawReader, runloader);
1145 if (fChains.Length()==0) {
1146 HLTError("custom configuration(s) specified, but no configuration to run in local reconstruction, use \'chains=<chain,...>\' option");
1151 SetStatusFlags(kConfigurationLoaded);
1152 if (CheckFilter(kHLTLogDebug))
1153 fpConfigurationHandler->PrintConfigurations();
1154 iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader);
1156 SetStatusFlags(kTaskListCreated);
1159 if (iResult<0) SetStatusFlags(kError);
1164 int AliHLTSystem::ScanOptions(const char* options)
1166 // see header file for class documentation
1169 //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
1171 TString alloptions(options);
1172 TObjArray* pTokens=alloptions.Tokenize(" ");
1174 int iEntries=pTokens->GetEntriesFast();
1175 for (int i=0; i<iEntries; i++) {
1176 TString token=(((TObjString*)pTokens->At(i))->GetString());
1177 if (token.Contains("loglevel=")) {
1178 TString param=token.ReplaceAll("loglevel=", "");
1179 if (param.IsDigit()) {
1180 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
1181 } else if (param.BeginsWith("0x") &&
1182 param.Replace(0,2,"",0).IsHex()) {
1184 sscanf(param.Data(),"%x", &severity);
1185 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
1187 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1189 } else if (token.Contains("frameworklog=")) {
1190 TString param=token.ReplaceAll("frameworklog=", "");
1191 if (param.IsDigit()) {
1192 SetFrameworkLog((AliHLTComponentLogSeverity)param.Atoi());
1193 } else if (param.BeginsWith("0x") &&
1194 param.Replace(0,2,"",0).IsHex()) {
1196 sscanf(param.Data(),"%x", &severity);
1197 SetFrameworkLog((AliHLTComponentLogSeverity)severity);
1199 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1201 } else if (token.Contains("alilog=off")) {
1203 } else if (token.Contains("config=")) {
1204 TString param=token.ReplaceAll("config=", "");
1206 gROOT->Macro(param.Data(), &error);
1208 SetStatusFlags(kConfigurationLoaded);
1210 HLTError("can not execute macro \'%s\'", param.Data());
1213 } else if (token.Contains("chains=")) {
1214 TString param=token.ReplaceAll("chains=", "");
1215 fChains=param.ReplaceAll(",", " ");
1216 if (fChains.IsNull()) fChains=" "; // disable all chains
1217 } else if (token.Contains("libmode=")) {
1218 TString param=token.ReplaceAll("libmode=", "");
1219 param.ReplaceAll(",", " ");
1220 if (fpComponentHandler) {
1221 if (param.CompareTo("static")==0) {
1222 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kStatic);
1223 } else if (param.CompareTo("dynamic")==0) {
1224 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kDynamic);
1226 HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
1229 } else if (token.BeginsWith("ECS=")) {
1230 fECSParams=token.ReplaceAll("ECS=", "");
1231 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
1235 HLTWarning("unknown option \'%s\'", token.Data());
1242 if (libs.IsNull()) {
1243 const char** deflib=fgkHLTDefaultLibs;
1249 if ((!CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
1250 (LoadComponentLibraries(libs.Data())<0)) {
1251 HLTError("error while loading HLT libraries");
1259 int AliHLTSystem::Reset(int bForce)
1261 // see header file for class documentation
1263 if (!bForce && CheckStatus(kRunning)) {
1264 HLTError("HLT system in running state, can not configure");
1268 ClearStatusFlags(~kUninitialized);
1272 int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader)
1274 // see header file for class documentation
1275 if (CheckStatus(kRunning)) {
1276 HLTError("HLT system in running state, can not configure");
1280 AliHLTModuleAgent* pAgent=NULL;
1282 // first check for the required libraries and load those
1284 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1285 pAgent && iResult>=0;
1286 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1287 const char* deplibs=pAgent->GetRequiredComponentLibraries();
1289 HLTDebug("required libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
1295 iResult=LoadComponentLibraries(extralibs.Data());
1298 // in order to register the configurations in the correct sequence
1299 // all agents need to be ordered with respect to the required
1300 // libraries. Ordering relies on the naming convention
1301 // libAliHLT<Module>.so
1303 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1304 pAgent && iResult>=0;
1305 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1306 AliHLTModuleAgent* pPrevDep=NULL;
1307 TString dependencies=pAgent->GetRequiredComponentLibraries();
1308 TObjArray* pTokens=dependencies.Tokenize(" ");
1310 for (int n=0; n<pTokens->GetEntriesFast(); n++) {
1311 TString module=((TObjString*)pTokens->At(n))->GetString();
1312 HLTDebug(" checking %s", module.Data());
1313 module.ReplaceAll("libAliHLT", "");
1314 module.ReplaceAll(".so", "");
1316 for (AliHLTModuleAgent* pCurrent=dynamic_cast<AliHLTModuleAgent*>(pPrevDep==NULL?agents.First():agents.After(pPrevDep));
1317 pCurrent!=NULL; pCurrent=dynamic_cast<AliHLTModuleAgent*>(agents.After(pCurrent))) {
1318 HLTDebug(" checking %s == %s", module.Data(), pCurrent->GetModuleId());
1320 if (module.CompareTo(pCurrent->GetModuleId())==0) {
1330 // insert right after the last dependency
1331 agents.AddAfter(pPrevDep, pAgent);
1332 HLTDebug("insert %s after %s", pAgent->GetModuleId(), pPrevDep->GetModuleId());
1334 // insert at the beginning
1335 agents.AddFirst(pAgent);
1336 HLTDebug("insert %s at beginning", pAgent->GetModuleId());
1340 // now we load the configurations
1341 if (agents.GetEntries()) {
1342 TIter next(&agents);
1343 while ((pAgent = dynamic_cast<AliHLTModuleAgent*>(next()))) {
1344 HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
1345 pAgent->CreateConfigurations(fpConfigurationHandler, rawReader, runloader);
1352 int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader)
1354 // see header file for class documentation
1355 if (CheckStatus(kRunning)) {
1356 HLTError("HLT system in running state, can not configure");
1359 if (!CheckStatus(kConfigurationLoaded)) {
1360 HLTWarning("configurations not yet loaded");
1369 if (fChains.Length()>0) {
1371 HLTImportant("custom reconstruction chain: %s", chains.Data());
1373 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
1374 while ((pAgent || fChains.Length()>0) && iResult>=0) {
1375 const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
1377 if (!chains.IsNull()) chains+=" ";
1378 chains+=agentchains;
1379 HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
1381 pAgent=AliHLTModuleAgent::GetNextAgent();
1385 // build task list for chains
1386 TObjArray* pTokens=chains.Tokenize(" ");
1388 int iEntries=pTokens->GetEntriesFast();
1389 for (int i=0; i<iEntries && iResult>=0; i++) {
1390 const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
1391 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
1393 iResult=BuildTaskList(pConf);
1394 if (true) { // condition was deprecated but kept for sake of svn diff
1395 // bHaveOutput variable has to be set for both running modes
1396 // AliHLTSimulation and AliHLTReconstruction
1397 assert(fpComponentHandler!=NULL);
1398 TString cid=pConf->GetComponentID();
1399 if (runloader!=NULL && cid.CompareTo("HLTOUT")==0) {
1400 // remove from the input of a global HLTOUT configuration
1401 chains.ReplaceAll(pCID, "");
1402 } else if (bHaveOutput==0) {
1403 // check whether this configuration produces data output
1404 if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) {
1406 chains.ReplaceAll(pCID, "");
1411 HLTWarning("can not find configuration %s", pCID);
1417 // build HLTOUT for simulation
1418 if (iResult>=0 && runloader) {
1420 // there are components in the chain which produce data which need to be
1421 // piped to an HLTOUT
1423 // add the SchemaEvolutionComponent which analyzes the ROOT objects in
1424 // the output stream
1425 if (fpComponentHandler->FindComponentIndex("ROOTSchemaEvolutionComponent")>=0 ||
1426 fpComponentHandler->LoadLibrary("libAliHLTUtil.so")>=0) {
1427 AliHLTConfiguration schemaevo("_schemaevolution_", "ROOTSchemaEvolutionComponent",
1428 chains.Data(), "-file=HLT.StreamerInfo.root");
1429 iResult=BuildTaskList("_schemaevolution_");
1431 HLTWarning("can not load libAliHLTUtil.so and ROOTSchemaEvolutionComponent");
1434 // add the HLTOUT component
1435 if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
1436 fpComponentHandler->LoadLibrary("libHLTsim.so")>=0) {
1437 AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
1438 iResult=BuildTaskList("_globalout_");
1440 HLTError("can not load libHLTsim.so and HLTOUT component");
1446 // build HLTOUT task for reconstruction
1447 // Matthias 08.07.2008 the rawReader is never set when running embedded into
1448 // AliReconstruction. The system is configured during AliHLTReconstructor::Init
1449 // where the RawReader is not available. It is available in the first invocation
1452 // That means that policy is slightly changed:
1453 // - if the run loader is available -> AliSimulation
1454 // - no run loader available -> AliReconstruction
1455 if (iResult>=0 && !runloader) {
1457 // there are components in the chain which produce data which need to be
1458 // piped to an HLTOUT sub-collection
1459 if (!fpHLTOUTTask) {
1460 iResult=AddHLTOUTTask(chains.Data());
1465 if (iResult>=0) SetStatusFlags(kTaskListCreated);
1470 int AliHLTSystem::AddHLTOUTTask(const char* hltoutchains)
1472 // see header file for class documentation
1474 if (!hltoutchains || hltoutchains[0]==0) return 0;
1476 // check chains for output
1477 TString chains=hltoutchains;
1478 TObjArray* pTokens=chains.Tokenize(" ");
1480 int iEntries=pTokens->GetEntriesFast();
1481 for (int i=0; i<iEntries && iResult>=0; i++) {
1482 const char* token=((TObjString*)pTokens->At(i))->GetString().Data();
1483 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(token);
1485 TString cid=pConf->GetComponentID();
1486 if (fpComponentHandler->HasOutputData(cid.Data())) {
1490 HLTWarning("can not find configuration %s", token);
1492 // remove from the list of hltout chains
1493 chains.ReplaceAll(token, "");
1498 // do not create the HLTOUT task if none of the chains have output
1499 if (chains.IsNull()) return 0;
1501 // indicate the task to be available
1505 if (strcmp(chains.Data(), fpHLTOUTTask->GetSourceChains())==0) {
1506 HLTWarning("HLTOUT task already added for chains \"%s\" %p", chains.Data(), fpHLTOUTTask);
1508 HLTError("HLTOUT task already added for chains \"%s\" %p, ignoring new chains \"%s\"",
1509 fpHLTOUTTask->GetSourceChains(), fpHLTOUTTask, chains.Data());
1514 fpHLTOUTTask=new AliHLTOUTTask(chains);
1516 if (fpHLTOUTTask->GetConf() && fpHLTOUTTask->GetConf()->SourcesResolved()>=0) {
1517 iResult=InsertTask(fpHLTOUTTask);
1519 HLTError("HLTOUT task (%s) sources not resolved", fpHLTOUTTask->GetName());
1524 delete fpHLTOUTTask;
1533 int AliHLTSystem::CheckStatus(int flag)
1535 // see header file for class documentation
1536 if (flag==kUninitialized && flag==fState) return 1;
1537 if ((fState&flag)==flag) return 1;
1541 int AliHLTSystem::GetStatusFlags()
1543 // see header file for class documentation
1547 int AliHLTSystem::SetStatusFlags(int flags)
1549 // see header file for class documentation
1554 int AliHLTSystem::ClearStatusFlags(int flags)
1556 // see header file for class documentation
1561 void (*AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol))()
1563 // see header file for class documentation
1564 if (fpComponentHandler==NULL) return NULL;
1565 return fpComponentHandler->FindSymbol(library, symbol);
1568 void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
1570 // see header file for class documentation
1571 SetLocalLoggingLevel(level);
1572 if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
1573 if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);
1576 int AliHLTSystem::LoggingVarargs(AliHLTComponentLogSeverity severity,
1577 const char* originClass, const char* originFunc,
1578 const char* file, int line, ... ) const
1580 // see header file for function documentation
1584 va_start(args, line);
1586 if (!fName.IsNull())
1587 AliHLTLogging::SetLogString(this, " (%p)", "%s_pfmt_: ", fName.Data());
1588 iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, !fName.IsNull() /*append if non empty*/));