ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigTools
TrigByteStreamTools
python
hltResult.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2
3
import
cppyy
4
from
CLIDComps.clidGenerator
import
clidGenerator
5
6
clidg = clidGenerator(
""
)
7
from
ROOT
import
HLT
8
stringSerializer = cppyy.gbl.StringSerializer()
9
10
class
hltResult
(
HLT.HLTResult
):
11
def
__init__
(self):
12
super( hltResult, self ).
__init__
()
13
self.
as_int_v
= cppyy.gbl.std.vector(
'unsigned int'
)()
14
15
def
load
(self, rob):
16
self.
nav_payload
= []
17
18
data = list(rob.rod_data())
19
self.
as_int_v
.
clear
()
20
self.
as_int_v
.reserve(len(data))
21
[ self.
as_int_v
.push_back(i)
for
i
in
data ]
22
23
if
self.
deserialize
(self.
as_int_v
)
is
False
:
24
raise
Exception(
'deserialization of the HLT result failed'
)
25
self.
__unpack_navigation
()
26
27
28
def
__unpack_navigation
(self):
29
nav_data = list(self.
getNavigationResult
())
30
if
len(nav_data) <= 1:
31
return
32
33
fidx=nav_data[2]
34
blob =
get_feature_data_blob
(nav_data, fidx)
35
while
len(blob):
36
fsize = len(blob)
37
clid = blob[0]
38
stidx = blob[1]
39
slabel = blob[2]
40
lwords = blob[3:3+slabel]
41
sdata = len(blob)-slabel-3
42
43
label =
deserialize_string
(lwords)
44
self.
nav_payload
.append( (clidg.getNameFromClid(clid), label, fsize*4, sdata*4, clid, stidx) )
45
fidx = fidx+fsize+1
46
blob =
get_feature_data_blob
(nav_data, fidx)
47
48
def
appName
(self):
49
if
self.
getExtras
().
size
()>1:
50
return
deserialize_string
(self.
getExtras
())
51
else
:
52
return
''
53
54
55
def
get_feature_data_blob
(data, index):
56
if
index == len(data):
57
return
[]
58
size = data[index]
59
begin = index
60
begin += 1
61
end = index
62
end +=1
63
end += size
64
if
end <= len(data):
65
index = end
66
#print "getting blob of data from: ", begin, " to ", end
67
return
data[begin:end]
68
else
:
69
return
[]
70
71
72
def
deserialize_string
(lwords):
73
"""Wrapper for the C++ StringSerializer"""
74
75
v = cppyy.gbl.std.vector('unsigned int')()
76
s = cppyy.gbl.std.string()
77
v.reserve(len(lwords))
78
for w in lwords:
79
v.push_back(w)
80
stringSerializer.deserialize(v, s)
81
return str(s)
82
83
84
#############################################################################
85
# printing utils
86
#
87
88
def print_ranges(l):
89
for i in range(len(l)):
90
print("%-16d%16d" % ( (i+1)*32, i*32))
91
92
def print_chain(counter, s):
93
ch = cppyy.makeClass('HLT::Chain')(s)
94
#ch.deserialize(s)
95
print(".... chain %-3d Counter:%-4d Passed: %d (Raw:%d Prescaled: %d PassThrough:%d) Rerun: %d LastStep: %d Err: %s"\
96
% ( counter, ch.getChainCounter(), ch.chainPassed(), ch.chainPassedRaw(), ch.isPrescaled(), ch.isPassedThrough(),\
97
ch.isResurrected(), ch.getChainStep(), ch.getErrorCode().str()))
98
99
def print_all_chains(blob):
100
print("... chains:")
101
for i in range(len(blob)):
102
print_chain(i, blob[i])
103
104
105
def print_all_navigation(result):
106
print("... features")
107
for f in result.nav_payload:
108
print(".... %-52s %6d B " % (str(f[0])+'#'+str(f[1]), f[2]))
109
return
110
111
112
def print_HLTResult(result, opt):
113
if opt.sizes:
114
print("... Payload size: ", result.as_int_v.size(), " ", (4.0*result.as_int_v.size())/(1024), "kB")
115
116
if result.as_int_v.size() == 0:
117
print("... Payload size is 0")
118
119
# header info
120
121
version = result.getHLTResultClassVersion()
122
l1id = result.getLvl1Id()
123
acc = result.isAccepted()
124
pt = result.isPassThrough()
125
status = result.getHLTStatus()
126
cnvstatus = result.getLvlConverterStatus()
127
level = result.getHLTLevel()
128
nosigs = result.getNumOfSatisfiedSigs()
129
bad = result.isCreatedOutsideHLT()
130
trunc = result.isHLTResultTruncated()
131
print('... Version:', version ,' Lvl1Id:',l1id ,' Decision:',acc ,
132
' PassThrough:',pt,' Status:',status.str(),
133
' ConverterStatus:', cnvstatus.str(),' LVL:',level,' Signatures:',nosigs,' Bad:',bad,' Truncated:', trunc,
134
' App:', result.appName())
135
print()
136
137
chains_data = list(result.getChainResult())
138
nchains = chains_data[0] if chains_data else 0
139
nav_data = list(result.getNavigationResult())
140
nnav = len(nav_data)
141
nver = nav_data[0] if nav_data else 0
142
143
if opt.sizes:
144
print('... tot:', result.as_int_v.size(), ' chains:', nchains, ' chains (expected):', len(chains_data)-1,
145
' navigation:', nnav, ' navigation (expected):',result.getNavigationResult()[1] if nnav > 1 else "0 or 1")
146
147
if opt.conf:
148
try:
149
print("... SMkey: ", result.getConfigSuperMasterKey(), " Prescalers key ", result.getConfigPrescalesKey())
150
except Exception:
151
print("... No config info ")
152
153
if opt.chains:
154
print_all_chains(chains_data[1:])
155
156
157
print("... Navigation version: ", nver)
158
if opt.tes:
159
if nnav > 3:
160
tessize = result.getNavigationResult()[2]
161
tescount = result.getNavigationResult()[3]
162
print("... Number of TEs: ", tescount, " and size: ", tessize, " ", 4.0*tessize/(1024), "kB")
163
else:
164
print("... Cannot print TriggerElement details (not enough navigation data)")
165
166
if opt.features:
167
print_all_navigation(result)
168
169
170
##############################################################################
171
# collect the sizes
172
def collect_feature_sizes(dest, result):
173
for f in result.nav_payload:
174
key = f[0]+'#'+f[1]
175
if key not in dest:
176
dest[key] = 0
177
dest[key] += f[2]
178
179
# keyed by type
180
key = f[0]
181
if key not in dest:
182
dest[key] = 0
183
dest[key] += f[2]
184
185
if 'Total' not in dest:
186
dest['Total'] = 0
187
dest['Total'] += 4*result.as_int_v.size()
clear
void clear()
Empty the pool.
GenericResult::deserialize
virtual bool deserialize(const std::vector< uint32_t > &source)=0
unpacking raw result into the usable high level object
HLT::HLTResult
HLT::HLTResult is sumarising result of trigger decision evaluation (online/offline) It contains basic...
Definition
HLTResult.h:49
HLT::HLTResult::getNavigationResult
const std::vector< uint32_t > & getNavigationResult() const
retrieve the sub-payloads (can be used to retrieve/write data)
Definition
HLTResult.h:248
HLT::HLTResult::size
unsigned int size() const
Definition
HLTResult.cxx:613
HLT::HLTResult::getExtras
const std::vector< uint32_t > & getExtras() const
Definition
HLTResult.h:251
python.hltResult.hltResult
Definition
hltResult.py:10
python.hltResult.hltResult.__unpack_navigation
__unpack_navigation(self)
Definition
hltResult.py:28
python.hltResult.hltResult.appName
appName(self)
Definition
hltResult.py:48
python.hltResult.hltResult.as_int_v
as_int_v
Definition
hltResult.py:13
python.hltResult.hltResult.nav_payload
list nav_payload
Definition
hltResult.py:16
python.hltResult.hltResult.load
load(self, rob)
Definition
hltResult.py:15
python.hltResult.hltResult.__init__
__init__(self)
Definition
hltResult.py:11
python.hltResult.deserialize_string
deserialize_string(lwords)
Definition
hltResult.py:72
python.hltResult.get_feature_data_blob
get_feature_data_blob(data, index)
Definition
hltResult.py:55
Generated on
for ATLAS Offline Software by
1.17.0