]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.h
- added libAliHLTRCU to default libraries
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.h
index 529bf6bbf4222dff6c04f86a6febaa30f4e57f68..a17a859979302c33480c8742605fd9dc5d448744 100644 (file)
@@ -47,8 +47,18 @@ 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 pointers */
+typedef vector<AliHLTComponent*>          AliHLTComponentPList;
+/** list of memory file pointers */
+typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
+
 /**
  * @class AliHLTComponent
  * Base class of HLT data processing components.
@@ -140,7 +150,7 @@ class AliHLTMemoryFile;
  * error/return code. Preferably the system error codes are used like
  * e.g. -EINVAL. This requires to include the header
  * <pre>
- * #include <cerrno>
+ * \#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
@@ -310,9 +320,38 @@ 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.
+   *
+   * 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.
 
   /**
@@ -335,7 +374,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.
@@ -353,7 +392,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.
@@ -381,7 +420,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.
@@ -397,13 +436,17 @@ 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);
 
   /**
    * 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
@@ -415,7 +458,60 @@ 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); 
 
   /**
    * Stopwatch type for benchmarking.
@@ -503,47 +599,6 @@ class AliHLTComponent : public AliHLTLogging {
 
  protected:
 
-  /**
-   * Fill AliHLTComponentBlockData structure with default values.
-   * @param blockData   reference to data structure
-   */
-  void FillBlockData( AliHLTComponentBlockData& blockData ) const;
-
-  /**
-   * Fill AliHLTComponentShmData structure with default values.
-   * @param shmData   reference to data structure
-   */
-  void FillShmData( AliHLTComponentShmData& shmData ) const;
-
-  /**
-   * Fill AliHLTComponentDataType structure with default values.
-   * @param dataType   reference to data structure
-   */
-  void FillDataType( AliHLTComponentDataType& dataType ) const;
-  
-  /**
-   * Copy data type structure
-   * Copies the value an AliHLTComponentDataType structure to another one
-   * @param[out] tgtdt   target structure
-   * @param[in] srcdt   source structure
-   */
-  void CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt);
-
-  /**
-   * Set the ID and Origin of an AliHLTComponentDataType structure.
-   * The function sets the fStructureSize member and copies the strings
-   * to the ID and Origin. Only characters from the valid part of the string
-   * are copied, the rest is fille with 0's.
-   * Please note that the fID and fOrigin members are not strings, just arrays of
-   * chars of size @ref kAliHLTComponentDataTypefIDsize and
-   * @ref kAliHLTComponentDataTypefOriginSize respectively and not necessarily with
-   * a terminating zero.
-   * @param tgtdt   target data type structure
-   * @param id      ID string
-   * @param origin  Origin string
-   */
-  void SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin);
-
   /**
    * Default method for the internal initialization.
    * The method is called by @ref Init
@@ -556,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
@@ -575,7 +663,7 @@ class AliHLTComponent : public AliHLTLogging {
    * framework. Function pointers are transferred via the @ref
    * AliHLTComponentEnvironment structure.
    */
-  int MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
+  int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
                               AliHLTComponentBlockData** outputBlocks );
 
   /**
@@ -730,6 +818,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,
@@ -905,6 +1016,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
@@ -1056,13 +1207,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
@@ -1070,6 +1221,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, 5)
 };
 #endif