ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigEvent
TrigMonitoringEvent
src
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
10
#include "
AthenaKernel/errorcheck.h
"
11
#include "
TrigMonitoringEvent/TrigMonSeq.h
"
12
13
namespace
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
22
const
static
uint16_t
LARGE_INDEX_SEQ_LOCATION
= 321;
23
24
//--------------------------------------------------------------------------------------
25
TrigMonSeq::TrigMonSeq
()
26
:
m_encoded
(0x0)
27
{
28
}
29
30
//--------------------------------------------------------------------------------------
31
TrigMonSeq::TrigMonSeq
(uint32_t encoded)
32
:
m_encoded
(encoded)
33
{
34
}
35
36
//--------------------------------------------------------------------------------------
37
TrigMonSeq::TrigMonSeq
(
const
TrigConfChain
&chn,
const
TrigConfSeq
&seq)
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
46
m_var_key
.push_back(
LARGE_INDEX_SEQ_LOCATION
);
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
{
50
m_encoded
|= (
index
<<
SeqBits::shiftIndex
);
51
}
52
}
53
54
//--------------------------------------------------------------------------------------
55
void
TrigMonSeq::addVar
(
const
TrigMonVar
&var)
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
//--------------------------------------------------------------------------------------
67
void
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
//--------------------------------------------------------------------------------------
77
void
TrigMonSeq::addState
(
State
value)
78
{
79
//
80
// Make OR with State enum value (already at correct bit position)
81
//
82
m_encoded
|= value;
83
}
84
85
//--------------------------------------------------------------------------------------
86
bool
TrigMonSeq::isInitial
()
const
87
{
88
//
89
// Check value of SEQ State enum
90
//
91
return
(
m_encoded
&
kInitial
);
92
}
93
94
//--------------------------------------------------------------------------------------
95
bool
TrigMonSeq::isExecuted
()
const
96
{
97
//
98
// Check value of SEQ State enum
99
//
100
return
(
m_encoded
&
kStart
);
101
}
102
103
//--------------------------------------------------------------------------------------
104
bool
TrigMonSeq::isAlreadyExecuted
()
const
105
{
106
//
107
// Check value of SEQ State enum
108
//
109
return
(
m_encoded
&
kAlreadyExecuted
);
110
}
111
112
//--------------------------------------------------------------------------------------
113
bool
TrigMonSeq::isPrevious
()
const
114
{
115
//
116
// Check value of SEQ State enum
117
//
118
return
(
m_encoded
&
kPrevious
);
119
}
120
121
//--------------------------------------------------------------------------------------
122
uint16_t
TrigMonSeq::getLevel
()
const
123
{
124
return
Trig::getLevelFromEncodedId
(
getChnEncodedId
());
125
}
126
127
//--------------------------------------------------------------------------------------
128
uint16_t
TrigMonSeq::getChnCounter
()
const
129
{
130
return
Trig::getCounterFromEncodedId
(
getChnEncodedId
());
131
}
132
133
//--------------------------------------------------------------------------------------
134
uint16_t
TrigMonSeq::getChnEncodedId
()
const
135
{
136
//
137
// Mask out low 16 bits and return encoded chain id
138
//
139
return
(
m_encoded
&
SeqBits::maskLow16
);
140
}
141
142
//--------------------------------------------------------------------------------------
143
uint16_t
TrigMonSeq::getSeqIndex
()
const
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
}
152
return
(
m_encoded
&
SeqBits::maskIndex
) >>
SeqBits::shiftIndex
;
153
}
154
155
//--------------------------------------------------------------------------------------
156
double
TrigMonSeq::getAlgTimer
()
const
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
//--------------------------------------------------------------------------------------
170
float
TrigMonSeq::getSeqTimer
()
const
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
//--------------------------------------------------------------------------------------
189
const
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
//--------------------------------------------------------------------------------------
213
void
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
}
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LARGE_INDEX_SEQ_LOCATION
static const uint16_t LARGE_INDEX_SEQ_LOCATION
Definition
TrigMonSeq.cxx:22
TrigMonSeq.h
TrigConfAlg
Definition
TrigConfAlg.h:25
TrigConfAlg::getName
const std::string & getName() const
Definition
TrigConfAlg.h:39
TrigConfChain
Definition
TrigConfChain.h:33
TrigConfSeq
Definition
TrigConfSeq.h:30
TrigConfSeq::getIndex
uint16_t getIndex() const
Definition
TrigConfSeq.h:42
TrigConfSeq::getAlg
const TrigConfAlg & getAlg(unsigned int pos) const
Definition
TrigConfSeq.cxx:37
TrigConfSeq::getName
const std::string & getName() const
Definition
TrigConfSeq.h:44
TrigMonAlg
Summary of single agorithm execution. Algorithm is identified by position within parent sequence....
Definition
TrigMonAlg.h:30
TrigMonAlg::getNRoi
uint8_t getNRoi() const
Definition
TrigMonAlg.cxx:107
TrigMonAlg::getRoiId
uint8_t getRoiId(unsigned int i=0) const
Definition
TrigMonAlg.cxx:116
TrigMonAlg::isCached
bool isCached() const
Definition
TrigMonAlg.cxx:136
TrigMonAlg::stop
const TrigMonTimer stop() const
Definition
TrigMonAlg.cxx:167
TrigMonAlg::elapsed
double elapsed() const
Definition
TrigMonAlg.h:57
TrigMonAlg::isCalled
bool isCalled() const
Definition
TrigMonAlg.cxx:145
TrigMonAlg::start
const TrigMonTimer start() const
Definition
TrigMonAlg.cxx:154
TrigMonAlg::getPosition
uint8_t getPosition() const
Definition
TrigMonAlg.cxx:98
TrigMonSeq::m_var_key
std::vector< uint16_t > m_var_key
Definition
TrigMonSeq.h:77
TrigMonSeq::m_encoded
uint32_t m_encoded
Definition
TrigMonSeq.h:75
TrigMonSeq::getSeqIndex
uint16_t getSeqIndex() const
Definition
TrigMonSeq.cxx:143
TrigMonSeq::m_alg
std::vector< TrigMonAlg > m_alg
Definition
TrigMonSeq.h:76
TrigMonSeq::isPrevious
bool isPrevious() const
Definition
TrigMonSeq.cxx:113
TrigMonSeq::getChnEncodedId
uint16_t getChnEncodedId() const
Definition
TrigMonSeq.cxx:134
TrigMonSeq::getAlgTimer
double getAlgTimer() const
Definition
TrigMonSeq.cxx:156
TrigMonSeq::TrigMonSeq
TrigMonSeq()
Definition
TrigMonSeq.cxx:25
TrigMonSeq::isExecuted
bool isExecuted() const
Definition
TrigMonSeq.cxx:95
TrigMonSeq::addState
void addState(State value)
Definition
TrigMonSeq.cxx:77
TrigMonSeq::addTimer
void addTimer(float timer)
Definition
TrigMonSeq.cxx:67
TrigMonSeq::getVar
const std::vector< TrigMonVar > getVar() const
Definition
TrigMonSeq.cxx:189
TrigMonSeq::print
void print(const TrigConfSeq &confg, std::ostream &os=std::cout) const
Definition
TrigMonSeq.cxx:213
TrigMonSeq::getSeqTimer
float getSeqTimer() const
Definition
TrigMonSeq.cxx:170
TrigMonSeq::addVar
void addVar(const TrigMonVar &var)
Definition
TrigMonSeq.cxx:55
TrigMonSeq::isInitial
bool isInitial() const
Definition
TrigMonSeq.cxx:86
TrigMonSeq::isAlreadyExecuted
bool isAlreadyExecuted() const
Definition
TrigMonSeq.cxx:104
TrigMonSeq::getChnCounter
uint16_t getChnCounter() const
Definition
TrigMonSeq.cxx:128
TrigMonSeq::m_var_val
std::vector< float > m_var_val
Definition
TrigMonSeq.h:78
TrigMonSeq::getLevel
uint16_t getLevel() const
Definition
TrigMonSeq.cxx:122
TrigMonSeq::State
State
Definition
TrigMonSeq.h:31
TrigMonSeq::kAlreadyExecuted
@ kAlreadyExecuted
Definition
TrigMonSeq.h:35
TrigMonSeq::kPrevious
@ kPrevious
Definition
TrigMonSeq.h:36
TrigMonSeq::kInitial
@ kInitial
Definition
TrigMonSeq.h:33
TrigMonSeq::kStart
@ kStart
Definition
TrigMonSeq.h:34
TrigMonTimer::getSec
uint32_t getSec() const
Definition
TrigMonTimer.cxx:61
TrigMonTimer::getMicroSec
uint32_t getMicroSec() const
Definition
TrigMonTimer.cxx:68
TrigMonVar
Definition
TrigMonVar.h:59
r
int r
Definition
globals.cxx:22
SeqBits
Definition
TrigMonSeq.cxx:14
SeqBits::maskLow16
const uint32_t maskLow16
Definition
TrigMonSeq.cxx:15
SeqBits::shiftIndex
const uint32_t shiftIndex
Definition
TrigMonSeq.cxx:17
SeqBits::maskIndex
const uint32_t maskIndex
Definition
TrigMonSeq.cxx:16
Trig::getLevelFromEncodedId
uint16_t getLevelFromEncodedId(uint16_t encoded)
Definition
TrigConfChain.h:169
Trig::getCounterFromEncodedId
uint16_t getCounterFromEncodedId(uint16_t encoded)
Definition
TrigConfChain.h:166
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0