// $Id$
-
//**************************************************************************
//* This file is property of and copyright by the ALICE HLT Project *
//* ALICE Experiment at CERN, All rights reserved. *
#include "AliHLTComponent.h"
#include "AliHLTConfiguration.h"
#include "AliHLTConfigurationHandler.h"
+#include "AliHLTOnlineConfiguration.h"
#include "AliHLTTask.h"
#include "AliHLTModuleAgent.h"
#include "AliHLTOfflineInterface.h"
#include "AliHLTOUTTask.h"
#include "AliHLTControlTask.h"
#include "AliHLTDataBuffer.h"
+#include "AliHLTMisc.h"
#include <TObjArray.h>
#include <TObjString.h>
#include <TStopwatch.h>
"libAliHLTRCU.so",
"libAliHLTTPC.so",
// "libAliHLTSample.so",
- "libAliHLTPHOS.so",
+ // "libAliHLTPHOS.so",
"libAliHLTMUON.so",
"libAliHLTTRD.so",
"libAliHLTITS.so",
+ "libAliHLTVZERO.so",
+ "libAliHLTZDC.so",
"libAliHLTGlobal.so",
"libAliHLTTrigger.so",
NULL
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTSystem)
-AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name)
- :
- fpComponentHandler(AliHLTComponentHandler::CreateHandler()),
- fpConfigurationHandler(AliHLTConfigurationHandler::CreateHandler()),
+AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name,
+ AliHLTComponentHandler* pCompHandler,
+ AliHLTConfigurationHandler* pConfHandler
+ )
+ : fpComponentHandler(pCompHandler==NULL?AliHLTComponentHandler::CreateHandler():pCompHandler)
+ , fpConfigurationHandler(pConfHandler==NULL?AliHLTConfigurationHandler::CreateHandler():pConfHandler),
fTaskList(),
fState(0),
fChains(),
fpHLTOUTTask(NULL),
fpControlTask(NULL),
fName(name)
+ , fECSParams()
+ , fUseHLTOUTComponentTypeGlobal(true)
{
// see header file for class documentation
// or
memset(&env, 0, sizeof(AliHLTAnalysisEnvironment));
env.fStructSize=sizeof(AliHLTAnalysisEnvironment);
env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
+ env.fGetEventDoneDataFunc=AliHLTSystem::AllocEventDoneData;
env.fLoggingFunc=NULL;
fpComponentHandler->SetEnvironment(&env);
InitAliLogFunc(fpComponentHandler);
fpComponentHandler->Destroy();
}
fpComponentHandler=NULL;
+ delete fStopwatches;
// note: fpHLTOUTTask and fpControlTask are deleted by
// CleanTaskList
int AliHLTSystem::fgNofInstances=0;
-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;
- }
- return iResult;
-}
-
-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;
- }
- return iResult;
-}
-
-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;
- }
- return iResult;
-}
-
int AliHLTSystem::BuildTaskList(const char* id)
{
// see header file for class documentation
}
// task for this configuration exists, terminate
pTask=NULL;
- } else if (pConf->SourcesResolved(1)!=1) {
+ // check first if the configuration has all sources resolved, try to extract otherwise
+ } else if (pConf->SourcesResolved()!=1 && pConf->ExtractSources()!=1) {
HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
iResult=-ENOLINK;
} else {
}
}
-int AliHLTSystem::Run(Int_t iNofEvents, int bStop)
+int AliHLTSystem::Run(Int_t iNofEvents, int bStop, AliHLTUInt64_t trgMask,
+ AliHLTUInt32_t timestamp, AliHLTUInt32_t eventtype,
+ AliHLTUInt32_t participatingDetectors)
{
// see header file for class documentation
int iResult=0;
// reset and prepare for new data
fpHLTOUTTask->Reset();
}
- if ((iResult=ProcessTasks(i))>=0) {
+ if (eventtype == 0) {
+ eventtype = gkAliEventTypeData;
+ participatingDetectors = 0x0;
+ }
+ if ((iResult=ProcessTasks(i, trgMask, timestamp, eventtype, participatingDetectors))>=0) {
fGoodEvents++;
iCount++;
} else {
return iResult;
}
-int AliHLTSystem::ProcessTasks(Int_t eventNo)
+int AliHLTSystem::ProcessTasks(Int_t eventNo, AliHLTUInt64_t trgMask,
+ AliHLTUInt32_t timestamp, AliHLTUInt32_t eventtype,
+ AliHLTUInt32_t participatingDetectors)
{
// see header file for class documentation
int iResult=0;
HLTDebug("processing event no %d", eventNo);
TObjLink *lnk=fTaskList.FirstLink();
- while (lnk && iResult>=0) {
+ while (lnk) {
TObject* obj=lnk->GetObject();
if (obj) {
AliHLTTask* pTask=(AliHLTTask*)obj;
- iResult=pTask->ProcessTask(eventNo);
+ if (iResult>=0) {
+ iResult=pTask->ProcessTask(eventNo, eventtype, trgMask, timestamp, participatingDetectors);
// ProcInfo_t ProcInfo;
// gSystem->GetProcInfo(&ProcInfo);
// HLTInfo("task %s processed (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
+ } else {
+ pTask->SubscribeSourcesAndSkip();
+ }
} else {
}
lnk = lnk->Next();
// see header file for class documentation
int iResult=0;
+ AliHLTComponentBlockDataList controlBlocks;
+ AliHLTComponentBlockData bd;
+
+ // run decriptor block of type kAliHLTDataTypeSOR/kAliHLTDataTypeEOR
+ AliHLTComponent::FillBlockData(bd);
AliHLTRunDesc runDesc;
memset(&runDesc, 0, sizeof(AliHLTRunDesc));
runDesc.fStructSize=sizeof(AliHLTRunDesc);
- AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, dt, kAliHLTVoidDataSpec, (AliHLTUInt8_t*)&runDesc, sizeof(AliHLTRunDesc));
+ runDesc.fRunNo=AliHLTMisc::Instance().GetCDBRunNo();
+ bd.fPtr=&runDesc;
+ bd.fSize=sizeof(AliHLTRunDesc);
+ bd.fDataType=dt;
+ bd.fSpecification=kAliHLTVoidDataSpec;
+ controlBlocks.push_back(bd);
+
+ // ECS parameter of type kAliHLTDataTypeECSParam
+ if (fECSParams.IsNull())
+ 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";
+ AliHLTComponent::FillBlockData(bd);
+ bd.fPtr=(void*)fECSParams.Data();
+ bd.fSize=fECSParams.Length()+1;
+ bd.fDataType=kAliHLTDataTypeECSParam;
+ bd.fSpecification=kAliHLTVoidDataSpec;
+ controlBlocks.push_back(bd);
+
+ AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
TObjLink *lnk=fTaskList.FirstLink();
while (lnk && iResult>=0) {
if (dt==kAliHLTDataTypeSOR) eventType=gkAliEventTypeStartOfRun;
else if (dt==kAliHLTDataTypeEOR) eventType=gkAliEventTypeEndOfRun;
else HLTWarning("unknown control event %s", AliHLTComponent::DataType2Text(dt).c_str());
- iResult=pTask->ProcessTask(-1, eventType);
+ iResult=pTask->ProcessTask(-1, eventType, 0, 0);
} else {
}
lnk = lnk->Next();
{
// see header file for class documentation
int iResult=0;
- TObjLink *lnk=fTaskList.FirstLink();
+ TObjLink *lnk=fTaskList.LastLink();
while (lnk) {
TObject* obj=lnk->GetObject();
if (obj) {
// HLTInfo("task %s cleaned (%d), current memory usage %d %d", pTask->GetName(), iResult, ProcInfo.fMemResident, ProcInfo.fMemVirtual);
} else {
}
- lnk = lnk->Next();
+ lnk = lnk->Prev();
}
fEventCount=-1;
fGoodEvents=-1;
return p;
}
+int AliHLTSystem::AllocEventDoneData( void* /*param*/, AliHLTEventID_t /*eventID*/, unsigned long size, AliHLTComponentEventDoneData** edd )
+{
+ // see header file for class documentation
+ unsigned long blocksize=sizeof(AliHLTComponentEventDoneData)+size;
+ void* block=AllocMemory(NULL, blocksize);
+ if (!block) return -ENOMEM;
+ memset(block, 0, blocksize);
+ *edd=reinterpret_cast<AliHLTComponentEventDoneData*>(block);
+ (*edd)->fStructSize=sizeof(AliHLTComponentEventDoneData);
+ (*edd)->fDataSize=size;
+ (*edd)->fData=reinterpret_cast<AliHLTUInt8_t*>(block)+sizeof(AliHLTComponentEventDoneData);
+
+ return 0;
+}
+
int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader,
AliRawReader* rawReader)
{
}
} else {
if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
+ AliHLTUInt64_t trgMask=0x1;
+ AliHLTUInt32_t timestamp=0;
+ AliHLTUInt32_t eventtype=0;
+ if (runLoader==NULL) {
+ // this is a quick workaround for the case of simulation
+ // the trigger framework is still under development, secondly, AliHLTSimulation
+ // does not yet add the emulated ECS parameters, so no CTP trigger is known in the HLT
+ // AliHLTTask will initialize one dummy CTP trigger class with bit 0, that's why the
+ // default trigger mask is 0x1
+ trgMask=AliHLTMisc::Instance().GetTriggerMask(rawReader);
+
+ // get the timestamp and type of the event from the raw reader
+ // this is currently only meaningfull for reconstruction (runloader==NULL)
+ timestamp=AliHLTMisc::Instance().GetTimeStamp(rawReader);
+ eventtype=AliHLTMisc::Instance().GetEventType(rawReader);
+ }
// the system always remains started after event processing, a specific
// call with nofEvents==0 is needed to execute the stop sequence
- if ((iResult=Run(nofEvents, 0))<0) SetStatusFlags(kError);
+ if ((iResult=Run(nofEvents, 0, trgMask, timestamp, eventtype))<0) SetStatusFlags(kError);
}
}
} else {
pHandler->ProcessData(pHLTOUT);
if ((size=pHandler->GetProcessedData(pBuffer))>0) {
AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler;
- AliHLTComponentDataType dt=desc;
+ //AliHLTComponentDataType dt=desc;
pHandler->ReleaseProcessedData(pBuffer, size);
}
TString libs(libraries);
TObjArray* pTokens=libs.Tokenize(" ");
if (pTokens) {
- int iEntries=pTokens->GetEntries();
+ int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries && iResult>=0; i++) {
iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
}
if (options) {
//AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic;
TString libs("");
+ TString excludelibs("");
TString alloptions(options);
TObjArray* pTokens=alloptions.Tokenize(" ");
if (pTokens) {
- int iEntries=pTokens->GetEntries();
+ int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries; i++) {
TString token=(((TObjString*)pTokens->At(i))->GetString());
if (token.Contains("loglevel=")) {
} else if (token.Contains("config=")) {
TString param=token.ReplaceAll("config=", "");
Int_t error=0;
- gROOT->Macro(param.Data(), &error);
- if (error==0) {
- SetStatusFlags(kConfigurationLoaded);
+ if (token.EndsWith(".xml", TString::kIgnoreCase)) {
+ Int_t filesize = 0;
+ AliHLTOnlineConfiguration conf;
+ filesize = conf.LoadConfiguration(param.Data());
+ if (filesize <= 0) {
+ HLTError("can not load config \'%s\'", param.Data());
+ iResult=-EBADF;
+ } else {
+ error = conf.Parse();
+ if (error==0) {
+ fChains = conf.GetDefaultChains();
+ libs = conf.GetComponentLibraries();
+ libs += " ";
+ SetStatusFlags(kConfigurationLoaded);
+ } else {
+ HLTError("can not parse config \'%s\'", param.Data());
+ iResult=-EBADF;
+ }
+ }
} else {
- HLTError("can not execute macro \'%s\'", param.Data());
- iResult=-EBADF;
- }
+ gROOT->Macro(param.Data(), &error);
+ if (error==0) {
+ SetStatusFlags(kConfigurationLoaded);
+ } else {
+ HLTError("can not execute macro \'%s\'", param.Data());
+ iResult=-EBADF;
+ }
+ }
} else if (token.Contains("chains=")) {
TString param=token.ReplaceAll("chains=", "");
fChains=param.ReplaceAll(",", " ");
HLTWarning("wrong argument for option \'libmode=\', use \'static\' or \'dynamic\'");
}
}
+ } else if (token.BeginsWith("ECS=")) {
+ fECSParams=token.ReplaceAll("ECS=", "");
+ } else if (token.BeginsWith("hltout-mode=")) {
+ // The actual parameter for argument 'hltout-mode' is treated in AliSimulation.
+ // For AliHLTSystem the occurrence with parameter 'split' signals the use of the
+ // separated HLTOUTComponents for digit and raw data. All others indicate
+ // HLTOUTComponent type 'global' where the data generation is steered from global
+ // flags
+ fUseHLTOUTComponentTypeGlobal=token.CompareTo("hltout-mode=split")==1;
} else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
libs+=token;
libs+=" ";
+ } else if (token.BeginsWith("!lib") && token.EndsWith(".so")) {
+ excludelibs+=token;
+ excludelibs+=" ";
} else {
HLTWarning("unknown option \'%s\'", token.Data());
}
if (iResult>=0) {
if (libs.IsNull()) {
const char** deflib=fgkHLTDefaultLibs;
- while (*deflib) {
- libs+=*deflib++;
+ for (;*deflib; deflib++) {
+ if (excludelibs.Contains(*deflib)) continue;
+ libs+=*deflib;
libs+=" ";
}
}
// build task list for chains
TObjArray* pTokens=chains.Tokenize(" ");
if (pTokens) {
- int iEntries=pTokens->GetEntries();
+ int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries && iResult>=0; i++) {
const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
if (bHaveOutput) {
// there are components in the chain which produce data which need to be
// piped to an HLTOUT
+
+ // add the SchemaEvolutionComponent which analyzes the ROOT objects in
+ // the output stream
+ if (fpComponentHandler->FindComponentIndex("ROOTSchemaEvolutionComponent")>=0 ||
+ fpComponentHandler->LoadLibrary("libAliHLTUtil.so")>=0) {
+ AliHLTConfiguration schemaevo("_schemaevolution_", "ROOTSchemaEvolutionComponent",
+ chains.Data(), "-file=HLT.StreamerInfo.root");
+ iResult=BuildTaskList("_schemaevolution_");
+ } else {
+ HLTWarning("can not load libAliHLTUtil.so and ROOTSchemaEvolutionComponent");
+ }
+
+ // add the HLTOUT component
if (fpComponentHandler->FindComponentIndex("HLTOUT")>=0 ||
fpComponentHandler->LoadLibrary("libHLTsim.so")>=0) {
- AliHLTConfiguration globalout("_globalout_", "HLTOUT", chains.Data(), NULL);
+ // for the default HLTOUTComponent type 'global' the data generation is steered
+ // by global flags from AliSimulation. This allows for emulation of the old
+ // AliHLTSimulation behavior where only one chain is run on either digits or
+ // simulated raw data and the HLT digits and raw files have been generated
+ // depending on the configuration
+ const char* HLTOUTComponentId="HLTOUT";
+ if (!fUseHLTOUTComponentTypeGlobal) {
+ // choose the type of output depending on the availability of
+ // the raw reader
+ if (rawReader) HLTOUTComponentId="HLTOUTraw";
+ else HLTOUTComponentId="HLTOUTdigits";
+ }
+ AliHLTConfiguration globalout("_globalout_", HLTOUTComponentId, chains.Data(), NULL);
iResult=BuildTaskList("_globalout_");
} else {
HLTError("can not load libHLTsim.so and HLTOUT component");
TString chains=hltoutchains;
TObjArray* pTokens=chains.Tokenize(" ");
if (pTokens) {
- int iEntries=pTokens->GetEntries();
+ int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries && iResult>=0; i++) {
const char* token=((TObjString*)pTokens->At(i))->GetString().Data();
AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(token);
return fState;
}
-void (*AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol))()
+AliHLTfctVoid AliHLTSystem::FindDynamicSymbol(const char* library, const char* symbol)
{
// see header file for class documentation
if (fpComponentHandler==NULL) return NULL;
va_start(args, line);
if (!fName.IsNull())
- AliHLTLogging::SetLogString("%s (%p): ", fName.Data(), this);
+ AliHLTLogging::SetLogString(this, " (%p)", "%s_pfmt_: ", fName.Data());
iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, !fName.IsNull() /*append if non empty*/));
va_end(args);