]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.h
Changes for #90436: Misuse of TClonesArray containing AliESDMuonCluster
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
index 933985e3797774a1a5553482886dbe28b7f9c130..849dcae870a2c354da8fad8a38060765715d9573 100644 (file)
@@ -7,13 +7,13 @@
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //* See cxx source for full Copyright notice                               *
 
-/** @file   AliHLTComponent.h
-    @author Matthias Richter, Timm Steinbeck
-    @date   
-    @brief  Base class declaration for HLT components. 
-    @note   The class is both used in Online (PubSub) and Offline (AliRoot)
-            context
-*/
+/ @file   AliHLTComponent.h
+//  @author Matthias Richter, Timm Steinbeck
+//  @date   
+//  @brief  Base class declaration for HLT components. 
+//  @note   The class is both used in Online (PubSub) and Offline (AliRoot)
+//          context
+
 
 /**
  * @defgroup alihlt_component Component handling of the HLT module
@@ -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
@@ -80,9 +80,14 @@ typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData;
 
 class AliHLTComponentHandler;
 class TObjArray;
+class TMap;
 class TStopwatch;
+class TUUID;
+struct AliRawDataHeader;
 class AliHLTComponent;
 class AliHLTMemoryFile;
+class AliHLTCTPData;
+class AliHLTReadoutList;
 
 /** list of component data type structures */
 typedef vector<AliHLTComponentDataType>   AliHLTComponentDataTypeList;
@@ -121,6 +126,9 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  *   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.
+ * - @ref Reconfigure
+ *   This function is invoked by the framework on a special event which
+ *   triggers the reconfiguration of the component.
  *
  * @subsection alihltcomponent-processing-mehods Data processing
  * 
@@ -143,11 +151,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 +173,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,11 +184,11 @@ 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.
  *
- * @subsection alihltcomponent-error-codes Data processing
+ * @subsection alihltcomponent-error-codes Return values/Error codes
  * 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
@@ -188,6 +196,8 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * <pre>
  * \#include \<cerrno\>
  * </pre>
+ * This schema aplies to all interface functions of the component base class.
+ * For data processing it is as follows:
  * - 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
@@ -252,15 +262,96 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * - @ref AliHLTDataSource::GetEvent
  * - @ref AliHLTDataSink::DumpEvent
  * 
- * 
+ * The base class passes all relevant parameters for data access directly on to the
+ * component. Input blocks can be accessed by means of the array <tt> blocks </tt>.
+ * Output data are written directly to shared memory provided by the pointer
+ * <tt> outputPtr </tt> and output block descriptors are inserted directly to the
+ * list <tt> outputBlocks </tt>.
+ *
+ * \b NOTE: The high-level input data access methods can be used also from the low
+ * level interface. Also the PushBack functions can be used BUT ONLY if no data is
+ * written to the output buffer and no data block descriptors are inserted into the
+ * output block list.
+ *
+ * @section alihltcomponent-initialization Component initialization and configuration
+ * The component interface provides two optional methods for component initialization
+ * and configuration. The @ref DoInit function is called once before the processing.
+ * During the event processing, a special event can trigger a reconfiguration and the
+ * @ref Reconfigure method is called. There are three possible options of initialization
+ * and configuration:
+ * - default values: set directly in the source code
+ * - OCDB objects: all necessary information must be loaded from OCDB objects. The
+ *   Offline Conditions Data Base stores objects specifically valid for individual runs
+ *   or run ranges.
+ * - Component arguments: can be specified for every component in the chain
+ *   configuration. The arguments can be used to override specific parameters of the
+ *   component.
+ *
+ * As a general rule, the three options should be processed in that sequence, i.e
+ * default parameters might be overridden by OCDB configuration, and the latter one
+ * by component arguments.
+ *
+ * @subsection alihltcomponent-initialization-arguments Component arguments
+ * In normal operation, components are supposed to run without any additional argument,
+ * however such arguments can be useful for testing and debugging. The idea follows
+ * the format of command line arguments. A keyword is indicated by a dash and an
+ * optional argument might follow, e.g.:
+ * <pre>
+ * -argument1 0.5 -argument2
+ * </pre>
+ * In this case argument1 requires an additional parameter whereas argument2 does not.
+ * The arguments will be provided as an array of separated arguments.
+ *
+ * Component arguments can be classified into initialization arguments and configuration
+ * arguments. The latter are applicable for both the @ref DoInit and @ref Reconfigure
+ * method whereas initialization arguments are not applicable after DoInit.
+ *
+ * @subsection alihltcomponent-initialization-ocdb OCDB objects
+ * OCDB objects are ROOT <tt>TObjects</tt> and can be of any type. This is in particular
+ * useful for complex parameter sets. However in most cases, a simple approach of human
+ * readable command line arguments is appropriate. Such a string can be simply stored
+ * in a TObjString (take note that the TString does not derive from TObject). The
+ * same arguments as for the command line can be used. Take note that in the TObjString
+ * all arguments are separated by blanks, instead of being in an array of separate
+ * strings.
+ *
+ * The base class provides two functions regarding OCDB objects: 
+ * - LoadAndExtractOCDBObject() loads the OCDB entry for the specified path and extracts
+ *                              the TObject from it. An optional key allows to access
+ *                              a TObject within a TMap
+ * - ConfigureFromCDBTObjString() can load a number of OCDB objects and calls the
+ *                              argument parsing ConfigureFromArgumentString
+ *
+ *
+ * @subsection alihltcomponent-initialization-sequence Initialization sequence
+ * Using the approach of <tt>TObjString</tt>-type configuration objects allows to treat
+ * configuration from both @ref DoInit and @ref Reconfigure in the same way.
+ *
+ * The base class provides the function ConfigureFromArgumentString() which loops over
+ * all arguments and calls the child's method ScanConfigurationArgument(). Here the
+ * actual treatment of the argument and its parameters needs to be implemented.
+ * ConfigureFromArgumentString() can treat both arrays of arguments and arguments in
+ * one single string separated by blanks. The two options can be mixed.
+ *
+ * A second base class function ConfigureFromCDBTObjString() allows to configure
+ * directly from a number of OCDB objects. This requires the entries to be of
+ * type TObjString and the child implementation of ScanConfigurationArgument().
+ * The object can also be of type TMap with TObjStrings as key-value pairs. The
+ * key identifier can be chosen by the component implementation. Normally it will
+ * be the run type ("p","A-A", "p-A", ...) or e.g. the trigger code secified by
+ * ECS.
+ *
  * @section alihltcomponent-handling Component handling 
  * The handling of HLT analysis components is carried out by the AliHLTComponentHandler.
  * Component are registered automatically at load-time of the component shared library
  * under the following suppositions:
  * - the component library has to be loaded from the AliHLTComponentHandler using the
  *   @ref AliHLTComponentHandler::LoadLibrary method.
+ * - the library defines an AliHLTModuleAgent which registers all components.
+ *   See AliHLTModuleAgent::RegisterComponents                               <br>
+ *     or                                                                    <br>
  * - the component implementation defines one global object (which is generated
- *   when the library is loaded)
+ *   when the library is loaded)                                             <br>
  *
  * @subsection alihltcomponent-design-rules General design considerations
  * The analysis code should be implemented in one or more destict class(es). A 
@@ -278,6 +369,23 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  *
  * Further rules:
  * - avoid big static arrays in the component, allocate the memory at runtime
+ * - allocate all kind of complex data members (like classes, ROOT TObjects of
+ *   any kind) dynamically in DoInit and clean up in DoDeinit
+ *
+ * @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 -loglevel=level     <br>
+ * \li -object-compression=level     <br>
+ *      compression level for ROOT objects, default is defined by
+ *      @ref ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION
+ * \li -pushback-period=period     <br>
+ *      scale down for PushBack of objects, shipped only for one event
+ *      every <i>period</i> seconds
+ * \li -event-module=number     <br>
+ *      This option reduces the event processing rate by processing only n'th event
+ *      based on the modulo number <i>number</i>. The scale down should be about
+ *      1/<i>number</i>, where <i>number</i> is a positive integer.
  *
  * @ingroup alihlt_component
  * @section alihltcomponent-members Class members
@@ -295,17 +403,17 @@ class AliHLTComponent : public AliHLTLogging {
   /**
    * Init function to prepare data processing.
    * Initialization of common data structures for a sequence of events.
-   * The call is redirected to the internal method @ref DoInit which can be
-   * overridden by the child class.<br>
+   * The call is redirected to the internal method DoInit which can be
+   * overridden by the child class.
    * During Init also the environment structure is passed to the component.
-   * @param environ        environment pointer with environment dependend function
+   * @param comenv         environment pointer with environment dependent function
    *                       calls
-   * @param environParam   additionel parameter for function calls, the pointer
+   * @param environParam   additional parameter for function calls, the pointer
    *                       is passed as it is
    * @param argc           size of the argument array
-   * @param argv           agument array for component initialization
+   * @param argv           augment array for component initialization
    */
-  virtual int Init( const AliHLTAnalysisEnvironment* environ, void* environParam, int argc, const char** argv );
+  virtual int Init( const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv );
 
   /**
    * Clean-up function to terminate data processing.
@@ -413,6 +521,18 @@ class AliHLTComponent : public AliHLTLogging {
    */
   int SetComponentDescription(const char* desc);
 
+  /**
+   * Set the running environment for the component.
+   * Originally, the environment was set in the Init function. However, the setup of
+   * the CDB is required before. In order to have proper logging functionality, the
+   * environment is required.
+   * @param comenv         environment pointer with environment dependent function
+   *                       calls
+   * @param environParam   additional parameter for function calls, the pointer
+   *                       is passed as it is
+   */
+  int SetComponentEnvironment(const AliHLTAnalysisEnvironment* comenv, void* environParam);
+
   // Information member functions for registration.
 
   /**
@@ -456,7 +576,7 @@ class AliHLTComponent : public AliHLTLogging {
   virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
 
   /**
-   * Get a ratio by how much the data volume is shrinked or enhanced.
+   * Get a ratio by how much the data volume is shrunken or enhanced.
    * The function is pure virtual and must be implemented by the child class.
    * @param constBase        <i>return</i>: additive part, independent of the
    *                                   input data volume  
@@ -465,6 +585,18 @@ class AliHLTComponent : public AliHLTLogging {
    */
   virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
 
+  /**
+   * Get a list of OCDB object description.
+   * The list of objects is provided in a TMap
+   * - key: complete OCDB path, e.g. GRP/GRP/Data
+   * - value: short description why the object is needed
+   * Key and value objects created inside this class go into ownership of
+   * target TMap.
+   * @param targetMap   TMap instance receiving the list
+   * @return void
+   */
+  virtual void GetOCDBObjectDescription( TMap* const targetArray);
+
   /**
    * Spawn function.
    * Each component must implement a spawn function to create a new instance of 
@@ -473,6 +605,17 @@ class AliHLTComponent : public AliHLTLogging {
    */
   virtual AliHLTComponent* Spawn() = 0;
 
+  /**
+   * check the availability of the OCDB entry descriptions in the TMap
+   *  key : complete OCDB path of the entry
+   *  value : auxiliary object - short description
+   * if the external map was not provided the function invokes
+   * interface function GetOCDBObjectDescription() to retrieve the list.
+   * @param externList  map of entries to be tested
+   * @result 0 if all found, -ENOENT if objects not found
+   */
+  int CheckOCDBEntries(const TMap* const externList=NULL);
+
   /**
    * Find matching data types between this component and a consumer component.
    * Currently, a component can produce only one type of data. This restriction is most
@@ -500,10 +643,17 @@ class AliHLTComponent : public AliHLTLogging {
    * @param type        data type structure
    * @param mode        0 print string origin:type          <br>
    *                    1 print chars                       <br>
-   *                    2 print numbers
+   *                    2 print numbers                     <br>
+   *                    3 print 'type' 'origin' 
    */
   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.
    */
@@ -542,8 +692,8 @@ class AliHLTComponent : public AliHLTLogging {
   /**
    * Copy data type structure
    * Copies the value an AliHLTComponentDataType structure to another one
-   * @param[out] tgtdt   target structure
-   * @param[in] srcdt   source structure
+   * @param [out] tgtdt   target structure
+   * @param [in] srcdt   source structure
    */
   static void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
 
@@ -574,6 +724,81 @@ 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) {
+    int dummy=0;
+    return ExtractComponentTableEntry(pBuffer, size, chainId, compId, compParam, parents, dummy);
+  }
+
+  static int ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
+                                       string& chainId, string& compId, string& compParam,
+                                       vector<AliHLTUInt32_t>& parents, int& level);
+
+  /**
+   * Extracts the different data parts from the trigger data structure.
+   * @param [in] trigData  The trigger data as passed to the DoProcessing method.
+   * @param [out] attributes  The data block attributes given by the HLT framework.
+   * @param [out] status  The HLT status bits given by the HLT framework.
+   * @param [out] cdh  The common data header received from DDL links.
+   * @param [out] readoutlist  The readout list to fill with readout list bits
+   *                           passed on by the HLT framework.
+   * @param [in] printErrors  If true then error messages are generated as necessary
+   *                          and suppressed otherwise.
+   * @note If any of the output parameters are set to NULL then the field is not set.
+   *   For example, the following line will only fill the CDH pointer.
+   *   \code
+   *     AliRawDataHeader* cdh;
+   *     ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL);
+   *   \endcode
+   * @return zero on success or one of the following error codes on failure.
+   *   if a non-zero error code is returned then none of the output parameters are
+   *   modified.
+   *    \li -ENOENT  The <i>trigData</i> structure size is wrong.
+   *    \li -EBADF   The <i>trigData</i> data size is wrong.
+   *    \li -EBADMSG The common data header (CDH) in the trigger data has the wrong
+   *                 number of words indicated.
+   *    \li -EPROTO  The readout list structure in the trigger data has the wrong
+   *                 number of words indicated.
+   */
+  static int ExtractTriggerData(
+      const AliHLTComponentTriggerData& trigData,
+      const AliHLTUInt8_t (**attributes)[gkAliHLTBlockDAttributeCount],
+      AliHLTUInt64_t* status,
+      const AliRawDataHeader** cdh,
+      AliHLTReadoutList* readoutlist,
+      bool printErrors = false
+    );
+
+  /**
+   * Extracts the readout list from a trigger data structure.
+   * @param [in] trigData  The trigger data as passed to the DoProcessing method.
+   * @param [out] list  The output readout list to fill.
+   * @param [in] printErrors  If true then error messages are generated as necessary
+   *                          and suppressed otherwise.
+   * @return zero on success or one of the error codes returned by ExtractTriggerData.
+   */
+  static int GetReadoutList(
+      const AliHLTComponentTriggerData& trigData, AliHLTReadoutList& list,
+      bool printErrors = false
+    )
+  {
+    return ExtractTriggerData(trigData, NULL, NULL, NULL, &list, printErrors);
+  }
+
+  /**
+   * Extracts the event type from the given Common Data Header.
+   * @param [in] cdh  The Common Data Header to extract the event type from.
+   * @return the event type code from the CDH.
+   */
+  static AliHLTUInt32_t ExtractEventTypeFromCDH(const AliRawDataHeader* cdh);
+  
   /**
    * Stopwatch type for benchmarking.
    */
@@ -622,7 +847,7 @@ class AliHLTComponent : public AliHLTLogging {
      *            be started<br>
      *            0 if it controls the same stopwatch
      */
-    int Hold(TStopwatch* pSucc);
+    int Hold(const TStopwatch* pSucc);
 
     /**
      * Resume the previous guard.
@@ -633,7 +858,7 @@ class AliHLTComponent : public AliHLTLogging {
      *            be stopped<br>
      *            0 if it controls the same stopwatch
      */
-    int Resume(TStopwatch* pSucc);
+    int Resume(const TStopwatch* pSucc);
 
     /** the stopwatch controlled by this guard */
     TStopwatch* fpStopwatch;                                                //!transient
@@ -658,6 +883,36 @@ class AliHLTComponent : public AliHLTLogging {
    */
   int SetStopwatches(TObjArray* pStopwatches);
 
+  /**
+   * 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;
+
+  /**
+   * 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.
+   */
+  int GetLastObjectSize() const {return fLastObjectSize;}
+
+  /**
+   * This method generates a V4 Globally Unique Identifier (GUID) using the
+   * ROOT TRandom3 pseudo-random number generator with the process' UID, GID
+   * PID and host address as seeds. For good measure MD5 sum hashing is also
+   * applied.
+   * @return the newly generated GUID structure.
+   */
+  static TUUID GenerateGUID();
+
+  /// get the compression level for TObjects
+  int GetCompressionLevel() const {return fCompressionLevel;}
+
  protected:
 
   /**
@@ -679,9 +934,14 @@ class AliHLTComponent : public AliHLTLogging {
    * 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
+   * leading absolute path of the CDB location. The framework might also
    * provide the id of the component in the analysis chain.
    *
+   * The actual sequence of configuration depends on the component. As a
+   * general rule, the component should load the specific OCDB object if
+   * provided as parameter, and load the default objects if the parameter
+   * is NULL. However, other schemes are possible. See @ref 
+   *
    * \b Note: The CDB will be initialized by the framework, either already set
    * from AliRoot or from the wrapper interface during initialization.
    *
@@ -707,6 +967,23 @@ class AliHLTComponent : public AliHLTLogging {
    */
   virtual int ReadPreprocessorValues(const char* modules);
 
+  /**
+   * Child implementation to scan a number of configuration arguments.
+   * The method is invoked by the framework in conjunction with the
+   * common framework functions ConfigureFromArgumentString and
+   * ConfigureFromCDBTObjString.
+   * Function needs to scan the argument and optional additional
+   * parameters and returns the number of elements in the array which
+   * have been treated.
+   * @param argc
+   * @param argv
+   * @return number of arguments which have been scanned or neg error
+   *         code if failed                                              <br>
+   *         \li -EINVAL      unknown argument
+   *         \li -EPROTO      protocol error, e.g. missing parameter
+   */
+  virtual int ScanConfigurationArgument(int argc, const char** argv);
+
   /**
    * Custom handler for the SOR event.
    * Is invoked from the base class if an SOR event is in the block list.
@@ -731,12 +1008,21 @@ class AliHLTComponent : public AliHLTLogging {
    * 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.
+   * See StartOfRun() for morcomments of the sequence of steering events.
    *
    * @return neg. error code if failed
    */
   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
@@ -765,13 +1051,73 @@ class AliHLTComponent : public AliHLTLogging {
    * framework. Function pointers are transferred via the @ref
    * AliHLTAnalysisEnvironment structure.
    */
-  int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd );
+  int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd ) const;
+
+  /**
+   * 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() const
+    {
+    return fEventDoneData;
+    }
 
   /**
    * Helper function to convert the data type to a string.
    */
   void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]) const;
 
+  /**
+   * Loop through a list of component arguments.
+   * The list can be either an array of separated strings or one single
+   * string containing blank separated arguments, or both mixed.
+   * ScanConfigurationArgument() is called to allow the component to treat
+   * the individual arguments.
+   * @return neg. error code if failed
+   */
+  int ConfigureFromArgumentString(int argc, const char** argv);
+
+  /**
+   * Read configuration objects from OCDB and configure from
+   * the content of TObjString entries.
+   * @param entries   blank separated list of OCDB paths
+   * @param key       if the entry is a TMap, search for the corresponding object
+   * @return neg. error code if failed
+   */
+  int ConfigureFromCDBTObjString(const char* entries, const char* key=NULL);
+
+  /**
+   * Load specified entry from the OCDB and extract the object.
+   * The entry is explicitely unloaded from the cache before it is loaded.
+   * If parameter key is specified the OCDB object is treated as TMap
+   * and the TObject associated with 'key' is loaded.
+   * @param path      path of the entry under to root of the OCDB
+   * @param version   version of the entry
+   * @param subVersion  subversion of the entry
+   * @param key       key of the object within TMap
+   */
+  TObject* LoadAndExtractOCDBObject(const char* path, const char* key=NULL) const;
+
   /**
    * Get event number.
    * @return value of the internal event counter
@@ -784,16 +1130,22 @@ 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
+   * The High-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>
+   * silently abandoned, unless the \em bForce parameter is set.<br>
    * \b Note: THE OBJECT MUST NOT BE DELETED by the caller.
    *
    * If called without parameters, the function tries to create objects from
@@ -813,14 +1165,14 @@ class AliHLTComponent : public AliHLTLogging {
 
   /**
    * Get the first object of a specific data type from the input data.
-   * The hight-level methods provide functionality to transfer ROOT data
+   * The High-level methods provide functionality to transfer ROOT data
    * structures which inherit from TObject.
    * The method looks for the first ROOT object of type specified by the ID and 
    * Origin strings 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>
+   * silently abandoned, unless the \em bForce parameter is set.<br>
    * \em Note: THE OBJECT MUST NOT BE DELETED by the caller.
    * @param dtID        data type ID of the object
    * @param dtOrigin    data type origin of the object
@@ -837,7 +1189,7 @@ class AliHLTComponent : public AliHLTLogging {
 
   /**
    * Get the next object of a specific data type from the input data.
-   * The hight-level methods provide functionality to transfer ROOT data
+   * The High-level methods provide functionality to transfer ROOT data
    * structures which inherit from TObject.
    * The method looks for the next ROOT object of type and class specified
    * to the previous @ref GetFirstInputObject call.<br>
@@ -914,13 +1266,13 @@ class AliHLTComponent : public AliHLTLogging {
 
   /**
    * Get data specification of an input block.
-   * Get data specification of the input bblock previously fetched via
+   * Get data specification of the input block previously fetched via
    * GetFirstInputObject/NextInputObject or the last one if no block
    * specified.
    * @param pBlock     pointer to input block
    * @return data specification, kAliHLTVoidDataSpec if failed
    */
-  AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock=NULL);
+  AliHLTUInt32_t GetSpecification(const AliHLTComponentBlockData* pBlock);
 
   /**
    * Forward an input object to the output.
@@ -949,6 +1301,9 @@ class AliHLTComponent : public AliHLTLogging {
    * Insert an object into the output.
    * If header is specified, it will be inserted before the root object,
    * default is no header.
+   * The publishing can be downscaled by means of the -pushback-period
+   * parameter. This is especially useful for histograms which do not
+   * need to be sent for every event.
    * @param pObject     pointer to root object
    * @param dt          data type of the object
    * @param spec        data specification
@@ -956,7 +1311,7 @@ class AliHLTComponent : public AliHLTLogging {
    * @param headerSize  size of Header
    * @return neg. error code if failed 
    */
-  int PushBack(TObject* pObject, const AliHLTComponentDataType& dt, 
+  int PushBack(const TObject* pObject, const AliHLTComponentDataType& dt, 
               AliHLTUInt32_t spec=kAliHLTVoidDataSpec, 
               void* pHeader=NULL, int headerSize=0);
 
@@ -964,6 +1319,9 @@ class AliHLTComponent : public AliHLTLogging {
    * Insert an object into the output.
    * If header is specified, it will be inserted before the root object,
    * default is no header.
+   * The publishing can be downscaled by means of the -pushback-period
+   * parameter. This is especially useful for histograms which do not
+   * need to be sent for every event.
    * @param pObject     pointer to root object
    * @param dtID        data type ID of the object
    * @param dtOrigin    data type origin of the object
@@ -972,7 +1330,7 @@ class AliHLTComponent : public AliHLTLogging {
    * @param headerSize  size of Header
    * @return neg. error code if failed 
    */
-  int PushBack(TObject* pObject, const char* dtID, const char* dtOrigin,
+  int PushBack(const TObject* pObject, const char* dtID, const char* dtOrigin,
               AliHLTUInt32_t spec=kAliHLTVoidDataSpec,
               void* pHeader=NULL, int headerSize=0);
  
@@ -986,9 +1344,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.
@@ -1001,16 +1359,16 @@ 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
    * @param pObject
    * @return buffer size in byte
    */
-  int EstimateObjectSize(TObject* pObject) const;
+  int EstimateObjectSize(const TObject* pObject) const;
 
   /**
    * Create a memory file in the output stream.
@@ -1126,44 +1484,88 @@ class AliHLTComponent : public AliHLTLogging {
   const char* GetChainId() const {return fChainId.c_str();}
 
   /**
-   * 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 )
+   * Get a timestamp of the current event
+   * Exact format needs to be documented.
    */
-  void EnableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
-    SetDDLBit( list, ddlId, kTRUE ); 
-  }
+  AliHLTUInt32_t    GetTimeStamp() const;
 
   /**
-   * 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 )
+   * Get the period number.
+   * Upper 28 bits (36 to 63) of the 64-bit event id 
    */
-  void DisableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const { 
-    SetDDLBit( list, ddlId, kFALSE );  
-  }
-  
+  AliHLTUInt32_t    GetPeriodNumber() const;
+
   /**
-   * 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
+   * Get the period number.
+   * 24 bits, 12 to 35 of the 64-bit event id 
    */
-  void SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const;
-  
+  AliHLTUInt32_t    GetOrbitNumber() const;
+
+  /**
+   * Get the bunch crossing number.
+   * 12 bits, 0 to 12 of the 64-bit event id 
+   */
+  AliHLTUInt16_t    GetBunchCrossNumber() const;
+
+  /**
+   * Setup the CTP accounting functionality of the base class.
+   * The method can be invoked from DoInit() for componenets which want to
+   * use the CTP functionality of the base class.
+   *
+   * The AliHLTCTPData is initialized with the trigger classes from the ECS
+   * parameters. The base class automatically increments the counters according
+   * to the trigger pattern in the CDH before the event processing. 
+   */
+  int SetupCTPData();
+
+  /**
+   * Get the instance of the CTP data.
+   */
+  const AliHLTCTPData* CTPData() const {return fpCTPData;}
+
+  /**
+   * Check whether a combination of trigger classes is fired.
+   * The expression can contain trigger class ids and logic operators
+   * like &&, ||, !, and ^, and may be grouped by parentheses.
+   * @note the function requires the setup of the CTP handling for the component by
+   * invoking SetupCTPData() from DoInit()
+   * @param expression     a logic expression of trigger class ids
+   * @param trigData       the trigger data data
+   */
+  bool EvaluateCTPTriggerClass(const char* expression, AliHLTComponentTriggerData& trigData) const;
+
+  /**
+   * Check state of a trigger class.
+   * If the class name is not part of the current trigger setup (i.e. ECS parameter
+   * does not contain a trigger definition for this class name) the function
+   * returns -1
+   * @note the function requires the setup of the CTP handling for the component by
+   * invoking SetupCTPData() from DoInit()
+   * @return -1 class name not initialized, 
+   *          0 trigger not active
+   *          1 trigger active
+   */
+  int CheckCTPTrigger(const char* name) const;
+
+  /**
+   * Get the overall solenoid field.
+   */
+  Double_t GetBz();
+  /**
+   * Get the solenoid field at point r.
+   */
+  Double_t GetBz(const Double_t *r);
+  /**
+   * Get the solenoid field components at point r.
+   */
+  void GetBxByBz(const Double_t r[3], Double_t b[3]);
+
   /**
-   * 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)
+   * 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
    */
-  Int_t GetFirstUsedDDLWord(AliHLTEventDDL &list) const;
+  bool IsDataEvent(AliHLTUInt32_t* pTgt=NULL) const;
 
   /**
    * Copy a struct from block data.
@@ -1272,13 +1674,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,
@@ -1286,6 +1689,45 @@ 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,
+                             int processingLevel) const;
+
+  /**
+   * Scan the ECS parameter string.
+   * The framework provides both the parameters of CONFIGURE and ENGAGE
+   * in one string in a special data block kAliHLTDataTypeECSParam
+   * {ECSPARAM:PRIV}. The general format is
+   * <command>;<parameterkey>=<parametervalue>;<parameterkey>=<parametervalue>;...
+   */
+  int ScanECSParam(const char* ecsParam);
+
+  /**
+   * The trigger classes are determined from the trigger and propagated by
+   * ECS as part of the ENGAGE command parameter which is sent through the
+   * framework during the SOR event. This function treats the value of the
+   * parameter key CTP_TRIGGER_CLASS.
+   */
+  int InitCTPTriggerClasses(const char* ctpString);
+
+  enum {
+    kRequireSteeringBlocks = 0x1,
+    kDisableComponentStat = 0x2
+  };
+
   /** The global component handler instance */
   static AliHLTComponentHandler* fgpComponentHandler;              //! transient
 
@@ -1340,21 +1782,51 @@ class AliHLTComponent : public AliHLTLogging {
   /** descriptor of the current run */
   AliHLTRunDesc* fpRunDesc;                                        //! transient
 
-  /** the current DDL list */
-  AliHLTEventDDL* fpDDLList;                                       //! transient
-
   /** external fct to set CDB run no, indicates external CDB initialization */
-  void* fCDBSetRunNoFunc;                                          //! transient
+  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
+  /** component flags, cleared in Deinit */
+  AliHLTUInt32_t fFlags;                                           //! 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
+
+ /**  array of trigger class descriptors */
+  AliHLTCTPData* fpCTPData;                                        //! transient
+
+  /// update period for PushBack calls
+  int fPushbackPeriod;                                             //! transient
+  /// time of last executed PushBack
+  int fLastPushBackTime;                                           //! transient
+  
+  /// Event modulo for down scaling the processing rate.
+  int fEventModulo;                                                //! transient
 
-  ClassDef(AliHLTComponent, 7)
+  ClassDef(AliHLTComponent, 0)
 };
 #endif