// $Id$
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
- * ALICE Experiment at CERN, All rights reserved. *
- * *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
- * for The ALICE HLT Project. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* for The ALICE HLT Project. *
+//* *
+//* Permission to use, copy, modify and distribute this software and its *
+//* documentation strictly for non-commercial purposes is hereby granted *
+//* without fee, provided that the above copyright notice appears in all *
+//* copies and that both the copyright notice and this permission notice *
+//* appear in the supporting documentation. The authors make no claims *
+//* about the suitability of this software for any purpose. It is *
+//* provided "as is" without express or implied warranty. *
+//**************************************************************************
/** @file AliHLTSystem.cxx
@author Matthias Richter
#include "AliHLTTask.h"
#include "AliHLTModuleAgent.h"
#include "AliHLTOfflineInterface.h"
+#include "AliHLTDataSource.h"
+#include "AliHLTOUT.h"
+#include "AliHLTOUTHandler.h"
#include <TObjArray.h>
#include <TObjString.h>
#include <TStopwatch.h>
//#include <TSystem.h>
#include <TROOT.h>
-#include <TInterpreter.h>
+//#include <TInterpreter.h>
/** HLT default component libraries */
-const char* kHLTDefaultLibs[]= {
+const char* AliHLTSystem::fgkHLTDefaultLibs[]= {
"libAliHLTUtil.so",
+ "libAliHLTRCU.so",
"libAliHLTTPC.so",
// "libAliHLTSample.so",
//"libAliHLTPHOS.so",
//"libAliHLTMUON.so",
"libAliHLTTRD.so",
+ "libAliHLTTrigger.so",
NULL
};
int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
{
// see header file for class documentation
+ HLTLogKeyword("configuration handling");
int iResult=0;
if (pConf) {
+ HLTError("function not yet implemented");
+ iResult=-ENOSYS;
} else {
iResult=-EINVAL;
}
int AliHLTSystem::InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec)
{
// see header file for class documentation
+ HLTLogKeyword("configuration handling");
int iResult=0;
if (pConf) {
if (pPrec) {
// find the position
+ HLTError("function not yet implemented");
+ iResult=-ENOSYS;
}
} else {
iResult=-EINVAL;
int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf)
{
// see header file for class documentation
+ HLTLogKeyword("configuration handling");
int iResult=0;
if (pConf) {
+ HLTError("function not yet implemented");
+ iResult=-ENOSYS;
} else {
iResult=-EINVAL;
}
AliHLTTask* pTask=NULL;
if ((pTask=FindTask(pConf->GetName()))!=NULL) {
if (pTask->GetConf()!=pConf) {
- HLTError("configuration missmatch, there is already a task with configuration name \"%s\", but it is different. Most likely configuration %p is not registered properly", pConf->GetName(), pConf);
+ 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);
iResult=-EEXIST;
}
// task for this configuration exists, terminate
TObjLink *lnk=fTaskList.FirstLink();
if (lnk==NULL) {
- HLTWarning("Task list is empty, aborting ...");
+ HLTWarning("Task list is empty, skipping HLT");
return -126 /*ENOKEY*/;
}
while (lnk && iResult>=0) {
} else {
fEventCount=0;
fGoodEvents=0;
+ if ((iResult=SendControlEvent(kAliHLTDataTypeSOR))<0) {
+ HLTError("can not send SOR event");
+ }
}
return iResult;
}
}
if (iResult>=0) {
- HLTInfo("Event %d successfully finished (%d)", eventNo, iResult);
+ HLTImportant("Event %d successfully finished (%d)", eventNo, iResult);
iResult=0;
} else {
HLTError("Processing of event %d failed (%d)", eventNo, iResult);
{
// see header file for class documentation
int iResult=0;
+ if ((iResult=SendControlEvent(kAliHLTDataTypeEOR))<0) {
+ HLTError("can not send EOR event");
+ }
TObjLink *lnk=fTaskList.FirstLink();
- while (lnk && iResult>=0) {
+ while (lnk) {
TObject* obj=lnk->GetObject();
if (obj) {
AliHLTTask* pTask=(AliHLTTask*)obj;
- iResult=pTask->EndRun();
+ int locResult=pTask->EndRun();
+ if (iResult>=0 && locResult<0) iResult=locResult;
// ProcInfo_t ProcInfo;
// gSystem->GetProcInfo(&ProcInfo);
// HLTInfo("task %s stopped (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
return iResult;
}
+int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt)
+{
+ // see header file for class documentation
+
+ // disabled for the moment
+ return 0;
+
+ int iResult=0;
+ AliHLTRunDesc runDesc;
+ memset(&runDesc, 0, sizeof(AliHLTRunDesc));
+ runDesc.fStructSize=sizeof(AliHLTRunDesc);
+ AliHLTDataSource::AliSpecialEventGuard g(&runDesc, dt, kAliHLTVoidDataSpec);
+ HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
+ TObjLink *lnk=fTaskList.FirstLink();
+ while (lnk && iResult>=0) {
+ TObject* obj=lnk->GetObject();
+ if (obj) {
+ AliHLTTask* pTask=(AliHLTTask*)obj;
+ iResult=pTask->ProcessTask(-1);
+ } else {
+ }
+ lnk = lnk->Next();
+ }
+ HLTDebug("event %s done (%d)", AliHLTComponent::DataType2Text(dt).c_str(), iResult);
+ return iResult;
+}
+
int AliHLTSystem::DeinitTasks()
{
// see header file for class documentation
return iResult;
}
+int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!pHLTOUT) return -EINVAL;
+
+ HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
+ AliHLTOUT::AliHLTOUTHandlerListEntryVector esdHandlers;
+ for (iResult=pHLTOUT->SelectFirstDataBlock();
+ iResult>=0;
+ iResult=pHLTOUT->SelectNextDataBlock()) {
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ pHLTOUT->GetDataBlockDescription(dt, spec);
+ AliHLTOUTHandler* pHandler=pHLTOUT->GetHandler();
+ AliHLTModuleAgent::AliHLTOUTHandlerType handlerType=pHLTOUT->GetDataBlockHandlerType();
+ if (!pHandler && (dt==kAliHLTDataTypeESDObject || dt==kAliHLTDataTypeESDTree)) {
+ handlerType=AliHLTModuleAgent::kEsd;
+ }
+ const char* pMsg="invalid";
+ switch (handlerType) {
+ case AliHLTModuleAgent::kEsd:
+ {
+ if (pHandler) {
+ // preprocess and write later
+ AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
+ pHandler->ProcessData(pHLTOUT);
+ pHLTOUT->InsertHandler(esdHandlers, pHLTOUT->GetDataBlockHandlerDesc());
+ } else {
+ // write directly
+ const AliHLTUInt8_t* pBuffer=NULL;
+ AliHLTUInt32_t size=0;
+ if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) {
+ pHLTOUT->WriteESD(pBuffer, size, dt);
+ pHLTOUT->ReleaseDataBuffer(pBuffer);
+ }
+ }
+ }
+ break;
+ case AliHLTModuleAgent::kRawReader:
+ // handled in the AliRawReaderHLT
+ break;
+ case AliHLTModuleAgent::kRawStream:
+ HLTWarning("HLTOUT handler type 'kRawStream' not yet implemented: agent %s, data type %s, specification %#x",
+ pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ break;
+ case AliHLTModuleAgent::kChain:
+ HLTWarning("HLTOUT handler type 'kChain' not yet implemented: agent %s, data type %s, specification %#x",
+ pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ break;
+ case AliHLTModuleAgent::kProprietary:
+ HLTDebug("processing proprietary data: agent %s, data type %s, specification %#x",
+ pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ if (pHandler) {
+ AliHLTOUT::AliHLTOUTLockGuard g(pHLTOUT);
+ int res=pHandler->ProcessData(pHLTOUT);
+ if (res<0) {
+ HLTWarning("processing proprietary data failed (%d): agent %s, data type %s, specification %#x",
+ res, pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ }
+ }
+ break;
+ case AliHLTModuleAgent::kUnknownOutput:
+ pMsg="unknown";
+ // fall trough intended
+ default:
+ HLTWarning("%s handler type: agent %s, data type %s, specification %#x, ... skipping data block",
+ pMsg, pHLTOUT->GetAgent()?pHLTOUT->GetAgent()->GetModuleId():"invalid",
+ AliHLTComponent::DataType2Text(dt).c_str(), spec);
+ }
+ }
+ // TODO: the return value of SelectFirst/NextDataBlock must be
+ // changed in order to avoid this check
+ if (iResult==-ENOENT) iResult=0;
+
+ AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator esdHandler;
+ // write all postponed esd data blocks
+ // first come first serve: the ESD of the first handler is also filled into
+ // the main ESD. Has to be changed later.
+ AliESDEvent* pMasterESD=esd;
+ for (esdHandler=esdHandlers.begin(); esdHandler!=esdHandlers.end() && iResult>=0; esdHandler++) {
+ AliHLTOUTHandler* pHandler=*esdHandler;
+ const AliHLTUInt8_t* pBuffer=NULL;
+ AliHLTUInt32_t size=0;
+ if ((size=pHandler->GetProcessedData(pBuffer))>0) {
+ AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*esdHandler;
+ AliHLTComponentDataType dt=desc;
+ pHLTOUT->WriteESD(pBuffer, size, dt);
+ if (pMasterESD) {
+ pHLTOUT->WriteESD(pBuffer, size, dt, pMasterESD);
+ pMasterESD=NULL;
+ }
+ pHandler->ReleaseProcessedData(pBuffer, size);
+ }
+ }
+
+ return iResult;
+}
+
int AliHLTSystem::LoadComponentLibraries(const char* libraries)
{
// see header file for class documentation
// see header file for class documentation
int iResult=0;
if (options) {
- AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
+ //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
TString libs("");
TString alloptions(options);
TObjArray* pTokens=alloptions.Tokenize(" ");
if (iResult>=0) {
if (libs.IsNull()) {
- const char** deflib=kHLTDefaultLibs;
+ const char** deflib=fgkHLTDefaultLibs;
while (*deflib) {
libs+=*deflib++;
libs+=" ";
TString chains;
if (fChains.Length()>0) {
chains=fChains;
- HLTInfo("custom reconstruction chain: %s", chains.Data());
+ HLTImportant("custom reconstruction chain: %s", chains.Data());
} else {
AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
while ((pAgent || fChains.Length()>0) && iResult>=0) {
void AliHLTSystem::SetFrameworkLog(AliHLTComponentLogSeverity level)
{
+ // see header file for class documentation
SetLocalLoggingLevel(level);
if (fpComponentHandler) fpComponentHandler->SetLocalLoggingLevel(level);
if (fpConfigurationHandler) fpConfigurationHandler->SetLocalLoggingLevel(level);