3 #ifndef ALIHLTTRIGGERMENU_H
4 #define ALIHLTTRIGGERMENU_H
5 /* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
9 /// @file AliHLTTriggerMenu.h
10 /// @author Artur Szostak <artursz@iafrica.com>
12 /// @brief Declaration of the AliHLTTriggerMenu base class.
16 #include "TClonesArray.h"
17 #include "AliHLTTriggerMenuSymbol.h"
18 #include "AliHLTTriggerMenuItem.h"
19 #include "AliHLTTriggerDomain.h"
22 * \class AliHLTTriggerMenu
23 * The trigger menu specifies the HLT global trigger component configuration.
24 * The global trigger has a list of individual input trigger components deriving
25 * from AliHLTTrigger. Each one of these triggers is named. Thus, the trigger menu
26 * is a list of trigger condition expressions, where the variables inside the
27 * expressions are the names of the input triggers. In this way the global trigger
28 * can be configured in a powerful manner using C++ expressions.
29 * Attached to each trigger condition expression is a trigger domain merging
30 * expression, which indicates how the final global trigger domain should be
31 * calculated from the fragments coming from each individual trigger component.
32 * Each entry in the trigger menu has a priority. These are set explicitly and
33 * set to zero by default. The higher the priority number for a menu item the
34 * higher its priority. Multiple items can have the same priority values.
36 * An important concept is the trigger priority group. This is a number of menu
37 * items that all have the same priority. If all trigger menu items have the
38 * same priority value then there is only one priority group with all the items
39 * being members of the same group. Otherwise there can be any number of priority
40 * groups with any number of one or more trigger menu items in a group.
41 * A trigger menu item belongs to priority group N if it has a priority number equal
42 * to N. The trigger menu is then evaluated by the global trigger component, such
43 * that the highest priority trigger groups (largest N) are evaluated first.
44 * Trigger items within a priority group are then evaluated in the order they
45 * were added to the trigger menu. Thus, the first item added to the menu in group
46 * N is evaluated first, and the last added to group N is evaluated last.
47 * Inside a priority group all trigger menu items have their trigger condition
48 * expressions evaluated. This is equivalent to evaluating the group's trigger
49 * condition expression, where the group's expression is a concatenation of the
50 * individual trigger condition expressions of the items in priority group N.
51 * This means that the trigger conditions expressions (indeed, also the trigger
52 * domain merging expressions) are allowed to have a dangling trailing operator.
53 * The trailing operator will then make sense in the full concatenated expression.
54 * If no such trailing operator is found then the default trigger conditions operator
55 * is used implicitly for the concatenation, as defined in the trigger menu.
56 * If the full concatenated condition expression evaluates to true then the priority
57 * group's result is also true and the output trigger domain can be calculated.
58 * This is done by taking all the merging expressions from only those trigger menu
59 * items whose trigger condition expression fragments were true, and concatenating
60 * those merging expression fragments together to arrive at the full merging expression.
61 * The final trigger domain is calculated by evaluating the merging expression.
62 * Note that the concatenation of the merging expression fragments works in the
63 * same manner as the trigger condition expressions. So a trailing operator is
64 * allowed in each trigger menu item's merging expression, and is implicitly removed
65 * if not needed, but used to concatenate with the next triggered expression.
66 * The default domain merging operator is used if no trailing operator is present
67 * but a concatenation is required.
68 * The evaluation of trigger menu items stops at the first priority group whose
69 * trigger condition expression evaluated to true. This is important to force
70 * mutually exclusive precedence of a higher priority trigger or triggers.
71 * The two extremes of this model are:
72 * - All trigger menu entries have the same priority so they are all part of the
73 * same priority group, and thus every trigger menu item is evaluated.
74 * - Every trigger menu entry has a different priority, so each forms its own priority
75 * group, and the trigger evaluation stops at the first highest priority item
76 * that matches the trigger condition.
77 * Another way to look at the model is that priority groups are mutually exclusive.
78 * Trigger menu items from two different priority groups cannot be active at the same
79 * time. While more than one trigger menu item can be active at the same time if they
80 * are from the same priority group.
81 * Yet another view at the model is that a priority group forms an explicit trigger
82 * condition and trigger domain merging expression, while trigger menu items specify
83 * the expression fragments that are concatenated together implicitly. If there is
84 * just one trigger menu item in a priority group then the groups expressions are
85 * explicit. On the other hand, for multiple items in a group they form implicit
86 * expression fragments.
88 * \note CTP trigger class names can be used in the trigger menu since the global
89 * trigger will generate and add corresponding trigger decision objects to the
91 * In addition, for software triggers, a special SOFTWARE trigger decision is
92 * generated and the SOFTWARE name can be used in the trigger menu for this.
93 * If the software trigger is a calibration event then a trigger decision with
94 * the name CALIBRATION is generated instead. START_OF_DATA and END_OF_DATA
95 * symbols are similarly defined for the start and end of data events respectively.
97 class AliHLTTriggerMenu : public TObject
102 * Default constructor.
107 * Default destructor.
109 virtual ~AliHLTTriggerMenu();
112 * Inherited from TObject, this prints the contents of the trigger menu.
113 * \param option Can be "short" which will print the short format.
115 virtual void Print(Option_t* option = "") const;
118 * This method removes all items and symbols from the trigger menu.
119 * \note The name and default values are not changed. Only the items and symbol
121 * \param option This is passed onto the internal fSymbols and fItems TClonesArrays.
122 * The method is inherited from TObject.
124 virtual void Clear(Option_t* option = "");
127 * Copy constructor performs a deep copy of the object.
128 * \param obj Object to copy from.
130 AliHLTTriggerMenu(const AliHLTTriggerMenu& obj);
133 * Assignment operator performs a deep copy of the object.
134 * \param obj Object to copy from.
135 * \return This object is returned after being replaced by a copy of <i>obj</i>.
137 AliHLTTriggerMenu& operator = (const AliHLTTriggerMenu& obj);
140 * Inherited from TObject. Returns the name of the trigger menu.
142 virtual const char* GetName() const { return fName.Data(); }
145 * Returns the name of the trigger menu.
147 const char* Name() const { return fName.Data(); }
150 * Sets the name of the trigger menu.
152 void Name(const char* name) { fName = name; }
155 * Returns the number of symbols in the trigger menu.
157 UInt_t NumberOfSymbols() const { return UInt_t(fSymbols.GetEntriesFast()); }
160 * Fetches the i'th trigger menu symbol.
162 const AliHLTTriggerMenuSymbol* Symbol(UInt_t i) const
164 if (i >= UInt_t(fSymbols.GetEntriesFast())) return NULL;
165 return static_cast<const AliHLTTriggerMenuSymbol*>( fSymbols.UncheckedAt(Int_t(i)) );
169 * Fetches the i'th trigger menu symbol for editing.
171 AliHLTTriggerMenuSymbol* Symbol(UInt_t i)
173 if (i >= UInt_t(fSymbols.GetEntriesFast())) return NULL;
174 return static_cast<AliHLTTriggerMenuSymbol*>( fSymbols.UncheckedAt(Int_t(i)) );
178 * Adds a new symbol to the trigger menu. If the symbol being added already
179 * exists in the trigger menu then the new symbol will not be added.
180 * \param entry The new trigger menu symbol being added.
182 void AddSymbol(const AliHLTTriggerMenuSymbol& entry);
185 * Returns the array of symbols.
187 const TClonesArray& SymbolArray() const { return fSymbols; }
190 * Returns the number of items in the trigger menu.
192 UInt_t NumberOfItems() const { return UInt_t(fItems.GetEntriesFast()); }
195 * Fetches the i'th trigger menu item.
197 const AliHLTTriggerMenuItem* Item(UInt_t i) const
199 if (i >= UInt_t(fItems.GetEntriesFast())) return NULL;
200 return static_cast<const AliHLTTriggerMenuItem*>( fItems.UncheckedAt(Int_t(i)) );
204 * Fetches the i'th trigger menu item for editing.
206 AliHLTTriggerMenuItem* Item(UInt_t i)
208 if (i >= UInt_t(fItems.GetEntriesFast())) return NULL;
209 return static_cast<AliHLTTriggerMenuItem*>( fItems.UncheckedAt(Int_t(i)) );
213 * Adds a new entry to the trigger menu.
215 void AddItem(const AliHLTTriggerMenuItem& entry)
217 new (fItems[fItems.GetEntriesFast()]) AliHLTTriggerMenuItem(entry);
221 * Returns the array of menu items.
223 const TClonesArray& ItemsArray() const { return fItems; }
226 * Sets the default trigger description to use if the global trigger does not
227 * fire and returns a negative result.
229 void DefaultDescription(const char* value) { fDefaultDescription = value; }
232 * Returns the default trigger description to use if the global trigger does not
233 * fire and returns a negative result.
235 const char* DefaultDescription() const { return fDefaultDescription.Data(); }
238 * Sets the default trigger domain to use if the global trigger does not
239 * fire and returns a negative result.
241 void DefaultTriggerDomain(const AliHLTTriggerDomain& value) { fDefaultDomain = value; }
244 * Returns the default trigger domain to use if the global trigger does not
245 * fire and returns a negative result.
247 const AliHLTTriggerDomain& DefaultTriggerDomain() const { return fDefaultDomain; }
250 * Returns the default trigger domain for modification.
252 AliHLTTriggerDomain& DefaultTriggerDomain() { return fDefaultDomain; }
255 * Sets the default operator used to merge trigger conditions that are matched from
256 * the same trigger menu priority group.
258 void DefaultConditionOperator(const char* value) { fDefaultConditionOperator = value; }
261 * Returns the default operator used to merge trigger conditions that are matched from
262 * the same trigger menu priority group.
264 const char* DefaultConditionOperator() const { return fDefaultConditionOperator.Data(); }
267 * Sets the default operator used to merge trigger domains that are matched from
268 * the same trigger menu priority group.
270 void DefaultDomainOperator(const char* value) { fDefaultDomainOperator = value; }
273 * Returns the default operator used to merge trigger domains that are matched from
274 * the same trigger menu priority group.
276 const char* DefaultDomainOperator() const { return fDefaultDomainOperator.Data(); }
279 * Returns the default result for the global trigger if no item is matched.
281 bool DefaultResult() const { return TestBit(BIT(15)) == 1; }
284 * Set the default result for the global trigger if no item is matched.
286 void DefaultResult(bool value) { SetBit(BIT(15), value); }
290 TString fName; /// Name of the trigger menu.
291 TClonesArray fSymbols; /// List of symbols used in trigger expressions.
292 TClonesArray fItems; /// List of trigger menu items.
293 TString fDefaultDescription; /// The default trigger description to use for negative global triggers.
294 AliHLTTriggerDomain fDefaultDomain; /// The default trigger domain to use for negative global triggers.
295 TString fDefaultConditionOperator; /// The default operator to use to merge trigger conditions from the same priority group.
296 TString fDefaultDomainOperator; /// The default operator to use to merge trigger domains from the same priority group.
298 ClassDef(AliHLTTriggerMenu, 4) // Trigger menu for the global HLT trigger.
301 #endif // ALIHLTTRIGGERMENU_H