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 */
7 /// @file AliHLTTrigger.cxx
8 /// @author Artur Szostak <artursz@iafrica.com>
10 /// @brief Declaration of the AliHLTTrigger base component class.
12 #include "AliHLTProcessor.h"
13 #include "AliHLTReadoutList.h"
14 #include "AliHLTTriggerDomain.h"
16 class AliHLTTriggerDecision;
19 * \class AliHLTTrigger
20 * This is the base class from which all HLT trigger components should inherit.
22 class AliHLTTrigger : public AliHLTProcessor
27 virtual ~AliHLTTrigger();
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.
34 virtual const char* GetTriggerName() const = 0;
37 * Inherited from AliHLTComponent. Returns the name of the trigger by default.
38 * @return string containing the trigger name as the component ID.
40 virtual const char* GetComponentID() { return GetTriggerName(); };
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.
47 virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list) const
49 list.push_back(kAliHLTAnyDataType);
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.
59 virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& /*list*/) const {}
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
67 * @param inputMultiplier <i>[out]</i>: multiplication ratio
69 virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
74 AliHLTTrigger(const AliHLTTrigger& obj);
76 AliHLTTrigger& operator = (const AliHLTTrigger& obj);
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
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
87 * @return Zero should be returned on success and a negative error code, which is
88 * compatible with the AliHLTSystem framework, on failure.
90 virtual int DoTrigger() = 0;
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
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.
102 int TriggerEvent(bool value = true);
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
112 * \returns zero on success and negative value on failure. The possible failure
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.
119 AliHLTTriggerDecision* result,
120 const AliHLTComponentDataType& type = kAliHLTDataTypeTObject|kAliHLTDataOriginOut,
121 AliHLTUInt32_t spec = kAliHLTVoidDataSpec
125 * Method for finding out the result of the last call to TriggerEvent.
126 * \returns the error code for the last call to TriggerEvent.
128 int GetLastTriggerEventResult() const { return fTriggerEventResult; }
131 * Returns the event data structure for the current event.
132 * NULL is returned if this method is not called inside the DoTrigger method.
134 const AliHLTComponentEventData* GetEventData() const { return fEventData; }
137 * Returns the trigger data structure for the current event.
138 * NULL is returned if this method is not called inside the DoTrigger method.
140 AliHLTComponentTriggerData* GetTriggerData() const { return fTriggerData; }
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.
146 void EnableDDLBit(Int_t ddlId)
148 AliHLTComponent::SetDDLBit(fReadoutList, ddlId, kTRUE);
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.
155 void DisableDDLBit(Int_t ddlId)
157 AliHLTComponent::SetDDLBit(fReadoutList, ddlId, kFALSE);
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.
165 void SetDDLBit(Int_t ddlId, Bool_t state)
167 AliHLTComponent::SetDDLBit(fReadoutList, ddlId, state);
171 * Returns the DDL readout list.
173 const AliHLTReadoutList& GetReadoutList() const { return fReadoutList; }
176 * Returns the DDL readout list for modification by hand.
178 AliHLTReadoutList& GetReadoutList() { return fReadoutList; }
181 * Sets the readout list object.
182 * \param value The new value to use for the readout list.
184 void SetReadoutList(const AliHLTReadoutList& value) { fReadoutList = value; }
187 * Returns the trigger domain object.
189 const AliHLTTriggerDomain& GetTriggerDomain() const { return fTriggerDomain; }
192 * Returns the trigger domain object for modification.
194 AliHLTTriggerDomain& GetTriggerDomain() { return fTriggerDomain; }
197 * Sets the trigger domain object.
198 * \param value The new value to use for the trigger domain.
200 void SetTriggerDomain(const AliHLTTriggerDomain& value) { fTriggerDomain = value; }
203 * Returns the trigger description string.
205 const char* GetDescription() const { return fDescription.Data(); }
208 * Sets the trigger description string.
209 * \param value The new value to use for the description string.
211 void SetDescription(const char* value) { fDescription = value; }
214 * \returns true if the trigger description, trigger domain and readout list
215 * should be cleared for each new event.
217 bool WillClearInfoForNewEvent() const { return fClearInfo; }
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.
224 void ClearInfoForNewEvent(bool value = true) { fClearInfo = value; }
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.
233 virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
235 using AliHLTProcessor::DoEvent;
238 * Inherited from AliHLTComponent. This method is deprecated so hide it.
239 * @return kAliHLTMultipleDataType is returned.
241 virtual AliHLTComponentDataType GetOutputDataType() { return kAliHLTMultipleDataType; };
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.
248 virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
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.
258 virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list);
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.
269 ClassDef(AliHLTTrigger, 0) // Base class for HLT triggers.
273 #endif // ALIHLTTRIGGER_H