]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.h
Enhanced doxygen documentation
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
index ae7f0ecb89aa3db4fb0a17f22d123ae07b4cf6f8..636528c895ffffa5546610b066b9d7a52247cd1e 100644 (file)
@@ -26,7 +26,7 @@
  * 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
+ * @section alihlt_component_implementation Component implementation
  * AliHLTComponent provides the interface for all components, see there
  * for details. Three types are provided:
  * - AliHLTProcessor
@@ -143,11 +143,11 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  *   also implements a standard method for @ref GetInputDataTypes.
  *   
  * - AliHLTProcessor for components of type @ref kProcessor <br>
- *   All types of data processors can inherit from AliHLTDataSource and must
+ *   All types of data processors can inherit from AliHLTProcessor and must
  *   implement the @ref AliHLTProcessor::DoEvent method.
  *
  * - AliHLTDataSink for components of type @ref kSink <br>
- *   All types of data processors can inherit from AliHLTDataSource and must
+ *   All types of data processors can inherit from AliHLTDataSink and must
  *   implement the @ref AliHLTDataSink::DumpEvent method. The class
  *   also implements a standard method for @ref GetOutputDataType and @ref
  *   GetOutputDataSize.
@@ -165,7 +165,7 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * and AliHLTDataSink provides it's own processing method (see
  * @ref alihltcomponent-type-std), which splits into a high and a low-level
  * method. For the @ref alihltcomponent-low-level-interface, all parameters are
- * shipped as function arguments, the component is supposed to dump data to the
+ * shipped as function arguments, the component is supposed to write data to the
  * output buffer and handle all block descriptors. 
  * The @ref alihltcomponent-high-level-interface is the standard processing
  * method and will be used whenever the low-level method is not overloaded.
@@ -176,7 +176,7 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * For that reason the @ref GetOutputDataSize function should return a rough
  * estimatian of the data to be produced by the component. The component is
  * responsible for checking the memory size and must return -ENOSPC if the
- * available buffer is to small, and update the estimator respectively. The
+ * available buffer is too small, and update the estimator respectively. The
  * framework will allocate a buffer of appropriate size and call the processing
  * again.
  *
@@ -279,6 +279,13 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * Further rules:
  * - avoid big static arrays in the component, allocate the memory at runtime
  *
+ * @section alihlt_component_arguments Default arguments
+ * The component base class provides some default arguments:
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -object-compression=level     <br>
+ *      compression level for ROOT objects, default is defined by
+ *      @ref ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION
+ *
  * @ingroup alihlt_component
  * @section alihltcomponent-members Class members
  */
@@ -305,7 +312,7 @@ class AliHLTComponent : public AliHLTLogging {
    * @param argc           size of the argument array
    * @param argv           agument array for component initialization
    */
-  virtual int Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv );
+  virtual int Init( const AliHLTAnalysisEnvironment* environ, void* environParam, int argc, const char** argv );
 
   /**
    * Clean-up function to terminate data processing.
@@ -402,6 +409,17 @@ class AliHLTComponent : public AliHLTLogging {
    */
   int SetRunDescription(const AliHLTRunDesc* desc, const char* runType);
 
+  /**
+   * Set the component description.
+   * The description string can contain tokens separated by blanks, a token
+   * consists of a key and an optional value separated by '='.
+   * Possible keys:
+   * \li -chainid=id        string id within the chain of the instance
+   *
+   * @param desc    component description
+   */
+  int SetComponentDescription(const char* desc);
+
   // Information member functions for registration.
 
   /**
@@ -493,6 +511,12 @@ class AliHLTComponent : public AliHLTLogging {
    */
   static string DataType2Text( const AliHLTComponentDataType& type, int mode=0);
 
+  /**
+   * Calculate a CRC checksum of a data buffer.
+   * Polynomial for the calculation is 0xD8.
+   */
+  static AliHLTUInt32_t CalculateChecksum(const AliHLTUInt8_t* buffer, int size);
+
   /**
    * Helper function to print content of data type.
    */
@@ -563,6 +587,15 @@ class AliHLTComponent : public AliHLTLogging {
    */
   static void SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t orig); 
 
+  /**
+   * Extract a component table entry from the payload buffer.
+   * The entry consists of the AliHLTComponentTableEntry structure, the array of
+   * parents and a description string of the format 'chain-id{component-id:component-args}'.
+   * The function fills all the variables after a consistency check.
+   */
+  static int ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
+                                       string& chainId, string& compId, string& compParam,
+                                       vector<AliHLTUInt32_t>& parents);
   /**
    * Stopwatch type for benchmarking.
    */
@@ -675,7 +708,9 @@ class AliHLTComponent : public AliHLTLogging {
    * 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
+   * @param chainId      the id/name of the component in the current analysis
+   *                     chain. This is not necessarily the same as what is
+   *                     returned by the GetComponentID() method.
    * @note both parameters can be NULL, check before usage
    */
   virtual int Reconfigure(const char* cdbEntry, const char* chainId);
@@ -724,13 +759,22 @@ class AliHLTComponent : public AliHLTLogging {
    */
   virtual int EndOfRun();
 
+  /**
+   * Check whether a component requires all steering blocks.
+   * Childs can overload in order to indicate that they want to
+   * receive also the steering data blocks. There is also the
+   * possibility to add the required data types to the input
+   * data type list in GetInputDataTypes().
+   */
+  virtual bool RequireSteeringBlocks() const {return false;}
+
   /**
    * General memory allocation method.
    * All memory which is going to be used 'outside' of the interface must
    * be provided by the framework (online or offline).
    * The method is redirected to a function provided by the current
    * framework. Function pointers are transferred via the @ref
-   * AliHLTComponentEnvironment structure.
+   * AliHLTAnalysisEnvironment structure.
    */
   void* AllocMemory( unsigned long size );
 
@@ -741,7 +785,7 @@ class AliHLTComponent : public AliHLTLogging {
    * interface pure C style, monilithic blocks must be exchanged. 
    * The method is redirected to a function provided by the current
    * framework. Function pointers are transferred via the @ref
-   * AliHLTComponentEnvironment structure.
+   * AliHLTAnalysisEnvironment structure.
    */
   int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
                               AliHLTComponentBlockData** outputBlocks );
@@ -750,10 +794,39 @@ class AliHLTComponent : public AliHLTLogging {
    * Fill the EventDoneData structure.
    * The method is redirected to a function provided by the current
    * framework. Function pointers are transferred via the @ref
-   * AliHLTComponentEnvironment structure.
+   * AliHLTAnalysisEnvironment structure.
    */
   int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd );
 
+  /**
+   * Allocate an EventDoneData structure for the current event .
+   * The method allocates the memory internally and does not interact with the current Framework.
+   * The allocated data structure is empty initially and can be filled by calls to the 
+   * @ref PushEventDoneData method. The memory will be automatically released after the event has been processed.
+   * 
+   */
+  int ReserveEventDoneData( unsigned long size );
+
+  /**
+   * Push a 32 bit word of data into event done data for the current event which
+   * has previously been allocated by the @ref ReserveEventDoneData method.
+   */
+  int PushEventDoneData( AliHLTUInt32_t eddDataWord );
+
+  /**
+   * Release event done data previously reserved by @ref ReserveEventDoneData
+   */
+   void ReleaseEventDoneData();
+
+  /**
+   * Get the pointer to the event done data available/built so far for the current event via
+   * @ref ReserveEventDoneData and @ref PushEventDoneData
+   */
+  AliHLTComponentEventDoneData* GetCurrentEventDoneData()
+    {
+    return fEventDoneData;
+    }
+
   /**
    * Helper function to convert the data type to a string.
    */
@@ -888,7 +961,7 @@ class AliHLTComponent : public AliHLTLogging {
    * \em Note: THE BLOCK DESCRIPTOR MUST NOT BE DELETED by the caller.
    * @return pointer to AliHLTComponentBlockData, NULL if index out of range
    */
-  const AliHLTComponentBlockData* GetInputBlock(int index);
+  const AliHLTComponentBlockData* GetInputBlock(int index) const;
 
   /**
    * Get the next block of a specific data type from the input data.
@@ -973,9 +1046,9 @@ class AliHLTComponent : public AliHLTLogging {
    * @param headerSize size of Header
    * @return neg. error code if failed 
    */
-  int PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
+  int PushBack(const void* pBuffer, int iSize, const AliHLTComponentDataType& dt,
               AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
-              void* pHeader=NULL, int headerSize=0);
+              const void* pHeader=NULL, int headerSize=0);
 
   /**
    * Insert an object into the output.
@@ -988,9 +1061,9 @@ class AliHLTComponent : public AliHLTLogging {
    * @param headerSize size of Header
    * @return neg. error code if failed 
    */
-  int PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
+  int PushBack(const void* pBuffer, int iSize, const char* dtID, const char* dtOrigin,
               AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
-              void* pHeader=NULL, int headerSize=0);
+              const void* pHeader=NULL, int headerSize=0);
 
   /**
    * Estimate size of a TObject
@@ -1107,6 +1180,18 @@ class AliHLTComponent : public AliHLTLogging {
    */
   AliHLTUInt32_t GetRunType() const;
 
+  /**
+   * Get the chain id of the component.
+   */
+  const char* GetChainId() const {return fChainId.c_str();}
+
+  /**
+   * Check whether the current event is a valid data event.
+   * @param pTgt    optional pointer to get the event type
+   * @return true if the current event is a real data event
+   */
+  bool IsDataEvent(AliHLTUInt32_t* pTgt=NULL);
+
   /**
    * Set a bit to 1 in a readout list ( = AliHLTEventDDL )
    * -> enable DDL for readout
@@ -1254,13 +1339,14 @@ class AliHLTComponent : public AliHLTLogging {
    * @param iHeaderSize size of Header
    * @return neg. error code if failed
    */
-  int InsertOutputBlock(void* pBuffer, int iBufferSize,
+  int InsertOutputBlock(const void* pBuffer, int iBufferSize,
                        const AliHLTComponentDataType& dt,
                        AliHLTUInt32_t spec,
-                       void* pHeader=NULL, int iHeaderSize=0);
+                       const void* pHeader=NULL, int iHeaderSize=0);
 
   /**
    * Add a component statistics block to the output.
+   * @return size of the added data
    */
   int AddComponentStatistics(AliHLTComponentBlockDataList& blocks, 
                             AliHLTUInt8_t* buffer,
@@ -1268,11 +1354,27 @@ class AliHLTComponent : public AliHLTLogging {
                             AliHLTUInt32_t offset,
                             AliHLTComponentStatisticsList& stats) const;
 
+  /**
+   * Add a component table entry (descriptor) to the output
+   * This is done at SOR/EOR. The component table is a list of chain ids
+   * and 32bit ids calculated by a crc algorithm from the chian id. This
+   * allows to tag data blocks with the id number rather than the string.
+   *
+   * The kAliHLTDataTypeComponentTable data block currently has the string
+   * as payload and the crc id as specification.
+   * @return size of the added data
+   */
+  int  AddComponentTableEntry(AliHLTComponentBlockDataList& blocks, 
+                             AliHLTUInt8_t* buffer,
+                             AliHLTUInt32_t bufferSize,
+                             AliHLTUInt32_t offset,
+                             const vector<AliHLTUInt32_t>& parents) const;
+
   /** The global component handler instance */
   static AliHLTComponentHandler* fgpComponentHandler;              //! transient
 
   /** The environment where the component is running in */
-  AliHLTComponentEnvironment fEnvironment;                         // see above
+  AliHLTAnalysisEnvironment fEnvironment;                         // see above
 
   /** Set by ProcessEvent before the processing starts */
   AliHLTEventID_t fCurrentEvent;                                   // see above
@@ -1331,12 +1433,31 @@ class AliHLTComponent : public AliHLTLogging {
   /** id of the component in the analysis chain */
   string fChainId;                                                 //! transient
 
+  /** crc value of the chainid, used as a 32bit id */
+  AliHLTUInt32_t fChainIdCrc;                                      //! transient
+
   /** optional benchmarking for the component statistics */
   TStopwatch* fpBenchmark;                                         //! transient
 
   /** component requires steering data blocks */
   bool fRequireSteeringBlocks;                                     //! transient
 
-  ClassDef(AliHLTComponent, 7)
+  /** current event type */
+  AliHLTUInt32_t fEventType;                                       //! transient
+
+  /** component arguments */
+  string fComponentArgs;                                           //! transient
+
+
+  /** event done data */
+  AliHLTComponentEventDoneData* fEventDoneData;                    //! transient
+
+  /** Reserved size of the memory stored at fEventDoneData */
+  unsigned long fEventDoneDataSize;                                //! transient
+
+  /** Comression level for ROOT objects */
+  int fCompressionLevel;                                           //! transient
+
+  ClassDef(AliHLTComponent, 9)
 };
 #endif