ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfChain.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
8// C/C++
9#include <algorithm>
10#include <sstream>
11
12//--------------------------------------------------------------------------------------
13uint16_t Trig::getEncodedId(int level,
14 int counter)
15{
16 // 16 bit word for encoded chain level and counter
17 uint16_t word = 0x0;
18
19 if(level < 1 || level > 2) {
20 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "Trig::getEncoded") << "Bad level";
21 return word;
22 }
23 if(counter < 0 || counter >= 16384) {
24 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "Trig::getEncoded") << "Bad counter";
25 return word;
26 }
27
28 word |= level << Bits::shiftLevel;
29 word |= counter;
30
31 return word;
32}
33
34//--------------------------------------------------------------------------------------
35uint16_t Trig::getEncodedId(const std::string &level, int counter)
36{
37 if(level == "L1") return Trig::getEncodedId(1, counter);
38 if(level == "HLT") return Trig::getEncodedId(2, counter);
39
40 return 0;
41}
42
43
44
45//--------------------------------------------------------------------------------------
46TrigConfChain::TrigConfChain(const std::string &chain_name,
47 int chain_counter,
48 unsigned int chain_id,
49 const std::string &level,
50 const std::string &lower_chain_name,
51 int lower_chain_counter,
52 unsigned int lower_chain_id,
53 float prescale,
54 float pass_through)
55 :m_chain_name(chain_name),
56 m_lower_name(lower_chain_name),
57 m_chain_id(chain_id),
58 m_lower_id(lower_chain_id),
61 m_level(0),
62 m_prescale(prescale),
63 m_pass_through(pass_through)
64{
65 // Set counters
66 if(0 <= chain_counter && chain_counter < 16384) {
67 m_chain_counter = static_cast<unsigned int>(chain_counter);
68 }
69 else {
70 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain") << "Bad chain counter";
71 }
72
73 if(0 <= lower_chain_counter && lower_chain_counter < 16384) {
74 m_lower_counter = static_cast<unsigned int>(lower_chain_counter);
75 }
76
77 // Set trigger level as integer
78 if (level == "L1") m_level = 1;
79 else if(level == "HLT") m_level = 2;
80 else {
81 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain")
82 << "TrigConfChain ctor error! " << chain_name << ": bad level " << level;
83 }
84}
85
86//--------------------------------------------------------------------------------------
87TrigConfChain::TrigConfChain(const std::string &chain_name,
88 int chain_counter,
89 unsigned int chain_id,
90 float prescale)
91 :m_chain_name(chain_name),
92 m_lower_name(""),
93 m_chain_id(chain_id),
94 m_lower_id(0),
97 m_level(1),
98 m_prescale(prescale),
100{
101 // Set counters
102 if(0 <= chain_counter && chain_counter < 16384) {
103 m_chain_counter = static_cast<unsigned int>(chain_counter);
104 }
105 else {
106 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain") << "Bad chain counter";
107 }
108}
109
110//--------------------------------------------------------------------------------------
111void TrigConfChain::addStream(const std::string &name, float prescale)
112{
113 //
114 // Save stream name and prescale
115 //
116 m_stream_name.push_back(name);
117 m_stream_prescale.push_back(prescale);
118}
119
120//--------------------------------------------------------------------------------------
122{
123 //
124 // Clear strings in this class and all vector classes
125 //
126 m_chain_name.clear();
127 m_lower_name.clear();
128 m_stream_name.clear();
129 m_stream_prescale.clear(); // prescale vector is meaningless without stream names
130 m_group.clear();
131 m_ebhypo_names.clear();
132
133 for(unsigned int i = 0; i < m_signature.size(); ++i) m_signature[i].clearStrings();
134}
135
136//--------------------------------------------------------------------------------------
138{
139 //
140 // Return level id
141 //
143 return 0;
144 }
145
147}
148
149//--------------------------------------------------------------------------------------
151{
152 //
153 // Get lower chain encoded id
154 //
155 if(m_level == 2) {
157 }
158
159 return 0;
160}
161
162//--------------------------------------------------------------------------------------
163const std::string TrigConfChain::getLevel() const
164{
165 //
166 // Get trigger level as integer
167 //
168 if (m_level == 1) return "L1";
169 else if(m_level == 2) return "HLT";
170
171 return "L0";
172}
173
174//--------------------------------------------------------------------------------------
175float TrigConfChain::getSignaturePrescale(const std::string &name) const
176{
177 //
178 // Find stream prescale
179 //
180 if(m_stream_prescale.size() != m_stream_name.size()) {
181 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain") << "getSignaturePrescale - logic error!";
182 return 0.0;
183 }
184
185 for(unsigned int i = 0; m_stream_name.size(); ++i) {
186 if(m_stream_name[i] == name) return m_stream_prescale[i];
187 }
188
189 return 0.0;
190}
191
192//--------------------------------------------------------------------------------------
193bool TrigConfChain::matchOutputTE(const uint32_t te_id) const
194{
195 //
196 // Match sequence to chain using signatures
197 //
198 for(std::vector<TrigConfSig>::const_iterator it = m_signature.begin();
199 it != m_signature.end(); ++it) {
200 if(it -> matchOutputTE(te_id)) {
201 return true;
202 }
203 }
204
205 return false;
206}
207
208//--------------------------------------------------------------------------------------
209void TrigConfChain::print(std::ostream &os) const
210{
211 os << str(*this) << std::endl;
212}
213
215{
216 std::cout << str(*this) << std::endl;
217}
218
219//--------------------------------------------------------------------------------------
220std::string str(const TrigConfChain &o)
221{
222 std::stringstream s;
223
224 s << "TrigConfChain: "
225 << o.getLevel() << " " << o.getName()
226 << " PS=" << o.getPS() << " PT=" << o.getPT()
227 << " lower chain=" << o.getLowerName() << std::endl;
228
229 s << " signatures: ";
230 for(unsigned int i = 0; i < o.getSignature().size(); ++i) {
231 s << str(o.getSignature()[i]) << " ";
232 }
233 s << "\n";
234
235 s << " streams: ";
236 for(unsigned int i = 0; i < o.getStream().size(); ++i) {
237 s << o.getStream()[i] << " ";
238 }
239 s << "\n";
240
241 s << " groups: ";
242 for(unsigned int i = 0; i < o.getGroup().size(); ++i) {
243 s << o.getGroup()[i] << " ";
244 }
245 s << std::endl;
246
247 return s.str();
248}
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
std::vector< std::string > m_ebhypo_names
unsigned int getLevelId() const
uint16_t m_chain_counter
float getPS() const
float getSignaturePrescale(const std::string &name) const
std::vector< std::string > m_stream_name
const std::vector< std::string > & getStream() const
const std::string & getName() const
std::vector< float > m_stream_prescale
std::string m_lower_name
std::vector< std::string > m_group
const std::string & getLowerName() const
const std::vector< std::string > & getGroup() const
uint16_t getLowerEncodedId() const
uint16_t getLowerCounter() const
bool matchOutputTE(uint32_t te_id) const
uint32_t m_chain_id
uint16_t getEncodedId() const
float getPT() const
const std::vector< TrigConfSig > & getSignature() const
uint16_t getCounter() const
const std::string getLevel() const
std::vector< TrigConfSig > m_signature
uint16_t m_lower_counter
TrigConfChain()=default
void addStream(const std::string &name, float prescale)
void print() const
std::string m_chain_name
uint32_t m_lower_id
const uint16_t shiftLevel
uint16_t getEncodedId(int level, int counter)