ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalDecision.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <iomanip>
6
11
12using namespace std;
13using namespace TCS;
14
15void
16GlobalDecision::setTriggerLines(const vector<TrigConf::TriggerLine> & triggers) {
17
18 m_triggers = triggers;
19 vector<string> connNames = {};
20 for (const TrigConf::TriggerLine & trigger : triggers){
21 auto it = find(connNames.begin(), connNames.end(), trigger.connName());
22 if (it == connNames.end()){
23 connNames.push_back(trigger.connName());
24 m_decision[trigger.connName()] = 0;
25 }
26 }
27}
28
29uint32_t
30GlobalDecision::decision_field(const string& connName, unsigned int clock) const {
31 try {
32 if(clock==0) {
33 // lower 32 bit
34 return (uint32_t) (m_decision.at(connName) & 0xffffffff);
35 } else {
36 // upper 32 bit
37 uint64_t clock1 = m_decision.at(connName) & 0xffffffff00000000;
38 return (uint32_t) (clock1 >> 32);
39 }
40 }
41 catch(std::exception &) {
42 TRG_MSG_ERROR("Connector name " << connName << " unknown");
43 throw;
44 }
45}
46
47uint32_t
48GlobalDecision::overflow_field(const std::string& connName, unsigned int clock) const {
49 if(clock==0) {
50 // lower 32 bit
51 return (uint32_t) (m_overflow.find(connName)->second & 0xffffffff);
52 } else {
53 // upper 32 bit
54 uint64_t clock1 = m_overflow.find(connName)->second & 0xffffffff00000000;
55 return (uint32_t) (clock1 >> 32);
56 }
57}
58
59
60GlobalDecision::GlobalDecision(const std::string &name) :
62{}
63
64/****************************************************************
65 *
66 * Fill the decision bits with the pass/fail of all decision algs.
67 * This is called by the TopoSteering after the connectors have
68 * been executed.
69 *
70 ****************************************************************/
71
73GlobalDecision::collectDecision(const set<DecisionConnector*> & outconn) {
75
76 for( const DecisionConnector * conn : outconn ) {
77
78 const Decision& dec = conn->decision();
79
80 unsigned int pos = 0; // for multi-output algorithms pos is the output index
81 for(const TrigConf::TriggerLine & trigger : conn->triggers() ) {
82 unsigned int position = trigger.flatindex();
83
84 uint64_t & connectorDec = m_decision[trigger.connName()];
85 uint64_t & connectorOvf = m_overflow[trigger.connName()];
86 uint64_t mask(0x1);
87
88 if( dec.bit(pos++) ) // bit set?
89 connectorDec |= (mask << position);
90 if( dec.overflow())
91 connectorOvf |= (mask << position);
92 }
93
94 }
95 m_valid = true;
97}
98
99
102 for(auto const& dec : m_decision)
103 m_decision[dec.first] = 0;
104 for(auto const& ovf : m_overflow)
105 m_overflow[ovf.first] = 0;
106 m_valid = false;
108}
109
110
111namespace TCS {
112
113
114std::ostream&
115operator<<(std::ostream& o, const TCS::GlobalDecision & dec) {
116
117 if(!dec.isValid())
118 o << "Note that the overall decision has not been calculated" << endl;
119
120 for(auto const& itdec : dec.m_decision)
121 o << "Overall decision for connector " << itdec.first << ": 0x" << right << hex << setfill('0') << setw(16) << dec.decision_field(itdec.first) << std::dec << setfill(' ') << endl;
122
123 if(dec.isValid()) {
124 for(const TrigConf::TriggerLine & trigger : dec.m_triggers){
125 unsigned int position = trigger.flatindex();
126 o << " " << setw(30) << left << trigger.name() << " " << (dec.passed(trigger.connName(), position) ? "pass" : "fail") << endl;}
127 } else {
128 for(const TrigConf::TriggerLine & trigger : dec.m_triggers)
129 o << " " << setw(30) << left << trigger.name() << " unset" << endl;
130 }
131 return o;
132}
133//----------------------------------------------------------
134void
136
137 if(!isValid())
138 TRG_MSG_INFO("Note that the overall decision has not been calculated");
139
140 for(auto const& dec : m_decision)
141 TRG_MSG_INFO("Overall decision from connector " << dec.first << ": 0x" << right << hex << setfill('0') << setw(16) << decision_field(dec.first) << std::dec << setfill(' '));
142
143 if(isValid()) {
144 for(const TrigConf::TriggerLine & trigger : m_triggers){
145 unsigned int position = trigger.flatindex();
146 TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " " << (passed(trigger.connName(), position) ? "pass" : "fail") );}
147 } else {
148 for(const TrigConf::TriggerLine & trigger : m_triggers)
149 TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " unset" );
150 }
151}
152
153}
bool overflow() const
Definition Decision.h:45
bool bit(unsigned int index) const
Definition Decision.h:40
uint64_t overflow_field(const std::string &connName) const
void setTriggerLines(const std::vector< TrigConf::TriggerLine > &triggers)
std::map< std::string, uint64_t > m_decision
std::vector< TrigConf::TriggerLine > m_triggers
bool passed(const std::string &connName, unsigned int bit) const
uint64_t decision_field(const std::string &connName) const
std::map< std::string, uint64_t > m_overflow
StatusCode collectDecision(const std::set< DecisionConnector * > &outconn)
GlobalDecision(const std::string &name="L1TopoGlobalDecision")
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:21
unsigned int flatindex() const
Definition L1Connector.h:28
const std::string & connName() const
Definition L1Connector.h:33
const std::string & name() const
Definition L1Connector.h:26
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
std::ostream & operator<<(std::ostream &os, const TCS::Bin &bin)
STL namespace.