]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTrigger.h
Changing TriggerEvent method interface to return error codes from the PushBack method...
[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.
21 */
a9670afe 22class AliHLTTrigger : public AliHLTProcessor
23{
4aa41877 24 public:
a9670afe 25
4aa41877 26 AliHLTTrigger();
27 virtual ~AliHLTTrigger();
a9670afe 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;
4aa41877 35
a9670afe 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.
1b9a175e 56 * \note The underlying non const version of GetOutputDataTypes adds the value
57 * kAliHLTDataTypeTObject to the list.
a9670afe 58 */
1b9a175e 59 virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& /*list*/) const {}
a9670afe 60
61 /**
1b9a175e 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
a9670afe 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 */
4adf50d6 69 virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
a9670afe 70
71 protected:
72
4adf50d6 73 /// Not implemented.
74 AliHLTTrigger(const AliHLTTrigger& obj);
75 /// Not implemented.
76 AliHLTTrigger& operator = (const AliHLTTrigger& obj);
77
a9670afe 78 /**
79 * This method needs to be implemented by child classes to implement the actual
1b9a175e 80 * trigger algorithm. A positive trigger decision is made by calling the TriggerEvent
a9670afe 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)
4654280e 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.
a9670afe 101 */
4654280e 102 int TriggerEvent(bool value = true);
a9670afe 103
5d79eb88 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).
4654280e 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.
5d79eb88 117 */
4654280e 118 int TriggerEvent(
5d79eb88 119 AliHLTTriggerDecision* result,
120 const AliHLTComponentDataType& type = kAliHLTDataTypeTObject|kAliHLTDataOriginOut,
121 AliHLTUInt32_t spec = kAliHLTVoidDataSpec
122 );
123
4654280e 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
a9670afe 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
4adf50d6 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
1b9a175e 170 /**
171 * Returns the DDL readout list.
172 */
173 const AliHLTReadoutList& GetReadoutList() const { return fReadoutList; }
174
4adf50d6 175 /**
176 * Returns the DDL readout list for modification by hand.
177 */
1b9a175e 178 AliHLTReadoutList& GetReadoutList() { return fReadoutList; }
4adf50d6 179
180 /**
1b9a175e 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.
4adf50d6 188 */
1b9a175e 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; }
4adf50d6 212
a9670afe 213 private:
214
215 /**
216 * Inherited from AliHLTComponent. This method will clear the fDecisionMade flag,
217 * remember the evtData and trigData pointers, then call DoTrigger to invoke the
218 * actual trigger algorithm.
219 */
220 virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
221
222 using AliHLTProcessor::DoEvent;
223
224 /**
225 * Inherited from AliHLTComponent. This method is deprecated so hide it.
226 * @return kAliHLTMultipleDataType is returned.
227 */
228 virtual AliHLTComponentDataType GetOutputDataType() { return kAliHLTMultipleDataType; };
5d79eb88 229
230 /**
231 * Inherited from AliHLTComponent. This method is deprecated so we hide it.
232 * Rather use the const version of this method which this method calls anyway.
233 * @param list list to receive the output data types.
234 */
235 virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
236
a9670afe 237 /**
238 * Inherited from AliHLTComponent. This method is replaced with one that is
239 * symmetric to GetInputDataTypes that returns void, so we make this method
1b9a175e 240 * private. The list will always contain kAliHLTDataTypeTObject, including whatever
241 * values were added by the const version of GetOutputDataTypes.
a9670afe 242 * @param list list to receive the output data types.
243 * @return the number of elements in the list.
244 */
5d79eb88 245 virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list);
4aa41877 246
1b9a175e 247 const AliHLTComponentEventData* fEventData; //! Event data for the current event. Only valid inside DoTrigger.
248 AliHLTComponentTriggerData* fTriggerData; //! Trigger data for the current event. Only valid inside DoTrigger.
249 bool fDecisionMade; //! Flag indicating if the trigger decision has been made for this trigger yet.
250 int fTriggerEventResult; //! Result returned by PushBack method in the TriggerEvent method.
251 TString fDescription; //! The description to use for the trigger decision.
252 AliHLTReadoutList fReadoutList; //! The DDL readout list object for the current event being processed.
253 AliHLTTriggerDomain fTriggerDomain; //! The trigger domain object for the current event being processed.
4aa41877 254
a9670afe 255 ClassDef(AliHLTTrigger, 0) // Base class for HLT triggers.
4aa41877 256
257};
258
a9670afe 259#endif // ALIHLTTRIGGER_H
4aa41877 260