]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/trigger/AliHLTTrigger.h
remaining coverity fixes
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTrigger.h
index 64d8185ee9b4364868b9e5836fb7d13d94ce0c09..cb1c79803baa6fe4e9847bcb897fb6940fd61583 100644 (file)
@@ -1,3 +1,5 @@
+//-*- Mode: C++ -*-
+// $Id$
 #ifndef ALIHLTTRIGGER_H
 #define ALIHLTTRIGGER_H
 /* This file is property of and copyright by the ALICE HLT Project        *
 #include "AliHLTReadoutList.h"
 #include "AliHLTTriggerDomain.h"
 
+class AliHLTTriggerDecision;
+
 /**
  * \class AliHLTTrigger
  * This is the base class from which all HLT trigger components should inherit.
+ *
+ * The class implements an AliHLTProcessor and implements specific functions
+ * for the implementation of a trigger component.
+ *
+ * Mandatory functions to be implemented by the child class
+ * - GetTriggerName()                                        <br>
+ *   must return a unique char string, serves also as component id
+ * - DoTrigger()
+ *   this is the processing method. Can loop over all input blocks and
+ *   calculate a trigger decision based on the input
+ * - Spawn()
+ *   refer to AliHLTComponent::Spawn() for more details
+ *
+ * The class provides default methods for the following methods of the
+ * component interface. The methods can still be overloaded if needed:
+ * - AliHLTComponent::GetNumberOfInputBlocks()
+ * - AliHLTComponent::GetInputDataTypes()
+ * - AliHLTComponent::GetOutputDataType()
+ * - AliHLTComponent::GetOutputDataTypes()
+ * - AliHLTComponent::GetOutputDataSize()
+ *
+ * Within the DoTrigger() function, the component has access to the input
+ * data via:
+ * - AliHLTComponent::GetFirstInputObject()
+ * - AliHLTComponent::GetNextInputObject()
+ * - AliHLTComponent::GetFirstInputBlock()
+ * - AliHLTComponent::GetNextInputBlock()
+ * - GetEventData()
+ * - GetTriggerData()
+ *
+ * Further information about the event and the external trigger classes
+ * can be checked by the base class methods:
+ * - AliHLTComponent::EvaluateCTPTriggerClass()
+ * - AliHLTComponent::GetRunNo() const;
+ * - AliHLTComponent::GetRunType() const;
+ * - AliHLTComponent::GetEventId()
+ *
+ * Inside DoTrigger() the component can call TriggerEvent() to create a
+ * trigger. The trigger information is stored and propagated in an
+ * AliHLTTriggerDecision object.
+ *
+ * \ingroup alihlt_trigger_components
  */
 class AliHLTTrigger : public AliHLTProcessor
 {
@@ -28,6 +74,11 @@ class AliHLTTrigger : public AliHLTProcessor
    * Returns the name of the trigger. This must be unique across the system.
    * This method is pure virtual and must be implemented by child classes.
    * @return string containing the trigger name.
+   * \note The name returned by this method should be a valid C++ symbol name.
+   *    Otherwise the global trigger component will not be able to handle the
+   *    derived trigger component properly.
+   *    As an extention the '-' character is allowed in the symbol name,
+   *    but not as the first character.
    */
   virtual const char* GetTriggerName() const = 0;
   
@@ -40,29 +91,25 @@ class AliHLTTrigger : public AliHLTProcessor
   /**
    * Get the input data types of the component.
    * This method returns kAliHLTAnyDataType by default.
-   * @param list <i>[out]</i>: The list of data types to be filled.
+   * @param [out] list The list of data types to be filled.
    */
-  virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list) const
-  {
-    list.push_back(kAliHLTAnyDataType);
-  }
+  virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list) const;
 
   /**
    * Returns extra output data types this trigger generates.
-   * This returns an empty list by default.
-   * @param list <i>[out]</i>: The list of data types to be filled.
+   * This returns kAliHLTDataTypeTriggerDecision by default.
+   * @param [out] list The list of data types to be filled.
    * \note The underlying non const version of GetOutputDataTypes adds the value
-   *    kAliHLTDataTypeTObject to the list.
+   *    kAliHLTDataTypeReadoutList to the list automatically.
    */
-  virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& /*list*/) const {}
+  virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& list) const;
 
   /**
    * Get a ratio by how much the data volume is shrunk or enhanced.
    * The method returns a size proportional to the trigger name string length
    * for constBase, and 1 for inputMultiplier.
-   * @param constBase        <i>[out]</i>: additive part, independent of the
-   *                                   input data volume  
-   * @param inputMultiplier  <i>[out]</i>: multiplication ratio
+   * @param [out] constBase        Additive part, independent of the input data volume  
+   * @param [out] inputMultiplier  Multiplication ratio.
    */
   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
 
@@ -92,8 +139,44 @@ class AliHLTTrigger : public AliHLTProcessor
    * method when a trigger decision has been made.
    * @param value  The trigger decision value. True for positive trigger and false
    *     for a negative result. (true by default)
+   * \returns zero on success and negative value on failure. The possible failure
+   *    codes are:<br>
+   *     -ENOSPC - If there is not enough output buffer space for the trigger decision.<br>
+   *     -ENOMSG - If the trigger decision object could not be serialised.
+   */
+  int TriggerEvent(bool value = true);
+  
+  /**
+   * Fills the output with the given trigger decision. This should be called in the
+   * DoTrigger method when a custom trigger decision has been constructed.
+   * @param result    The custom trigger decision object.
+   * @param type  The data block type to use (set to
+   *    kAliHLTDataTypeTObject|kAliHLTDataOriginOut by default).
+   * @param spec  The data block specification to use (set to kAliHLTVoidDataSpec
+   *    by default).
+   * \returns zero on success and negative value on failure. The possible failure
+   *    codes are:<br>
+   *     -ENOSPC - If there is not enough output buffer space for the trigger decision.<br>
+   *     -ENOMSG - If the trigger decision object could not be serialised.<br>
+   *     -EINVAL - If the <i>result</i> object is NULL.
+   */
+  int TriggerEvent(
+      AliHLTTriggerDecision* result,
+      const AliHLTComponentDataType& type = kAliHLTDataTypeTObject|kAliHLTDataOriginOut,
+      AliHLTUInt32_t spec = kAliHLTVoidDataSpec
+    );
+  
+  /**
+   * This method allows one to completely ignore an event. The DoEvent method will
+   * not even generate a false trigger decision if this method is called.
    */
-  void TriggerEvent(bool value = true);
+  void IgnoreEvent(bool value = true) { fDecisionMade = value; }
+  
+  /**
+   * Method for finding out the result of the last call to TriggerEvent.
+   * \returns the error code for the last call to TriggerEvent.
+   */
+  int GetLastTriggerEventResult() const { return fTriggerEventResult; }
   
   /**
    * Returns the event data structure for the current event.
@@ -113,7 +196,7 @@ class AliHLTTrigger : public AliHLTProcessor
    */
   void EnableDDLBit(Int_t ddlId)
   {
-    AliHLTComponent::SetDDLBit(fReadoutList, ddlId, kTRUE);
+    fReadoutList.EnableDDLBit(ddlId);
   }
 
   /**
@@ -122,7 +205,7 @@ class AliHLTTrigger : public AliHLTProcessor
    */
   void DisableDDLBit(Int_t ddlId)
   {
-    AliHLTComponent::SetDDLBit(fReadoutList, ddlId, kFALSE);
+    fReadoutList.DisableDDLBit(ddlId);
   }
   
   /**
@@ -132,7 +215,7 @@ class AliHLTTrigger : public AliHLTProcessor
    */
   void SetDDLBit(Int_t ddlId, Bool_t state)
   {
-    AliHLTComponent::SetDDLBit(fReadoutList, ddlId, state);
+    fReadoutList.SetDDLBit(ddlId, state);
   }
   
   /**
@@ -151,6 +234,16 @@ class AliHLTTrigger : public AliHLTProcessor
    */
   void SetReadoutList(const AliHLTReadoutList& value) { fReadoutList = value; }
   
+  /**
+   * Returns the DDL readout list block specification bits to be used.
+   */
+  AliHLTUInt32_t GetReadoutListSpecBits() const { return fReadoutListSpecBits; }
+
+  /**
+   * Sets the DDL readout list block specification bits to be used.
+   */
+  void SetReadoutListSpecBits(AliHLTUInt32_t spec) { fReadoutListSpecBits = spec; }
+  
   /**
    * Returns the trigger domain object.
    */
@@ -177,6 +270,30 @@ class AliHLTTrigger : public AliHLTProcessor
    * \param value  The new value to use for the description string.
    */
   void SetDescription(const char* value) { fDescription = value; }
+  
+  /**
+   * \returns true if the trigger description, trigger domain and readout list
+   *    should be cleared for each new event.
+   */
+  bool WillClearInfoForNewEvent() const { return fClearInfo; }
+  
+  /**
+   * Sets the flag indicating in the trigger description, trigger domain and
+   * readout list should be cleared for each new event.
+   * \param value  The new value to use for the flag.
+   */
+  void ClearInfoForNewEvent(bool value = true) { fClearInfo = value; }
+
+  /**
+   * Create the EventDoneData and add the specified readout list
+   * from a Trigger domain object.
+   * @param domain   the domain as calculated by the (Global)trigger
+   * @param type     type of the readout list, defined by PubSub
+   *                  3 monitoring filter
+   *                  4 monitoring filter
+   *                  5 monitoring filter
+   */
+  int CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type);
 
  private:
  
@@ -194,7 +311,14 @@ class AliHLTTrigger : public AliHLTProcessor
    * @return kAliHLTMultipleDataType is returned.
    */
   virtual AliHLTComponentDataType GetOutputDataType() { return kAliHLTMultipleDataType; };
-
+  /**
+   * Inherited from AliHLTComponent. This method is deprecated so we hide it.
+   * Rather use the const version of this method which this method calls anyway.
+   * @param list     list to receive the output data types.
+   */
+  virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
+  
   /**
    * Inherited from AliHLTComponent. This method is replaced with one that is
    * symmetric to GetInputDataTypes that returns void, so we make this method
@@ -203,20 +327,17 @@ class AliHLTTrigger : public AliHLTProcessor
    * @param list     list to receive the output data types.
    * @return the number of elements in the list.
    */
-  virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list)
-  {
-    const AliHLTTrigger* t = this; t->GetOutputDataTypes(list);
-    list.push_back(kAliHLTDataTypeTObject);
-    return list.size();
-  }
+  virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list);
   
   const AliHLTComponentEventData* fEventData; //! Event data for the current event. Only valid inside DoTrigger.
   AliHLTComponentTriggerData* fTriggerData; //! Trigger data for the current event. Only valid inside DoTrigger.
   bool fDecisionMade;  //! Flag indicating if the trigger decision has been made for this trigger yet.
+  bool fClearInfo;  //! Flag indicating if fDescription, fReadoutList and fTriggerDomain should be cleared for each new event.
   int fTriggerEventResult;  //! Result returned by PushBack method in the TriggerEvent method.
   TString fDescription;   //! The description to use for the trigger decision.
   AliHLTReadoutList fReadoutList; //! The DDL readout list object for the current event being processed.
   AliHLTTriggerDomain fTriggerDomain; //! The trigger domain object for the current event being processed.
+  AliHLTUInt32_t fReadoutListSpecBits;  //! Readout list data block specification bits used when generating the data block.
   
   ClassDef(AliHLTTrigger, 0) // Base class for HLT triggers.