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