]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTGlobalTriggerConfig.cxx
added EMCAL electron trigger component and related modifications
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTriggerConfig.cxx
1 // $Id$
2 /**************************************************************************
3  * This file is property of and copyright by the ALICE HLT Project        *
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  *                                                                        *
6  * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
7  *                  for The ALICE HLT Project.                            *
8  *                                                                        *
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  **************************************************************************/
17
18 /// @file   AliHLTGlobalTriggerConfig.cxx
19 /// @author Artur Szostak <artursz@iafrica.com>
20 /// @date   28 Dec 2008
21 /// @brief  Implementation of the AliHLTGlobalTriggerConfig class.
22 ///
23 /// The AliHLTGlobalTriggerConfigComponent class is an interface class used to create
24 /// global HLT trigger menu configurations.
25
26 #include "AliHLTGlobalTriggerConfig.h"
27 #include "AliHLTTriggerMenu.h"
28 #include "Riostream.h"
29
30 ClassImp(AliHLTGlobalTriggerConfig)
31
32 AliHLTTriggerMenu* AliHLTGlobalTriggerConfig::fgMenu = NULL;
33
34
35 AliHLTGlobalTriggerConfig::AliHLTGlobalTriggerConfig(const char* name)
36 {
37   // Default constructor.
38   
39   NewMenu(name);
40 }
41
42
43 AliHLTGlobalTriggerConfig::~AliHLTGlobalTriggerConfig()
44 {
45   // Default destructor.
46 }
47
48
49 void AliHLTGlobalTriggerConfig::NewMenu(const char* name)
50 {
51   // Creates a new trigger menu.
52   
53   if (fgMenu != NULL)
54   {
55     delete fgMenu;
56     fgMenu = NULL;
57   }
58   fgMenu = new AliHLTTriggerMenu;
59   fgMenu->Name(name);
60 }
61
62
63 void AliHLTGlobalTriggerConfig::Clear()
64 {
65   // Deletes the current trigger menu.
66   
67   if (fgMenu != NULL)
68   {
69     delete fgMenu;
70     fgMenu = NULL;
71   }
72 }
73
74
75 void AliHLTGlobalTriggerConfig::AddSymbol(
76     const char* name, const char* type, const char* defaultExpr
77   )
78 {
79   // Adds a new constant symbol to the trigger menu.
80   
81   if (fgMenu == NULL) NewMenu("");
82   
83   AliHLTTriggerMenuSymbol entry;
84   entry.Name(name);
85   entry.Type(type);
86   entry.ObjectClass("");
87   entry.AssignExpression("");
88   entry.DefaultValue(defaultExpr);
89   fgMenu->AddSymbol(entry);
90 }
91
92
93 void AliHLTGlobalTriggerConfig::AddSymbol(
94     const char* name, const char* type, const char* assignExpr,
95     const char* defaultExpr, const char* className
96   )
97 {
98   // Adds a new symbol to the trigger menu.
99   
100   if (fgMenu == NULL) NewMenu("");
101   
102   AliHLTTriggerMenuSymbol entry;
103   entry.Name(name);
104   entry.Type(type);
105   entry.ObjectClass(className);
106   entry.AssignExpression(assignExpr);
107   entry.DefaultValue(defaultExpr);
108   fgMenu->AddSymbol(entry);
109 }
110
111
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
116   )
117 {
118   // Adds a new symbol to the trigger menu.
119   
120   if (fgMenu == NULL) NewMenu("");
121   
122   AliHLTTriggerMenuSymbol entry;
123   entry.Name(name);
124   entry.Type(type);
125   entry.ObjectClass(className);
126   entry.AssignExpression(assignExpr);
127   entry.DefaultValue(defaultExpr);
128   entry.BlockType(blockType);
129   fgMenu->AddSymbol(entry);
130 }
131
132
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
137   )
138 {
139   // Adds a new symbol to the trigger menu.
140   
141   if (fgMenu == NULL) NewMenu("");
142   
143   AliHLTTriggerMenuSymbol entry;
144   entry.Name(name);
145   entry.Type(type);
146   entry.ObjectClass(className);
147   entry.AssignExpression(assignExpr);
148   entry.DefaultValue(defaultExpr);
149   entry.BlockType(blockType, spec);
150   fgMenu->AddSymbol(entry);
151 }
152
153
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
158   )
159 {
160   // Adds a new symbol to the trigger menu.
161   
162   if (fgMenu == NULL) NewMenu("");
163   
164   AliHLTTriggerMenuSymbol entry;
165   entry.Name(name);
166   entry.Type(type);
167   entry.ObjectClass(className);
168   entry.AssignExpression(assignExpr);
169   entry.DefaultValue(defaultExpr);
170   entry.BlockType(blockType, origin);
171   fgMenu->AddSymbol(entry);
172 }
173
174
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
179   )
180 {
181   // Adds a new symbol to the trigger menu.
182   
183   if (fgMenu == NULL) NewMenu("");
184   
185   AliHLTTriggerMenuSymbol entry;
186   entry.Name(name);
187   entry.Type(type);
188   entry.ObjectClass(className);
189   entry.AssignExpression(assignExpr);
190   entry.DefaultValue(defaultExpr);
191   entry.BlockType(blockType, origin, spec);
192   fgMenu->AddSymbol(entry);
193 }
194     
195     
196 void AliHLTGlobalTriggerConfig::AddItem(
197     UInt_t priority, const char* conditionExpr, const char* domainExpr,
198     UInt_t prescalar, const char* description, bool defaultResult
199   )
200 {
201   // Adds a new entry to the trigger menu with a particular priority.
202   
203   if (fgMenu == NULL) NewMenu("");
204   
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);
213 }
214
215
216 void AliHLTGlobalTriggerConfig::AddItem(
217     UInt_t priority, const char* conditionExpr, const char* domainExpr,
218     const char* description, Double_t scaledown, bool defaultResult
219   )
220 {
221   // Adds a new entry to the trigger menu with a particular priority.
222   
223   if (scaledown < 0)
224   {
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;
227     return;
228   }
229   if (scaledown < 0)
230   {
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;
233     return;
234   }
235   
236   if (fgMenu == NULL) NewMenu("");
237   
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);
246 }
247
248
249 void AliHLTGlobalTriggerConfig::AddItem(
250     const char* conditionExpr, const char* domainExpr, UInt_t prescalar,
251     const char* description
252   )
253 {
254   // Adds a new entry to the trigger menu.
255   
256   if (fgMenu == NULL) NewMenu("");
257   
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);
264 }
265
266
267 void AliHLTGlobalTriggerConfig::AddItem(
268     const char* conditionExpr, const char* domainExpr, const char* description
269   )
270 {
271   // Adds a new entry to the trigger menu.
272   
273   if (fgMenu == NULL) NewMenu("");
274   
275   AliHLTTriggerMenuItem entry;
276   entry.TriggerCondition(conditionExpr);
277   entry.MergeExpression(domainExpr);
278   if (description != NULL) entry.Description(description);
279   fgMenu->AddItem(entry);
280 }
281
282
283 void AliHLTGlobalTriggerConfig::SetDefaultTriggerDescription(const char* description)
284 {
285   // Sets the default trigger decription.
286   
287   if (fgMenu == NULL) NewMenu("");
288   fgMenu->DefaultDescription(description);
289 }
290
291
292 void AliHLTGlobalTriggerConfig::SetDefaultTriggerDomain(const AliHLTTriggerDomain& domain)
293 {
294   // Sets the default trigger domain.
295   
296   if (fgMenu == NULL) NewMenu("");
297   fgMenu->DefaultTriggerDomain(domain);
298 }
299
300
301 AliHLTTriggerDomain& AliHLTGlobalTriggerConfig::DefaultTriggerDomain()
302 {
303   // Returns the default trigger domain for the current trigger menu.
304   
305   if (fgMenu == NULL) NewMenu("");
306   return fgMenu->DefaultTriggerDomain();
307 }
308
309
310 void AliHLTGlobalTriggerConfig::SetDefaultConditionOperator(const char* op)
311 {
312   // Sets the default operator for trigger condition merging.
313   
314   if (fgMenu == NULL) NewMenu("");
315   fgMenu->DefaultConditionOperator(op);
316 }
317
318
319 void AliHLTGlobalTriggerConfig::SetDefaultDomainOperator(const char* op)
320 {
321   // Sets the default operator for trigger domain merging.
322   
323   if (fgMenu == NULL) NewMenu("");
324   fgMenu->DefaultDomainOperator(op);
325 }
326
327
328 void AliHLTGlobalTriggerConfig::SetDefaultResult(bool value)
329 {
330   // Sets the default result when no item is matched.
331   
332   if (fgMenu == NULL) NewMenu("");
333   fgMenu->DefaultResult(value);
334 }
335
336
337 void AliHLTGlobalTriggerConfig::Print(Option_t* option) const
338 {
339   // Prints the contents of the current trigger menu being manipulated.
340   
341   if (fgMenu != NULL)
342   {
343     fgMenu->Print(option);
344   }
345   else
346   {
347     cout << "No trigger menu currently being configured, it is empty." << endl;
348   }
349 }
350