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",
66 "libAliHLTTrigger.so",
70 /** ROOT macro for the implementation of ROOT specific class methods */
71 ClassImp(AliHLTSystem)
73 AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name)
75 fpComponentHandler(AliHLTComponentHandler::CreateHandler()),
76 fpConfigurationHandler(AliHLTConfigurationHandler::CreateHandler()),
80 fStopwatches(new TObjArray),
83 fpChainHandlers(NULL),
85 fpProprietaryHandlers(NULL),
91 // see header file for class documentation
93 // refer to README to build package
95 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
97 if (fgNofInstances++>0) {
98 // July 2008: multiple instances are now allowed
99 // AliHLTSystem is used in multiple instances for the kChain HLTOUT handler
100 //HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
103 SetGlobalLoggingLevel(loglevel);
104 SetFrameworkLog(loglevel);
105 if (fpComponentHandler) {
106 AliHLTAnalysisEnvironment env;
107 memset(&env, 0, sizeof(AliHLTAnalysisEnvironment));
108 env.fStructSize=sizeof(AliHLTAnalysisEnvironment);
109 env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
110 env.fGetEventDoneDataFunc=AliHLTSystem::AllocEventDoneData;
111 env.fLoggingFunc=NULL;
112 fpComponentHandler->SetEnvironment(&env);
113 InitAliLogFunc(fpComponentHandler);
114 if (fgNofInstances==1) {
115 fpComponentHandler->AnnounceVersion();
118 HLTFatal("can not create Component Handler");
120 if (fpConfigurationHandler) {
121 AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
123 HLTFatal("can not create Configuration Handler");
127 AliHLTSystem::~AliHLTSystem()
129 // see header file for class documentation
133 AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
134 if (fpConfigurationHandler) {
135 fpConfigurationHandler->Destroy();
137 fpConfigurationHandler=NULL;
139 if (fpComponentHandler) {
140 fpComponentHandler->Destroy();
142 fpComponentHandler=NULL;
145 // note: fpHLTOUTTask and fpControlTask are deleted by
149 int AliHLTSystem::fgNofInstances=0;
151 int AliHLTSystem::BuildTaskList(const char* id)
153 // see header file for class documentation
156 if (fpConfigurationHandler) {
157 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id);
159 iResult=BuildTaskList(pConf);
161 HLTError("unknown configuration \"%s\"", id);
173 int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf)
175 // see header file for class documentation
178 AliHLTTask* pTask=NULL;
179 if ((pTask=FindTask(pConf->GetName()))!=NULL) {
180 if (pTask->GetConf()!=pConf) {
181 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);
184 // task for this configuration exists, terminate
186 } else if (pConf->SourcesResolved(1)!=1) {
187 HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
190 pTask=new AliHLTTask(pConf);
194 pTask->SetLocalLoggingLevel(GetLocalLoggingLevel());
197 static int iterationLevel=0;
198 if (pTask && iResult>=0) {
199 // check for circular dependencies
200 if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
201 HLTError("detected circular dependency for configuration \"%s\"", pTask->GetName());
202 pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
203 HLTError("aborted ...");
207 // check whether all dependencies are already in the task list
208 // create the missing ones
209 // this step is an iterative process which calls this function again for the missing
210 // configurations, in order to avoid the currently processed task to be created
211 // again it is added to the list temporarily and removed afterwards
212 // This is of high importance to preserve the order of the tasks. Furthermore, the
213 // InsertTask method has to be used in order to set all the cross links right
214 fTaskList.Add(pTask);
215 AliHLTConfiguration* pDep=pConf->GetFirstSource();
216 while (pDep!=NULL && iResult>=0) {
217 HLTDebug("iteration %d: checking dependency %s (%p)", iterationLevel, pDep->GetName(), pDep);
218 if (FindTask(pDep->GetName())==NULL) {
219 HLTDebug("iteration %d: building task list for configuration %s (%p)", iterationLevel, pDep->GetName(), pDep);
221 iResult=BuildTaskList(pDep);
224 pDep=pConf->GetNextSource();
226 // remove the temporarily added task
227 fTaskList.Remove(pTask);
229 // insert the task and set the cross-links
231 HLTDebug("iteration %d: inserting task %s (%p)", iterationLevel, pTask->GetName(), pTask);
232 iResult=InsertTask(pTask);
245 int AliHLTSystem::CleanTaskList()
247 // see header file for class documentation
252 while ((lnk=fTaskList.LastLink())!=NULL) {
253 delete (lnk->GetObject());
254 fTaskList.Remove(lnk);
260 int AliHLTSystem::InsertTask(AliHLTTask* pTask)
262 // see header file for class documentation
264 if (fpControlTask==NULL) {
265 fpControlTask=new AliHLTControlTask;
266 if (!fpControlTask) return -ENOMEM;
267 fTaskList.AddFirst(fpControlTask);
269 TObjLink *controlLnk=NULL;
270 TObjLink *lnk = fTaskList.FirstLink();
271 assert(!lnk || lnk->GetObject()==fpControlTask || fpControlTask==NULL);
272 if (lnk && lnk->GetObject()==fpControlTask) {
273 if (pTask->GetConf() && pTask->GetConf()->GetFirstSource()==NULL) {
274 pTask->SetDependency(fpControlTask);
275 fpControlTask->SetTarget(pTask);
280 if ((iResult=pTask->CheckDependencies())<=0)
282 while (lnk && iResult>0) {
283 AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
284 //HLTDebug("checking \"%s\"", pCurr->GetName());
285 iResult=pTask->Depends(pCurr);
287 iResult=pTask->SetDependency(pCurr);
288 pCurr->SetTarget(pTask);
289 HLTDebug("set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
291 if (pCurr->Depends(pTask)) {
292 // circular dependency
293 HLTError("circular dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
295 } else if ((iResult=pTask->CheckDependencies())>0) {
301 fTaskList.AddAfter(lnk, pTask);
302 } else if (controlLnk) {
303 fTaskList.AddAfter(controlLnk, pTask);
305 fTaskList.AddFirst(pTask);
307 HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask));
308 } else if (iResult>0) {
309 HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
315 AliHLTTask* AliHLTSystem::FindTask(const char* id)
317 // see header file for class documentation
318 AliHLTTask* pTask=NULL;
320 pTask=dynamic_cast<AliHLTTask*>(fTaskList.FindObject(id));
325 void AliHLTSystem::PrintTaskList()
327 // see header file for class documentation
328 HLTLogKeyword("task list");
329 TObjLink *lnk = NULL;
330 HLTMessage("Task List");
331 lnk=fTaskList.FirstLink();
333 TObject* obj=lnk->GetObject();
335 HLTMessage(" %s - status:", obj->GetName());
336 AliHLTTask* pTask=(AliHLTTask*)obj;
337 pTask->PrintStatus();
344 int AliHLTSystem::Run(Int_t iNofEvents, int bStop, AliHLTUInt64_t trgMask,
345 AliHLTUInt32_t timestamp, AliHLTUInt32_t eventtype,
346 AliHLTUInt32_t participatingDetectors)
348 // see header file for class documentation
351 SetStatusFlags(kRunning);
352 if (fEventCount>=0 || (iResult=InitTasks())>=0) {
353 if (fEventCount>=0 || (iResult=StartTasks())>=0) {
354 if (fEventCount==0) {
355 InitBenchmarking(fStopwatches);
357 // Matthias Oct 11 2008 this is a bug
358 // By resuming the stopwatches at this point, all continued counting, but the
359 // starting and stopping is controlled by the AliHLTStopwatchGuard
360 //ResumeBenchmarking(fStopwatches);
362 for (int i=fEventCount; i<fEventCount+iNofEvents && iResult>=0; i++) {
364 if (iNofEvents>1 && i==fEventCount) {
365 HLTWarning("can not add more than one event to the HLTOUT, skipping all but last block");
367 // reset and prepare for new data
368 fpHLTOUTTask->Reset();
370 if (eventtype == 0) {
371 eventtype = gkAliEventTypeData;
372 participatingDetectors = 0x0;
374 if ((iResult=ProcessTasks(i, trgMask, timestamp, eventtype, participatingDetectors))>=0) {
378 // TODO: define different running modes to either ignore errors in
379 // event processing or not
383 AliHLTDataBuffer::SetGlobalEventCount(iCount);
385 fEventCount+=iNofEvents;
386 if (bStop) StopTasks();
387 else PauseBenchmarking(fStopwatches);
389 if (bStop) DeinitTasks();
393 } else if (iResult==-126 /*ENOKEY*/) {
394 iResult=0; // do not propagate the error
396 ClearStatusFlags(kRunning);
397 AliHLTDataBuffer::PrintStatistics();
401 int AliHLTSystem::InitTasks()
403 // see header file for class documentation
405 TObjLink *lnk=fTaskList.FirstLink();
408 HLTInfo("Task list is empty, skipping HLT");
409 return -126 /*ENOKEY*/;
411 while (lnk && iResult>=0) {
412 TObject* obj=lnk->GetObject();
414 AliHLTTask* pTask=(AliHLTTask*)obj;
415 iResult=pTask->Init(NULL, fpComponentHandler);
416 // ProcInfo_t ProcInfo;
417 // gSystem->GetProcInfo(&ProcInfo);
418 // HLTInfo("task %s initialized (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
424 HLTError("can not initialize task list, error %d", iResult);
430 int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
432 // see header file for class documentation
434 if (pStopwatches==NULL) return 0;
436 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
437 TStopwatch* pStopwatch= new TStopwatch;
440 pStopwatches->AddAt(pStopwatch, i);
447 TObjLink *lnk=fTaskList.FirstLink();
448 while (lnk && iResult>=0) {
449 TObject* obj=lnk->GetObject();
451 AliHLTTask* pTask=(AliHLTTask*)obj;
452 AliHLTComponent* pComp=NULL;
453 if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) {
454 switch (pComp->GetComponentType()) {
455 case AliHLTComponent::kProcessor:
456 pComp->SetStopwatches(pStopwatches);
458 case AliHLTComponent::kSource:
460 // this switch determines whether the time consumption of the
461 // AliHLTComponent base methods should be counted to the input
462 // stopwatch or base stopwatch.
463 //int inputBase=(int)AliHLTComponent::kSWBase;
464 int inputBase=(int)AliHLTComponent::kSWInput;
465 pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase);
466 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA);
469 case AliHLTComponent::kSink:
471 // this switch determines whether the time consumption of the
472 // AliHLTComponent base methods should be counted to the output
473 // stopwatch or base stopwatch.
474 //int outputBase=(int)AliHLTComponent::kSWBase;
475 int outputBase=(int)AliHLTComponent::kSWOutput;
476 pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase);
477 pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA);
481 HLTWarning("unknown component type %d", (int)pComp->GetComponentType());
491 int AliHLTSystem::PauseBenchmarking(TObjArray* pStopwatches) const
493 // see header file for class documentation
494 if (pStopwatches==NULL) return 0;
496 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
497 if (!pStopwatches->At(i)) continue;
498 TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
499 if (pSw) pSw->Stop();
504 int AliHLTSystem::ResumeBenchmarking(TObjArray* pStopwatches) const
506 // see header file for class documentation
507 if (pStopwatches==NULL) return 0;
509 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
510 if (!pStopwatches->At(i)) continue;
511 TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
512 if (pSw) pSw->Continue();
517 int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean) const
519 // see header file for class documentation
521 if (pStopwatches==NULL) return 0;
523 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
524 if (!dynamic_cast<TStopwatch*>(pStopwatches->At(i))) {
530 if (iInitialized!=0) {
531 HLTImportant("HLT statistics:\n"
532 " base: R:%.3fs C:%.3fs\n"
533 " input: R:%.3fs C:%.3fs\n"
534 " output: R:%.3fs C:%.3fs\n"
535 " event processing : R:%.3fs C:%.3fs"
536 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->RealTime()
537 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWBase))->CpuTime()
538 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->RealTime()
539 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWInput))->CpuTime()
540 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->RealTime()
541 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWOutput))->CpuTime()
542 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->RealTime()
543 , dynamic_cast<TStopwatch*>(pStopwatches->At(AliHLTComponent::kSWDA))->CpuTime()
548 for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
549 TObject* pObj=pStopwatches->RemoveAt(i);
550 if (pObj) delete pObj;
556 int AliHLTSystem::StartTasks()
558 // see header file for class documentation
560 TObjLink *lnk=fTaskList.FirstLink();
561 while (lnk && iResult>=0) {
562 TObject* obj=lnk->GetObject();
564 AliHLTTask* pTask=(AliHLTTask*)obj;
565 iResult=pTask->StartRun();
566 // ProcInfo_t ProcInfo;
567 // gSystem->GetProcInfo(&ProcInfo);
568 // HLTInfo("task %s started (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
574 HLTError("can not start task list, error %d", iResult);
576 SetStatusFlags(kStarted);
579 if ((iResult=SendControlEvent(kAliHLTDataTypeSOR))<0) {
580 HLTError("can not send SOR event: error %d", iResult);
586 int AliHLTSystem::ProcessTasks(Int_t eventNo, AliHLTUInt64_t trgMask,
587 AliHLTUInt32_t timestamp, AliHLTUInt32_t eventtype,
588 AliHLTUInt32_t participatingDetectors)
590 // see header file for class documentation
592 HLTDebug("processing event no %d", eventNo);
593 TObjLink *lnk=fTaskList.FirstLink();
594 while (lnk && iResult>=0) {
595 TObject* obj=lnk->GetObject();
597 AliHLTTask* pTask=(AliHLTTask*)obj;
598 iResult=pTask->ProcessTask(eventNo, eventtype, trgMask, timestamp, participatingDetectors);
599 // ProcInfo_t ProcInfo;
600 // gSystem->GetProcInfo(&ProcInfo);
601 // HLTInfo("task %s processed (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
608 HLTImportant("Event %d successfully finished (%d)", eventNo, iResult);
611 HLTError("Processing of event %d failed (%d)", eventNo, iResult);
617 int AliHLTSystem::StopTasks()
619 // see header file for class documentation
621 if ((iResult=SendControlEvent(kAliHLTDataTypeEOR))<0) {
622 HLTError("can not send EOR event");
625 // cleanup blocks from the last event. This is a bit awkward. All output
626 // blocks from the chains need to be stored in the HLTOUT task. Though,
627 // we do not know, whether HLTOUT is going to be processed or not.
629 fpHLTOUTTask->Reset();
631 TObjLink *lnk=fTaskList.FirstLink();
633 TObject* obj=lnk->GetObject();
635 AliHLTTask* pTask=(AliHLTTask*)obj;
636 int locResult=pTask->EndRun();
637 if (iResult>=0 && locResult<0) iResult=locResult;
638 // ProcInfo_t ProcInfo;
639 // gSystem->GetProcInfo(&ProcInfo);
640 // HLTInfo("task %s stopped (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
645 PrintBenchmarking(fStopwatches, 1 /*clean*/);
646 ClearStatusFlags(kStarted);
650 int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt)
652 // see header file for class documentation
655 AliHLTComponentBlockDataList controlBlocks;
656 AliHLTComponentBlockData bd;
658 // run decriptor block of type kAliHLTDataTypeSOR/kAliHLTDataTypeEOR
659 AliHLTComponent::FillBlockData(bd);
660 AliHLTRunDesc runDesc;
661 memset(&runDesc, 0, sizeof(AliHLTRunDesc));
662 runDesc.fStructSize=sizeof(AliHLTRunDesc);
663 runDesc.fRunNo=AliHLTMisc::Instance().GetCDBRunNo();
665 bd.fSize=sizeof(AliHLTRunDesc);
667 bd.fSpecification=kAliHLTVoidDataSpec;
668 controlBlocks.push_back(bd);
670 // ECS parameter of type kAliHLTDataTypeECSParam
671 if (fECSParams.IsNull())
672 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";
673 AliHLTComponent::FillBlockData(bd);
674 bd.fPtr=(void*)fECSParams.Data();
675 bd.fSize=fECSParams.Length()+1;
676 bd.fDataType=kAliHLTDataTypeECSParam;
677 bd.fSpecification=kAliHLTVoidDataSpec;
678 controlBlocks.push_back(bd);
680 AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
681 HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
682 TObjLink *lnk=fTaskList.FirstLink();
683 while (lnk && iResult>=0) {
684 TObject* obj=lnk->GetObject();
686 AliHLTTask* pTask=(AliHLTTask*)obj;
687 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
688 if (dt==kAliHLTDataTypeSOR) eventType=gkAliEventTypeStartOfRun;
689 else if (dt==kAliHLTDataTypeEOR) eventType=gkAliEventTypeEndOfRun;
690 else HLTWarning("unknown control event %s", AliHLTComponent::DataType2Text(dt).c_str());
691 iResult=pTask->ProcessTask(-1, eventType, 0, 0);
697 // control events are not supposed to go into the HLTOUT
699 fpHLTOUTTask->Reset();
701 HLTDebug("event %s done (%d)", AliHLTComponent::DataType2Text(dt).c_str(), iResult);
705 int AliHLTSystem::DeinitTasks()
707 // see header file for class documentation
709 TObjLink *lnk=fTaskList.LastLink();
711 TObject* obj=lnk->GetObject();
713 AliHLTTask* pTask=(AliHLTTask*)obj;
714 int localRes=pTask->Deinit();
715 if (iResult>=0) iResult=localRes;
716 // ProcInfo_t ProcInfo;
717 // gSystem->GetProcInfo(&ProcInfo);
718 // HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
729 int AliHLTSystem::CleanHLTOUT()
731 // see header file for class documentation
732 if (fpChainHandlers) {
733 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
734 fpChainHandlers=NULL;
736 AliHLTOUT::InvalidateBlocks(*pHandlers);
737 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
739 assert(pHandlers->size()==0);
744 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
747 AliHLTOUT::InvalidateBlocks(*pHandlers);
748 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
750 assert(pHandlers->size()==0);
754 if (fpProprietaryHandlers) {
755 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
756 fpProprietaryHandlers=NULL;
758 AliHLTOUT::InvalidateBlocks(*pHandlers);
759 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pHandlers);
761 assert(pHandlers->size()==0);
767 void* AliHLTSystem::AllocMemory( void* /*param*/, unsigned long size )
769 // see header file for class documentation
772 p=(void*)new char[size];
776 log.LoggingVarargs(kHLTLogError, "AliHLTSystem" , "AllocMemory" , __FILE__ , __LINE__ , "exeption during memory allocation" );
781 int AliHLTSystem::AllocEventDoneData( void* /*param*/, AliHLTEventID_t /*eventID*/, unsigned long size, AliHLTComponentEventDoneData** edd )
783 // see header file for class documentation
784 unsigned long blocksize=sizeof(AliHLTComponentEventDoneData)+size;
785 void* block=AllocMemory(NULL, blocksize);
786 if (!block) return -ENOMEM;
787 memset(block, 0, blocksize);
788 *edd=reinterpret_cast<AliHLTComponentEventDoneData*>(block);
789 (*edd)->fStructSize=sizeof(AliHLTComponentEventDoneData);
790 (*edd)->fDataSize=size;
791 (*edd)->fData=reinterpret_cast<AliHLTUInt8_t*>(block)+sizeof(AliHLTComponentEventDoneData);
796 int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
797 AliRawReader* rawReader)
799 // see header file for class documentation
801 if (runLoader || rawReader || nofEvents==0) {
802 if (nofEvents>0) {HLTInfo("Run Loader %p, Raw Reader %p , %d event(s)", runLoader, rawReader, nofEvents);}
803 if (CheckStatus(kReady)) {
805 // special case to close the reconstruction
806 if (!CheckStatus(kError)) {
812 if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
813 AliHLTUInt64_t trgMask=0x1;
814 AliHLTUInt32_t timestamp=0;
815 AliHLTUInt32_t eventtype=0;
816 if (runLoader==NULL) {
817 // this is a quick workaround for the case of simulation
818 // the trigger framework is still under development, secondly, AliHLTSimulation
819 // does not yet add the emulated ECS parameters, so no CTP trigger is known in the HLT
820 // AliHLTTask will initialize one dummy CTP trigger class with bit 0, that's why the
821 // default trigger mask is 0x1
822 trgMask=AliHLTMisc::Instance().GetTriggerMask(rawReader);
824 // get the timestamp and type of the event from the raw reader
825 // this is currently only meaningfull for reconstruction (runloader==NULL)
826 timestamp=AliHLTMisc::Instance().GetTimeStamp(rawReader);
827 eventtype=AliHLTMisc::Instance().GetEventType(rawReader);
829 // the system always remains started after event processing, a specific
830 // call with nofEvents==0 is needed to execute the stop sequence
831 if ((iResult=Run(nofEvents, 0, trgMask, timestamp, eventtype))<0) SetStatusFlags(kError);
835 HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
838 HLTError("missing RunLoader (%p)/RawReader (%p) instance", runLoader, rawReader);
844 int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd)
846 // see header file for class documentation
848 if (runLoader || esd) {
849 HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd);
850 iResult=AliHLTOfflineInterface::FillComponentESDs(eventNo, runLoader, esd);
852 HLTError("missing run loader/ESD instance(s)");
858 int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd)
860 // see header file for class documentation
862 if (!pHLTOUT) return -EINVAL;
863 HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
865 // add the current HLTOUT task to the collection
867 AliHLTOUT* pTask=dynamic_cast<AliHLTOUT*>(fpHLTOUTTask);
868 if (pTask && (iResult=pTask->Init())>=0) {
869 if (pTask->GetNofDataBlocks()>0) {
870 pHLTOUT->AddSubCollection(pTask);
873 HLTWarning("can not initialize HLTOUT sub collection %s for reconstruction chain (%d), data blocks are lost", pTask?fpHLTOUTTask->GetName():"nil", iResult);
880 // process all kChain handlers first
882 if ((iResult=ProcessHLTOUTkChain(pHLTOUT))<0) {
883 HLTWarning("Processing of kChain-type data blocks failed with error code %d", iResult);
888 fpEsdHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
889 if (!fpProprietaryHandlers)
890 fpProprietaryHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
892 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pEsdHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpEsdHandlers);
893 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pProprietaryHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpProprietaryHandlers);
894 if (!pEsdHandlers || !pProprietaryHandlers) return -ENOMEM;
896 // invalidate all blocks
897 AliHLTOUT::InvalidateBlocks(*pEsdHandlers);
898 AliHLTOUT::InvalidateBlocks(*pProprietaryHandlers);
900 AliHLTComponentDataTypeList esdBlocks;
902 for (iResult=pHLTOUT->SelectFirstDataBlock();
904 iResult=pHLTOUT->SelectNextDataBlock()) {
905 AliHLTComponentDataType dt=kAliHLTVoidDataType;
906 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
907 pHLTOUT->GetDataBlockDescription(dt, spec);
908 AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
909 AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
911 // default handling for ESD data blocks does not require an explicite handler
912 if (!pHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
913 handlerType=AliHLTModuleAgent::kEsd;
915 const char* pMsg="invalid";
916 switch (handlerType) {
917 case AliHLTModuleAgent::kEsd:
920 // schedule for later processing
921 pHLTOUT->InsertHandler(*pEsdHandlers, pHLTOUT->GetDataBlockHandlerDesc());
923 AliHLTComponentDataTypeList::iterator element=esdBlocks.begin();
924 for (; element!=esdBlocks.end(); element++) {
926 HLTWarning("multiple ESDs of identical data type %s, please add appropriate handler to merge ESDs", AliHLTComponent::DataType2Text(dt).c_str());
930 if (element==esdBlocks.end()) esdBlocks.push_back(dt);
933 const AliHLTUInt8_t* pBuffer=NULL;
934 AliHLTUInt32_t size=0;
935 if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) {
936 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
937 pHLTOUT->ReleaseDataBuffer(pBuffer);
939 pHLTOUT->MarkDataBlockProcessed();
943 case AliHLTModuleAgent::kRawReader:
944 // handled in the AliRawReaderHLT
946 case AliHLTModuleAgent::kRawStream:
947 HLTWarning("HLTOUT handler type 'kRawStream' not yet implemented: agent %s, data type %s, specification %#x",
948 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
949 AliHLTComponent::DataType2Text(dt).c_str(), spec);
951 case AliHLTModuleAgent::kChain:
952 HLTWarning("HLTOUT handler type 'kChain' has already been processed: agent %s, data type %s, specification %#x\n"
953 "New block of this type added by the chain? Skipping data block ...",
954 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
955 AliHLTComponent::DataType2Text(dt).c_str(), spec);
957 case AliHLTModuleAgent::kProprietary:
958 HLTDebug("processing proprietary data: agent %s, data type %s, specification %#x",
959 pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
960 AliHLTComponent::DataType2Text(dt).c_str(), spec);
962 AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
963 int res=pHandler->ProcessData(pHLTOUT);
965 HLTWarning("processing proprietary data failed (%d): agent %s, data type %s, specification %#x",
966 res, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
967 AliHLTComponent::DataType2Text(dt).c_str(), spec);
971 case AliHLTModuleAgent::kUnknownOutput:
973 // fall trough intended
975 HLTWarning("%s handler type: agent %s, data type %s, specification %#x, ... skipping data block",
976 pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"<invalid>",
977 AliHLTComponent::DataType2Text(dt).c_str(), spec);
980 // TODO: the return value of SelectFirst/NextDataBlock must be
981 // changed in order to avoid this check
982 if (iResult==-ENOENT) iResult=0;
984 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator handler;
986 // process and write all esd data blocks
987 for (handler=pEsdHandlers->begin(); handler!=pEsdHandlers->end() && iResult>=0; handler++) {
988 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
989 AliHLTOUTHandler* pHandler=*handler;
990 const AliHLTUInt8_t* pBuffer=NULL;
991 AliHLTUInt32_t size=0;
992 pHandler->ProcessData(pHLTOUT);
993 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
994 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*handler;
995 AliHLTComponentDataType dt=desc;
996 pHLTOUT->WriteESD(pBuffer, size, dt, esd);
997 pHandler->ReleaseProcessedData(pBuffer, size);
999 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1002 // process all kProprietary data blocks
1003 for (handler=pProprietaryHandlers->begin(); handler!=pProprietaryHandlers->end() && iResult>=0; handler++) {
1004 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler));
1005 AliHLTOUTHandler* pHandler=*handler;
1006 const AliHLTUInt8_t* pBuffer=NULL;
1007 AliHLTUInt32_t size=0;
1008 pHandler->ProcessData(pHLTOUT);
1009 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1010 HLTWarning("data produced by kProprietary handler ignored");
1011 pHandler->ReleaseProcessedData(pBuffer, size);
1013 pHLTOUT->MarkDataBlocksProcessed(&(*handler));
1016 // remove all empty handlers form the list (handlers which did not get a block this time)
1017 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pEsdHandlers);
1018 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pProprietaryHandlers);
1023 int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT)
1025 // see header file for class documentation
1027 if (!pHLTOUT) return -EINVAL;
1029 if (!fpChainHandlers)
1030 fpChainHandlers=new AliHLTOUT::AliHLTOUTHandlerListEntryVector;
1032 AliHLTOUT::AliHLTOUTHandlerListEntryVector* pChainHandlers=reinterpret_cast<AliHLTOUT::AliHLTOUTHandlerListEntryVector*>(fpChainHandlers);
1033 if (!pChainHandlers) return -ENOMEM;
1035 // invalidate all blocks
1036 AliHLTOUT::InvalidateBlocks(*pChainHandlers);
1039 pHLTOUT->FillHandlerList(*pChainHandlers, AliHLTModuleAgent::kChain);
1041 // process all defined chain handlers
1042 AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator chainHandler;
1043 for (chainHandler=pChainHandlers->begin(); chainHandler!=pChainHandlers->end() && iResult>=0; chainHandler++) {
1044 if (chainHandler->IsEmpty()) continue;
1045 AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*chainHandler));
1046 AliHLTOUTHandler* pHandler=*chainHandler;
1047 const AliHLTUInt8_t* pBuffer=NULL;
1048 AliHLTUInt32_t size=0;
1049 pHandler->ProcessData(pHLTOUT);
1050 if ((size=pHandler->GetProcessedData(pBuffer))>0) {
1051 AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler;
1052 //AliHLTComponentDataType dt=desc;
1054 pHandler->ReleaseProcessedData(pBuffer, size);
1056 pHLTOUT->MarkDataBlocksProcessed(&(*chainHandler));
1059 // remove all empty handlers form the list (handlers which did not get a block this time)
1060 AliHLTOUT::RemoveEmptyDuplicateHandlers(*pChainHandlers);
1065 int AliHLTSystem::LoadComponentLibraries(const char* libraries)
1067 // see header file for class documentation
1070 if (fpComponentHandler) {
1071 TString libs(libraries);
1072 TObjArray* pTokens=libs.Tokenize(" ");
1074 int iEntries=pTokens->GetEntriesFast();
1075 for (int i=0; i<iEntries && iResult>=0; i++) {
1076 iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
1081 SetStatusFlags(kLibrariesLoaded);
1083 // lets see if we need this, probably not
1084 //fpComponentHandler->UnloadLibraries();
1085 ClearStatusFlags(kLibrariesLoaded);
1089 HLTFatal("no component handler available");
1097 int AliHLTSystem::Configure(AliRunLoader* runloader)
1099 // see header file for class documentation
1100 return Configure(NULL, runloader);
1103 int AliHLTSystem::Configure(AliRawReader* rawReader, AliRunLoader* runloader)
1105 // see header file for class documentation
1107 if (CheckStatus(kRunning)) {
1108 HLTError("HLT system in running state, can not configure");
1111 ClearStatusFlags(kTaskListCreated);
1112 if (CheckFilter(kHLTLogDebug))
1113 AliHLTModuleAgent::PrintStatus();
1114 if (CheckStatus(kConfigurationLoaded)==0) {
1115 iResult=LoadConfigurations(rawReader, runloader);
1117 if (fChains.Length()==0) {
1118 HLTError("custom configuration(s) specified, but no configuration to run in local reconstruction, use \'chains=<chain,...>\' option");
1123 SetStatusFlags(kConfigurationLoaded);
1124 if (CheckFilter(kHLTLogDebug))
1125 fpConfigurationHandler->PrintConfigurations();
1126 iResult=BuildTaskListsFromReconstructionChains(rawReader, runloader);
1128 SetStatusFlags(kTaskListCreated);
1131 if (iResult<0) SetStatusFlags(kError);
1136 int AliHLTSystem::ScanOptions(const char* options)
1138 // see header file for class documentation
1141 //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
1143 TString excludelibs("");
1144 TString alloptions(options);
1145 TObjArray* pTokens=alloptions.Tokenize(" ");
1147 int iEntries=pTokens->GetEntriesFast();
1148 for (int i=0; i<iEntries; i++) {
1149 TString token=(((TObjString*)pTokens->At(i))->GetString());
1150 if (token.Contains("loglevel=")) {
1151 TString param=token.ReplaceAll("loglevel=", "");
1152 if (param.IsDigit()) {
1153 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
1154 } else if (param.BeginsWith("0x") &&
1155 param.Replace(0,2,"",0).IsHex()) {
1157 sscanf(param.Data(),"%x", &severity);
1158 SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
1160 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1162 } else if (token.Contains("frameworklog=")) {
1163 TString param=token.ReplaceAll("frameworklog=", "");
1164 if (param.IsDigit()) {
1165 SetFrameworkLog((AliHLTComponentLogSeverity)param.Atoi());
1166 } else if (param.BeginsWith("0x") &&
1167 param.Replace(0,2,"",0).IsHex()) {
1169 sscanf(param.Data(),"%x", &severity);
1170 SetFrameworkLog((AliHLTComponentLogSeverity)severity);
1172 HLTWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
1174 } else if (token.Contains("alilog=off")) {
1176 } else if (token.Contains("config=")) {
1177 TString param=token.ReplaceAll("config=", "");
1179 gROOT->Macro(param.Data(), &error);
1181 SetStatusFlags(kConfigurationLoaded);
1183 HLTError("can not execute macro \'%s\'", param.Data());
1186 } else if (token.Contains("chains=")) {
1187 TString param=token.ReplaceAll("chains=", "");
1188 fChains=param.ReplaceAll(",", " ");
1189 if (fChains.IsNull()) fChains=" "; // disable all chains
1190 } else if (token.Contains("libmode=")) {
1191 TString param=token.ReplaceAll("libmode=", "");
1192 param.ReplaceAll(",", " ");
1193 if (fpComponentHandler) {
1194 if (param.CompareTo("static")==0) {
1195 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kStatic);
1196 } else if (param.CompareTo("dynamic")==0) {
1197 fpComponentHandler->SetLibraryMode(AliHLTComponentHandler::kDynamic);
1199 HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
1202 } else if (token.BeginsWith("ECS=")) {
1203 fECSParams=token.ReplaceAll("ECS=", "");
1204 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
1207 } else if (token.BeginsWith("!lib") && token.EndsWith(".so")) {
1211 HLTWarning("unknown option \'%s\'", token.Data());
1218 if (libs.IsNull()) {
1219 const char** deflib=fgkHLTDefaultLibs;
1220 for (;*deflib; deflib++) {
1221 if (excludelibs.Contains(*deflib)) continue;
1226 if ((!CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
1227 (LoadComponentLibraries(libs.Data())<0)) {
1228 HLTError("error while loading HLT libraries");
1236 int AliHLTSystem::Reset(int bForce)
1238 // see header file for class documentation
1240 if (!bForce && CheckStatus(kRunning)) {
1241 HLTError("HLT system in running state, can not configure");
1245 ClearStatusFlags(~kUninitialized);
1249 int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader)
1251 // see header file for class documentation
1252 if (CheckStatus(kRunning)) {
1253 HLTError("HLT system in running state, can not configure");
1257 AliHLTModuleAgent* pAgent=NULL;
1259 // first check for the required libraries and load those
1261 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1262 pAgent && iResult>=0;
1263 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1264 const char* deplibs=pAgent->GetRequiredComponentLibraries();
1266 HLTDebug("required libraries \'%s\' for agent %s (%p)", deplibs, pAgent->GetName(), pAgent);
1272 iResult=LoadComponentLibraries(extralibs.Data());
1275 // in order to register the configurations in the correct sequence
1276 // all agents need to be ordered with respect to the required
1277 // libraries. Ordering relies on the naming convention
1278 // libAliHLT<Module>.so
1280 for (pAgent=AliHLTModuleAgent::GetFirstAgent();
1281 pAgent && iResult>=0;
1282 pAgent=AliHLTModuleAgent::GetNextAgent()) {
1283 AliHLTModuleAgent* pPrevDep=NULL;
1284 TString dependencies=pAgent->GetRequiredComponentLibraries();
1285 TObjArray* pTokens=dependencies.Tokenize(" ");
1287 for (int n=0; n<pTokens->GetEntriesFast(); n++) {
1288 TString module=((TObjString*)pTokens->At(n))->GetString();
1289 HLTDebug(" checking %s", module.Data());
1290 module.ReplaceAll("libAliHLT", "");
1291 module.ReplaceAll(".so", "");
1293 for (AliHLTModuleAgent* pCurrent=dynamic_cast<AliHLTModuleAgent*>(pPrevDep==NULL?agents.First():agents.After(pPrevDep));
1294 pCurrent!=NULL; pCurrent=dynamic_cast<AliHLTModuleAgent*>(agents.After(pCurrent))) {
1295 HLTDebug(" checking %s == %s", module.Data(), pCurrent->GetModuleId());
1297 if (module.CompareTo(pCurrent->GetModuleId())==0) {
1307 // insert right after the last dependency
1308 agents.AddAfter(pPrevDep, pAgent);
1309 HLTDebug("insert %s after %s", pAgent->GetModuleId(), pPrevDep->GetModuleId());
1311 // insert at the beginning
1312 agents.AddFirst(pAgent);
1313 HLTDebug("insert %s at beginning", pAgent->GetModuleId());
1317 // now we load the configurations
1318 if (agents.GetEntries()) {
1319 TIter next(&agents);
1320 while ((pAgent = dynamic_cast<AliHLTModuleAgent*>(next()))) {
1321 HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent);
1322 pAgent->CreateConfigurations(fpConfigurationHandler, rawReader, runloader);
1329 int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, AliRunLoader* runloader)
1331 // see header file for class documentation
1332 if (CheckStatus(kRunning)) {
1333 HLTError("HLT system in running state, can not configure");
1336 if (!CheckStatus(kConfigurationLoaded)) {
1337 HLTWarning("configurations not yet loaded");
1346 if (fChains.Length()>0) {
1348 HLTImportant("custom reconstruction chain: %s", chains.Data());
1350 AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
1351 while ((pAgent || fChains.Length()>0) && iResult>=0) {
1352 const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
1354 if (!chains.IsNull()) chains+=" ";
1355 chains+=agentchains;
1356 HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
1358 pAgent=AliHLTModuleAgent::GetNextAgent();
1362 // build task list for chains
1363 TObjArray* pTokens=chains.Tokenize(" ");
1365 int iEntries=pTokens->GetEntriesFast();
1366 for (int i=0; i<iEntries && iResult>=0; i++) {
1367 const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
1368 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
1370 iResult=BuildTaskList(pConf);
1371 if (true) { // condition was deprecated but kept for sake of svn diff
1372 // bHaveOutput variable has to be set for both running modes
1373 // AliHLTSimulation and AliHLTReconstruction
1374 assert(fpComponentHandler!=NULL);
1375 TString cid=pConf->GetComponentID();
1376 if (runloader!=NULL && cid.CompareTo("HLTOUT")==0) {
1377 // remove from the input of a global HLTOUT configuration
1378 chains.ReplaceAll(pCID, "");
1379 } else if (bHaveOutput==0) {
1380 // check whether this configuration produces data output
1381 if ((bHaveOutput=fpComponentHandler->HasOutputData(cid.Data()))<0) {
1383 chains.ReplaceAll(pCID, "");
1388 HLTWarning("can not find configuration %s", pCID);
1394 // build HLTOUT for simulation
1395 if (iResult>=0 && runloader) {
1397 // there are components in the chain which produce data which need to be
1398 // piped to an HLTOUT
1400 // add the SchemaEvolutionComponent which analyzes the ROOT objects in
1401 // the output stream
1402 if (fpComponentHandler->FindComponentIndex("ROOTSchemaEvolutionComponent")>=0 ||
1403 fpComponentHandler->LoadLibrary("libAliHLTUtil.so")>=0) {
1404 AliHLTConfiguration schemaevo("_schemaevolution_", "ROOTSchemaEvolutionComponent",
1405 chains.Data(), "-file=HLT.StreamerInfo.root");
1406 iResult=BuildTaskList("_schemaevolution_");
1408 HLTWarning("can not load libAliHLTUtil.so and ROOTSchemaEvolutionComponent");
1411 // add the HLTOUT component
1412 if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
1413 fpComponentHandler->LoadLibrary("libHLTsim.so")>=0) {
1414 AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
1415 iResult=BuildTaskList("_globalout_");
1417 HLTError("can not load libHLTsim.so and HLTOUT component");
1423 // build HLTOUT task for reconstruction
1424 // Matthias 08.07.2008 the rawReader is never set when running embedded into
1425 // AliReconstruction. The system is configured during AliHLTReconstructor::Init
1426 // where the RawReader is not available. It is available in the first invocation
1429 // That means that policy is slightly changed:
1430 // - if the run loader is available -> AliSimulation
1431 // - no run loader available -> AliReconstruction
1432 if (iResult>=0 && !runloader) {
1434 // there are components in the chain which produce data which need to be
1435 // piped to an HLTOUT sub-collection
1436 if (!fpHLTOUTTask) {
1437 iResult=AddHLTOUTTask(chains.Data());
1442 if (iResult>=0) SetStatusFlags(kTaskListCreated);
1447 int AliHLTSystem::AddHLTOUTTask(const char* hltoutchains)
1449 // see header file for class documentation
1451 if (!hltoutchains || hltoutchains[0]==0) return 0;
1453 // check chains for output
1454 TString chains=hltoutchains;
1455 TObjArray* pTokens=chains.Tokenize(" ");
1457 int iEntries=pTokens->GetEntriesFast();
1458 for (int i=0; i<iEntries && iResult>=0; i++) {
1459 const char* token=((TObjString*)pTokens->At(i))->GetString().Data();
1460 AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(token);
1462 TString cid=pConf->GetComponentID();
1463 if (fpComponentHandler->HasOutputData(cid.Data())) {
1467 HLTWarning("can not find configuration %s", token);
1469 // remove from the list of hltout chains
1470 chains.ReplaceAll(token, "");
1475 // do not create the HLTOUT task if none of the chains have output
1476 if (chains.IsNull()) return 0;
1478 // indicate the task to be available
1482 if (strcmp(chains.Data(), fpHLTOUTTask->GetSourceChains())==0) {
1483 HLTWarning("HLTOUT task already added for chains \"%s\" %p", chains.Data(), fpHLTOUTTask);
1485 HLTError("HLTOUT task already added for chains \"%s\" %p, ignoring new chains \"%s\"",
1486 fpHLTOUTTask->GetSourceChains(), fpHLTOUTTask, chains.Data());
1491 fpHLTOUTTask=new AliHLTOUTTask(chains);
1493 if (fpHLTOUTTask->GetConf() && fpHLTOUTTask->GetConf()->SourcesResolved()>=0) {
1494 iResult=InsertTask(fpHLTOUTTask);
1496 HLTError("HLTOUT task (%s) sources not resolved", fpHLTOUTTask->GetName());
1501 delete fpHLTOUTTask;
1510 int AliHLTSystem::CheckStatus(int flag)
1512 // see header file for class documentation
1513 if (flag==kUninitialized && flag==fState) return 1;
1514 if ((fState&flag)==flag) return 1;
1518 int AliHLTSystem::GetStatusFlags()
1520 // see header file for class documentation
1524 int AliHLTSystem::SetStatusFlags(int flags)
1526 // see header file for class documentation
1531 int AliHLTSystem::ClearStatusFlags(int flags)
1533 // see header file for class documentation
1538 AliHLTfctVoid AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol)
1540 // see header file for class documentation
1541 if (fpComponentHandler==NULL) return NULL;
1542 return fpComponentHandler->FindSymbol(library, symbol);
1545 void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
1547 // see header file for class documentation
1548 SetLocalLoggingLevel(level);
1549 if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
1550 if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);
1553 int AliHLTSystem::LoggingVarargs(AliHLTComponentLogSeverity severity,
1554 const char* originClass, const char* originFunc,
1555 const char* file, int line, ... ) const
1557 // see header file for function documentation
1561 va_start(args, line);
1563 if (!fName.IsNull())
1564 AliHLTLogging::SetLogString(this, " (%p)", "%s_pfmt_: ", fName.Data());
1565 iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, !fName.IsNull() /*append if non empty*/));