// $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> *
- * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
- * 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> *
+//* Timm Steinbeck <timm@kip.uni-heidelberg.de> *
+//* 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
#include "AliHLTComponentHandler.h"
#include "AliHLTMessage.h"
#include "TString.h"
+#include "TMath.h"
#include "TObjArray.h"
#include "TObjectTable.h"
#include "TClass.h"
#include "TStopwatch.h"
#include "AliHLTMemoryFile.h"
+#include "AliHLTMisc.h"
#include <cassert>
/** ROOT macro for the implementation of ROOT specific class methods */
fpStopwatches(new TObjArray(kSWTypeCount)),
fMemFiles(),
fpRunDesc(NULL),
- fpDDLList(NULL)
-
+ fpDDLList(NULL),
+ fCDBSetRunNoFunc(false),
+ fChainId(),
+ fpBenchmark(NULL),
+ fRequireSteeringBlocks(false)
{
// see header file for class documentation
// or
// refer to README to build package
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
- memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
+ memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
if (fgpComponentHandler)
fgpComponentHandler->ScheduleRegister(this);
//SetLocalLoggingLevel(kHLTLogDefault);
AliHLTComponent::~AliHLTComponent()
{
// see header file for function documentation
+ if (fpBenchmark) delete fpBenchmark;
+ fpBenchmark=NULL;
+
CleanupInputObjects();
if (fpStopwatches!=NULL) delete fpStopwatches;
fpStopwatches=NULL;
}
element++;
}
+ if (fpRunDesc) {
+ delete fpRunDesc;
+ fpRunDesc=NULL;
+ }
}
AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
return SetGlobalComponentHandler(NULL,1);
}
-int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv )
+int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, 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));
+ if (comenv) {
+ memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
+ memcpy(&fEnvironment, comenv, comenv->fStructSize<sizeof(AliHLTAnalysisEnvironment)?comenv->fStructSize:sizeof(AliHLTAnalysisEnvironment));
+ fEnvironment.fStructSize=sizeof(AliHLTAnalysisEnvironment);
fEnvironment.fParam=environParam;
}
const char** pArguments=NULL;
if (iResult>=0) {
iResult=DoInit(iNofChildArgs, pArguments);
}
- if (iResult>=0) fEventCount=0;
+ if (iResult>=0) {
+ fEventCount=0;
+
+ // find out if the component wants to get the steering events
+ // explicitly
+ AliHLTComponentDataTypeList inputDt;
+ GetInputDataTypes(inputDt);
+ for (AliHLTComponentDataTypeList::iterator dt=inputDt.begin();
+ dt!=inputDt.end() && !fRequireSteeringBlocks;
+ dt++) {
+ fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeSOR);
+ fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeRunType);
+ fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeEOR);
+ fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeDDL);
+ fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeComponentStatistics);
+ }
+ }
if (pArguments) delete [] pArguments;
+
+#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
+ // benchmarking stopwatch for the component statistics
+ fpBenchmark=new TStopwatch;
+ if (fpBenchmark) {
+ fpBenchmark->Start();
+ }
+#endif
+
return iResult;
}
int AliHLTComponent::Deinit()
{
// see header file for function documentation
+ HLTLogKeyword(GetComponentID());
int iResult=0;
iResult=DoDeinit();
if (fpRunDesc) {
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::SetRunDescription(const AliHLTRunDesc* desc, const char* /*runType*/)
+{
+ // see header file for function documentation
+ if (!desc) return -EINVAL;
+ if (desc->fStructSize!=sizeof(AliHLTRunDesc)) {
+ HLTError("invalid size of RunDesc struct (%ul)", desc->fStructSize);
+ return -EINVAL;
+ }
+
+ if (!fpRunDesc) {
+ fpRunDesc=new AliHLTRunDesc;
+ if (!fpRunDesc) return -ENOMEM;
+ *fpRunDesc=kAliHLTVoidRunDesc;
+ }
+
+ if (fpRunDesc->fRunNo!=kAliHLTVoidRunNo && fpRunDesc->fRunNo!=desc->fRunNo) {
+ HLTWarning("Run description has already been set");
+ }
+ *fpRunDesc=*desc;
+ SetCDBRunNo(fpRunDesc->fRunNo);
+ // TODO: we have to decide about the runType
+ return 0;
+}
+
+int AliHLTComponent::SetComponentDescription(const char* desc)
+{
+ // default implementation, childs can overload
+ int iResult=0;
+ if (!desc) return 0;
+
+ TString descriptor=desc;
+ TObjArray* pTokens=descriptor.Tokenize(" ");
+ if (pTokens) {
+ for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+ TString argument=((TObjString*)pTokens->At(i++))->GetString();
+ if (!argument || argument.IsNull()) continue;
+
+ // chainid
+ if (argument.BeginsWith("chainid")) {
+ argument.ReplaceAll("chainid", "");
+ if (argument.BeginsWith("=")) {
+ fChainId=argument.Replace(0,1,"");
+ } else {
+ fChainId="";
+ }
+ } else {
+ HLTWarning("unknown component discription %s", argument.Data());
+ }
+ }
+ }
+
+ return iResult;
+}
+
+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::StartOfRun()
+{
+ // default implementation, childs can overload
+ HLTLogKeyword("dummy");
+ return 0;
+}
+
+int AliHLTComponent::EndOfRun()
+{
+ // default implementation, childs can overload
+ HLTLogKeyword("dummy");
+ return 0;
+}
+
+
int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/)
{
+ // default implementation, childs can overload
HLTLogKeyword("dummy");
return 0;
}
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 ********:****.
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++;
}
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 )
}
}
+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
if (fpInputBlocks!=NULL) {
int idx=startIdx<0?0:startIdx;
for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
+ if (dt!=fpInputBlocks[idx].fDataType) continue;
+
if (bObject!=0) {
if (fpInputBlocks[idx].fPtr==NULL) continue;
AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
}
- if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt ||
- (memcmp(dt.fID, kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize)==0 &&
- memcmp(dt.fOrigin, fpInputBlocks[idx].fDataType.fOrigin, kAliHLTComponentDataTypefOriginSize)==0) ||
- (memcmp(dt.fID, fpInputBlocks[idx].fDataType.fID, kAliHLTComponentDataTypefIDsize)==0) &&
- memcmp(dt.fOrigin, kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize)==0) {
- iResult=idx;
- }
+ iResult=idx;
}
}
return iResult;
}
//} else {
} else if (bForce!=0) {
- HLTError("size missmatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
+ HLTError("size mismatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
}
} else {
HLTFatal("block descriptor empty");
return iSpec;
}
+int AliHLTComponent::Forward(const TObject* pObject)
+{
+ // see header file for function documentation
+ int iResult=0;
+ int idx=fCurrentInputBlock;
+ if (pObject) {
+ if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(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
return GetFirstInputBlock(dt);
}
-const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index)
+const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index) const
{
// 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];
}
AliHLTComponentEventDoneData*& edd )
{
// see header file for function documentation
+ HLTLogKeyword(GetComponentID());
ALIHLTCOMPONENT_BASE_STOPWATCH();
int iResult=0;
fCurrentEvent=evtData.fEventID;
fOutputBufferSize=size;
fOutputBufferFilled=0;
fOutputBlocks.clear();
+ outputBlockCnt=0;
+ outputBlocks=NULL;
+ AliHLTComponentStatisticsList compStats;
+#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
+ AliHLTComponentStatistics outputStat;
+ memset(&outputStat, 0, sizeof(AliHLTComponentStatistics));
+ compStats.push_back(outputStat);
+ if (fpBenchmark) {
+ fpBenchmark->Reset();
+ fpBenchmark->Start();
+ }
+#endif
+
+ // data processing is skipped if there are only steering events
+ // in the block list. It is not skipped if there is no block list
+ // at all for the sake of data source components. Data processing
+ // is always skipped if the event is of type
+ // - gkAliEventTypeConfiguration
+ // - gkAliEventTypeReadPreprocessor
+ const unsigned int skipModeDefault=0x1;
+ const unsigned int skipModeForce=0x2;
+ unsigned int bSkipDataProcessing=skipModeDefault;
// find special events
- if (fpInputBlocks) {
+ if (fpInputBlocks && evtData.fBlockCnt>0) {
+ // 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<evtData.fBlockCnt && iResult>=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);
+ indexSOREvent=i;
+ // the AliHLTCalibrationProcessor relies on the SOR and EOR events
+ bSkipDataProcessing&=~skipModeDefault;
+ } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeRunType) {
+ // run type string
+ // handling is not clear yet
+ if (fpInputBlocks[i].fPtr) {
+ HLTDebug("got run type \"%s\"\n", fpInputBlocks[i].fPtr);
+ }
+ } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
+ indexEOREvent=i;
+ // the calibration processor relies on the SOR and EOR events
+ bSkipDataProcessing&=~skipModeDefault;
+ } 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;
+ if (fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration) bSkipDataProcessing|=skipModeForce;
+ if (fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor) bSkipDataProcessing|=skipModeForce;
+ } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentStatistics) {
+ if (compStats.size()>0) {
+ AliHLTUInt8_t* pData=reinterpret_cast<AliHLTUInt8_t*>(fpInputBlocks[i].fPtr);
+ for (AliHLTUInt32_t offset=0;
+ offset+sizeof(AliHLTComponentStatistics)<=fpInputBlocks[i].fSize;
+ offset+=sizeof(AliHLTComponentStatistics)) {
+ AliHLTComponentStatistics* pStat=reinterpret_cast<AliHLTComponentStatistics*>(pData+offset);
+ if (pStat && compStats[0].fLevel<=pStat->fLevel) {
+ compStats[0].fLevel=pStat->fLevel+1;
}
- } else {
- iResult=-ENOMEM;
+ compStats.push_back(*pStat);
}
- } else {
- HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
}
- } 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 {
+ // the processing function is called if there is at least one
+ // non-steering data block. Steering blocks are not filtered out
+ // for sake of performance
+ bSkipDataProcessing&=~skipModeDefault;
+ if (compStats.size()>0) {
+ compStats[0].fInputBlockCount++;
+ compStats[0].fTotalInputSize+=fpInputBlocks[i].fSize;
+ }
+ }
+ }
+
+ if (indexSOREvent>=0) {
+ // start of run
+ if (fpRunDesc==NULL) {
+ fpRunDesc=new AliHLTRunDesc;
+ }
+ if (fpRunDesc) {
+ AliHLTRunDesc rundesc;
+ if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) {
+ if (fpRunDesc->fRunNo==kAliHLTVoidRunNo) {
+ *fpRunDesc=rundesc;
+ HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
+ SetCDBRunNo(fpRunDesc->fRunNo);
+ } else if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
+ HLTWarning("already set run properties run no %d, ignoring SOR with run no %d", fpRunDesc->fRunNo, rundesc.fRunNo);
+ }
+ }
+ } else {
+ iResult=-ENOMEM;
+ }
+ }
+ 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<const char*>(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<const char*>(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);
}
}
+ } else {
+ // processing function needs to be called if there are no input data
+ // blocks in order to make data source components working.
+ bSkipDataProcessing&=~skipModeDefault;
}
-
+
+ // data processing is not skipped if the component explicitly asks
+ // for the private blocks
+ if (fRequireSteeringBlocks) bSkipDataProcessing=0;
+
AliHLTComponentBlockDataList blockData;
+ if (iResult>=0 && !bSkipDataProcessing)
{ // dont delete, sets the scope for the stopwatch guard
- ALIHLTCOMPONENT_DA_STOPWATCH();
+ // do not use ALIHLTCOMPONENT_DA_STOPWATCH(); macro
+ // in order to avoid 'shadowed variable' warning
+ AliHLTStopwatchGuard swguard2(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)kSWDA)):NULL);
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());
-
+ // High Level interface
+
+ //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
// sync memory files and descriptors
AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
int i=0;
HLTError("low level and high interface must not be mixed; use PushBack methods to insert data blocks");
iResult=-EFAULT;
} else {
+ if (compStats.size()>0) {
+ int offset=AddComponentStatistics(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, compStats);
+ if (offset>0) fOutputBufferFilled+=offset;
+ }
iResult=MakeOutputDataBlockList(fOutputBlocks, &outputBlockCnt, &outputBlocks);
size=fOutputBufferFilled;
}
}
} else {
+ // Low Level interface
+ if (compStats.size()>0) {
+ int offset=AddComponentStatistics(blockData, fpOutputBuffer, fOutputBufferSize, size, compStats);
+ if (offset>0) size+=offset;
+ }
iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
}
if (iResult<0) {
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();
}
+ if (outputBlockCnt==0) {
+ // no output blocks, set size to 0
+ size=0;
+ }
+ return iResult;
+}
+
+int AliHLTComponent::AddComponentStatistics(AliHLTComponentBlockDataList& blocks,
+ AliHLTUInt8_t* buffer,
+ AliHLTUInt32_t bufferSize,
+ AliHLTUInt32_t offset,
+ AliHLTComponentStatisticsList& stats) const
+{
+ // see header file for function documentation
+ int iResult=0;
+ if (stats.size()==0) return -ENOENT;
+ stats[0].fTotalOutputSize=offset;
+ stats[0].fOutputBlockCount=blocks.size();
+ if (fpBenchmark) {
+ stats[0].fTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*1000000);
+ stats[0].fCTime=(AliHLTUInt32_t)(fpBenchmark->CpuTime()*1000000);
+ }
+ if (offset+stats.size()*sizeof(AliHLTComponentStatistics)<=bufferSize) {
+ AliHLTComponentBlockData bd;
+ FillBlockData( bd );
+ bd.fOffset = offset;
+ bd.fSize = stats.size()*sizeof(AliHLTComponentStatistics);
+ bd.fDataType = kAliHLTDataTypeComponentStatistics;
+ bd.fSpecification = kAliHLTVoidDataSpec;
+ unsigned int master=0;
+ for (unsigned int i=1; i<blocks.size(); i++) {
+ if (blocks[i].fSize>blocks[master].fSize &&
+ !MatchExactly(blocks[i].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate))
+ master=i;
+ }
+ if (blocks.size()>0 && !MatchExactly(blocks[master].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate)) {
+ // take the data origin of the biggest block as specification
+ // this is similar to the treatment in the HOMER interface. For traditional
+ // reasons, the bytes are swapped there on a little endian architecture, so
+ // we do it as well.
+ memcpy(&bd.fSpecification, &blocks[master].fDataType.fOrigin, sizeof(bd.fSpecification));
+#ifdef R__BYTESWAP // set on little endian architectures
+ bd.fSpecification=((bd.fSpecification & 0xFFULL) << 24) |
+ ((bd.fSpecification & 0xFF00ULL) << 8) |
+ ((bd.fSpecification & 0xFF0000ULL) >> 8) |
+ ((bd.fSpecification & 0xFF000000ULL) >> 24);
+#endif
+ }
+ memcpy(buffer+offset, &(stats[0]), bd.fSize);
+ blocks.push_back(bd);
+ iResult=bd.fSize;
+ }
return iResult;
}
AliHLTUInt32_t AliHLTComponent::GetRunNo() const
{
// see header file for function documentation
- if (fpRunDesc==NULL) return 0;
+ if (fpRunDesc==NULL) return kAliHLTVoidRunNo;
return fpRunDesc->fRunNo;
}
AliHLTUInt32_t AliHLTComponent::GetRunType() const
{
// see header file for function documentation
- if (fpRunDesc==NULL) return 0;
+ if (fpRunDesc==NULL) return kAliHLTVoidRunType;
return fpRunDesc->fRunType;
}
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 {
}
return iResult;
}
+
+void AliHLTComponent::SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const
+{
+ // see header file for function documentation
+
+ // -- Detector offset
+ Int_t ddlIdBase = TMath::FloorNint( (Double_t) ddlId / 256.0 );
+
+ // -- Word Base = 1. word of detector ( TPC has 8 words, TOF 3 )
+ Int_t wordBase = 0;
+
+ if ( ddlIdBase <= 3 )
+ wordBase = ddlIdBase;
+ else if ( ddlIdBase > 3 && ddlIdBase < 5 )
+ wordBase = ddlIdBase + 7;
+ else
+ wordBase = ddlIdBase + 9;
+
+ // -- Bit index in Word
+ Int_t bitIdx = ddlId % 32;
+
+ // -- Index of word
+ Int_t wordIdx = wordBase;
+
+ // -- if TPC (3) or TOD (5) add word idx
+ if ( ( ddlIdBase == 3 ) || ( ddlIdBase == 5 ) ) {
+ wordIdx += TMath::FloorNint( (Double_t) ( ddlId - ( ddlIdBase * 256 ) ) / 32.0 );
+ }
+
+ // -- Set -- 'OR' word with bit mask;
+ if ( state )
+ list.fList[wordIdx] |= ( 0x00000001 << bitIdx );
+ // -- Unset -- 'AND' word with bit mask;
+ else
+ list.fList[wordIdx] &= ( 0xFFFFFFFF ^ ( 0x00000001 << bitIdx ) );
+}
+
+Int_t AliHLTComponent::GetFirstUsedDDLWord(AliHLTEventDDL &list) const
+{
+ // see header file for function documentation
+
+ Int_t iResult = -1;
+
+ for ( Int_t wordNdx = 0 ; wordNdx < gkAliHLTDDLListSize ; wordNdx++ ) {
+
+ if ( list.fList[wordNdx] != 0 && iResult == -1 ) {
+ // check for special cases TPC and TOF
+ if ( wordNdx > 3 && wordNdx <= 10 ) {
+ wordNdx = 10;
+ iResult = 3;
+ }
+ else if ( wordNdx > 12 && wordNdx <= 14 ) {
+ wordNdx = 14;
+ iResult = 12;
+ }
+ else
+ iResult = wordNdx;
+ }
+ else if ( list.fList[wordNdx] != 0 && iResult >= 0 ) {
+ HLTError( "DDLIDs for minimum of TWO detectors ( %d, %d ) set, this function works only for ONE detector.", iResult, wordNdx );
+ iResult = -1;
+ break;
+ }
+ }
+
+ return iResult;
+}