]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.h
- AliHLTEsdManager: minor bufix -> correct error handling
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
index f413e378de437edfa07f9343db36818bbd38b5a0..b29115a748f4873b1b4ed0cc9328cd96c275a5b1 100644 (file)
@@ -29,7 +29,7 @@
 #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
@@ -323,6 +323,35 @@ class AliHLTComponent : public AliHLTLogging {
                            AliHLTComponentBlockDataList& outputBlocks,
                            AliHLTComponentEventDoneData*& edd ) = 0;
 
+  /**
+   * Init the CDB.
+   * The function must not be called when running in AliRoot unless it it
+   * really wanted. The CDB path will be set to the specified path, which might
+   * override the path initialized at the beginning of the AliRoot reconstruction.
+   *
+   * The method is used from the external interface in order to set the correct
+   * path when running on-line. The function also initializes the function
+   * callback for setting the run no during operation.
+   *
+   * A separation of library and component handling is maybe appropriate in the
+   * future. Using the global component handler here is maybe not the cleanest
+   * solution.
+   * @param cdbPath      path of the CDB
+   * @param pHandler     the component handler used for llibrary handling.
+   */
+  int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler);
+
+  /**
+   * Set the run no for the CDB.
+   * The function must not be called when running in AliRoot unless it it
+   * really wanted. The CDB path will be set to the specified path, which might
+   * override the run no initialized at the beginning of the AliRoot reconstruction.
+   *
+   * The method is used from the external interface in order to set the correct
+   * path when running on-line.
+   */
+  int SetCDBRunNo(int runNo);
+
   // Information member functions for registration.
 
   /**
@@ -417,7 +446,7 @@ class AliHLTComponent : public AliHLTLogging {
   /**
    * 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
@@ -429,7 +458,7 @@ 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.
@@ -461,17 +490,29 @@ class AliHLTComponent : public AliHLTLogging {
    * 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.
+   * 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.
+   * a terminating zero. <br>
+   * It is possible to pass NULL pointers as id or origin argument, in that case they
+   * are just ignored.
    * @param tgtdt   target data type structure
    * @param id      ID string
    * @param origin  Origin string
    */
   static void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
 
+  /**
+   * Set the ID and Origin of an AliHLTComponentDataType structure.
+   * Given the fact that the data type ID is 64bit wide and origin 32, this helper
+   * function sets the data type from those two parameters.
+   * @param dt      target data type structure
+   * @param id      64bit id
+   * @param orig    32bit origin
+   */
+  static void SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t orig); 
+
   /**
    * Stopwatch type for benchmarking.
    */
@@ -570,6 +611,39 @@ class AliHLTComponent : public AliHLTLogging {
    */
   virtual int DoDeinit();
 
+  /**
+   * Reconfigure the component.
+   * The method is called when an event of type @ref kAliHLTDataTypeComConf
+   * {COM_CONF:PRIV} is received by the component. If the event is sent as
+   * part of a normal event, the component configuration is called first.
+   *
+   * The CDB path parameter specifies the path in the CDB, i.e. without
+   * leading absolute path of the CDB location. The framework might alse
+   * provide the id of the component in the analysis chain.
+   *
+   * \b Note: The CDB will be initialized by the framework, either already set
+   * from AliRoot or from the wrapper interface during initialization.
+   *
+   * @param cdbEntry     path of the cdbEntry
+   * @param chainId      the id of the component in the analysis chain
+   * @note both parameters can be NULL, check before usage
+   */
+  virtual int Reconfigure(const char* cdbEntry, const char* chainId);
+
+  /**
+   * Read the Preprocessor values.
+   * The function is invoked when the component is notified about available/
+   * updated data points from the detector Preprocessors. The 'modules'
+   * argument contains all detectors for which the Preprocessors have
+   * updated data points. The component has to implement the CDB access to
+   * get the desired data points.
+   * @param modules     detectors for which the Preprocessors have updated
+   *                    data points: TPC, TRD, ITS, PHOS, MUON, or ALL if
+   *                    no argument was received.
+   * @return neg. error code if failed
+   */
+  virtual int ReadPreprocessorValues(const char* modules);
+
   /**
    * General memory allocation method.
    * All memory which is going to be used 'outside' of the interface must
@@ -621,12 +695,18 @@ 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
    * 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
@@ -634,7 +714,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);
 
@@ -697,13 +777,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.
@@ -744,6 +829,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,
@@ -919,6 +1027,46 @@ class AliHLTComponent : public AliHLTLogging {
    */
   AliHLTUInt32_t GetRunType() const;
 
+  /**
+   * Set a bit to 1 in a readout list ( = AliHLTEventDDL )
+   * -> enable DDL for readout
+   * @param list        readout list
+   * @param ddlId       DDL Id to be turned on ( Decimal )
+   */
+  void EnableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const {
+    SetDDLBit( list, ddlId, kTRUE ); 
+  }
+
+  /**
+   * Set a bit to 0 in a readout list ( = AliHLTEventDDL )
+   * -> disable DDL for readout
+   * @param list        readout list
+   * @param ddlId       DDL Id to be turned on ( Decimal )
+   */
+  void DisableDDLBit(AliHLTEventDDL &list, Int_t ddlId ) const { 
+    SetDDLBit( list, ddlId, kFALSE );  
+  }
+  
+  /**
+   * Set or unset  bit a readout list ( = AliHLTEventDDL )
+   * -> enable or disable DDL for readout
+   * @param list        readout list
+   * @param ddlId       DDL Id to be turned on ( Decimal )
+   * @param state       kTRUE sets it, kFALSE unsets it
+   */
+  void SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const;
+  
+  /**
+   * Get the first word of a detector, which has a set DDL bit. 
+   * Beware, this only works if DDLs of 1 detector are set. In the 
+   * case of the TPC and TOF, which use 8 and 3 words, the first 
+   * word is returned.
+   * @param list        readout list
+   * @return            returns the detector index, -1 if no bit is set
+   *                    at all or several detectors (=error)
+   */
+  Int_t GetFirstUsedDDLWord(AliHLTEventDDL &list) const;
+
   /**
    * Copy a struct from block data.
    * The function checks for block size and struct size. The least common
@@ -955,6 +1103,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
@@ -1084,6 +1236,12 @@ 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
+
+  ClassDef(AliHLTComponent, 6)
 };
 #endif