#include <string>
#include "AliHLTLogging.h"
#include "AliHLTDataTypes.h"
-//#include "AliHLTDefinitions.h"
+#include "AliHLTCommonCDBEntries.h"
/* Matthias Dec 2006
* The names have been changed for Aliroot's coding conventions sake
class AliHLTComponentHandler;
class TObjArray;
class TStopwatch;
+class AliHLTComponent;
class AliHLTMemoryFile;
+/** list of component data type structures */
+typedef vector<AliHLTComponentDataType> AliHLTComponentDataTypeList;
+/** list of component block data structures */
+typedef vector<AliHLTComponentBlockData> AliHLTComponentBlockDataList;
+/** list of component pointers */
+typedef vector<AliHLTComponent*> AliHLTComponentPList;
+/** list of memory file pointers */
+typedef vector<AliHLTMemoryFile*> AliHLTMemoryFilePList;
+
/**
* @class AliHLTComponent
* Base class of HLT data processing components.
* @subsection alihltcomponent-opt-mehods Optional handlers
* - @ref DoInit
* - @ref DoDeinit
+ * - @ref GetOutputDataTypes
+ * If the component has multiple output data types @ref GetOutputDataType
+ * should return @ref kAliHLTMultipleDataType. The framework will invoke
+ * @ref GetOutputDataTypes, a list can be filled.
*
* @subsection alihltcomponent-processing-mehods Data processing
*
* framework will allocate a buffer of appropriate size and call the processing
* again.
*
+ * @subsection alihltcomponent-error-codes Data processing
+ * For return codes, the following scheme applies:
+ * - The data processing methods have to indicate error conditions by a negative
+ * error/return code. Preferably the system error codes are used like
+ * e.g. -EINVAL. This requires to include the header
+ * <pre>
+ * \#include \<cerrno\>
+ * </pre>
+ * - If no suitable input block could be found (e.g. no clusters for the TPC cluster
+ * finder) set size to 0, block list is empty, return 0
+ * - If no ususable or significant signal could be found in the input blocks
+ * return an empty output block, set size accordingly, and return 0. An empty output
+ * block here could be either a real empty one of size 0 (in which case size also
+ * would have to be set to zero) or a block filled with just the minimum necessary
+ * accounting/meta-structures. E.g. in the TPC
+ *
* @subsection alihltcomponent-high-level-interface High-level interface
* The high-level component interface provides functionality to exchange ROOT
* structures between components. In contrast to the
virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t& size,
- vector<AliHLTComponentBlockData>& outputBlocks,
+ AliHLTComponentBlockDataList& outputBlocks,
AliHLTComponentEventDoneData*& edd ) = 0;
+ /**
+ * Init the CDB.
+ * 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 path initialized at the beginning of the AliRoot reconstruction.
+ *
+ * The method is used from the external interface in order to set the correct
+ * path when running on-line. The function also initializes the function
+ * callback for setting the run no during operation.
+ *
+ * A separation of library and component handling is maybe appropriate in the
+ * future. Using the global component handler here is maybe not the cleanest
+ * solution.
+ * @param cdbPath path of the CDB
+ * @param pHandler the component handler used for llibrary handling.
+ */
+ int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler);
+
+ /**
+ * Set the run no for the CDB.
+ * 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.
+ *
+ * The method is used from the external interface in order to set the correct
+ * path when running on-line.
+ */
+ int SetCDBRunNo(int runNo);
+
// Information member functions for registration.
/**
* The function is pure virtual and must be implemented by the child class.
* @return list of data types in the vector reference
*/
- virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& ) = 0;
+ virtual void GetInputDataTypes( AliHLTComponentDataTypeList& ) = 0;
/**
* Get the output data type of the component.
*/
virtual AliHLTComponentDataType GetOutputDataType() = 0;
+ /**
+ * Get the output data types of the component.
+ * The function can be implemented to indicate multiple output data types
+ * in the target array.
+ * @ref GetOutputDataType must return @ref kAliHLTMultipleDataType in order
+ * to invoke this method.
+ * @param tgtList list to receive the data types
+ * @return no of output data types, data types in the target list
+ */
+ virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+
/**
* Get a ratio by how much the data volume is shrinked or enhanced.
* The function is pure virtual and must be implemented by the child class.
* @param tgtList reference to a vector list to receive the matching data types.
* @return >= 0 success, neg. error code if failed
*/
- int FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList);
+ int FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList);
/**
* Set the global component handler.
/**
* Helper function to convert the data type to a string.
+ * @param type data type structure
+ * @param mode 0 print string origin:type <br>
+ * 1 print chars <br>
+ * 2 print numbers
*/
- static string DataType2Text( const AliHLTComponentDataType& type );
+ static string DataType2Text( const AliHLTComponentDataType& type, int mode=0);
/**
* Helper function to print content of data type.
*/
- void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL) const;
+ static void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL);
/**
* helper function to initialize AliHLTComponentEventData structure
* This is just a helper function to examine an @ref AliHLTComponentDataType
* structur.
*/
- void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt);
+ static void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt);
+
+ /**
+ * Fill AliHLTComponentBlockData structure with default values.
+ * @param blockData reference to data structure
+ */
+ static void FillBlockData( AliHLTComponentBlockData& blockData );
+
+ /**
+ * Fill AliHLTComponentShmData structure with default values.
+ * @param shmData reference to data structure
+ */
+ static void FillShmData( AliHLTComponentShmData& shmData );
+
+ /**
+ * Fill AliHLTComponentDataType structure with default values.
+ * @param dataType reference to data structure
+ */
+ static void FillDataType( AliHLTComponentDataType& dataType );
+
+ /**
+ * Copy data type structure
+ * Copies the value an AliHLTComponentDataType structure to another one
+ * @param[out] tgtdt target structure
+ * @param[in] srcdt source structure
+ */
+ static void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
+
+ /**
+ * Set the ID and Origin of an AliHLTComponentDataType structure.
+ * The function sets the fStructureSize member and copies the strings
+ * to the ID and Origin. Only characters from the valid part of the string
+ * are copied, the rest is filled with 0's. <br>
+ * Please note that the fID and fOrigin members are not strings, just arrays of
+ * chars of size @ref kAliHLTComponentDataTypefIDsize and
+ * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
+ * a terminating zero. <br>
+ * It is possible to pass NULL pointers as id or origin argument, in that case they
+ * are just ignored.
+ * @param tgtdt target data type structure
+ * @param id ID string
+ * @param origin Origin string
+ */
+ static void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
+
+ /**
+ * Set the ID and Origin of an AliHLTComponentDataType structure.
+ * Given the fact that the data type ID is 64bit wide and origin 32, this helper
+ * function sets the data type from those two parameters.
+ * @param dt target data type structure
+ * @param id 64bit id
+ * @param orig 32bit origin
+ */
+ static void SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t orig);
/**
* Stopwatch type for benchmarking.
protected:
- /**
- * Fill AliHLTComponentBlockData structure with default values.
- * @param blockData reference to data structure
- */
- void FillBlockData( AliHLTComponentBlockData& blockData ) const;
-
- /**
- * Fill AliHLTComponentShmData structure with default values.
- * @param shmData reference to data structure
- */
- void FillShmData( AliHLTComponentShmData& shmData ) const;
-
- /**
- * Fill AliHLTComponentDataType structure with default values.
- * @param dataType reference to data structure
- */
- void FillDataType( AliHLTComponentDataType& dataType ) const;
-
- /**
- * Copy data type structure
- * Copies the value an AliHLTComponentDataType structure to another one
- * @param[out] tgtdt target structure
- * @param[in] srcdt source structure
- */
- void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
-
- /**
- * Set the ID and Origin of an AliHLTComponentDataType structure.
- * The function sets the fStructureSize member and copies the strings
- * to the ID and Origin. Only characters from the valid part of the string
- * are copied, the rest is fille with 0's.
- * Please note that the fID and fOrigin members are not strings, just arrays of
- * chars of size @ref kAliHLTComponentDataTypefIDsize and
- * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
- * a terminating zero.
- * @param tgtdt target data type structure
- * @param id ID string
- * @param origin Origin string
- */
- void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
-
/**
* Default method for the internal initialization.
* The method is called by @ref Init
*/
virtual int DoDeinit();
+ /**
+ * Reconfigure the component.
+ * The method is called when an event of type @ref kAliHLTDataTypeComConf
+ * {COM_CONF:PRIV} is received by the component. If the event is sent as
+ * part of a normal event, the component configuration is called first.
+ *
+ * The CDB path parameter specifies the path in the CDB, i.e. without
+ * leading absolute path of the CDB location. The framework might alse
+ * provide the id of the component in the analysis chain.
+ *
+ * \b Note: The CDB will be initialized by the framework, either already set
+ * from AliRoot or from the wrapper interface during initialization.
+ *
+ * @param cdbEntry path of the cdbEntry
+ * @param chainId the id of the component in the analysis chain
+ * @note both parameters can be NULL, check before usage
+ */
+ virtual int Reconfigure(const char* cdbEntry, const char* chainId);
+
+ /**
+ * Read the Preprocessor values.
+ * The function is invoked when the component is notified about available/
+ * updated data points from the detector Preprocessors. The 'modules'
+ * argument contains all detectors for which the Preprocessors have
+ * updated data points. The component has to implement the CDB access to
+ * get the desired data points.
+ * @param modules detectors for which the Preprocessors have updated
+ * data points: TPC, TRD, ITS, PHOS, MUON, or ALL if
+ * no argument was received.
+ * @return neg. error code if failed
+ */
+ virtual int ReadPreprocessorValues(const char* modules);
+
/**
* General memory allocation method.
* All memory which is going to be used 'outside' of the interface must
* framework. Function pointers are transferred via the @ref
* AliHLTComponentEnvironment structure.
*/
- int MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
+ int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
AliHLTComponentBlockData** outputBlocks );
/**
* Get the first object of a specific data type from the input data.
* The hight-level methods provide functionality to transfer ROOT data
* structures which inherit from TObject.
+ *
* The method looks for the first ROOT object of type dt in the input stream.
* If also the class name is provided, the object is checked for the right
* class type. The input data block needs a certain structure, namely the
* buffer size as first word. If the cross check fails, the retrieval is
* silently abondoned, unless the \em bForce parameter is set.<br>
- * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
+ * \b Note: THE OBJECT MUST NOT BE DELETED by the caller.
+ *
+ * If called without parameters, the function tries to create objects from
+ * all available input blocks, also the ones of data type kAliHLTVoidDataType
+ * which are not matched by kAliHLTAnyDataType.
+ *
* @param dt data type of the object
* @param classname class name of the object
* @param bForce force the retrieval of an object, error messages
* @return pointer to @ref TObject, NULL if no objects of specified type
* available
*/
- const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAnyDataType,
+ const TObject* GetFirstInputObject(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes,
const char* classname=NULL,
int bForce=0);
/**
* Get the first block of a specific data type from the input data.
- * The method looks for the first block of type dt in the input stream. It is intended
- * to be used within the high-level interface.<br>
+ * The method looks for the first block of type dt in the input stream.
+ * It is intended to be used within the high-level interface.<br>
* \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
+ *
+ * If called without parameters, the function works on all input blocks,
+ * also the ones of data type kAliHLTVoidDataType which are not matched by
+ * kAliHLTAnyDataType.
+ *
* @param dt data type of the block
* @return pointer to @ref AliHLTComponentBlockData
*/
- const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAnyDataType);
+ const AliHLTComponentBlockData* GetFirstInputBlock(const AliHLTComponentDataType& dt=kAliHLTAllDataTypes);
/**
* Get the first block of a specific data type from the input data.
*/
AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock=NULL);
+ /**
+ * Forward an input object to the output.
+ * Forward the input block of an object previously fetched via
+ * GetFirstInputObject/NextInputObject or the last one if no object
+ * specified.
+ * The block descriptor of the input block is forwarded to the
+ * output block list.
+ * @param pObject pointer to TObject
+ * @return neg. error code if failed
+ */
+ int Forward(const TObject* pObject);
+
+ /**
+ * Forward an input block to the output.
+ * Forward the input block fetched via GetFirstInputObject/
+ * NextInputBlock or the last one if no block specified.
+ * The block descriptor of the input block is forwarded to the
+ * output block list.
+ * @param pBlock pointer to input block
+ * @return neg. error code if failed
+ */
+ int Forward(const AliHLTComponentBlockData* pBlock=NULL);
+
/**
* Insert an object into the output.
* If header is specified, it will be inserted before the root object,
* @param dt data type of the object
* @param spec data specification
* @param pHeader pointer to header
- * @param iHeaderSize size of Header
+ * @param headerSize size of Header
* @return neg. error code if failed
*/
int PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
* @param dtOrigin data type origin of the object
* @param spec data specification
* @param pHeader pointer to header
- * @param iHeaderSize size of Header
+ * @param headerSize size of Header
* @return neg. error code if failed
*/
int PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
*/
AliHLTUInt32_t GetRunType() const;
+ /**
+ * Set a bit to 1 in a readout list ( = AliHLTEventDDL )
+ * -> enable DDL for readout
+ * @param list readout list
+ * @param ddlId DDL Id to be turned on ( Decimal )
+ */
+ void EnableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
+ SetDDLBit( list, ddlId, kTRUE );
+ }
+
+ /**
+ * Set a bit to 0 in a readout list ( = AliHLTEventDDL )
+ * -> disable DDL for readout
+ * @param list readout list
+ * @param ddlId DDL Id to be turned on ( Decimal )
+ */
+ void DisableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
+ SetDDLBit( list, ddlId, kFALSE );
+ }
+
+ /**
+ * Set or unset bit a readout list ( = AliHLTEventDDL )
+ * -> enable or disable DDL for readout
+ * @param list readout list
+ * @param ddlId DDL Id to be turned on ( Decimal )
+ * @param state kTRUE sets it, kFALSE unsets it
+ */
+ void SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const;
+
+ /**
+ * Get the first word of a detector, which has a set DDL bit.
+ * Beware, this only works if DDLs of 1 detector are set. In the
+ * case of the TPC and TOF, which use 8 and 3 words, the first
+ * word is returned.
+ * @param list readout list
+ * @return returns the detector index, -1 if no bit is set
+ * at all or several detectors (=error)
+ */
+ Int_t GetFirstUsedDDLWord(AliHLTEventDDL &list) const;
+
/**
* Copy a struct from block data.
* The function checks for block size and struct size. The least common
* @param eventname name of the event (log messages)
* @return size copied, neg. error if failed
*/
- int CopyStruct(void* pStruct, int iStructSize, int iBlockNo,
+ int CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
const char* structname="", const char* eventname="");
private:
- /** not a valid copy constructor, defined according to effective C++ style */
+ /** copy constructor prohibited */
AliHLTComponent(const AliHLTComponent&);
- /** not a valid assignment op, but defined according to effective C++ style */
+ /** assignment operator prohibited */
AliHLTComponent& operator=(const AliHLTComponent&);
/**
* Input blocks containing a TObject have the size of the object as an
* unsigned 32 bit number in the first 4 bytes. This has to match the block
* size minus 4.
+ *
+ * kAliHLTAllDataTypes is a special data type which includes both
+ * kAliHLTVoidDataType and kAliHLTAnyDataType.
+ *
* @param dt data type
* @param startIdx index to start the search
* @param bObject check if this is an object
AliHLTUInt32_t fOutputBufferFilled; // see above
/** list of ouput block data descriptors */
- vector<AliHLTComponentBlockData> fOutputBlocks; // see above
+ AliHLTComponentBlockDataList fOutputBlocks; // see above
/** stopwatch array */
TObjArray* fpStopwatches; //! transient
/** array of memory files AliHLTMemoryFile */
- vector<AliHLTMemoryFile*> fMemFiles; //! transient
+ AliHLTMemoryFilePList fMemFiles; //! transient
/** descriptor of the current run */
AliHLTRunDesc* fpRunDesc; //! transient
/** the current DDL list */
AliHLTEventDDL* fpDDLList; //! transient
- ClassDef(AliHLTComponent, 3)
+ /** external fct to set CDB run no, indicates external CDB initialization */
+ void* fCDBSetRunNoFunc; //! transient
+
+ /** id of the component in the analysis chain */
+ string fChainId; //! transient
+
+ ClassDef(AliHLTComponent, 6)
};
#endif