ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfL1Data
Root
Menu.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigConfL1Data/Menu.h
"
6
#include "
TrigConfL1Data/DiffStruct.h
"
7
#include "
TrigConfL1Data/TriggerItem.h
"
8
#include "
TrigConfL1Data/HelperFunctions.h
"
9
#include <iostream>
10
#include <iomanip>
11
12
using namespace
std
;
13
using namespace
TrigConf
;
14
15
TrigConf::Menu::Menu
()
16
:
L1DataBaseclass
()
17
{}
18
19
TrigConf::Menu::~Menu
()
20
{
21
for
(
PIT
*pit :
m_PITs
)
22
{
23
delete
pit;
24
}
25
for
(
TIP
*tip :
m_TIPs
)
26
{
27
delete
tip;
28
}
29
for
(
ThresholdMonitor
*thrm :
m_ThresholdMonitorVector
)
30
{
31
delete
thrm;
32
}
33
for
(
TriggerItem
*
item
:
m_TriggerItemVector
)
34
{
35
delete
item
;
36
}
37
}
38
39
std::vector<uint16_t>
40
TrigConf::Menu::bunchgroupMask
()
const
{
41
std::vector<uint16_t> bgmask(512);
42
for
(
TriggerItem
*
item
:
item_by_ctpid
() )
43
bgmask[
item
->ctpId()] =
item
->bunchgroupMask();
44
return
bgmask;
45
}
46
47
48
void
TrigConf::Menu::addTriggerItem
(
TriggerItem
* ti) {
49
// they all work:
50
// pair<item_by_ctpid_iterator, bool> ins = item_by_ctpid().insert(ti);
51
// pair<item_by_name_iterator, bool> ins = item_by_name().insert(ti);
52
pair<ItemContainer::iterator, bool> ins =
m_TriggerItemVector
.push_back(ti);
53
if
(! ins.second) {
54
cerr <<
"FATAL Menu: insertion of TriggerItem ("
<< ti->
name
() <<
", ctp ID="
<< ti->
ctpId
() <<
") failed, uniqueness constraint violated."
<< endl;
55
throw
runtime_error(
"Menu insertion of TriggerItem failed"
);
56
}
57
}
58
59
60
void
TrigConf::Menu::addThresholdMonitor
(
ThresholdMonitor
* thrm) {
61
m_ThresholdMonitorVector
.push_back(thrm);
62
}
63
64
void
TrigConf::Menu::addPit
(
PIT
* pit) {
65
m_PITs
.push_back(pit);
66
}
67
68
69
void
TrigConf::Menu::addTip
(
TIP
* tip) {
70
m_TIPs
.push_back(tip);
71
}
72
73
void
74
TrigConf::Menu::addLutOutputName
(
unsigned
int
lutCounter,
const
std::string & lutCondition) {
75
if
(
m_LUT
.find(lutCounter) !=
m_LUT
.end()) {
76
cerr <<
"WARNING Menu: insertion of LUT output (counter "
<< lutCounter <<
", name "
<< lutCounter <<
") failed, uniqueness constraint violated."
<< endl;
77
return
;
78
}
79
m_LUT
[lutCounter] = lutCondition;
80
}
81
82
83
TrigConf::TriggerItem
*
84
TrigConf::Menu::item
(
int
ctpid)
const
{
85
const
item_by_ctpid_t
& byctpid =
item_by_ctpid
();
86
item_by_ctpid_iterator
item
= byctpid.find(ctpid);
87
if
(
item
== byctpid.end())
return
0;
88
return
*
item
;
89
}
90
91
TrigConf::TriggerItem
*
92
TrigConf::Menu::item
(
const
string
&
name
)
const
{
93
const
item_by_name_t
& byname =
items
().get<
tag_name_hash
>();
94
item_by_name_iterator
item
= byname.find(
name
);
95
if
(
item
== byname.end())
return
0;
96
return
*
item
;
97
}
98
99
TrigConf::ThresholdMonitor
*
100
TrigConf::Menu::findThresholdMonitor
(
unsigned
int
id
) {
101
for
(
ThresholdMonitor
* thrm :
m_ThresholdMonitorVector
)
102
if
( thrm->id()==
id
)
return
thrm;
103
return
0;
104
}
105
106
TrigConf::PIT
*
107
TrigConf::Menu::findPIT
(
unsigned
int
id
) {
108
for
(
PIT
* pit :
m_PITs
)
109
if
( pit->id()==
id
)
return
pit;
110
return
0;
111
}
112
113
TrigConf::TIP
*
114
TrigConf::Menu::findTIP
(
unsigned
int
id
) {
115
for
(
TIP
* tip :
m_TIPs
)
116
if
( tip->id()==
id
)
return
tip;
117
return
0;
118
}
119
120
121
// another interface to access the TriggerThreshold vector
122
const
std::vector<TrigConf::TriggerThreshold*>&
123
TrigConf::Menu::thresholdVector
()
const
{
124
return
m_ThresholdConfig
.getThresholdVector();
125
}
126
127
void
128
TrigConf::Menu::addTriggerThreshold
(
TrigConf::TriggerThreshold
* tt) {
129
m_ThresholdConfig
.addTriggerThreshold(tt);
130
}
131
132
133
TrigConf::DiffStruct
*
134
TrigConf::Menu::compareTo
(
const
Menu
* o)
const
{
135
DiffStruct
* ds =
new
DiffStruct
(
"TriggerMenu"
);
136
ds->check(
"name"
,
name
(), o->
name
());
137
for
(
TriggerItem
*
item
:
items
() ) {
138
TriggerItem
* o_item(o->
item
(
item
->name()));
139
if
(o_item) {
140
ds->addSub(
item
->compareTo(o_item) );
141
}
else
{
142
ds->addLeftOnlySub(
"TriggerItem"
,
item
->name() );
143
}
144
}
145
for
(
TriggerItem
* o_item : o->
items
()) {
146
const
TriggerItem
*
item
= this->item(o_item->name());
147
if
(
item
==0)
148
ds->addRightOnlySub(
"TriggerItem"
, o_item->name() );
149
}
150
if
(ds->empty()) {
151
delete
ds; ds=0;
152
}
153
return
ds;
154
}
155
156
157
158
159
void
160
TrigConf::Menu::clear
() {
161
m_ThresholdConfig
.clear();
162
163
for
(
TriggerItem
*
item
:
m_TriggerItemVector
)
delete
item
;
164
m_TriggerItemVector
.clear();
165
166
for
(
ThresholdMonitor
* thrMon :
m_ThresholdMonitorVector
)
delete
thrMon;
167
m_ThresholdMonitorVector
.clear();
168
169
for
(
PIT
* pit :
m_PITs
)
delete
pit;
170
m_PITs
.clear();
171
}
172
173
174
175
namespace
{
176
177
// strict weak ordering: x and y are equivalent if compX(x,y) and compX(y,x) are false
178
179
bool
compThr(
TriggerThreshold
*
x
,
TriggerThreshold
*
y
) {
180
return
x
->id() <
y
->id();
181
}
182
183
bool
compMon(
ThresholdMonitor
*
x
,
ThresholdMonitor
*
y
) {
184
if
(
x
->thresholdName() !=
y
->thresholdName() )
185
return
x
->thresholdName() <
y
->thresholdName();
186
return
x
->multiplicity() <
y
->multiplicity();
187
}
188
189
bool
compMonByID(
ThresholdMonitor
*
x
,
ThresholdMonitor
*
y
) {
190
return
x
->internalCounter() <
y
->internalCounter();
191
}
192
193
bool
compTIP(
TIP
*
x
,
TIP
*
y
) {
194
if
(
x
->tipNumber() !=
y
->tipNumber())
195
return
x
->tipNumber() <
y
->tipNumber();
196
return
x
->thresholdBit()<
y
->thresholdBit();
197
}
198
199
bool
compPIT(
PIT
*
x
,
PIT
*
y
) {
200
if
(
x
->pitNumber() !=
y
->pitNumber())
201
return
x
->pitNumber() <
y
->pitNumber();
202
return
x
->thresholdBit()<
y
->thresholdBit();
203
}
204
205
}
206
207
208
209
void
210
TrigConf::Menu::print
(
const
std::string&
indent
,
unsigned
int
detail
)
const
{
211
if
(
detail
>=1) {
212
cout <<
indent
<<
"Trigger menu "
;
printNameIdV
();
213
cout <<
indent
<<
" number of pits : "
<<
pitVector
().size() << endl;
214
cout <<
indent
<<
" number of tips : "
<<
tipVector
().size() << endl;
215
cout <<
indent
<<
" number of thresholds : "
<<
m_ThresholdConfig
.size() << endl;
216
cout <<
indent
<<
" number of items : "
<<
m_TriggerItemVector
.size() << endl;
217
cout <<
indent
<<
" number of thr monitors: "
<<
m_ThresholdMonitorVector
.size() << endl;
218
219
if
(
detail
>=2) {
220
221
cout <<
indent
<<
"=================================="
<< endl;
222
cout <<
indent
<<
"Trigger Items : "
<<
m_TriggerItemVector
.size() << endl;
223
cout <<
indent
<<
"=================================="
<< endl;
224
for
(
TriggerItem
*
item
:
m_TriggerItemVector
)
225
item
->print(
indent
+
" "
,
detail
);
226
227
cout <<
indent
<<
"=================================="
<< endl;
228
cout <<
indent
<<
"Trigger Thresholds:"
<< endl;
229
cout <<
indent
<<
"=================================="
<< endl;
230
m_ThresholdConfig
.print(
indent
+
" "
,
detail
);
231
}
232
233
if
(
detail
>=3) {
234
cout <<
indent
<<
"=================================="
<< endl;
235
cout <<
indent
<<
" The ThresholdMonitorVector:"
<< endl;
236
cout <<
indent
<<
"=================================="
<< endl;
237
auto
sortedMon =
m_ThresholdMonitorVector
;
238
sort
(sortedMon.begin(),sortedMon.end(),compMonByID);
239
for
(
ThresholdMonitor
* thrm : sortedMon)
240
thrm->print(
indent
+
" "
,
detail
);
241
}
242
243
if
(
detail
>=3 &&
m_PITs
.size()>0) {
244
cout <<
indent
<<
"=================================="
<< endl;
245
cout <<
indent
<<
" PITs:"
<< endl;
246
cout <<
indent
<<
"=================================="
<< endl;
247
auto
sortedPITs =
m_PITs
;
248
sort
(sortedPITs.begin(),sortedPITs.end(),compPIT);
249
for
(
PIT
* pit : sortedPITs)
250
pit->print(
indent
+
" "
);
251
}
252
253
if
(
detail
>=3) {
254
cout <<
indent
<<
"=================================="
<< endl;
255
cout <<
indent
<<
" TIPs:"
<< endl;
256
cout <<
indent
<<
"=================================="
<< endl;
257
auto
sortedTIPs =
m_TIPs
;
258
sort
(sortedTIPs.begin(),sortedTIPs.end(),compTIP);
259
for
(
TIP
* tip : sortedTIPs)
260
tip->print(
indent
+
" "
);
261
}
262
263
if
(
detail
>=4) {
264
cout <<
indent
<<
"=================================="
<< endl;
265
cout <<
indent
<<
" TriggerType summary:"
<< endl;
266
cout <<
indent
<<
"=================================="
<< endl;
267
for
(
int
i=0; i<8; ++i) {
268
cout <<
indent
<<
"TriggerType bit "
<< i << endl;
269
for
(
TriggerItem
*
item
:
m_TriggerItemVector
)
270
if
(
item
->isTriggerTypeBitOn(i))
271
cout <<
indent
<<
" "
<<
item
->name() << endl;
272
}
273
}
274
if
(
detail
>=4) {
275
cout <<
indent
<<
"=================================="
<< endl;
276
cout <<
indent
<<
" BunchGroup mask summary:"
<< endl;
277
cout <<
indent
<<
"=================================="
<< endl;
278
unsigned
int
i=0;
279
for
( uint16_t m :
bunchgroupMask
() )
280
cout <<
indent
<<
" ctpid="
<< setw(3) << i++ <<
": bgmask="
<<
uint2bin
(m, 16) << endl;
281
}
282
283
}
284
}
285
286
287
void
288
TrigConf::Menu::writeXMLItems
(std::ostream &
xmlfile
,
int
indentLevel,
int
indentWidth)
const
{
289
indent
(
xmlfile
, indentLevel, indentWidth)
290
<<
"<TriggerMenu name=\""
<<
name
()
291
<<
"\" phase=\"lumi\">"
<< endl;
292
for
(
TriggerItem
*
item
:
m_TriggerItemVector
)
293
item
->writeXML(
xmlfile
, indentLevel+1, indentWidth);
294
indent
(
xmlfile
, indentLevel, indentWidth) <<
"</TriggerMenu>"
<< endl;
295
}
296
297
298
void
299
TrigConf::Menu::writeXMLThresholds
(std::ostream &
xmlfile
,
int
indentLevel,
int
indentWidth)
const
{
300
indent
(
xmlfile
, indentLevel, indentWidth) <<
"<TriggerThresholdList>"
<< endl;
301
302
auto
sortedThresholds =
m_ThresholdConfig
.getThresholdVector();
303
sort
(sortedThresholds.begin(),sortedThresholds.end(),compThr);
304
305
for
(
TriggerThreshold
* thr: sortedThresholds) {
306
if
(!thr->isInternal())
307
thr->writeXML(
xmlfile
, indentLevel+1, indentWidth);
308
}
309
indent
(
xmlfile
, indentLevel, indentWidth) <<
"</TriggerThresholdList>"
<< endl;
310
}
311
312
void
313
TrigConf::Menu::writeXMLMonCounters
(std::ostream &
xmlfile
,
int
indentLevel,
int
indentWidth)
const
{
314
indent
(
xmlfile
, indentLevel, indentWidth) <<
"<TriggerCounterList>"
<< endl;
315
316
auto
sortedMonitors =
m_ThresholdMonitorVector
;
317
sort
(sortedMonitors.begin(),sortedMonitors.end(),compMon);
318
319
for
(
const
ThresholdMonitor
* mon: sortedMonitors)
320
mon->writeXML(
xmlfile
, indentLevel+1, indentWidth);
321
indent
(
xmlfile
, indentLevel, indentWidth) <<
"</TriggerCounterList>"
<< endl;
322
}
323
324
325
326
// for python
327
vector<TriggerItem*>
328
Menu::itemsV
()
const
{
329
vector<TriggerItem*> it(
items
().
size
());
330
copy(
items
().begin(),
items
().end(), it.begin());
331
return
it;
332
}
DiffStruct.h
Menu.h
TriggerItem.h
HelperFunctions.h
y
#define y
x
#define x
TrigConf::DiffStruct
Definition
DiffStruct.h:14
TrigConf::L1DataBaseclass::L1DataBaseclass
L1DataBaseclass()
Definition
L1DataBaseclass.h:24
TrigConf::Menu::Menu
Menu()
Definition
Menu.cxx:15
TrigConf::Menu::addTriggerThreshold
void addTriggerThreshold(TriggerThreshold *tt)
Definition
Menu.cxx:128
TrigConf::Menu::~Menu
virtual ~Menu() override
Definition
Menu.cxx:19
TrigConf::Menu::item
TriggerItem * item(int ctpid) const
Definition
Menu.cxx:84
TrigConf::Menu::compareTo
DiffStruct * compareTo(const Menu *o) const
Definition
Menu.cxx:134
TrigConf::Menu::addTriggerItem
void addTriggerItem(TriggerItem *ti)
Definition
Menu.cxx:48
TrigConf::Menu::thresholdVector
const std::vector< TriggerThreshold * > & thresholdVector() const
Definition
Menu.cxx:123
TrigConf::Menu::m_ThresholdMonitorVector
std::vector< ThresholdMonitor * > m_ThresholdMonitorVector
Definition
Menu.h:118
TrigConf::Menu::addLutOutputName
void addLutOutputName(unsigned int, const std::string &)
Definition
Menu.cxx:74
TrigConf::Menu::m_ThresholdConfig
ThresholdConfig m_ThresholdConfig
Definition
Menu.h:114
TrigConf::Menu::m_TIPs
std::vector< TIP * > m_TIPs
Definition
Menu.h:120
TrigConf::Menu::item_by_ctpid
item_by_ctpid_t & item_by_ctpid()
Definition
Menu.h:128
TrigConf::Menu::pitVector
const std::vector< PIT * > & pitVector() const
Definition
Menu.h:70
TrigConf::Menu::itemsV
std::vector< TrigConf::TriggerItem * > itemsV() const
Definition
Menu.cxx:328
TrigConf::Menu::writeXMLThresholds
void writeXMLThresholds(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Definition
Menu.cxx:299
TrigConf::Menu::addThresholdMonitor
void addThresholdMonitor(ThresholdMonitor *thrm)
Definition
Menu.cxx:60
TrigConf::Menu::clear
void clear()
Definition
Menu.cxx:160
TrigConf::Menu::addTip
void addTip(TIP *tip)
Definition
Menu.cxx:69
TrigConf::Menu::findThresholdMonitor
ThresholdMonitor * findThresholdMonitor(unsigned int id)
Definition
Menu.cxx:100
TrigConf::Menu::addPit
void addPit(PIT *pit)
Definition
Menu.cxx:64
TrigConf::Menu::size
int size() const
Definition
Menu.h:143
TrigConf::Menu::findTIP
TIP * findTIP(unsigned int id)
Definition
Menu.cxx:114
TrigConf::Menu::writeXMLMonCounters
void writeXMLMonCounters(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Definition
Menu.cxx:313
TrigConf::Menu::print
virtual void print(const std::string &indent="", unsigned int detail=1) const override
Definition
Menu.cxx:210
TrigConf::Menu::m_LUT
std::map< unsigned int, std::string > m_LUT
Definition
Menu.h:121
TrigConf::Menu::findPIT
PIT * findPIT(unsigned int id)
Definition
Menu.cxx:107
TrigConf::Menu::bunchgroupMask
std::vector< uint16_t > bunchgroupMask() const
Definition
Menu.cxx:40
TrigConf::Menu::m_PITs
std::vector< PIT * > m_PITs
Definition
Menu.h:119
TrigConf::Menu::writeXMLItems
void writeXMLItems(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Definition
Menu.cxx:288
TrigConf::Menu::items
const ItemContainer & items() const
Definition
Menu.h:140
TrigConf::Menu::tipVector
const std::vector< TIP * > & tipVector() const
Definition
Menu.h:71
TrigConf::Menu::m_TriggerItemVector
ItemContainer m_TriggerItemVector
Definition
Menu.h:116
TrigConf::PIT
Definition
PIT.h:13
TrigConf::TIP
Definition
TIP.h:13
TrigConf::ThresholdMonitor
Definition
ThresholdMonitor.h:18
TrigConf::TrigConfData::indent
std::ostream & indent(std::ostream &o, int lvl, int size) const
Definition
TrigConfData.cxx:23
TrigConf::TrigConfData::name
const std::string & name() const
Definition
TrigConfData.h:22
TrigConf::TrigConfData::printNameIdV
void printNameIdV(const std::string &indent="") const
Definition
TrigConfData.cxx:31
TrigConf::TriggerItem
Definition
TriggerItem.h:26
TrigConf::TriggerItem::ctpId
int ctpId() const
Definition
TriggerItem.h:35
TrigConf::TriggerThreshold
Definition
TriggerThreshold.h:20
xmlfile
static std::vector< std::string > xmlfile
Definition
iLumiCalc.h:29
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition
Config.h:22
TrigConf::uint2bin
std::string uint2bin(uint32_t uinteger, uint16_t width)
Definition
Trigger/TrigConfiguration/TrigConfL1Data/Root/HelperFunctions.cxx:324
TrigConf::item_by_name_t
ItemContainer::index< tag_name_hash >::type item_by_name_t
Definition
Menu.h:44
TrigConf::item_by_name_iterator
ItemContainer::index< tag_name_hash >::type::iterator item_by_name_iterator
Definition
Menu.h:45
TrigConf::item_by_ctpid_t
ItemContainer::index< tag_ctpid >::type item_by_ctpid_t
Definition
Menu.h:41
TrigConf::item_by_ctpid_iterator
item_by_ctpid_t::iterator item_by_ctpid_iterator
Definition
Menu.h:42
detail
Definition
extract_histogram_tag.cxx:14
std
STL namespace.
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
TrigConf::name
Definition
HLTChainList.h:35
TrigConf::tag_name_hash
Definition
Menu.h:31
Generated on
for ATLAS Offline Software by
1.17.0