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