]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTTrigger.h
620d215fddd09e1f02c2dd7c5ae4e27f7c1ce7b9
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTrigger.h
1 #ifndef ALIHLTTRIGGER_H
2 #define ALIHLTTRIGGER_H
3 /* This file is property of and copyright by the ALICE HLT Project        * 
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  * See cxx source for full Copyright notice                               */
6
7 #include "AliHLTProcessor.h"
8
9 class AliHLTTrigger : public AliHLTProcessor
10 {
11  public:
12  
13   AliHLTTrigger();
14   virtual ~AliHLTTrigger();
15
16   /**
17    * Returns the name of the trigger. This must be unique across the system.
18    * This method is pure virtual and must be implemented by child classes.
19    * @return string containing the trigger name.
20    */
21   virtual const char* GetTriggerName() const = 0;
22   
23   /**
24    * Inherited from AliHLTComponent. Returns the name of the trigger by default.
25    * @return string containing the trigger name as the component ID.
26    */
27   virtual const char* GetComponentID() { return GetTriggerName(); };
28
29   /**
30    * Get the input data types of the component.
31    * This method returns kAliHLTAnyDataType by default.
32    * @param list <i>[out]</i>: The list of data types to be filled.
33    */
34   virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list) const
35   {
36     list.push_back(kAliHLTAnyDataType);
37   }
38
39   /**
40    * Returns extra output data types this trigger generates.
41    * This returns an empty list by default.
42    * @param list <i>[out]</i>: The list of data types to be filled.
43    */
44   virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& list) const
45   {
46     list.push_back(kAliHLTDataTypeTObject);
47   }
48
49   /**
50    * Get a ratio by how much the data volume is shrinked or enhanced.
51    * The method returns a size proporional to the trigger name string length
52    * for constBase, and 1 for inputMultiplier.
53    * @param constBase        <i>[out]</i>: additive part, independent of the
54    *                                   input data volume  
55    * @param inputMultiplier  <i>[out]</i>: multiplication ratio
56    */
57   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
58   {
59     constBase = strlen(GetTriggerName()) + sizeof(TObjString) + 1;
60     inputMultiplier = 1;
61   }
62
63  protected:
64
65   /**
66    * This method needs to be implemented by child classes to implement the actual
67    * trigger algorithm. A possitive trigger decision is made by calling the TriggerEvent
68    * method with TriggerEvent(true), or TriggerEvent(false) for a negative result
69    * (no trigger).
70    * If the AliHLTComponentEventData structure is needed for the current event being
71    * processed then the GetEventData method can be used to fetch it.
72    * Similarly, the AliHLTComponentTriggerData structure can be fetched with a call
73    * to GetTriggerData.
74    * @return Zero should be returned on success and a negative error code, which is
75    *     compatible with the AliHLTSystem framework, on failure.
76    */
77   virtual int DoTrigger() = 0;
78   
79   /**
80    * Fills the output with the trigger decision. This should be called in the DoTrigger
81    * method when a trigger decision has been made.
82    * @param value  The trigger decision value. True for positive trigger and false
83    *     for a negative result. (true by default)
84    */
85   void TriggerEvent(bool value = true);
86   
87   /**
88    * Returns the event data structure for the current event.
89    * NULL is returned if this method is not called inside the DoTrigger method.
90    */
91   const AliHLTComponentEventData* GetEventData() const { return fEventData; }
92   
93   /**
94    * Returns the trigger data structure for the current event.
95    * NULL is returned if this method is not called inside the DoTrigger method.
96    */
97   AliHLTComponentTriggerData* GetTriggerData() const { return fTriggerData; }
98
99  private:
100  
101   /**
102    * Inherited from AliHLTComponent. This method will clear the fDecisionMade flag,
103    * remember the evtData and trigData pointers, then call DoTrigger to invoke the
104    * actual trigger algorithm.
105    */
106   virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
107   
108   using AliHLTProcessor::DoEvent;
109  
110   /**
111    * Inherited from AliHLTComponent. This method is deprecated so hide it.
112    * @return kAliHLTMultipleDataType is returned.
113    */
114   virtual AliHLTComponentDataType GetOutputDataType() { return kAliHLTMultipleDataType; };
115
116   /**
117    * Inherited from AliHLTComponent. This method is replaced with one that is
118    * symmetric to GetInputDataTypes that returns void, so we make this method
119    * private.
120    * @param list     list to receive the output data types.
121    * @return the number of elements in the list.
122    */
123   virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list)
124   {
125     GetOutputDataTypes(list);
126     return list.size();
127   }
128   
129   const AliHLTComponentEventData* fEventData; ///! Event data for the current event. Only valid inside DoTrigger.
130   AliHLTComponentTriggerData* fTriggerData; ///! Trigger data for the current event. Only valid inside DoTrigger.
131   bool fDecisionMade;  ///! Flag indicating if the trigger decision has been made for this trigger yet.
132   int fTriggerEventResult;  ///! Result returned by PushBack method in the TriggerEvent method.
133   
134   ClassDef(AliHLTTrigger, 0) // Base class for HLT triggers.
135
136 };
137
138 #endif // ALIHLTTRIGGER_H
139