ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMonSeq.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 <iostream>
7#include <iomanip>
8#include <sstream>
9
12
13namespace SeqBits
14{
15 const uint32_t maskLow16 = 0x0000ffff; // mask low 16 bits
16 const uint32_t maskIndex = 0xfff00000; // mask index bits
17 const uint32_t shiftIndex = 20;
18}
19
20
21// This is to work around an edm change
22const static uint16_t LARGE_INDEX_SEQ_LOCATION = 321;
23
24//--------------------------------------------------------------------------------------
29
30//--------------------------------------------------------------------------------------
31TrigMonSeq::TrigMonSeq(uint32_t encoded)
32 :m_encoded(encoded)
33{
34}
35
36//--------------------------------------------------------------------------------------
38 :m_encoded(chn.getEncodedId())
39{
40 //
41 // Encoded index into
42 //
43 const uint32_t index = seq.getIndex();
44 if(index >= 4096) {
45 // EDM limitation workaround with big run-2 menus
47 m_var_val.push_back((float) index); // This is not going to get so large that we'll loose info in a float
48 }
49 else {
51 }
52}
53
54//--------------------------------------------------------------------------------------
56{
57 //
58 // Store variable as int and float, reserve 0-9 keys
59 //
60 if(var.getKey() > 9) {
61 m_var_key.push_back(var.getKey());
62 m_var_val.push_back(var.getData());
63 }
64}
65
66//--------------------------------------------------------------------------------------
67void TrigMonSeq::addTimer(float timer)
68{
69 //
70 // Add sequence timer at key = 0
71 //
72 m_var_key.push_back(0);
73 m_var_val.push_back(timer);
74}
75
76//--------------------------------------------------------------------------------------
78{
79 //
80 // Make OR with State enum value (already at correct bit position)
81 //
82 m_encoded |= value;
83}
84
85//--------------------------------------------------------------------------------------
87{
88 //
89 // Check value of SEQ State enum
90 //
91 return (m_encoded & kInitial);
92}
93
94//--------------------------------------------------------------------------------------
96{
97 //
98 // Check value of SEQ State enum
99 //
100 return (m_encoded & kStart);
101}
102
103//--------------------------------------------------------------------------------------
105{
106 //
107 // Check value of SEQ State enum
108 //
109 return (m_encoded & kAlreadyExecuted);
110}
111
112//--------------------------------------------------------------------------------------
114{
115 //
116 // Check value of SEQ State enum
117 //
118 return (m_encoded & kPrevious);
119}
120
121//--------------------------------------------------------------------------------------
122uint16_t TrigMonSeq::getLevel() const
123{
125}
126
127//--------------------------------------------------------------------------------------
132
133//--------------------------------------------------------------------------------------
135{
136 //
137 // Mask out low 16 bits and return encoded chain id
138 //
139 return (m_encoded & SeqBits::maskLow16);
140}
141
142//--------------------------------------------------------------------------------------
144{
145 //
146 // Mask out SEQ State enum bits and return index
147 //
148 // Check it's not stored in the hack way first
149 for (uint32_t i=0; i < m_var_key.size(); ++i) {
150 if (m_var_key.at(i) == LARGE_INDEX_SEQ_LOCATION) return (uint16_t) m_var_val.at(i);
151 }
153}
154
155//--------------------------------------------------------------------------------------
157{
158 //
159 // Explicit loop over timers to get total time measures by algorithms
160 //
161 if(m_alg.empty()) return 0.0;
162
163 double timer_sum = 0.0;
164 for(unsigned int i = 0; i < m_alg.size(); ++i) timer_sum += m_alg[i].getTimer();
165
166 return timer_sum;
167}
168
169//--------------------------------------------------------------------------------------
171{
172 //
173 // Get sequence timer which is stored at key=0
174 //
175
176 if(m_var_key.size() == m_var_val.size()) {
177 //
178 // Look for key == 0
179 //
180 for(unsigned int i = 0; i < m_var_key.size(); ++i) {
181 if(m_var_key[i] == 0) return m_var_val[i];
182 }
183 }
184
185 return 0.0;
186}
187
188//--------------------------------------------------------------------------------------
189const std::vector<TrigMonVar> TrigMonSeq::getVar() const
190{
191 //
192 // Build variables on a fly and return vector by value
193 //
194 std::vector<TrigMonVar> var;
195
196 if(m_var_key.size() == m_var_val.size()) {
197 //
198 // Iterate over keys abd values
199 //
200 var.reserve(m_var_key.size());
201
202 for(unsigned int i = 0; i < m_var_key.size(); ++i) {
203 if(m_var_key[i] != 0) {
204 var.push_back(TrigMonVar(m_var_key[i], m_var_val[i]));
205 }
206 }
207 }
208
209 return var;
210}
211
212//--------------------------------------------------------------------------------------
213void TrigMonSeq::print(const TrigConfSeq &confg, std::ostream &os) const
214{
215 //
216 // Print payload
217 //
218 if(confg.getIndex() != getSeqIndex()) {
219 os << "TrigMonSeq::Print - error configuration does not match this sequence\n";
220 return;
221 }
222
223 std::stringstream st;
224
225 st << "TrigMonSeq: " << confg.getName()
226 << " isExecuted=" << int(isExecuted())
227 << " isAlreadyExecuted=" << int(isAlreadyExecuted())
228 << " isInitial=" << int(isInitial())
229 << " isPrevious=" << int(isPrevious()) << "\n"
230 << " t_seq-t_alg=" << getSeqTimer() << "-" << getAlgTimer() << "="
231 << getSeqTimer() - getAlgTimer()
232 << " SEQ contains " << m_alg.size() << " algorithm(s)"
233 << "\n";
234
235 unsigned int iwidth = 0;
236 for(unsigned int j = 0; j < m_alg.size(); ++j) {
237 const TrigMonAlg &alg_entry = m_alg[j];
238 const TrigConfAlg &alg_confg = confg.getAlg(alg_entry.getPosition());
239
240 iwidth = std::max<unsigned int>(iwidth, alg_confg.getName().size());
241 }
242
243 for(unsigned int j = 0; j < m_alg.size(); ++j) {
244 const TrigMonAlg &alg_entry = m_alg[j];
245 const TrigConfAlg &alg_confg = confg.getAlg(alg_entry.getPosition());
246
247 st << " " << std::setw(2) << std::setfill(' ') << std::right << j << ": "
248 << std::setw(iwidth) << std::left << alg_confg.getName()
249 << " isCached=" << int(alg_entry.isCached())
250 << " timer=" << alg_entry.elapsed()
251 << " RoiId=";
252
253 for(unsigned int r = 0; r < alg_entry.getNRoi(); ++r) {
254 st << static_cast<unsigned int>(alg_entry.getRoiId(r)) << " ";
255 }
256
257 if(alg_entry.isCalled()) {
258 st << " t1-t0="
259 << alg_entry.start().getSec() << "." << alg_entry.start().getMicroSec()
260 << "-"
261 << alg_entry.stop().getSec() << "." << alg_entry.stop().getMicroSec()
262 << "="
263 << alg_entry.elapsed();
264 }
265
266 st << "\n";
267 }
268
269 os << st.str();
270}
Helpers for checking error return status codes and reporting errors.
static const uint16_t LARGE_INDEX_SEQ_LOCATION
const std::string & getName() const
Definition TrigConfAlg.h:39
uint16_t getIndex() const
Definition TrigConfSeq.h:42
const TrigConfAlg & getAlg(unsigned int pos) const
const std::string & getName() const
Definition TrigConfSeq.h:44
Summary of single agorithm execution. Algorithm is identified by position within parent sequence....
Definition TrigMonAlg.h:30
uint8_t getNRoi() const
uint8_t getRoiId(unsigned int i=0) const
bool isCached() const
const TrigMonTimer stop() const
double elapsed() const
Definition TrigMonAlg.h:57
bool isCalled() const
const TrigMonTimer start() const
uint8_t getPosition() const
std::vector< uint16_t > m_var_key
Definition TrigMonSeq.h:77
uint32_t m_encoded
Definition TrigMonSeq.h:75
uint16_t getSeqIndex() const
std::vector< TrigMonAlg > m_alg
Definition TrigMonSeq.h:76
bool isPrevious() const
uint16_t getChnEncodedId() const
double getAlgTimer() const
bool isExecuted() const
void addState(State value)
void addTimer(float timer)
const std::vector< TrigMonVar > getVar() const
void print(const TrigConfSeq &confg, std::ostream &os=std::cout) const
float getSeqTimer() const
void addVar(const TrigMonVar &var)
bool isInitial() const
bool isAlreadyExecuted() const
uint16_t getChnCounter() const
std::vector< float > m_var_val
Definition TrigMonSeq.h:78
uint16_t getLevel() const
@ kAlreadyExecuted
Definition TrigMonSeq.h:35
uint32_t getSec() const
uint32_t getMicroSec() const
int r
Definition globals.cxx:22
const uint32_t maskLow16
const uint32_t shiftIndex
const uint32_t maskIndex
uint16_t getLevelFromEncodedId(uint16_t encoded)
uint16_t getCounterFromEncodedId(uint16_t encoded)
Definition index.py:1