ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoCoreSim
Root
GlobalOutput.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <iomanip>
6
#include <bitset>
7
8
#include "
L1TopoCoreSim/GlobalOutput.h
"
9
#include "
L1TopoCoreSim/DecisionConnector.h
"
10
#include "
L1TopoCoreSim/CountingConnector.h
"
11
#include "
L1TopoCommon/Exception.h
"
12
#include "
L1TopoInterfaces/DecisionAlg.h
"
13
#include "
L1TopoInterfaces/CountingAlg.h
"
14
15
using namespace
std
;
16
using namespace
TCS
;
17
18
void
19
GlobalOutput::setDecisionTriggerLines
(
const
vector<TrigConf::TriggerLine> & triggers) {
20
21
m_triggersDec
= triggers;
22
vector<string> l1connNames = {};
23
for
(
const
TrigConf::TriggerLine
& trigger : triggers){
24
auto
it =
find
(l1connNames.begin(), l1connNames.end(), trigger.connName());
25
if
(it == l1connNames.end()){
26
l1connNames.push_back(trigger.connName());
27
m_decision
[trigger.connName()] = 0;
28
}
29
}
30
}
31
32
void
33
GlobalOutput::setMultiplicityTriggerLines
(
const
vector<TrigConf::TriggerLine> & triggers) {
34
35
m_triggersCount
= triggers;
36
vector<string> l1connNames = {};
37
for
(
const
TrigConf::TriggerLine
& trigger : triggers){
38
auto
it =
find
(l1connNames.begin(), l1connNames.end(), trigger.connName());
39
if
(it == l1connNames.end()){
40
l1connNames.push_back(trigger.connName());
41
m_count
[trigger.connName()] = 0;
42
}
43
}
44
}
45
46
uint64_t
47
GlobalOutput::decision_field
(
const
std::string & l1connName)
const
{
48
if
(
m_decision
.find(l1connName) !=
m_decision
.end()) {
49
return
m_decision
.find(l1connName)->second;
50
}
else
{
51
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
52
return
0;
53
}
54
}
55
56
uint32_t
57
GlobalOutput::decision_field
(
const
std::string& l1connName,
unsigned
int
clock)
const
{
58
if
(
m_decision
.find(l1connName) !=
m_decision
.end()) {
59
if
(clock==0) {
60
// lower 32 bit
61
return
static_cast<
uint32_t
>
(
m_decision
.at(l1connName) & 0xffffffff);
62
}
else
{
63
// upper 32 bit
64
uint64_t clock1 =
m_decision
.at(l1connName) & 0xffffffff00000000;
65
return
static_cast<
uint32_t
>
(clock1 >> 32);
66
}
67
}
else
{
68
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
69
return
0;
70
}
71
}
72
73
std::bitset<128>
74
GlobalOutput::count_field
(
const
std::string& l1connName)
const
{
75
if
(
m_count
.find(l1connName) !=
m_count
.end()) {
76
return
m_count
.find(l1connName)->second;
77
}
else
{
78
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
79
return
0;
80
}
81
}
82
83
uint64_t
84
GlobalOutput::overflow_field
(
const
std::string& l1connName)
const
{
85
if
(
m_overflow
.find(l1connName) !=
m_overflow
.end()) {
86
return
m_overflow
.find(l1connName)->second;
87
}
else
{
88
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
89
return
0;
90
}
91
}
92
93
uint32_t
94
GlobalOutput::overflow_field
(
const
std::string& l1connName,
unsigned
int
clock)
const
{
95
if
(
m_overflow
.find(l1connName) !=
m_overflow
.end()) {
96
if
(clock==0) {
97
// lower 32 bit
98
return
static_cast<
uint32_t
>
(
m_overflow
.find(l1connName)->second & 0xffffffff);
99
}
else
{
100
// upper 32 bit
101
uint64_t clock1 =
m_overflow
.find(l1connName)->second & 0xffffffff00000000;
102
return
static_cast<
uint32_t
>
(clock1 >> 32);
103
}
104
}
else
{
105
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
106
return
0;
107
}
108
}
109
110
uint64_t
111
GlobalOutput::ambiguity_field
(
const
std::string& l1connName)
const
{
112
if
(
m_ambiguity
.find(l1connName) !=
m_ambiguity
.end()) {
113
return
m_ambiguity
.find(l1connName)->second;
114
}
else
{
115
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
116
return
0;
117
}
118
}
119
120
uint32_t
121
GlobalOutput::ambiguity_field
(
const
std::string& l1connName,
unsigned
int
clock)
const
{
122
if
(
m_ambiguity
.find(l1connName) !=
m_ambiguity
.end()) {
123
if
(clock==0) {
124
// lower 32 bit
125
return
static_cast<
uint32_t
>
(
m_ambiguity
.find(l1connName)->second & 0xffffffff);
126
}
else
{
127
// upper 32 bit
128
uint64_t clock1 =
m_ambiguity
.find(l1connName)->second & 0xffffffff00000000;
129
return
static_cast<
uint32_t
>
(clock1 >> 32);
130
}
131
}
else
{
132
TRG_MSG_WARNING
(
"Connector name "
<< l1connName <<
" unknown"
);
133
return
0;
134
}
135
}
136
137
GlobalOutput::GlobalOutput
(
const
std::string &name) :
138
TrigConfMessaging
(name)
139
{}
140
141
/****************************************************************
142
*
143
* Fill the decision bits with the pass/fail of all decision algs.
144
* This is called by the TopoSteering after the connectors have
145
* been executed.
146
*
147
****************************************************************/
148
149
TCS::StatusCode
150
GlobalOutput::collectOutput
(
const
set<DecisionConnector*> & outConn,
const
set<CountingConnector*> & countConn) {
151
resetOutput
();
152
153
for
(
const
DecisionConnector
* conn : outConn ) {
154
155
const
Decision
& dec = conn->decision();
156
157
unsigned
int
pos = 0;
// for multi-output algorithms pos is the output index
158
for
(
const
TrigConf::TriggerLine
& trigger : conn->triggers() ) {
159
unsigned
int
position = trigger.flatindex();
160
161
uint64_t & l1connectorDec =
m_decision
[trigger.connName()];
162
uint64_t & l1connectorOvf =
m_overflow
[trigger.connName()];
163
uint64_t & l1connectorAmb =
m_ambiguity
[trigger.connName()];
164
uint64_t mask(0x1);
165
166
if
( dec.
bit
(pos++) )
// bit set?
167
l1connectorDec |= (mask << position);
168
if
( dec.
overflow
())
169
l1connectorOvf |= (mask << position);
170
if
( dec.
ambiguity
())
171
l1connectorAmb |= (mask << position);
172
}
173
174
}
175
176
for
(
const
CountingConnector
* conn : countConn) {
177
178
const
Count
&
count
= conn->count();
179
180
const
TrigConf::TriggerLine
& trigger = conn->triggers().at(0);
// counting connectors only have one trigger line
181
182
std::bitset<128> & l1connectorCount =
m_count
[trigger.
connName
()];
183
184
l1connectorCount |=
count
.getCountBits();
185
186
}
187
188
m_valid
=
true
;
189
return
TCS::StatusCode::SUCCESS
;
190
}
191
192
193
TCS::StatusCode
194
GlobalOutput::resetOutput
() {
195
m_decision
.clear();
196
m_overflow
.clear();
197
m_ambiguity
.clear();
198
m_count
.clear();
199
200
m_valid
=
false
;
201
return
TCS::StatusCode::SUCCESS
;
202
}
203
204
205
namespace
TCS
{
206
207
208
std::ostream&
209
operator<<
(std::ostream& o,
const
TCS::GlobalOutput
& dec){
210
// Save stream state
211
const
auto
flags = o.flags();
212
const
auto
fill
= o.fill();
213
const
auto
width
= o.width();
214
215
if
(!dec.
isValid
())
216
o <<
"Note that the overall decision has not been calculated\n"
;
217
218
for
(
auto
const
& itdec : dec.
m_decision
) {
219
o <<
"Overall decision for connector "
<< itdec.first <<
": 0x"
220
<< std::right << std::hex << std::setfill(
'0'
) << std::setw(16)
221
<< dec.
decision_field
(itdec.first)
222
<< std::dec << std::setfill(
' '
) <<
'\n'
;
223
}
224
225
if
(dec.
isValid
()) {
226
for
(
const
TrigConf::TriggerLine
& trigger : dec.
m_triggersDec
) {
227
unsigned
int
position = trigger.
flatindex
();
228
o <<
" "
<< std::setw(30) << std::left << trigger.
name
()
229
<<
" "
<< (dec.
passed
(trigger.
connName
(), position) ?
"pass"
:
"fail"
)
230
<<
'\n'
;
231
}
232
}
else
{
233
for
(
const
TrigConf::TriggerLine
& trigger : dec.
m_triggersDec
) {
234
o <<
" "
<< std::setw(30) << std::left << trigger.
name
()
235
<<
" unset\n"
;
236
}
237
}
238
239
// Restore stream state
240
o.flags(flags);
241
o.fill(
fill
);
242
o.width(
width
);
243
244
return
o;
245
}
246
247
//----------------------------------------------------------
248
void
249
GlobalOutput::print
()
const
{
250
251
if
(!
isValid
())
252
TRG_MSG_INFO
(
"Note that the overall decision has not been calculated"
);
253
254
for
(
auto
const
& dec :
m_decision
)
255
TRG_MSG_INFO
(
"Overall decision from connector "
<< dec.first <<
": 0x"
<< right << hex << setfill(
'0'
) << setw(16) <<
decision_field
(dec.first) << std::dec << setfill(
' '
));
256
257
if
(
isValid
()) {
258
for
(
const
TrigConf::TriggerLine
& trigger :
m_triggersDec
){
259
unsigned
int
position = trigger.flatindex();
260
TRG_MSG_INFO
(
" "
<< setw(30) << left << trigger.name() <<
" "
<< (
passed
(trigger.connName(), position) ?
"pass"
:
"fail"
) );}
261
}
else
{
262
for
(
const
TrigConf::TriggerLine
& trigger :
m_triggersDec
)
263
TRG_MSG_INFO
(
" "
<< setw(30) << left << trigger.name() <<
" unset"
);
264
}
265
}
266
267
}
CountingAlg.h
CountingConnector.h
DecisionAlg.h
DecisionConnector.h
GlobalOutput.h
width
const double width
Definition
TTileTripReader.cxx:24
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TRG_MSG_WARNING
#define TRG_MSG_WARNING(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:28
Exception.h
TCS::Count
Definition
Count.h:20
TCS::CountingConnector
Definition
CountingConnector.h:26
TCS::DecisionConnector
Definition
DecisionConnector.h:23
TCS::Decision
Definition
Decision.h:19
TCS::Decision::ambiguity
bool ambiguity() const
Definition
Decision.h:46
TCS::Decision::overflow
bool overflow() const
Definition
Decision.h:45
TCS::Decision::bit
bool bit(unsigned int index) const
Definition
Decision.h:40
TCS::GlobalOutput
Definition
GlobalOutput.h:37
TCS::GlobalOutput::resetOutput
StatusCode resetOutput()
Definition
GlobalOutput.cxx:194
TCS::GlobalOutput::m_overflow
std::map< std::string, uint64_t > m_overflow
Definition
GlobalOutput.h:74
TCS::GlobalOutput::isValid
bool isValid() const
Definition
GlobalOutput.h:57
TCS::GlobalOutput::print
void print() const
Definition
GlobalOutput.cxx:249
TCS::GlobalOutput::m_valid
bool m_valid
Definition
GlobalOutput.h:82
TCS::GlobalOutput::m_count
std::map< std::string, std::bitset< 128 > > m_count
Definition
GlobalOutput.h:79
TCS::GlobalOutput::count_field
std::bitset< 128 > count_field(const std::string &l1connName) const
Definition
GlobalOutput.cxx:74
TCS::GlobalOutput::setMultiplicityTriggerLines
void setMultiplicityTriggerLines(const std::vector< TrigConf::TriggerLine > &triggers)
Definition
GlobalOutput.cxx:33
TCS::GlobalOutput::decision_field
uint64_t decision_field(const std::string &l1connName) const
Definition
GlobalOutput.cxx:47
TCS::GlobalOutput::ambiguity_field
uint64_t ambiguity_field(const std::string &l1connName) const
Definition
GlobalOutput.cxx:111
TCS::GlobalOutput::setDecisionTriggerLines
void setDecisionTriggerLines(const std::vector< TrigConf::TriggerLine > &triggers)
Definition
GlobalOutput.cxx:19
TCS::GlobalOutput::GlobalOutput
GlobalOutput(const std::string &name="L1TopoGlobalOutput")
Definition
GlobalOutput.cxx:137
TCS::GlobalOutput::collectOutput
StatusCode collectOutput(const std::set< DecisionConnector * > &outConn, const std::set< CountingConnector * > &countConn)
Definition
GlobalOutput.cxx:150
TCS::GlobalOutput::m_decision
std::map< std::string, uint64_t > m_decision
Definition
GlobalOutput.h:72
TCS::GlobalOutput::overflow_field
uint64_t overflow_field(const std::string &l1connName) const
Definition
GlobalOutput.cxx:84
TCS::GlobalOutput::m_ambiguity
std::map< std::string, uint64_t > m_ambiguity
Definition
GlobalOutput.h:76
TCS::GlobalOutput::m_triggersDec
std::vector< TrigConf::TriggerLine > m_triggersDec
Definition
GlobalOutput.h:85
TCS::GlobalOutput::m_triggersCount
std::vector< TrigConf::TriggerLine > m_triggersCount
Definition
GlobalOutput.h:86
TCS::GlobalOutput::passed
bool passed(const std::string &connName, unsigned int bit) const
Definition
GlobalOutput.h:45
TCS::StatusCode
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TrigConf::TrigConfMessaging::TrigConfMessaging
TrigConfMessaging(const std::string &name)
Constructor with parameters.
Definition
TrigConfMessaging.h:34
TrigConf::TriggerLine
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition
L1Connector.h:22
TrigConf::TriggerLine::flatindex
unsigned int flatindex() const
Definition
L1Connector.h:29
TrigConf::TriggerLine::connName
const std::string & connName() const
Definition
L1Connector.h:34
TrigConf::TriggerLine::name
const std::string & name() const
Definition
L1Connector.h:27
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
TCS
Definition
AnomalyDetectionBDT.h:18
TCS::operator<<
std::ostream & operator<<(std::ostream &os, const TCS::Bin &bin)
Definition
AnomalyDetectionBDT.cxx:50
std
STL namespace.
fill
void fill(H5::Group &out_file, size_t iterations)
Definition
test-half-precision.cxx:64
Generated on
for ATLAS Offline Software by
1.17.0