}
element++;
}
+ if (fpRunDesc) {
+ delete fpRunDesc;
+ fpRunDesc=NULL;
+ }
}
AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
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::DoInit( int /*argc*/, const char** /*argv*/)
{
// default implementation, childs can overload
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
outputBlockCnt=0;
outputBlocks=NULL;
- bool bSkipDataProcessing=false;
+ // 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;
for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) {
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
indexUpdtDCSEvent=i;
} else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) {
eventType=fpInputBlocks[i].fSpecification;
- bSkipDataProcessing|=(fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration);
- bSkipDataProcessing|=(fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor);
+ if (fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration) bSkipDataProcessing|=skipModeForce;
+ if (fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor) bSkipDataProcessing|=skipModeForce;
+ } 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 (indexSOREvent>=0) {
// start of run
if (fpRunDesc==NULL) {
fpRunDesc=new AliHLTRunDesc;
- if (fpRunDesc) {
- if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) {
+ }
+ 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;
}
} else {
- HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
+ iResult=-ENOMEM;
}
}
if (indexEOREvent>=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;
}
AliHLTComponentBlockDataList blockData;
+ if (iResult>=0 && !bSkipDataProcessing)
{ // dont delete, sets the scope for the stopwatch guard
// do not use ALIHLTCOMPONENT_DA_STOPWATCH(); macro
// in order to avoid 'shadowed variable' warning
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;
}
//-*- Mode: C++ -*-
-// @(#) $Id$
+// $Id$
#ifndef ALIHLTCOMPONENT_H
#define ALIHLTCOMPONENT_H
-/* This file is property of and copyright by the ALICE HLT Project *
- * ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice */
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* See cxx source for full Copyright notice *
/** @file AliHLTComponent.h
@author Matthias Richter, Timm Steinbeck
@brief Base class declaration for HLT components.
@note The class is both used in Online (PubSub) and Offline (AliRoot)
context
+*/
-// see below for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
- */
/**
* @defgroup alihlt_component Component handling of the HLT module
- * This section describes the the component handling for the HLT module.
+ * This section describes the the component base classes and handling for
+ * the HLT module.
+ *
+ * @section alihlt_component_intro General remarks
+ * HLT analysis is organized in so called components. Each component can
+ * subscribe to the data produced by other components and can from the
+ * analysis publish new data for the subsequent components. Only the
+ * input data blocks and entries from CDB are available for the analysis.
+ *
+ * @section alihlt_component_intro Component implementation
+ * AliHLTComponent provides the interface for all components, see there
+ * for details. Three types are provided:
+ * - AliHLTProcessor
+ * - AliHLTDataSource
+ * - AliHLTDataSink
+ *
+ * The two last represent data sinks and sources for the HLT integration
+ * into AliRoot. When running only, only the processors are relevant,
+ * sources and sinks are provided by the HLT PubSub framework. Please check
+ * AliHLTComponent for detailed description.
+ *
+ * @section alihlt_component_registration Component registration
+ * Components need to be registered with the AliHLTComponentHandler in
+ * order to be used with the system. Registration is purely done from the
+ * module library. Two methods are possible:
+ * - the module library implements an AliHLTModuleAgent and overloads the
+ * AliHLTModuleAgent::RegisterComponents() function
+ * - in the implementation file, one object is defined. The global object is
+ * automatically instantiated when the library is loaded for the first
+ * time and the object is used for registration.
+ *
+ * In both cases, the library must be loaded via the method
+ * <pre>
+ * AliHLTComponentHandler::LoadComponentLibraries()
+ * </pre>
+ * For the global object approach it is important that the library is
+ * not loaded elsewhere before (e.g. a gSystem->Load operation in your
+ * rootlogon.C).
+ *
+ *
*/
#include <vector>
* The function must not be called when running in AliRoot unless it it
* really wanted. The CDB path will be set to the specified path, which might
* override the run no initialized at the beginning of the AliRoot reconstruction.
+ * InitCDB() has to be called before in order to really change the CDB settings.
*
* The method is used from the external interface in order to set the correct
* path when running on-line.
*/
int SetCDBRunNo(int runNo);
+ /**
+ * Set the run description.
+ * The run description is set before the call of Init() -> DoInit().
+ * @note: This functionality has been added in Juli 2008. The transmission of
+ * run properties by a special SOR (SOD event in DAQ terminalogy but this was
+ * changed after the HLT interface was designed) event is not sufficient because
+ * the data might be needed already in the DoInit handler of the component.
+ * @param desc run descriptor, currently only the run no member is used
+ * @param runType originally, run type was supposed to be a number and part
+ * of the run descriptor. But it was defined as string later
+ */
+ int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
+
// Information member functions for registration.
/**
*/
virtual int ReadPreprocessorValues(const char* modules);
+ /**
+ * Custom handler for the SOR event.
+ * Is invoked from the base class if an SOR event is in the block list.
+ * The handler is called before the processing function. The processing
+ * function is skipped if there are no other data blocks available.
+ *
+ * The SOR event is generated by the PubSub framework in response to
+ * the DAQ start of data (SOD - has been renamed after HLT interface
+ * was designed). The SOD event consists of 3 blocks:
+ * - ::kAliHLTDataTypeEvent block: spec ::gkAliEventTypeStartOfRun
+ * - SOD block of type ::kAliHLTDataTypeSOR, payload: AliHLTRunDesc struct
+ * - run type block ::kAliHLTDataTypeRunType, payload: run type string
+ *
+ * Run properties can be retrieved by getters like GetRunNo().
+ * @return neg. error code if failed
+ */
+ virtual int StartOfRun();
+
+ /**
+ * Custom handler for the EOR event.
+ * Is invoked from the base class if an EOR event is in the block list.
+ * The handler is called before the processing function. The processing
+ * function is skipped if there are no other data blocks available.
+ *
+ * See StartOfRun() for mor ecomments of the sequence of steering events.
+ *
+ * @return neg. error code if failed
+ */
+ virtual int EndOfRun();
+
/**
* General memory allocation method.
* All memory which is going to be used 'outside' of the interface must
fLibraryList(),
fEnvironment(),
fOwnedComponents(),
- fLibraryMode(kDynamic)
+ fLibraryMode(kDynamic),
+ fRunDesc(kAliHLTVoidRunDesc),
+ fRunType(NULL)
{
// see header file for class documentation
// or
fLibraryList(),
fEnvironment(),
fOwnedComponents(),
- fLibraryMode(kDynamic)
+ fLibraryMode(kDynamic),
+ fRunDesc(kAliHLTVoidRunDesc),
+ fRunType(NULL)
{
// see header file for class documentation
if (pEnv) {
// see header file for class documentation
DeleteOwnedComponents();
UnloadLibraries();
+ if (fRunType) delete [] fRunType;
+ fRunType=NULL;
}
AliHLTComponentHandler* AliHLTComponentHandler::fgpInstance=NULL;
component=pSample->Spawn();
if (component) {
HLTDebug("component \"%s\" created (%p)", componentID, component);
- component->InitCDB(cdbPath, this);
+ if (cdbPath && cdbPath[0]!=0) {
+ component->InitCDB(cdbPath, this);
+ component->SetRunDescription(&fRunDesc, fRunType);
+ }
if ((iResult=component->Init(&fEnvironment, pEnvParam, argc, argv))!=0) {
HLTError("Initialization of component \"%s\" failed with error %d", componentID, iResult);
delete component;
}
return iResult;
}
+
+int AliHLTComponentHandler::SetRunDescription(const AliHLTRunDesc* desc, const char* runType)
+{
+ // see header file for class documentation
+ if (!desc) return -EINVAL;
+ if (desc->fStructSize!=sizeof(AliHLTRunDesc)) {
+ HLTError("invalid size of RunDesc struct (%ul)", desc->fStructSize);
+ return -EINVAL;
+ }
+
+ memcpy(&fRunDesc, desc, sizeof(AliHLTRunDesc));
+ if (runType) {
+ if (fRunType) delete [] fRunType;
+ fRunType=new char[sizeof(runType)+1];
+ if (fRunType) {
+ strcpy(fRunType, runType);
+ }
+ }
+ return 0;
+}
return CreateComponent( componentID, pEnvParam, 0, NULL, component );
}
+ /**
+ * Set the run description.
+ * The run description is set globally for all components. Each component
+ * is initialized from the global run description after creation and before
+ * call of AliHLTComponent::Init().
+ *
+ * @param desc run descriptor, currently only the run no member is used
+ * @param runType originally, run type was supposed to be a number and part
+ * of the run descriptor. But it was defined as string later
+ */
+ int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
+
/**
* Check if a registered component has output data, e.g. is of type
* kSource or kProcessor (see @ref AliHLTComponent::TComponentType).
/** library mode effects all loaded libraries until a new mode is set */
TLibraryMode fLibraryMode; // see above
+ /** run descriptor */
+ AliHLTRunDesc fRunDesc; //!transient
+ /** run type string */
+ char* fRunType; //!transient
+
/** the global singleton */
static AliHLTComponentHandler* fgpInstance; //!transient
/** number of used instances of the global singleton */
static int fgNofInstances; //!transient
- ClassDef(AliHLTComponentHandler, 1);
+ ClassDef(AliHLTComponentHandler, 2);
};
#endif
kAliHLTDataOriginAny
}|kAliHLTDataOriginPrivate;
+/** run type data block */
+const AliHLTComponentDataType kAliHLTDataTypeRunType = (AliHLTComponentDataType) {
+ sizeof(AliHLTComponentDataType),
+ kAliHLTRunTypeDataTypeID,
+ kAliHLTDataOriginAny
+}|kAliHLTDataOriginPrivate;
+
/** Event type specification */
const AliHLTComponentDataType kAliHLTDataTypeEvent = (AliHLTComponentDataType) {
sizeof(AliHLTComponentDataType),
* 6 Common data types for TreeD and TreeR defined
* kAliHLTAllDataTypes and kAliHLTDataOriginSample added
* kAliHLTDataOriginEMCAL added
+ * kAliHLTDataTypeRunType added
*/
#define ALIHLT_DATA_TYPES_VERSION 6
*/
# define kAliHLTEORDataTypeID {'E','N','D','O','F','R','U','N'}
+/** run type data block
+ * string with run type as payload
+ * @ingroup alihlt_component_datatypes
+ */
+# define kAliHLTRunTypeDataTypeID {'R','U','N','T','Y','P','E',' '}
+
/** DDL list event
* @ref AliHLTEventDDL
* @ingroup alihlt_component_datatypes
/**
* @struct AliHLTRunDesc
* Event descriptor.
- * The struct is send with the SOR and EOR events.
+ * The struct is sent with the SOR and EOR events.
+ *
+ * @note
+ * Originally, run type was supposed to be a number and part
+ * of the run descriptor. But it was defined as string later.
+ * The string is passed as argument of the AliHLT_C_SetRunDescription
+ * interface function.
*/
struct AliHLTRunDesc
{
*/
const AliHLTUInt32_t kAliHLTVoidDataSpec = ~(AliHLTUInt32_t)0;
+ /** invalid run no
+ * @ingroup alihlt_component_datatypes
+ */
+ const AliHLTUInt32_t kAliHLTVoidRunNo = ~(AliHLTUInt32_t)0;
+
+ /** invalid run type
+ * @ingroup alihlt_component_datatypes
+ */
+ const AliHLTUInt32_t kAliHLTVoidRunType = ~(AliHLTUInt32_t)0;
+
+ /** invalid run descriptor
+ * @ingroup alihlt_component_datatypes
+ */
+ const AliHLTRunDesc kAliHLTVoidRunDesc={sizeof(AliHLTRunDesc), kAliHLTVoidRunNo, kAliHLTVoidRunType};
+
/** invalid shared memory type */
const AliHLTUInt32_t gkAliHLTComponentInvalidShmType = 0;
*/
extern const AliHLTComponentDataType kAliHLTDataTypeEOR;
+ /** Run type data block
+ * @ingroup alihlt_component_datatypes
+ */
+ extern const AliHLTComponentDataType kAliHLTDataTypeRunType;
+
/** Event type specification
* @ingroup alihlt_component_datatypes
*/
static AliHLTComponentHandler *gComponentHandler_C = NULL;
-
int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* comenv )
{
if ( gComponentHandler_C )
delete pComp;
}
+int AliHLT_C_SetRunDescription(const AliHLTRunDesc* desc, const char* runType)
+{
+ if (!desc) return -EINVAL;
+ if (desc->fStructSize<sizeof(AliHLTUInt32_t)) return -EINVAL;
+ if (!gComponentHandler_C) return ENXIO;
+
+ AliHLTRunDesc internalDesc=kAliHLTVoidRunDesc;
+ memcpy(&internalDesc, desc, desc->fStructSize<sizeof(internalDesc)?desc->fStructSize:sizeof(internalDesc));
+ return gComponentHandler_C->SetRunDescription(&internalDesc, runType);
+}
+
int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponentEventData* evtData, const AliHLTComponentBlockData* blocks,
AliHLTComponentTriggerData* trigData, AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
*/
void AliHLT_C_DestroyComponent( AliHLTComponentHandle );
+/**
+ *
+ * @ingroup alihlt_wrapper_interface
+ */
+int AliHLT_C_SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
+
/**
*
* @ingroup alihlt_wrapper_interface