X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FBASE%2FAliHLTSystem.cxx;h=1508db209f9c1522796a31a9e3e29177a347a0fb;hb=820b4d9ec8aaaa083ffa8d6753d1c2b767c6ef3f;hp=cbef2c8378dd93d3954fd535fc52c8791dfbb331;hpb=5e9d702403cbe545a75bd72c678847be4f7b3289;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index cbef2c8378d..1508db209f9 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -32,6 +32,7 @@ using namespace std; #include "AliHLTComponent.h" #include "AliHLTConfiguration.h" #include "AliHLTConfigurationHandler.h" +#include "AliHLTOnlineConfiguration.h" #include "AliHLTTask.h" #include "AliHLTModuleAgent.h" #include "AliHLTOfflineInterface.h" @@ -56,10 +57,14 @@ const char* AliHLTSystem::fgkHLTDefaultLibs[]= { "libAliHLTRCU.so", "libAliHLTTPC.so", // "libAliHLTSample.so", - // "libAliHLTPHOS.so", + "libAliHLTCalo.so", + "libAliHLTEMCAL.so", + "libAliHLTPHOS.so", "libAliHLTMUON.so", "libAliHLTTRD.so", "libAliHLTITS.so", + "libAliHLTVZERO.so", + "libAliHLTZDC.so", "libAliHLTGlobal.so", "libAliHLTTrigger.so", NULL @@ -68,10 +73,12 @@ const char* AliHLTSystem::fgkHLTDefaultLibs[]= { /** 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(), @@ -82,9 +89,12 @@ AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name fpEsdHandlers(NULL), fpProprietaryHandlers(NULL), fpHLTOUTTask(NULL), + fpHLTOUT(NULL), + fHLTOUTUse(0), fpControlTask(NULL), fName(name) , fECSParams() + , fUseHLTOUTComponentTypeGlobal(true) { // see header file for class documentation // or @@ -115,9 +125,7 @@ AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name } else { HLTFatal("can not create Component Handler"); } - if (fpConfigurationHandler) { - AliHLTConfiguration::GlobalInit(fpConfigurationHandler); - } else { + if (fpConfigurationHandler==NULL) { HLTFatal("can not create Configuration Handler"); } } @@ -126,9 +134,8 @@ AliHLTSystem::~AliHLTSystem() { // see header file for class documentation fgNofInstances--; - CleanHLTOUT(); + CleanupHLTOUTHandlers(); CleanTaskList(); - AliHLTConfiguration::GlobalDeinit(fpConfigurationHandler); if (fpConfigurationHandler) { fpConfigurationHandler->Destroy(); } @@ -146,51 +153,6 @@ AliHLTSystem::~AliHLTSystem() 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 @@ -226,7 +188,8 @@ int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf) } // 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 { @@ -384,7 +347,9 @@ void AliHLTSystem::PrintTaskList() } } -int AliHLTSystem::Run(Int_t iNofEvents, int bStop, AliHLTUInt64_t trgMask) +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; @@ -408,7 +373,11 @@ int AliHLTSystem::Run(Int_t iNofEvents, int bStop, AliHLTUInt64_t trgMask) // reset and prepare for new data fpHLTOUTTask->Reset(); } - if ((iResult=ProcessTasks(i, trgMask))>=0) { + if (eventtype == 0) { + eventtype = gkAliEventTypeData; + participatingDetectors = 0x0; + } + if ((iResult=ProcessTasks(i, trgMask, timestamp, eventtype, participatingDetectors))>=0) { fGoodEvents++; iCount++; } else { @@ -620,20 +589,26 @@ int AliHLTSystem::StartTasks() return iResult; } -int AliHLTSystem::ProcessTasks(Int_t eventNo, AliHLTUInt64_t trgMask) +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, gkAliEventTypeData, trgMask); + 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(); @@ -678,6 +653,9 @@ int AliHLTSystem::StopTasks() 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; } @@ -723,7 +701,7 @@ int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt) 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(); @@ -761,7 +739,7 @@ int AliHLTSystem::DeinitTasks() return iResult; } -int AliHLTSystem::CleanHLTOUT() +int AliHLTSystem::CleanupHLTOUTHandlers() { // see header file for class documentation if (fpChainHandlers) { @@ -841,11 +819,13 @@ int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader, if (!CheckStatus(kError)) { StopTasks(); DeinitTasks(); - CleanHLTOUT(); + CleanupHLTOUTHandlers(); } } 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 @@ -853,11 +833,35 @@ int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader, // 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, trgMask))<0) SetStatusFlags(kError); + 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(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); @@ -890,20 +894,6 @@ int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) 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(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 // @@ -1077,7 +1067,7 @@ int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT) pHandler->ProcessData(pHLTOUT); if ((size=pHandler->GetProcessedData(pBuffer))>0) { AliHLTModuleAgent::AliHLTOUTHandlerDesc desc=*chainHandler; - AliHLTComponentDataType dt=desc; + //AliHLTComponentDataType dt=desc; pHandler->ReleaseProcessedData(pBuffer, size); } @@ -1101,7 +1091,7 @@ int AliHLTSystem::LoadComponentLibraries(const char* libraries) if (pTokens) { int iEntries=pTokens->GetEntriesFast(); for (int i=0; i=0; i++) { - iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data()); + iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->String()).Data()); } delete pTokens; } @@ -1168,12 +1158,13 @@ int AliHLTSystem::ScanOptions(const char* options) if (options) { //AliHLTComponentHandler::TLibraryMode libMode=AliHLTComponentHandler::kDynamic; TString libs(""); + TString excludelibs(""); TString alloptions(options); TObjArray* pTokens=alloptions.Tokenize(" "); if (pTokens) { int iEntries=pTokens->GetEntriesFast(); for (int i=0; iAt(i))->GetString()); + TString token=(((TObjString*)pTokens->At(i))->String()); if (token.Contains("loglevel=")) { TString param=token.ReplaceAll("loglevel=", ""); if (param.IsDigit()) { @@ -1200,15 +1191,53 @@ int AliHLTSystem::ScanOptions(const char* options) } } 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=", ""); @@ -1228,9 +1257,19 @@ int AliHLTSystem::ScanOptions(const char* options) } } 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+=" "; + } else if (token.BeginsWith("!lib") && token.EndsWith(".so")) { + excludelibs+=token; + excludelibs+=" "; } else { HLTWarning("unknown option \'%s\'", token.Data()); } @@ -1241,8 +1280,9 @@ int AliHLTSystem::ScanOptions(const char* options) 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+=" "; } } @@ -1308,7 +1348,7 @@ int AliHLTSystem::LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runl TObjArray* pTokens=dependencies.Tokenize(" "); if (pTokens) { for (int n=0; nGetEntriesFast(); 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", ""); @@ -1370,15 +1410,15 @@ int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader 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(); } } @@ -1387,7 +1427,7 @@ int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader if (pTokens) { int iEntries=pTokens->GetEntriesFast(); for (int i=0; i=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); @@ -1434,7 +1474,19 @@ int AliHLTSystem::BuildTaskListsFromReconstructionChains(AliRawReader* rawReader // 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"); @@ -1479,7 +1531,7 @@ int AliHLTSystem::AddHLTOUTTask(const char* hltoutchains) if (pTokens) { int iEntries=pTokens->GetEntriesFast(); for (int i=0; i=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(); @@ -1513,7 +1565,9 @@ int AliHLTSystem::AddHLTOUTTask(const char* hltoutchains) 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()); @@ -1558,7 +1612,7 @@ int AliHLTSystem::ClearStatusFlags(int flags) 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; @@ -1590,3 +1644,46 @@ int AliHLTSystem::LoggingVarargs(AliHLTComponentLogSeverity severity, 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; +}