ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalOutput.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <iomanip>
6#include <bitset>
7
14
15using namespace std;
16using namespace TCS;
17
18void
19GlobalOutput::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
32void
33GlobalOutput::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
46uint64_t
47GlobalOutput::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
56uint32_t
57GlobalOutput::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
73std::bitset<128>
74GlobalOutput::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
83uint64_t
84GlobalOutput::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
93uint32_t
94GlobalOutput::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
110uint64_t
111GlobalOutput::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
120uint32_t
121GlobalOutput::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
137GlobalOutput::GlobalOutput(const std::string &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
150GlobalOutput::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;
190}
191
192
195 m_decision.clear();
196 m_overflow.clear();
197 m_ambiguity.clear();
198 m_count.clear();
199
200 m_valid = false;
202}
203
204
205namespace TCS {
206
207
208std::ostream&
209operator<<(std::ostream& o, const TCS::GlobalOutput & dec) {
210
211 if(!dec.isValid())
212 o << "Note that the overall decision has not been calculated" << endl;
213
214 for(auto const& itdec : dec.m_decision)
215 o << "Overall decision for connector " << itdec.first << ": 0x" << right << hex << setfill('0') << setw(16) << dec.decision_field(itdec.first) << std::dec << setfill(' ') << endl;
216
217 if(dec.isValid()) {
218 for(const TrigConf::TriggerLine & trigger : dec.m_triggersDec){
219 unsigned int position = trigger.flatindex();
220 o << " " << setw(30) << left << trigger.name() << " " << (dec.passed(trigger.connName(), position) ? "pass" : "fail") << endl;}
221 } else {
222 for(const TrigConf::TriggerLine & trigger : dec.m_triggersDec)
223 o << " " << setw(30) << left << trigger.name() << " unset" << endl;
224 }
225 return o;
226}
227//----------------------------------------------------------
228void
230
231 if(!isValid())
232 TRG_MSG_INFO("Note that the overall decision has not been calculated");
233
234 for(auto const& dec : m_decision)
235 TRG_MSG_INFO("Overall decision from connector " << dec.first << ": 0x" << right << hex << setfill('0') << setw(16) << decision_field(dec.first) << std::dec << setfill(' '));
236
237 if(isValid()) {
238 for(const TrigConf::TriggerLine & trigger : m_triggersDec){
239 unsigned int position = trigger.flatindex();
240 TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " " << (passed(trigger.connName(), position) ? "pass" : "fail") );}
241 } else {
242 for(const TrigConf::TriggerLine & trigger : m_triggersDec)
243 TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " unset" );
244 }
245}
246
247}
bool ambiguity() const
Definition Decision.h:46
bool overflow() const
Definition Decision.h:45
bool bit(unsigned int index) const
Definition Decision.h:40
StatusCode resetOutput()
std::map< std::string, uint64_t > m_overflow
bool isValid() const
std::map< std::string, std::bitset< 128 > > m_count
std::bitset< 128 > count_field(const std::string &l1connName) const
void setMultiplicityTriggerLines(const std::vector< TrigConf::TriggerLine > &triggers)
uint64_t decision_field(const std::string &l1connName) const
uint64_t ambiguity_field(const std::string &l1connName) const
void setDecisionTriggerLines(const std::vector< TrigConf::TriggerLine > &triggers)
GlobalOutput(const std::string &name="L1TopoGlobalOutput")
StatusCode collectOutput(const std::set< DecisionConnector * > &outConn, const std::set< CountingConnector * > &countConn)
std::map< std::string, uint64_t > m_decision
uint64_t overflow_field(const std::string &l1connName) const
std::map< std::string, uint64_t > m_ambiguity
std::vector< TrigConf::TriggerLine > m_triggersDec
std::vector< TrigConf::TriggerLine > m_triggersCount
bool passed(const std::string &connName, unsigned int bit) const
TrigConfMessaging(const std::string &name)
Constructor with parameters.
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition L1Connector.h:22
unsigned int flatindex() const
Definition L1Connector.h:29
const std::string & connName() const
Definition L1Connector.h:34
const std::string & name() const
Definition L1Connector.h:27
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
std::ostream & operator<<(std::ostream &os, const TCS::Bin &bin)
STL namespace.