]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTTrigger.h
Adding trigger domain and trigger decision classes. AliHLTTrigger now produces an...
[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 /// @file   AliHLTTrigger.cxx
8 /// @author Artur Szostak <artursz@iafrica.com>
9 /// @date   12 Aug 2008
10 /// @brief  Declaration of the AliHLTTrigger base component class.
11
12 #include "AliHLTProcessor.h"
13 #include "AliHLTReadoutList.h"
14 #include "AliHLTTriggerDomain.h"
15
16 /**
17  * \class AliHLTTrigger
18  * This is the base class from which all HLT trigger components should inherit.
19  */
20 class AliHLTTrigger : public AliHLTProcessor
21 {
22  public:
23  
24   AliHLTTrigger();
25   virtual ~AliHLTTrigger();
26
27   /**
28    * Returns the name of the trigger. This must be unique across the system.
29    * This method is pure virtual and must be implemented by child classes.
30    * @return string containing the trigger name.
31    */
32   virtual const char* GetTriggerName() const = 0;
33   
34   /**
35    * Inherited from AliHLTComponent. Returns the name of the trigger by default.
36    * @return string containing the trigger name as the component ID.
37    */
38   virtual const char* GetComponentID() { return GetTriggerName(); };
39
40   /**
41    * Get the input data types of the component.
42    * This method returns kAliHLTAnyDataType by default.
43    * @param list <i>[out]</i>: The list of data types to be filled.
44    */
45   virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list) const
46   {
47     list.push_back(kAliHLTAnyDataType);
48   }
49
50   /**
51    * Returns extra output data types this trigger generates.
52    * This returns an empty list by default.
53    * @param list <i>[out]</i>: The list of data types to be filled.
54    * \note The underlying non const version of GetOutputDataTypes adds the value
55    *    kAliHLTDataTypeTObject to the list.
56    */
57   virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& /*list*/) const {}
58
59   /**
60    * Get a ratio by how much the data volume is shrunk or enhanced.
61    * The method returns a size proportional to the trigger name string length
62    * for constBase, and 1 for inputMultiplier.
63    * @param constBase        <i>[out]</i>: additive part, independent of the
64    *                                   input data volume  
65    * @param inputMultiplier  <i>[out]</i>: multiplication ratio
66    */
67   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
68
69  protected:
70
71   /// Not implemented.
72   AliHLTTrigger(const AliHLTTrigger& obj);
73   /// Not implemented.
74   AliHLTTrigger& operator = (const AliHLTTrigger& obj);
75
76   /**
77    * This method needs to be implemented by child classes to implement the actual
78    * trigger algorithm. A positive trigger decision is made by calling the TriggerEvent
79    * method with TriggerEvent(true), or TriggerEvent(false) for a negative result
80    * (no trigger).
81    * If the AliHLTComponentEventData structure is needed for the current event being
82    * processed then the GetEventData method can be used to fetch it.
83    * Similarly, the AliHLTComponentTriggerData structure can be fetched with a call
84    * to GetTriggerData.
85    * @return Zero should be returned on success and a negative error code, which is
86    *     compatible with the AliHLTSystem framework, on failure.
87    */
88   virtual int DoTrigger() = 0;
89   
90   /**
91    * Fills the output with the trigger decision. This should be called in the DoTrigger
92    * method when a trigger decision has been made.
93    * @param value  The trigger decision value. True for positive trigger and false
94    *     for a negative result. (true by default)
95    */
96   void TriggerEvent(bool value = true);
97   
98   /**
99    * Returns the event data structure for the current event.
100    * NULL is returned if this method is not called inside the DoTrigger method.
101    */
102   const AliHLTComponentEventData* GetEventData() const { return fEventData; }
103   
104   /**
105    * Returns the trigger data structure for the current event.
106    * NULL is returned if this method is not called inside the DoTrigger method.
107    */
108   AliHLTComponentTriggerData* GetTriggerData() const { return fTriggerData; }
109
110   /**
111    * Set a bit to 1 in the readout list which will enable that DDL for readout
112    * @param ddlId     Equipment ID of DDL to readout, in decimal.
113    */
114   void EnableDDLBit(Int_t ddlId)
115   {
116     AliHLTComponent::SetDDLBit(fReadoutList, ddlId, kTRUE);
117   }
118
119   /**
120    * Set a bit to 0 in the readout list which will exclude that DDL from the readout.
121    * @param ddlId     Equipment ID of DDL not to readout, in decimal.
122    */
123   void DisableDDLBit(Int_t ddlId)
124   {
125     AliHLTComponent::SetDDLBit(fReadoutList, ddlId, kFALSE);
126   }
127   
128   /**
129    * Set or unset bit in the readout list.
130    * @param ddlId     Equipment ID of DDL to set, in decimal.
131    * @param state     kTRUE will enable readout of that DDL, kFALSE will disable readout.
132    */
133   void SetDDLBit(Int_t ddlId, Bool_t state)
134   {
135     AliHLTComponent::SetDDLBit(fReadoutList, ddlId, state);
136   }
137   
138   /**
139    * Returns the DDL readout list.
140    */
141   const AliHLTReadoutList& GetReadoutList() const { return fReadoutList; }
142
143   /**
144    * Returns the DDL readout list for modification by hand.
145    */
146   AliHLTReadoutList& GetReadoutList() { return fReadoutList; }
147
148   /**
149    * Sets the readout list object.
150    * \param value  The new value to use for the readout list.
151    */
152   void SetReadoutList(const AliHLTReadoutList& value) { fReadoutList = value; }
153   
154   /**
155    * Returns the trigger domain object.
156    */
157   const AliHLTTriggerDomain& GetTriggerDomain() const { return fTriggerDomain; }
158
159   /**
160    * Returns the trigger domain object for modification.
161    */
162   AliHLTTriggerDomain& GetTriggerDomain() { return fTriggerDomain; }
163
164   /**
165    * Sets the trigger domain object.
166    * \param value  The new value to use for the trigger domain.
167    */
168   void SetTriggerDomain(const AliHLTTriggerDomain& value) { fTriggerDomain = value; }
169   
170   /**
171    * Returns the trigger description string.
172    */
173   const char* GetDescription() const { return fDescription.Data(); }
174   
175   /**
176    * Sets the trigger description string.
177    * \param value  The new value to use for the description string.
178    */
179   void SetDescription(const char* value) { fDescription = value; }
180
181  private:
182  
183   /**
184    * Inherited from AliHLTComponent. This method will clear the fDecisionMade flag,
185    * remember the evtData and trigData pointers, then call DoTrigger to invoke the
186    * actual trigger algorithm.
187    */
188   virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
189   
190   using AliHLTProcessor::DoEvent;
191  
192   /**
193    * Inherited from AliHLTComponent. This method is deprecated so hide it.
194    * @return kAliHLTMultipleDataType is returned.
195    */
196   virtual AliHLTComponentDataType GetOutputDataType() { return kAliHLTMultipleDataType; };
197
198   /**
199    * Inherited from AliHLTComponent. This method is replaced with one that is
200    * symmetric to GetInputDataTypes that returns void, so we make this method
201    * private. The list will always contain kAliHLTDataTypeTObject, including whatever
202    * values were added by the const version of GetOutputDataTypes.
203    * @param list     list to receive the output data types.
204    * @return the number of elements in the list.
205    */
206   virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list)
207   {
208     const AliHLTTrigger* t = this; t->GetOutputDataTypes(list);
209     list.push_back(kAliHLTDataTypeTObject);
210     return list.size();
211   }
212   
213   const AliHLTComponentEventData* fEventData; //! Event data for the current event. Only valid inside DoTrigger.
214   AliHLTComponentTriggerData* fTriggerData; //! Trigger data for the current event. Only valid inside DoTrigger.
215   bool fDecisionMade;  //! Flag indicating if the trigger decision has been made for this trigger yet.
216   int fTriggerEventResult;  //! Result returned by PushBack method in the TriggerEvent method.
217   TString fDescription;   //! The description to use for the trigger decision.
218   AliHLTReadoutList fReadoutList; //! The DDL readout list object for the current event being processed.
219   AliHLTTriggerDomain fTriggerDomain; //! The trigger domain object for the current event being processed.
220   
221   ClassDef(AliHLTTrigger, 0) // Base class for HLT triggers.
222
223 };
224
225 #endif // ALIHLTTRIGGER_H
226