]>
Commit | Line | Data |
---|---|---|
81d62bb4 | 1 | // $Id$ |
e2bb8ddd | 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 AliHLTTriggerMenu.cxx | |
19 | /// @author Artur Szostak <artursz@iafrica.com> | |
20 | /// @date 19 Dec 2008 | |
21 | /// @brief Implementation of the AliHLTTriggerMenu base class. | |
22 | /// | |
23 | /// The AliHLTTriggerMenu class implements the HLT global trigger menu, | |
24 | /// which defines how and on what events the HLT triggers. | |
25 | ||
26 | #include "AliHLTTriggerMenu.h" | |
27 | #include "Riostream.h" | |
f925a066 | 28 | #include <sstream> |
e2bb8ddd | 29 | |
30 | ClassImp(AliHLTTriggerMenu) | |
31 | ||
32 | ||
33 | AliHLTTriggerMenu::AliHLTTriggerMenu() : | |
34 | TObject(), | |
35 | fName("Unknown"), | |
52f67e50 | 36 | fSymbols(AliHLTTriggerMenuSymbol::Class(), 100), |
acc7214e | 37 | fItems(AliHLTTriggerMenuItem::Class(), 100), |
38 | fDefaultDescription(), | |
81d62bb4 | 39 | fDefaultDomain(), |
40 | fDefaultConditionOperator("||"), | |
41 | fDefaultDomainOperator("|") | |
e2bb8ddd | 42 | { |
43 | // Default constructor. | |
44 | } | |
45 | ||
46 | ||
47 | AliHLTTriggerMenu::~AliHLTTriggerMenu() | |
48 | { | |
49 | // Default destructor. | |
50 | } | |
51 | ||
52 | ||
53 | AliHLTTriggerMenu::AliHLTTriggerMenu(const AliHLTTriggerMenu& obj) : | |
54 | TObject(obj), | |
55 | fName(obj.fName), | |
52f67e50 | 56 | fSymbols(AliHLTTriggerMenuSymbol::Class(), obj.fSymbols.GetEntriesFast()), |
acc7214e | 57 | fItems(AliHLTTriggerMenuItem::Class(), obj.fItems.GetEntriesFast()), |
58 | fDefaultDescription(obj.fDefaultDescription), | |
81d62bb4 | 59 | fDefaultDomain(obj.fDefaultDomain), |
60 | fDefaultConditionOperator(obj.fDefaultConditionOperator), | |
61 | fDefaultDomainOperator(obj.fDefaultDomainOperator) | |
e2bb8ddd | 62 | { |
63 | // Copy constructor performs a deep copy. | |
64 | ||
52f67e50 | 65 | for (UInt_t i = 0; i < obj.NumberOfSymbols(); i++) |
66 | { | |
67 | AddSymbol(*obj.Symbol(i)); | |
68 | } | |
e2bb8ddd | 69 | for (UInt_t i = 0; i < obj.NumberOfItems(); i++) |
70 | { | |
71 | AddItem(*obj.Item(i)); | |
72 | } | |
73 | } | |
74 | ||
75 | ||
76 | AliHLTTriggerMenu& AliHLTTriggerMenu::operator = (const AliHLTTriggerMenu& obj) | |
77 | { | |
78 | // Assignment operator performs a deep copy. | |
79 | ||
80 | if (this != &obj) | |
81 | { | |
82 | TObject::operator = (obj); | |
83 | fName = obj.fName; | |
acc7214e | 84 | fSymbols.Clear(); |
52f67e50 | 85 | for (UInt_t i = 0; i < obj.NumberOfSymbols(); i++) |
86 | { | |
87 | AddSymbol(*obj.Symbol(i)); | |
88 | } | |
acc7214e | 89 | fItems.Clear(); |
e2bb8ddd | 90 | for (UInt_t i = 0; i < obj.NumberOfItems(); i++) |
91 | { | |
92 | AddItem(*obj.Item(i)); | |
93 | } | |
acc7214e | 94 | fDefaultDescription = obj.fDefaultDescription; |
95 | fDefaultDomain = obj.fDefaultDomain; | |
81d62bb4 | 96 | fDefaultConditionOperator = obj.fDefaultConditionOperator; |
97 | fDefaultDomainOperator = obj.fDefaultDomainOperator; | |
e2bb8ddd | 98 | } |
99 | return *this; | |
100 | } | |
101 | ||
102 | ||
103 | void AliHLTTriggerMenu::Print(Option_t* option) const | |
104 | { | |
105 | // Prints the contents of the trigger menu. | |
106 | ||
107 | cout << "HLT Trigger Menu: " << fName.Data(); | |
108 | TString opt = option; | |
109 | if (opt.Contains("short")) | |
110 | { | |
111 | cout << ", contains " << NumberOfItems() << " entries." << endl; | |
112 | return; | |
113 | } | |
114 | cout << endl; | |
f925a066 | 115 | |
116 | size_t prescalarColWidth = 9; | |
117 | size_t scaledownColWidth = 9; | |
118 | size_t priorityColWidth = 8; | |
119 | size_t resultColWidth = 6; | |
120 | size_t conditionColWidth = 17; | |
121 | size_t mergexprColWidth = 23; | |
122 | size_t descColWidth = 11; | |
123 | // Find out the required widths of the columns: | |
e2bb8ddd | 124 | for (UInt_t i = 0; i < NumberOfItems(); i++) |
125 | { | |
f925a066 | 126 | std::stringstream buf; |
127 | buf.copyfmt(cout); | |
128 | buf << Item(i)->PreScalar(); | |
129 | if (buf.str().length() > prescalarColWidth) prescalarColWidth = buf.str().length(); | |
130 | buf.str(""); | |
131 | buf << Item(i)->ScaleDown(); | |
132 | if (buf.str().length()+1 > scaledownColWidth) scaledownColWidth = buf.str().length()+1; | |
133 | buf.str(""); | |
134 | buf << Item(i)->Priority(); | |
135 | if (buf.str().length() > priorityColWidth) priorityColWidth = buf.str().length(); | |
136 | size_t len = strlen(Item(i)->TriggerCondition()); | |
137 | if (len > conditionColWidth and len < 128) conditionColWidth = len; | |
138 | len = strlen(Item(i)->MergeExpression()); | |
139 | if (len > mergexprColWidth and len < 128) mergexprColWidth = len; | |
140 | len = strlen(Item(i)->Description()); | |
141 | if (len > descColWidth and len < 128) descColWidth = len; | |
142 | } | |
143 | cout << setw(prescalarColWidth) << "Prescalar" << " | " | |
144 | << setw(scaledownColWidth) << "Scaledown" << " | " | |
145 | << setw(priorityColWidth) << "Priority" << " | " | |
146 | << setw(resultColWidth) << "Result" << " | " | |
147 | << setw(conditionColWidth) << "Trigger condition" << " | " | |
148 | << setw(mergexprColWidth) << "Domain merge expression" << " | " | |
149 | << setw(descColWidth) << "Description" << setw(0) << endl; | |
150 | cout << setfill('-') << setw(prescalarColWidth) << "-" << "-+-" | |
151 | << setw(scaledownColWidth) << "-" << "-+-" | |
152 | << setw(priorityColWidth) << "-" << "-+-" | |
153 | << setw(resultColWidth) << "-" << "-+-" | |
154 | << setw(conditionColWidth) << "-" << "-+-" | |
155 | << setw(mergexprColWidth) << "-" << "-+-" | |
156 | << setw(descColWidth) << "-" << setw(0) << setfill(' ') << endl; | |
157 | for (UInt_t i = 0; i < NumberOfItems(); i++) | |
158 | { | |
159 | if (Item(i)->PreScalar() == 0) | |
160 | cout << setw(prescalarColWidth) << "off" << " | "; | |
161 | else | |
162 | cout << setw(prescalarColWidth) << Item(i)->PreScalar() << " | "; | |
163 | if (Item(i)->ScaleDown() == 1) | |
164 | cout << setw(scaledownColWidth) << "none" << " | "; | |
165 | else | |
166 | cout << setw(scaledownColWidth-1) << Item(i)->ScaleDown()*100 << "% | "; | |
167 | cout << setw(priorityColWidth) << Item(i)->Priority() << " | " | |
168 | << setw(resultColWidth) << (Item(i)->DefaultResult() ? "true" : "false") << " | " | |
169 | << setw(conditionColWidth) << Item(i)->TriggerCondition() << " | " | |
170 | << setw(mergexprColWidth) << Item(i)->MergeExpression() << " | " | |
171 | << setw(descColWidth) << Item(i)->Description() << setw(0) << endl; | |
e2bb8ddd | 172 | } |
52f67e50 | 173 | if (NumberOfItems() == 0) cout << "(none)" << endl; |
f925a066 | 174 | |
52f67e50 | 175 | cout << "Symbol list:" << endl; |
f925a066 | 176 | size_t nameColWidth = 4; |
177 | size_t typeColWidth = 9; | |
178 | size_t classColWidth = 10; | |
179 | size_t assignColWidth = 14; | |
180 | size_t valueColWidth = 13; | |
181 | // Find out the required widths of the columns: | |
182 | for (UInt_t i = 0; i < NumberOfSymbols(); i++) | |
183 | { | |
184 | size_t len = strlen(Symbol(i)->RealName()); | |
185 | if (len > nameColWidth and len < 128) nameColWidth = len; | |
186 | len = strlen(Symbol(i)->Type()); | |
187 | if (len > typeColWidth and len < 128) typeColWidth = len; | |
188 | len = strlen(Symbol(i)->ObjectClass()); | |
189 | if (len > classColWidth and len < 128) classColWidth = len; | |
190 | len = strlen(Symbol(i)->AssignExpression()); | |
191 | if (len > assignColWidth and len < 128) assignColWidth = len; | |
192 | len = strlen(Symbol(i)->DefaultValue()); | |
193 | if (len > valueColWidth and len < 128) valueColWidth = len; | |
194 | } | |
195 | cout << setw(nameColWidth) << "Name" | |
196 | << " | " << setw(typeColWidth) << "Data type" | |
52f67e50 | 197 | << " | " << setw(24) << "Block type & spec" |
f925a066 | 198 | << " | " << setw(classColWidth) << "Class name" |
199 | << " | " << setw(assignColWidth) << "Assigned value" | |
200 | << " | " << setw(valueColWidth) << "Default value" | |
52f67e50 | 201 | << setw(0) << endl; |
f925a066 | 202 | cout << setw(nameColWidth) << setfill('-') << "-" |
203 | << "-+-" << setw(typeColWidth) << "-" | |
52f67e50 | 204 | << "-+-" << setw(24) << "-" |
f925a066 | 205 | << "-+-" << setw(classColWidth) << "-" |
206 | << "-+-" << setw(assignColWidth) << "-" | |
207 | << "-+-" << setw(valueColWidth) << "-" | |
52f67e50 | 208 | << setw(0) << setfill(' ') << endl; |
209 | for (UInt_t i = 0; i < NumberOfSymbols(); i++) | |
210 | { | |
f925a066 | 211 | cout << setw(nameColWidth) << Symbol(i)->RealName() << " | " |
212 | << setw(typeColWidth) << Symbol(i)->Type() << " | "; | |
213 | Symbol(i)->BlockType().Print("noendl"); | |
214 | cout << " | " << setw(classColWidth) << Symbol(i)->ObjectClass() | |
215 | << " | " << setw(assignColWidth) << Symbol(i)->AssignExpression() | |
216 | << " | " << setw(valueColWidth) << Symbol(i)->DefaultValue() | |
217 | << setw(0) << endl; | |
52f67e50 | 218 | } |
219 | if (NumberOfSymbols() == 0) cout << "(none)" << endl; | |
f925a066 | 220 | |
81d62bb4 | 221 | cout << "Default trigger condition operator: " << fDefaultConditionOperator << endl; |
222 | cout << " Default trigger domain operator: " << fDefaultDomainOperator << endl; | |
223 | cout << " Default trigger description: \"" << fDefaultDescription << "\"" << endl; | |
f925a066 | 224 | cout << " Default global trigger result: " << (DefaultResult() ? "true" : "false") << "" << endl; |
acc7214e | 225 | cout << "Default "; fDefaultDomain.Print(); |
e2bb8ddd | 226 | } |
227 | ||
acc7214e | 228 | |
229 | void AliHLTTriggerMenu::Clear(Option_t* option) | |
230 | { | |
231 | // Clears the internal symbol and items arrays. | |
232 | ||
233 | fSymbols.Clear(option); | |
234 | fItems.Clear(option); | |
235 | } | |
81d62bb4 | 236 | |
237 | ||
238 | void AliHLTTriggerMenu::AddSymbol(const AliHLTTriggerMenuSymbol& entry) | |
239 | { | |
240 | // Adds a new symbol to the trigger menu. | |
241 | ||
242 | for (Int_t i = 0; i < fSymbols.GetEntriesFast(); i++) | |
243 | { | |
244 | const char* symbolname = static_cast<AliHLTTriggerMenuSymbol*>(fSymbols.UncheckedAt(i))->Name(); | |
245 | if ( strcmp(symbolname, entry.Name()) == 0 ) | |
246 | { | |
247 | Warning("AliHLTTriggerMenu::AddSymbol", | |
248 | "The symbol '%s' already exists in the trigger menu. Will not add the new entry.", | |
249 | entry.RealName() | |
250 | ); | |
251 | return; | |
252 | } | |
253 | } | |
254 | new (fSymbols[fSymbols.GetEntriesFast()]) AliHLTTriggerMenuSymbol(entry); | |
255 | } | |
256 |