ATLAS Offline Software
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 
11 #include "L1TopoCommon/Exception.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 
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 
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 
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;
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 
205 namespace TCS {
206 
207 
208 std::ostream&
209 operator<<(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 //----------------------------------------------------------
228 void
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 }
TrigConf::TriggerLine::flatindex
unsigned int flatindex() const
Definition: L1Connector.h:28
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
checkCorrelInHIST.conn
conn
Definition: checkCorrelInHIST.py:25
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::GlobalOutput::collectOutput
StatusCode collectOutput(const std::set< DecisionConnector * > &outConn, const std::set< CountingConnector * > &countConn)
Definition: GlobalOutput.cxx:150
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TCS::GlobalOutput::m_decision
std::map< std::string, uint64_t > m_decision
Definition: GlobalOutput.h:72
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::Decision::ambiguity
bool ambiguity() const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:46
TCS::GlobalOutput::print
void print() const
Definition: GlobalOutput.cxx:229
TCS::Decision::overflow
bool overflow() const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:45
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TCS::GlobalOutput::m_valid
bool m_valid
Definition: GlobalOutput.h:82
TCS::CountingConnector
Definition: CountingConnector.h:26
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
CountingAlg.h
DecisionConnector.h
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
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
Definition: GlobalOutput.h:37
TrigConf::TriggerLine
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition: L1Connector.h:21
GlobalOutput.h
TrigConf::TriggerLine::connName
const std::string & connName() const
Definition: L1Connector.h:33
CountingConnector.h
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
TCS::GlobalOutput::m_count
std::map< std::string, std::bitset< 128 > > m_count
Definition: GlobalOutput.h:79
TCS::Decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:19
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TrigConf::TriggerLine::name
const std::string & name() const
Definition: L1Connector.h:26
TRG_MSG_WARNING
#define TRG_MSG_WARNING(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:28
DecisionAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TCS::GlobalOutput::isValid
bool isValid() const
Definition: GlobalOutput.h:57
TCS::GlobalOutput::decision_field
uint64_t decision_field(const std::string &l1connName) const
Definition: GlobalOutput.cxx:47
TCS::Count
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Count.h:20
TCS::GlobalOutput::passed
bool passed(const std::string &connName, unsigned int bit) const
Definition: GlobalOutput.h:45
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::operator<<
std::ostream & operator<<(std::ostream &, const TCS::CountingConnector &)
Definition: CountingConnector.cxx:93
Exception.h
TCS::DecisionConnector
Definition: DecisionConnector.h:23
TCS::StatusCode
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15