]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.h
extended logging for multiple instances of AliHLTComponent, -Task, and -System
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
index 2733f5595a42e2dd9486c9aa924e997064fc2c62..c9d29a6a73af80258025719cad759eaf61085bd4 100644 (file)
@@ -1,11 +1,11 @@
 //-*- 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_implementation 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>
 #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
@@ -47,8 +81,20 @@ typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData;
 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 statistics struct */
+typedef vector<AliHLTComponentStatistics> AliHLTComponentStatisticsList;
+/** 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.
@@ -97,11 +143,11 @@ class AliHLTMemoryFile;
  *   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.
@@ -119,7 +165,7 @@ class AliHLTMemoryFile;
  * 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.
@@ -130,10 +176,26 @@ class AliHLTMemoryFile;
  * 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.
  *
+ * @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 
@@ -217,6 +279,13 @@ class AliHLTMemoryFile;
  * 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
  */
@@ -243,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.
@@ -294,9 +363,63 @@ class AliHLTComponent : public AliHLTLogging {
   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.
+   * 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);
+
+  /**
+   * 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.
 
   /**
@@ -319,7 +442,7 @@ class AliHLTComponent : public AliHLTLogging {
    * 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.
@@ -337,7 +460,7 @@ class AliHLTComponent : public AliHLTLogging {
    * @param tgtList          list to receive the data types
    * @return no of output data types, data types in the target list
    */
-  virtual int GetOutputDataTypes(vector<AliHLTComponentDataType>& tgtList);
+  virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
 
   /**
    * Get a ratio by how much the data volume is shrinked or enhanced.
@@ -365,7 +488,7 @@ class AliHLTComponent : public AliHLTLogging {
    * @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.
@@ -381,13 +504,23 @@ class AliHLTComponent : public AliHLTLogging {
 
   /**
    * 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);
+
+  /**
+   * 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.
    */
-  void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL) const;
+  static void PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format=NULL);
 
   /**
    * helper function to initialize AliHLTComponentEventData structure
@@ -399,8 +532,70 @@ class AliHLTComponent : public AliHLTLogging {
    * 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); 
+
+  /**
+   * 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.
    */
@@ -485,60 +680,111 @@ class AliHLTComponent : public AliHLTLogging {
    */
   int SetStopwatches(TObjArray* pStopwatches);
 
- protected:
+  /**
+   * Customized logging function.
+   * The chain id, component id and pointer is added at the beginning of each message.
+   */
+  int LoggingVarargs(AliHLTComponentLogSeverity severity, 
+                    const char* originClass, const char* originFunc,
+                    const char* file, int line, ... ) const;
 
   /**
-   * Fill AliHLTComponentBlockData structure with default values.
-   * @param blockData   reference to data structure
+   * Get size of last serialized object.
+   * During PushBack, TObjects are serialized in a separate buffer. The
+   * size of the last object can be retrieved by this function.
+   *
+   * This might be especially useful for PushBack failures caused by too
+   * small output buffer.
    */
-  void FillBlockData( AliHLTComponentBlockData& blockData ) const;
+  int GetLastObjectSize() const {return fLastObjectSize;}
+
+ protected:
 
   /**
-   * Fill AliHLTComponentShmData structure with default values.
-   * @param shmData   reference to data structure
+   * Default method for the internal initialization.
+   * The method is called by @ref Init
    */
-  void FillShmData( AliHLTComponentShmData& shmData ) const;
+  virtual int DoInit( int argc, const char** argv );
 
   /**
-   * Fill AliHLTComponentDataType structure with default values.
-   * @param dataType   reference to data structure
+   * Default method for the internal clean-up.
+   * The method is called by @ref Deinit
    */
-  void FillDataType( AliHLTComponentDataType& dataType ) const;
-  
+  virtual int DoDeinit();
+
   /**
-   * Copy data type structure
-   * Copies the value an AliHLTComponentDataType structure to another one
-   * @param[out] tgtdt   target structure
-   * @param[in] srcdt   source structure
+   * 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/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);
+
+  /**
+   * 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
    */
-  void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
+  virtual int ReadPreprocessorValues(const char* modules);
 
   /**
-   * 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
+   * 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
    */
-  void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
+  virtual int StartOfRun();
 
   /**
-   * Default method for the internal initialization.
-   * The method is called by @ref Init
+   * 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 DoInit( int argc, const char** argv );
+  virtual int EndOfRun();
 
   /**
-   * Default method for the internal clean-up.
-   * The method is called by @ref Deinit
+   * 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 int DoDeinit();
+  virtual bool RequireSteeringBlocks() const {return false;}
 
   /**
    * General memory allocation method.
@@ -546,7 +792,7 @@ class AliHLTComponent : public AliHLTLogging {
    * 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 );
 
@@ -557,19 +803,48 @@ 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 vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
+  int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
                               AliHLTComponentBlockData** outputBlocks );
 
   /**
    * 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.
    */
@@ -587,16 +862,28 @@ class AliHLTComponent : public AliHLTLogging {
    */
   int GetNumberOfInputBlocks() const;
 
+  /**
+   * Get id of the current event
+   * @return event id
+   */
+  AliHLTEventID_t GetEventId() const;
+
   /**
    * 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
@@ -604,7 +891,7 @@ class AliHLTComponent : public AliHLTLogging {
    * @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);
 
@@ -667,13 +954,18 @@ class AliHLTComponent : public AliHLTLogging {
 
   /**
    * 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.
@@ -693,7 +985,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.
@@ -714,6 +1006,29 @@ class AliHLTComponent : public AliHLTLogging {
    */
   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,
@@ -755,9 +1070,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.
@@ -770,9 +1085,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
@@ -889,6 +1204,58 @@ 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
+   * @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
@@ -902,13 +1269,13 @@ class AliHLTComponent : public AliHLTLogging {
    * @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&);
 
   /**
@@ -925,6 +1292,10 @@ class AliHLTComponent : public AliHLTLogging {
    * 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
@@ -992,16 +1363,42 @@ 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,
+                            AliHLTUInt32_t bufferSize,
+                            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
@@ -1040,13 +1437,13 @@ class AliHLTComponent : public AliHLTLogging {
   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
@@ -1054,6 +1451,40 @@ class AliHLTComponent : public AliHLTLogging {
   /** 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
+
+  /** 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
+
+  /** 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
+
+  /** size of last PushBack-serialized object */
+  int fLastObjectSize;                                             //! transient
+
+  ClassDef(AliHLTComponent, 10)
 };
 #endif