X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FBASE%2FAliHLTComponent.cxx;h=501c7d0142fd3e095714847fc702051fe171a946;hb=703bcca6353aa37422d317cd3b4a4e32db12f13d;hp=ba0c77ad270a6d6b0e2820cbd61504596b69e7ab;hpb=ed50401172d9086bffd39864f822558aa2ff780f;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index ba0c77ad270..501c7d0142f 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -1,33 +1,27 @@ // $Id$ -/************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * * - * Primary Authors: Matthias Richter * - * Timm Steinbeck * - * 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 * +//* Timm Steinbeck * +//* 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 AliHLTComponent.cxx @author Matthias Richter, Timm Steinbeck @date @brief Base class implementation for HLT components. */ -// see header file for class documentation -// or -// refer to README to build package -// or -// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt - #if __GNUC__>= 3 using namespace std; #endif @@ -43,6 +37,7 @@ using namespace std; #include "TClass.h" #include "TStopwatch.h" #include "AliHLTMemoryFile.h" +#include "AliHLTMisc.h" #include /** ROOT macro for the implementation of ROOT specific class methods */ @@ -76,8 +71,9 @@ AliHLTComponent::AliHLTComponent() fpStopwatches(new TObjArray(kSWTypeCount)), fMemFiles(), fpRunDesc(NULL), - fpDDLList(NULL) - + fpDDLList(NULL), + fCDBSetRunNoFunc(false), + fChainId() { // see header file for class documentation // or @@ -133,6 +129,7 @@ int AliHLTComponent::UnsetGlobalComponentHandler() int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv ) { // see header file for function documentation + HLTLogKeyword(GetComponentID()); int iResult=0; if (environ) { memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment)); @@ -189,6 +186,7 @@ int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environPar int AliHLTComponent::Deinit() { // see header file for function documentation + HLTLogKeyword(GetComponentID()); int iResult=0; iResult=DoDeinit(); if (fpRunDesc) { @@ -197,28 +195,86 @@ int AliHLTComponent::Deinit() fpRunDesc=NULL; delete pRunDesc; } + fEventCount=0; return iResult; } -int AliHLTComponent::DoInit( int argc, const char** argv ) +int AliHLTComponent::InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler) { // see header file for function documentation - if (argc==0 && argv==NULL) { - // this is currently just to get rid of the warning "unused parameter" + int iResult=0; + if (pHandler) { + // I have to think about separating the library handling from the + // component handler. Requiring the component hanlder here is not + // the cleanest solution. + // We presume the library already to be loaded + // find the symbol + AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB); + if (pFunc) { + TString path; + if (cdbPath && cdbPath[0]!=0) { + path=cdbPath; + // very temporary fix, have to check for other formats + if (!path.BeginsWith("local://")) { + path="local://"; + path+=cdbPath; + } + } + if ((iResult=(*pFunc)(path.Data()))>=0) { + if (!(fCDBSetRunNoFunc=pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO))) { + Message(NULL, kHLTLogWarning, "AliHLTComponent::InitCDB", "init CDB", + "can not find function to set CDB run no"); + } + } + } else { + Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB", + "can not find initialization function"); + iResult=-ENOSYS; } - fEventCount=0; + } else { + iResult=-EINVAL; + } + return iResult; +} + +int AliHLTComponent::SetCDBRunNo(int runNo) +{ + // see header file for function documentation + if (!fCDBSetRunNoFunc) return 0; + return (*((AliHLTMiscSetCDBRunNo_t)fCDBSetRunNoFunc))(runNo); +} + +int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/) +{ + // default implementation, childs can overload + HLTLogKeyword("dummy"); return 0; } int AliHLTComponent::DoDeinit() { - // see header file for function documentation - fEventCount=0; + // default implementation, childs can overload + HLTLogKeyword("dummy"); + return 0; +} + +int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) +{ + // default implementation, childs can overload + HLTLogKeyword("dummy"); + return 0; +} + +int AliHLTComponent::ReadPreprocessorValues(const char* /*modules*/) +{ + // default implementation, childs can overload + HLTLogKeyword("dummy"); return 0; } int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/) { + // default implementation, childs can overload HLTLogKeyword("dummy"); return 0; } @@ -321,7 +377,7 @@ int AliHLTComponent::MakeOutputDataBlockList( const AliHLTComponentBlockDataList return -ENOMEM; for ( unsigned long i = 0; i < count; i++ ) { (*outputBlocks)[i] = blocks[i]; - if (blocks[i].fDataType==kAliHLTAnyDataType) { + if (MatchExactly(blocks[i].fDataType, kAliHLTAnyDataType)) { (*outputBlocks)[i].fDataType=GetOutputDataType(); /* data type was set to the output data type by the PubSub AliRoot Wrapper component, if data type of the block was ********:****. @@ -368,8 +424,7 @@ int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTCom AliHLTComponentDataTypeList::iterator otype=otypes.begin(); while (otype!=otypes.end() && (*itype)!=(*otype)) otype++; //if (otype!=otypes.end()) PrintDataTypeContent(*otype, "publisher \'%s\'"); - if (otype!=otypes.end() || - (*itype)==kAliHLTAnyDataType) { + if (otype!=otypes.end()) { if (tgtList) tgtList->push_back(*itype); iResult++; } @@ -381,25 +436,26 @@ int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTCom return iResult; } -void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) const +void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) { // see header file for function documentation - const char* fmt="publisher \'%s\'"; + const char* fmt="\'%s\'"; if (format) fmt=format; - HLTMessage(fmt, (DataType2Text(dt)).c_str()); - HLTMessage("%x %x %x %x %x %x %x %x : %x %x %x %x", - dt.fID[0], - dt.fID[1], - dt.fID[2], - dt.fID[3], - dt.fID[4], - dt.fID[5], - dt.fID[6], - dt.fID[7], - dt.fOrigin[0], - dt.fOrigin[1], - dt.fOrigin[2], - dt.fOrigin[3]); + AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, Form(fmt, (DataType2Text(dt)).c_str())); + AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, + Form("%x %x %x %x %x %x %x %x : %x %x %x %x", + dt.fID[0], + dt.fID[1], + dt.fID[2], + dt.fID[3], + dt.fID[4], + dt.fID[5], + dt.fID[6], + dt.fID[7], + dt.fOrigin[0], + dt.fOrigin[1], + dt.fOrigin[2], + dt.fOrigin[3])); } void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData ) @@ -449,6 +505,16 @@ void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id } } +void AliHLTComponent::SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t origin) +{ + // see header file for function documentation + dt.fStructSize=sizeof(AliHLTComponentDataType); + assert(kAliHLTComponentDataTypefIDsize==sizeof(id)); + assert(kAliHLTComponentDataTypefOriginSize==sizeof(origin)); + memcpy(&dt.fID, &id, kAliHLTComponentDataTypefIDsize); + memcpy(&dt.fOrigin, &origin, kAliHLTComponentDataTypefOriginSize); +} + void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData) { // see header file for function documentation @@ -551,18 +617,14 @@ int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int start if (fpInputBlocks!=NULL) { int idx=startIdx<0?0:startIdx; for ( ; (UInt_t)idxIndexOf(pObject))>=0) { + } else { + HLTError("unknown object %p", pObject); + iResult=-ENOENT; + } + } + if (idx>=0) { + fOutputBlocks.push_back(fpInputBlocks[idx]); + } + return iResult; +} + +int AliHLTComponent::Forward(const AliHLTComponentBlockData* pBlock) +{ + // see header file for function documentation + int iResult=0; + int idx=fCurrentInputBlock; + if (pBlock) { + if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) { + } else { + HLTError("unknown Block %p", pBlock); + iResult=-ENOENT; + } + } + if (idx>=0) { + // check for fpInputBlocks pointer done in FindInputBlock + fOutputBlocks.push_back(fpInputBlocks[idx]); + } + return iResult; +} + const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt) { // see header file for function documentation @@ -715,7 +814,7 @@ const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index) { // see header file for function documentation ALIHLTCOMPONENT_BASE_STOPWATCH(); - assert( 0 <= index and index < fCurrentEventData.fBlockCnt ); + assert( 0 <= index and index < (int)fCurrentEventData.fBlockCnt ); return &fpInputBlocks[index]; } @@ -1027,6 +1126,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, AliHLTComponentEventDoneData*& edd ) { // see header file for function documentation + HLTLogKeyword(GetComponentID()); ALIHLTCOMPONENT_BASE_STOPWATCH(); int iResult=0; fCurrentEvent=evtData.fEventID; @@ -1039,44 +1139,89 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, fOutputBufferFilled=0; fOutputBlocks.clear(); + bool bSkipDataProcessing=false; // find special events if (fpInputBlocks) { + // first look for all special events and execute in the appropriate + // sequence afterwords + AliHLTUInt32_t eventType=gkAliEventTypeUnknown; + int indexComConfEvent=-1; + int indexUpdtDCSEvent=-1; + int indexSOREvent=-1; + int indexEOREvent=-1; for (unsigned int i=0; i=0; i++) { if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) { - // start of run - if (fpRunDesc==NULL) { - fpRunDesc=new AliHLTRunDesc; - if (fpRunDesc) { - if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) { - HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo); - } - } else { - iResult=-ENOMEM; + indexSOREvent=i; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) { + indexEOREvent=i; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) { + // DDL list + // this event is most likely deprecated + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) { + indexComConfEvent=i; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeUpdtDCS) { + indexUpdtDCSEvent=i; + } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) { + eventType=fpInputBlocks[i].fSpecification; + bSkipDataProcessing|=(fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration); + bSkipDataProcessing|=(fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor); + } + } + if (indexSOREvent>=0) { + // start of run + if (fpRunDesc==NULL) { + fpRunDesc=new AliHLTRunDesc; + if (fpRunDesc) { + if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) { + HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo); + SetCDBRunNo(fpRunDesc->fRunNo); } } else { - HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo); + iResult=-ENOMEM; } - } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) { - if (fpRunDesc!=NULL) { - if (fpRunDesc) { - AliHLTRunDesc rundesc; - if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) { - if (fpRunDesc->fRunNo!=rundesc.fRunNo) { - HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo); - } else { - HLTDebug("EOR run no %d", fpRunDesc->fRunNo); - } + } else { + HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo); + } + } + if (indexEOREvent>=0) { + if (fpRunDesc!=NULL) { + if (fpRunDesc) { + AliHLTRunDesc rundesc; + if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexEOREvent, "AliHLTRunDesc", "SOR"))>0) { + if (fpRunDesc->fRunNo!=rundesc.fRunNo) { + HLTWarning("run no mismatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo); + } else { + HLTDebug("EOR run no %d", fpRunDesc->fRunNo); } - AliHLTRunDesc* pRunDesc=fpRunDesc; - fpRunDesc=NULL; - delete pRunDesc; } - } else { - HLTWarning("did not receive SOR, ignoring EOR"); + AliHLTRunDesc* pRunDesc=fpRunDesc; + fpRunDesc=NULL; + delete pRunDesc; } - // end of run - } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) { - // DDL list + } else { + HLTWarning("did not receive SOR, ignoring EOR"); + } + } + if (indexComConfEvent>=0 || eventType==gkAliEventTypeConfiguration) { + TString cdbEntry; + if (indexComConfEvent>=0 && fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) { + cdbEntry.Append(reinterpret_cast(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize); + } + HLTDebug("received component configuration command: entry %s", cdbEntry.IsNull()?"none":cdbEntry.Data()); + int tmpResult=Reconfigure(cdbEntry[0]==0?NULL:cdbEntry.Data(), fChainId.c_str()); + if (tmpResult<0) { + HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult); + } + } + if (indexUpdtDCSEvent>=0 || eventType==gkAliEventTypeReadPreprocessor) { + TString modules; + if (fpInputBlocks[indexUpdtDCSEvent].fPtr!=NULL && fpInputBlocks[indexUpdtDCSEvent].fSize>0) { + modules.Append(reinterpret_cast(fpInputBlocks[indexUpdtDCSEvent].fPtr), fpInputBlocks[indexUpdtDCSEvent].fSize); + } + HLTDebug("received preprocessor update command: detectors %s", modules.IsNull()?"ALL":modules.Data()); + int tmpResult=ReadPreprocessorValues(modules[0]==0?"ALL":modules.Data()); + if (tmpResult<0) { + HLTWarning("preprocessor update of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult); } } } @@ -1086,7 +1231,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, ALIHLTCOMPONENT_DA_STOPWATCH(); iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd); } // end of the scope of the stopwatch guard - if (iResult>=0) { + if (iResult>=0 && !bSkipDataProcessing) { if (fOutputBlocks.size()>0) { //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size()); @@ -1120,12 +1265,12 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this); } } - if (iResult<0) { + if (iResult<0 || bSkipDataProcessing) { outputBlockCnt=0; outputBlocks=NULL; } CleanupInputObjects(); - if (iResult>=0) { + if (iResult>=0 && !bSkipDataProcessing) { IncrementEventCounter(); } return iResult; @@ -1266,11 +1411,11 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) { AliHLTUInt32_t copy=*((AliHLTUInt32_t*)fpInputBlocks[iBlockNo].fPtr); if (fpInputBlocks[iBlockNo].fSize!=copy) { - HLTWarning("%s event: missmatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy); + HLTWarning("%s event: mismatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy); if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize; } if (copy!=iStructSize) { - HLTWarning("%s event: missmatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION); + HLTWarning("%s event: mismatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION); if (copy>iStructSize) { copy=iStructSize; } else {