#include "AliHLTComponent.h"
#include "AliHLTConfiguration.h"
#include "AliHLTConfigurationHandler.h"
+#include "AliHLTOnlineConfiguration.h"
#include "AliHLTTask.h"
#include "AliHLTModuleAgent.h"
#include "AliHLTOfflineInterface.h"
"libAliHLTRCU.so",
"libAliHLTTPC.so",
// "libAliHLTSample.so",
- // "libAliHLTPHOS.so",
+ "libAliHLTCalo.so",
+ "libAliHLTEMCAL.so",
+ "libAliHLTPHOS.so",
"libAliHLTMUON.so",
"libAliHLTTRD.so",
"libAliHLTITS.so",
/** 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(),
fpEsdHandlers(NULL),
fpProprietaryHandlers(NULL),
fpHLTOUTTask(NULL),
+ fpHLTOUT(NULL),
+ fHLTOUTUse(0),
fpControlTask(NULL),
fName(name)
, fECSParams()
+ , fUseHLTOUTComponentTypeGlobal(true)
{
// see header file for class documentation
// or
} else {
HLTFatal("can not create Component Handler");
}
- if (fpConfigurationHandler) {
- AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
- } else {
+ if (fpConfigurationHandler==NULL) {
HLTFatal("can not create Configuration Handler");
}
}
{
// see header file for class documentation
fgNofInstances--;
- CleanHLTOUT();
+ CleanupHLTOUTHandlers();
CleanTaskList();
- AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler);
if (fpConfigurationHandler) {
fpConfigurationHandler->Destroy();
}
lnk = lnk->Next();
}
PrintBenchmarking(fStopwatches, 1 /*clean*/);
+ if (fEventCount!=fGoodEvents) {
+ HLTError("%d out of %d event(s) failed", fEventCount-fGoodEvents, fEventCount);
+ }
ClearStatusFlags(kStarted);
return iResult;
}
return iResult;
}
-int AliHLTSystem::CleanHLTOUT()
+int AliHLTSystem::CleanupHLTOUTHandlers()
{
// see header file for class documentation
if (fpChainHandlers) {
if (!CheckStatus(kError)) {
StopTasks();
DeinitTasks();
- CleanHLTOUT();
+ CleanupHLTOUTHandlers();
}
} else {
if ((iResult=AliHLTOfflineInterface::SetParamsToComponents(runLoader, rawReader))>=0) {
if ((iResult=Run(nofEvents, 0, trgMask, timestamp, eventtype))<0) SetStatusFlags(kError);
}
}
+
+ // add the current HLTOUT task to the collection
+ if (fpHLTOUTTask) {
+ AliHLTOUT* pTask=dynamic_cast<AliHLTOUT*>(fpHLTOUTTask);
+ if (pTask && (iResult=pTask->Init())>=0) {
+ if (pTask->GetNofDataBlocks()>0) {
+ AliHLTOUT* pHLTOUT=RequestHLTOUT();
+ if (pHLTOUT) {
+ pHLTOUT->AddSubCollection(pTask);
+ ReleaseHLTOUT(pHLTOUT);
+ } else {
+ HLTWarning("no HLTOUT instance available, output blocks of the chain are ignored");
+ }
+ }
+ } else {
+ HLTWarning("can not initialize HLTOUT sub collection %s for reconstruction chain (%d), data blocks are lost", pTask?fpHLTOUTTask->GetName():"nil", iResult);
+ iResult=0;
+ }
+ }
} else {
HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady);
}
if (!pHLTOUT) return -EINVAL;
HLTDebug("processing %d HLT data blocks", pHLTOUT->GetNofDataBlocks());
- // add the current HLTOUT task to the collection
- if (fpHLTOUTTask) {
- AliHLTOUT* pTask=dynamic_cast<AliHLTOUT*>(fpHLTOUTTask);
- if (pTask && (iResult=pTask->Init())>=0) {
- if (pTask->GetNofDataBlocks()>0) {
- pHLTOUT->AddSubCollection(pTask);
- }
- } else {
- HLTWarning("can not initialize HLTOUT sub collection %s for reconstruction chain (%d), data blocks are lost", pTask?fpHLTOUTTask->GetName():"nil", iResult);
- iResult=0;
- }
- }
-
-
//
// process all kChain handlers first
//
if (pTokens) {
int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries && iResult>=0; i++) {
- iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data());
+ iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->String()).Data());
}
delete pTokens;
}
if (pTokens) {
int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries; i++) {
- TString token=(((TObjString*)pTokens->At(i))->GetString());
+ TString token=(((TObjString*)pTokens->At(i))->String());
if (token.Contains("loglevel=")) {
TString param=token.ReplaceAll("loglevel=", "");
if (param.IsDigit()) {
}
} else if (token.Contains("alilog=off")) {
SwitchAliLog(0);
- } else if (token.Contains("config=")) {
- TString param=token.ReplaceAll("config=", "");
- Int_t error=0;
- gROOT->Macro(param.Data(), &error);
- if (error==0) {
- SetStatusFlags(kConfigurationLoaded);
+ } else if (token.Contains("config=") || token.Contains("run-online-config")) {
+ if (!CheckStatus(kConfigurationLoaded)) {
+ Int_t error=0;
+ AliHLTOnlineConfiguration* pConf = NULL;
+ if (token.Contains("run-online-config")) {
+ AliCDBEntry* pEntry=AliHLTMisc::Instance().LoadOCDBEntry("HLT/Calib/OnlineConfig");
+ if (pEntry) {
+ TObject* pObject=AliHLTMisc::Instance().ExtractObject(pEntry);
+ if (pObject && pObject->IsA() == AliHLTOnlineConfiguration::Class())
+ pConf = (AliHLTOnlineConfiguration*)pObject;
+ }
+ }
+ if (token.Contains("config=")) {
+ TString param=token.ReplaceAll("config=", "");
+ if (token.EndsWith(".xml", TString::kIgnoreCase)) {
+ Int_t filesize = 0;
+ pConf = new AliHLTOnlineConfiguration;
+ filesize = pConf->LoadConfiguration(param.Data());
+ if (filesize <= 0) {
+ HLTError("cannot load config \'%s\'", param.Data());
+ iResult=-EBADF;
+ }
+ } else {
+ gROOT->Macro(param.Data(), &error);
+ if (error==0) {
+ SetStatusFlags(kConfigurationLoaded);
+ } else {
+ HLTError("cannot execute macro \'%s\'", param.Data());
+ iResult=-EBADF;
+ }
+ }
+ }
+ if (pConf) {
+ error = pConf->Parse();
+ if (error==0) {
+ fChains = pConf->GetDefaultChains();
+ libs = pConf->GetComponentLibraries();
+ libs += " ";
+ SetStatusFlags(kConfigurationLoaded);
+ } else {
+ HLTError("cannot parse online configuration");
+ iResult=-EBADF;
+ }
+ }
+ delete pConf; pConf=NULL;
} else {
- HLTError("can not execute macro \'%s\'", param.Data());
- iResult=-EBADF;
+ HLTWarning("HLT options has both a config file and run-online-config set");
}
} else if (token.Contains("chains=")) {
TString param=token.ReplaceAll("chains=", "");
}
} 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")!=0;
} else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
libs+=token;
libs+=" ";
TObjArray* pTokens=dependencies.Tokenize(" ");
if (pTokens) {
for (int n=0; n<pTokens->GetEntriesFast(); n++) {
- TString module=((TObjString*)pTokens->At(n))->GetString();
+ TString module=((TObjString*)pTokens->At(n))->String();
HLTDebug(" checking %s", module.Data());
module.ReplaceAll("libAliHLT", "");
module.ReplaceAll(".so", "");
chains=fChains;
HLTImportant("custom reconstruction chain: %s", chains.Data());
} else {
- AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
- while ((pAgent || fChains.Length()>0) && iResult>=0) {
+ for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
+ pAgent && iResult>=0;
+ pAgent=AliHLTModuleAgent::GetNextAgent()) {
const char* agentchains=pAgent->GetReconstructionChains(rawReader, runloader);
if (agentchains) {
if (!chains.IsNull()) chains+=" ";
chains+=agentchains;
HLTInfo("reconstruction chains for agent %s (%p): %s", pAgent->GetName(), pAgent, agentchains);
}
- pAgent=AliHLTModuleAgent::GetNextAgent();
}
}
if (pTokens) {
int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries && iResult>=0; i++) {
- const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data();
+ const char* pCID=((TObjString*)pTokens->At(i))->String().Data();
AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID);
if (pConf) {
iResult=BuildTaskList(pConf);
// 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");
if (pTokens) {
int iEntries=pTokens->GetEntriesFast();
for (int i=0; i<iEntries && iResult>=0; i++) {
- const char* token=((TObjString*)pTokens->At(i))->GetString().Data();
+ const char* token=((TObjString*)pTokens->At(i))->String().Data();
AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(token);
if (pConf) {
TString cid=pConf->GetComponentID();
fpHLTOUTTask=new AliHLTOUTTask(chains);
if (fpHLTOUTTask) {
- if (fpHLTOUTTask->GetConf() && fpHLTOUTTask->GetConf()->SourcesResolved()>=0) {
+ if (fpHLTOUTTask->GetConf() &&
+ (fpHLTOUTTask->GetConf()->SourcesResolved()>0 ||
+ fpHLTOUTTask->GetConf()->ExtractSources()>0)) {
iResult=InsertTask(fpHLTOUTTask);
} else {
HLTError("HLTOUT task (%s) sources not resolved", fpHLTOUTTask->GetName());
return iResult;
}
+
+int AliHLTSystem::InitHLTOUT(AliHLTOUT* instance)
+{
+ // Init the HLTOUT instance for the current event.
+ // The instance can be used by other classes to get hold on the data
+ // from HLTOUT.
+ if (!instance) return -EINVAL;
+ if (fpHLTOUT && fpHLTOUT!=instance) return -EBUSY;
+ fpHLTOUT=instance;
+ return 0;
+}
+
+int AliHLTSystem::InvalidateHLTOUT(AliHLTOUT** target)
+{
+ // Clear the HLTOUT instance.
+ int iResult=0;
+ if (fHLTOUTUse>0) {
+ HLTWarning("HLTOUT instance still in use, potential problem due to invalid pointer ahead");
+ fHLTOUTUse=0;
+ iResult=-EBUSY;
+ }
+ if (target) *target=fpHLTOUT;
+ fpHLTOUT=NULL;
+ return iResult;
+}
+
+AliHLTOUT* AliHLTSystem::RequestHLTOUT()
+{
+ // Get the HLTOUT instance.
+ // User method for processing classes. To be released after use.
+ if (!fpHLTOUT) return NULL;
+ fHLTOUTUse++;
+ return fpHLTOUT;
+}
+
+int AliHLTSystem::ReleaseHLTOUT(const AliHLTOUT* instance)
+{
+ // Release the HLTOUT instance after use.
+ if (!instance) return -EINVAL;
+ if (instance!=fpHLTOUT) return -ENOENT;
+ fHLTOUTUse--;
+ return 0;
+}