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