ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigHypothesis
TrigHLTJetHypo
python
hypoToolDisplay.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3
from
TrigHLTJetHypo.HypoToolAnalyser
import
HypoToolAnalyser
4
5
import
os
6
7
from
AthenaCommon.Logging
import
logging
8
from
AthenaCommon.Constants
import
DEBUG
9
logger = logging.getLogger( __name__)
10
11
logger.setLevel(DEBUG)
12
13
def
toolname
(tool):
14
"""string containing class/instance name for and AlgTool"""
15
16
return
'%s/%s'
% (tool.__class__.__name__, tool.name)
17
18
def
tool_label
(tool, do_dot=False):
19
"""make a label for a dot node consisting of the non-child attributes
20
of an AlgTool"""
21
22
23
indent =
' '
24
if
do_dot:
25
label =
toolname
(tool)
26
else
:
27
label = indent +
toolname
(tool)
28
for
k, v
in
tool._properties.items():
29
# if v.__class__.__name__ == 'TrigJetHypoToolHelperNoGrouper':
30
# continue
31
32
if
v.__class__.__name__ ==
'PrivateToolHandleArray'
:
33
continue
34
else
:
35
if
do_dot:
36
label +=
'\\n%s %s'
% (k, str(v))
37
else
:
38
label +=
'\n%s%s %s'
% (indent, k, str(v))
39
return
label
40
41
42
def
hypoToolToDot
(node_labels, connections, toolname, dotdir):
43
""" Produce a dot file to visualise the nested AlgTools used
44
to configure a jet hypo AlgTool."""
45
46
text = [
'digraph G{'
]
47
for
k, l
in
connections.items():
48
for
n
in
l:
49
text.append(
'%d -> %d;'
% (k, n))
50
51
text.append(
'\n'
)
52
53
for
k, label
in
node_labels.items():
54
description =
'[shape=box, label="%s"];'
% label
55
text.append(
'%d %s'
% (k, description))
56
57
text.append(
'}'
)
58
59
text =
'\n'
.join(text)
60
61
if
not
dotdir:
62
dotdir = os.environ[
'HOME'
]
63
64
outfn = os.path.join(dotdir, toolname+
'.dot'
)
65
66
67
with
open(outfn,
'w'
)
as
fh:
68
logger.debug(
'writing dot file to '
+ outfn)
69
fh.write(text)
70
71
72
def
hypoToolDisplay(tool, do_dot=False, dotdir=''):
73
74
analyser = HypoToolAnalyser(tool)
75
node_table, connections = analyser.tables()
76
77
node_labels = {k:
tool_label
(v, do_dot=
False
)
for
k, v
in
node_table.items()}
78
s = [tool.name,
'\n:'
]
79
for
k, v
in
node_labels.items():
80
s.append(
'\n%3d\n%s'
% (k, v))
81
82
s.append(
'\nconnections:\n'
)
83
84
for
k, v
in
connections.items():
85
s.append(
'%3d: %s'
% (k, str(v)))
86
87
text =
'\n'
.join(s)
88
logger.info(text)
89
90
91
if
do_dot:
92
node_labels = {k:
tool_label
(v, do_dot)
for
k, v
in
node_table.items()}
93
hypoToolToDot
(node_labels, connections, tool.name, dotdir)
94
95
96
Constants
python.hypoToolDisplay.toolname
toolname(tool)
Definition
hypoToolDisplay.py:13
python.hypoToolDisplay.hypoToolToDot
hypoToolToDot(node_labels, connections, toolname, dotdir)
Definition
hypoToolDisplay.py:42
python.hypoToolDisplay.tool_label
tool_label(tool, do_dot=False)
Definition
hypoToolDisplay.py:18
Generated on
for ATLAS Offline Software by
1.17.0