ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoCoreSim
Root
GlobalDecision.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
7
#include "
L1TopoCoreSim/GlobalDecision.h
"
8
#include "
L1TopoCoreSim/DecisionConnector.h
"
9
#include "
L1TopoCommon/Exception.h
"
10
#include "
L1TopoInterfaces/DecisionAlg.h
"
11
12
using namespace
std
;
13
using namespace
TCS
;
14
15
namespace
{
16
struct
ios_state_guard {
17
std::ostream& os;
18
std::ios::fmtflags flags;
19
char
fill;
20
std::streamsize width;
21
22
explicit
ios_state_guard(std::ostream& o)
23
: os(o), flags(o.flags()), fill(o.fill()), width(o.width()) {}
24
25
~ios_state_guard() {
26
os.flags(flags);
27
os.fill(fill);
28
os.width(width);
29
}
30
};
31
}
32
33
void
34
GlobalDecision::setTriggerLines
(
const
vector<TrigConf::TriggerLine> & triggers) {
35
36
m_triggers
= triggers;
37
vector<string> connNames = {};
38
for
(
const
TrigConf::TriggerLine
& trigger : triggers){
39
auto
it =
find
(connNames.begin(), connNames.end(), trigger.connName());
40
if
(it == connNames.end()){
41
connNames.push_back(trigger.connName());
42
m_decision
[trigger.connName()] = 0;
43
}
44
}
45
}
46
47
uint32_t
48
GlobalDecision::decision_field
(
const
string
& connName,
unsigned
int
clock)
const
{
49
try
{
50
if
(clock==0) {
51
// lower 32 bit
52
return
(uint32_t) (
m_decision
.at(connName) & 0xffffffff);
53
}
else
{
54
// upper 32 bit
55
uint64_t clock1 =
m_decision
.at(connName) & 0xffffffff00000000;
56
return
(uint32_t) (clock1 >> 32);
57
}
58
}
59
catch
(std::exception &) {
60
TRG_MSG_ERROR
(
"Connector name "
<< connName <<
" unknown"
);
61
throw
;
62
}
63
}
64
65
uint32_t
66
GlobalDecision::overflow_field
(
const
std::string& connName,
unsigned
int
clock)
const
{
67
if
(clock==0) {
68
// lower 32 bit
69
return
(uint32_t) (
m_overflow
.find(connName)->second & 0xffffffff);
70
}
else
{
71
// upper 32 bit
72
uint64_t clock1 =
m_overflow
.find(connName)->second & 0xffffffff00000000;
73
return
(uint32_t) (clock1 >> 32);
74
}
75
}
76
77
78
GlobalDecision::GlobalDecision
(
const
std::string &name) :
79
TrigConfMessaging
(name)
80
{}
81
82
/****************************************************************
83
*
84
* Fill the decision bits with the pass/fail of all decision algs.
85
* This is called by the TopoSteering after the connectors have
86
* been executed.
87
*
88
****************************************************************/
89
90
TCS::StatusCode
91
GlobalDecision::collectDecision
(
const
set<DecisionConnector*> & outconn) {
92
resetDecision
();
93
94
for
(
const
DecisionConnector
* conn : outconn ) {
95
96
const
Decision
& dec = conn->decision();
97
98
unsigned
int
pos = 0;
// for multi-output algorithms pos is the output index
99
for
(
const
TrigConf::TriggerLine
& trigger : conn->triggers() ) {
100
unsigned
int
position = trigger.flatindex();
101
102
uint64_t & connectorDec =
m_decision
[trigger.connName()];
103
uint64_t & connectorOvf =
m_overflow
[trigger.connName()];
104
uint64_t mask(0x1);
105
106
if
( dec.
bit
(pos++) )
// bit set?
107
connectorDec |= (mask << position);
108
if
( dec.
overflow
())
109
connectorOvf |= (mask << position);
110
}
111
112
}
113
m_valid
=
true
;
114
return
TCS::StatusCode::SUCCESS
;
115
}
116
117
118
TCS::StatusCode
119
GlobalDecision::resetDecision
() {
120
for
(
auto
const
& dec :
m_decision
)
121
m_decision
[dec.first] = 0;
122
for
(
auto
const
& ovf :
m_overflow
)
123
m_overflow
[ovf.first] = 0;
124
m_valid
=
false
;
125
return
TCS::StatusCode::SUCCESS
;
126
}
127
128
129
namespace
TCS
{
130
131
132
std::ostream&
133
operator<<
(std::ostream& o,
const
TCS::GlobalDecision
& dec) {
134
ios_state_guard guard{o};
135
if
(!dec.
isValid
())
136
o <<
"Note that the overall decision has not been calculated"
<< endl;
137
138
for
(
auto
const
& itdec : dec.
m_decision
)
139
o <<
"Overall decision for connector "
<< itdec.first <<
": 0x"
<< right << hex << setfill(
'0'
) << setw(16) << dec.
decision_field
(itdec.first) << std::dec << setfill(
' '
) << endl;
140
141
if
(dec.
isValid
()) {
142
for
(
const
TrigConf::TriggerLine
& trigger : dec.
m_triggers
){
143
unsigned
int
position = trigger.
flatindex
();
144
o <<
" "
<< setw(30) << left << trigger.
name
() <<
" "
<< (dec.
passed
(trigger.
connName
(), position) ?
"pass"
:
"fail"
) << endl;}
145
}
else
{
146
for
(
const
TrigConf::TriggerLine
& trigger : dec.
m_triggers
)
147
o <<
" "
<< setw(30) << left << trigger.
name
() <<
" unset"
<< endl;
148
}
149
return
o;
150
}
151
//----------------------------------------------------------
152
void
153
GlobalDecision::print
()
const
{
154
155
if
(!
isValid
())
156
TRG_MSG_INFO
(
"Note that the overall decision has not been calculated"
);
157
158
for
(
auto
const
& dec :
m_decision
)
159
TRG_MSG_INFO
(
"Overall decision from connector "
<< dec.first <<
": 0x"
<< right << hex << setfill(
'0'
) << setw(16) <<
decision_field
(dec.first) << std::dec << setfill(
' '
));
160
161
if
(
isValid
()) {
162
for
(
const
TrigConf::TriggerLine
& trigger :
m_triggers
){
163
unsigned
int
position = trigger.flatindex();
164
TRG_MSG_INFO
(
" "
<< setw(30) << left << trigger.name() <<
" "
<< (
passed
(trigger.connName(), position) ?
"pass"
:
"fail"
) );}
165
}
else
{
166
for
(
const
TrigConf::TriggerLine
& trigger :
m_triggers
)
167
TRG_MSG_INFO
(
" "
<< setw(30) << left << trigger.name() <<
" unset"
);
168
}
169
}
170
171
}
DecisionAlg.h
DecisionConnector.h
GlobalDecision.h
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
Exception.h
TCS::DecisionConnector
Definition
DecisionConnector.h:23
TCS::Decision
Definition
Decision.h:19
TCS::Decision::overflow
bool overflow() const
Definition
Decision.h:45
TCS::Decision::bit
bool bit(unsigned int index) const
Definition
Decision.h:40
TCS::GlobalDecision
Definition
GlobalDecision.h:34
TCS::GlobalDecision::overflow_field
uint64_t overflow_field(const std::string &connName) const
Definition
GlobalDecision.h:43
TCS::GlobalDecision::setTriggerLines
void setTriggerLines(const std::vector< TrigConf::TriggerLine > &triggers)
Definition
GlobalDecision.cxx:34
TCS::GlobalDecision::resetDecision
StatusCode resetDecision()
Definition
GlobalDecision.cxx:119
TCS::GlobalDecision::m_decision
std::map< std::string, uint64_t > m_decision
Definition
GlobalDecision.h:62
TCS::GlobalDecision::print
void print() const
Definition
GlobalDecision.cxx:153
TCS::GlobalDecision::m_triggers
std::vector< TrigConf::TriggerLine > m_triggers
Definition
GlobalDecision.h:70
TCS::GlobalDecision::passed
bool passed(const std::string &connName, unsigned int bit) const
Definition
GlobalDecision.h:42
TCS::GlobalDecision::decision_field
uint64_t decision_field(const std::string &connName) const
Definition
GlobalDecision.h:38
TCS::GlobalDecision::m_overflow
std::map< std::string, uint64_t > m_overflow
Definition
GlobalDecision.h:64
TCS::GlobalDecision::collectDecision
StatusCode collectDecision(const std::set< DecisionConnector * > &outconn)
Definition
GlobalDecision.cxx:91
TCS::GlobalDecision::m_valid
bool m_valid
Definition
GlobalDecision.h:67
TCS::GlobalDecision::GlobalDecision
GlobalDecision(const std::string &name="L1TopoGlobalDecision")
Definition
GlobalDecision.cxx:78
TCS::GlobalDecision::isValid
bool isValid() const
Definition
GlobalDecision.h:49
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
TCS
Definition
AnomalyDetectionBDT.h:18
TCS::operator<<
std::ostream & operator<<(std::ostream &os, const TCS::Bin &bin)
Definition
AnomalyDetectionBDT.cxx:50
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0