2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
6 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
7 * for The ALICE HLT Project. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /// @file AliHLTGlobalTriggerConfig.cxx
19 /// @author Artur Szostak <artursz@iafrica.com>
21 /// @brief Implementation of the AliHLTGlobalTriggerConfig class.
23 /// The AliHLTGlobalTriggerConfigComponent class is an interface class used to create
24 /// global HLT trigger menu configurations.
26 #include "AliHLTGlobalTriggerConfig.h"
27 #include "AliHLTTriggerMenu.h"
28 #include "Riostream.h"
30 ClassImp(AliHLTGlobalTriggerConfig)
32 AliHLTTriggerMenu* AliHLTGlobalTriggerConfig::fgMenu = NULL;
35 AliHLTGlobalTriggerConfig::AliHLTGlobalTriggerConfig(const char* name)
37 // Default constructor.
43 AliHLTGlobalTriggerConfig::~AliHLTGlobalTriggerConfig()
45 // Default destructor.
49 void AliHLTGlobalTriggerConfig::NewMenu(const char* name)
51 // Creates a new trigger menu.
58 fgMenu = new AliHLTTriggerMenu;
63 void AliHLTGlobalTriggerConfig::Clear()
65 // Deletes the current trigger menu.
75 void AliHLTGlobalTriggerConfig::AddSymbol(
76 const char* name, const char* type, const char* defaultExpr
79 // Adds a new constant symbol to the trigger menu.
81 if (fgMenu == NULL) NewMenu("");
83 AliHLTTriggerMenuSymbol entry;
86 entry.ObjectClass("");
87 entry.AssignExpression("");
88 entry.DefaultValue(defaultExpr);
89 fgMenu->AddSymbol(entry);
93 void AliHLTGlobalTriggerConfig::AddSymbol(
94 const char* name, const char* type, const char* assignExpr,
95 const char* defaultExpr, const char* className
98 // Adds a new symbol to the trigger menu.
100 if (fgMenu == NULL) NewMenu("");
102 AliHLTTriggerMenuSymbol entry;
105 entry.ObjectClass(className);
106 entry.AssignExpression(assignExpr);
107 entry.DefaultValue(defaultExpr);
108 fgMenu->AddSymbol(entry);
112 void AliHLTGlobalTriggerConfig::AddSymbol(
113 const char* name, const char* type, const char* assignExpr,
114 const char* defaultExpr, const char* className,
115 const AliHLTComponentDataType& blockType
118 // Adds a new symbol to the trigger menu.
120 if (fgMenu == NULL) NewMenu("");
122 AliHLTTriggerMenuSymbol entry;
125 entry.ObjectClass(className);
126 entry.AssignExpression(assignExpr);
127 entry.DefaultValue(defaultExpr);
128 entry.BlockType(blockType);
129 fgMenu->AddSymbol(entry);
133 void AliHLTGlobalTriggerConfig::AddSymbol(
134 const char* name, const char* type, const char* assignExpr,
135 const char* defaultExpr, const char* className,
136 const AliHLTComponentDataType& blockType, UInt_t spec
139 // Adds a new symbol to the trigger menu.
141 if (fgMenu == NULL) NewMenu("");
143 AliHLTTriggerMenuSymbol entry;
146 entry.ObjectClass(className);
147 entry.AssignExpression(assignExpr);
148 entry.DefaultValue(defaultExpr);
149 entry.BlockType(blockType, spec);
150 fgMenu->AddSymbol(entry);
154 void AliHLTGlobalTriggerConfig::AddSymbol(
155 const char* name, const char* type, const char* assignExpr,
156 const char* defaultExpr, const char* className,
157 const char* blockType, const char* origin
160 // Adds a new symbol to the trigger menu.
162 if (fgMenu == NULL) NewMenu("");
164 AliHLTTriggerMenuSymbol entry;
167 entry.ObjectClass(className);
168 entry.AssignExpression(assignExpr);
169 entry.DefaultValue(defaultExpr);
170 entry.BlockType(blockType, origin);
171 fgMenu->AddSymbol(entry);
175 void AliHLTGlobalTriggerConfig::AddSymbol(
176 const char* name, const char* type, const char* assignExpr,
177 const char* defaultExpr, const char* className,
178 const char* blockType, const char* origin, UInt_t spec
181 // Adds a new symbol to the trigger menu.
183 if (fgMenu == NULL) NewMenu("");
185 AliHLTTriggerMenuSymbol entry;
188 entry.ObjectClass(className);
189 entry.AssignExpression(assignExpr);
190 entry.DefaultValue(defaultExpr);
191 entry.BlockType(blockType, origin, spec);
192 fgMenu->AddSymbol(entry);
196 void AliHLTGlobalTriggerConfig::AddItem(
197 UInt_t priority, const char* conditionExpr, const char* domainExpr,
198 UInt_t prescalar, const char* description, bool defaultResult
201 // Adds a new entry to the trigger menu with a particular priority.
203 if (fgMenu == NULL) NewMenu("");
205 AliHLTTriggerMenuItem entry;
206 entry.TriggerCondition(conditionExpr);
207 entry.MergeExpression(domainExpr);
208 entry.PreScalar(prescalar);
209 entry.Priority(priority);
210 entry.DefaultResult(defaultResult);
211 if (description != NULL) entry.Description(description);
212 fgMenu->AddItem(entry);
216 void AliHLTGlobalTriggerConfig::AddItem(
217 UInt_t priority, const char* conditionExpr, const char* domainExpr,
218 const char* description, Double_t scaledown, bool defaultResult
221 // Adds a new entry to the trigger menu with a particular priority.
225 cerr << "ERROR: Cannot have a scale-down value smaller than 0. But a value of "
226 << scaledown << " was specified. The valid range is [0..100]." << endl;
231 cerr << "ERROR: Cannot have a scale-down value larger than 100. But a value of "
232 << scaledown << " was specified. The valid range is [0..100]." << endl;
236 if (fgMenu == NULL) NewMenu("");
238 AliHLTTriggerMenuItem entry;
239 entry.TriggerCondition(conditionExpr);
240 entry.MergeExpression(domainExpr);
241 entry.Priority(priority);
242 entry.ScaleDown(scaledown / 100.);
243 entry.DefaultResult(defaultResult);
244 if (description != NULL) entry.Description(description);
245 fgMenu->AddItem(entry);
249 void AliHLTGlobalTriggerConfig::AddItem(
250 const char* conditionExpr, const char* domainExpr, UInt_t prescalar,
251 const char* description
254 // Adds a new entry to the trigger menu.
256 if (fgMenu == NULL) NewMenu("");
258 AliHLTTriggerMenuItem entry;
259 entry.TriggerCondition(conditionExpr);
260 entry.MergeExpression(domainExpr);
261 entry.PreScalar(prescalar);
262 if (description != NULL) entry.Description(description);
263 fgMenu->AddItem(entry);
267 void AliHLTGlobalTriggerConfig::AddItem(
268 const char* conditionExpr, const char* domainExpr, const char* description
271 // Adds a new entry to the trigger menu.
273 if (fgMenu == NULL) NewMenu("");
275 AliHLTTriggerMenuItem entry;
276 entry.TriggerCondition(conditionExpr);
277 entry.MergeExpression(domainExpr);
278 if (description != NULL) entry.Description(description);
279 fgMenu->AddItem(entry);
283 void AliHLTGlobalTriggerConfig::SetDefaultTriggerDescription(const char* description)
285 // Sets the default trigger decription.
287 if (fgMenu == NULL) NewMenu("");
288 fgMenu->DefaultDescription(description);
292 void AliHLTGlobalTriggerConfig::SetDefaultTriggerDomain(const AliHLTTriggerDomain& domain)
294 // Sets the default trigger domain.
296 if (fgMenu == NULL) NewMenu("");
297 fgMenu->DefaultTriggerDomain(domain);
301 AliHLTTriggerDomain& AliHLTGlobalTriggerConfig::DefaultTriggerDomain()
303 // Returns the default trigger domain for the current trigger menu.
305 if (fgMenu == NULL) NewMenu("");
306 return fgMenu->DefaultTriggerDomain();
310 void AliHLTGlobalTriggerConfig::SetDefaultConditionOperator(const char* op)
312 // Sets the default operator for trigger condition merging.
314 if (fgMenu == NULL) NewMenu("");
315 fgMenu->DefaultConditionOperator(op);
319 void AliHLTGlobalTriggerConfig::SetDefaultDomainOperator(const char* op)
321 // Sets the default operator for trigger domain merging.
323 if (fgMenu == NULL) NewMenu("");
324 fgMenu->DefaultDomainOperator(op);
328 void AliHLTGlobalTriggerConfig::SetDefaultResult(bool value)
330 // Sets the default result when no item is matched.
332 if (fgMenu == NULL) NewMenu("");
333 fgMenu->DefaultResult(value);
337 void AliHLTGlobalTriggerConfig::Print(Option_t* option) const
339 // Prints the contents of the current trigger menu being manipulated.
343 fgMenu->Print(option);
347 cout << "No trigger menu currently being configured, it is empty." << endl;