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