The Gaudi Framework
master (6507eef1)
Toggle main menu visibility
Loading...
Searching...
No Matches
axes_labels.py
Go to the documentation of this file.
1
11
import
os
12
from
traceback
import
format_exc
13
14
FILENAME = f
"{__name__}.root"
15
FILENAMEJSON = f
"{__name__}.json"
16
17
18
def
config
():
19
import
GaudiConfig2.Configurables
as
C
20
import
GaudiConfig2.Configurables.Gaudi.Tests.Histograms.AxesLabels
as
T
21
22
algs = []
23
svcs = []
24
25
HistoAlgo = T.HistWithLabelsAlg
26
algs.append(HistoAlgo(
"HistoAlgo"
))
27
28
svcs.append(C.Gaudi.Histograming.Sink.Root(FileName=FILENAME))
29
svcs.append(C.Gaudi.Monitoring.JSONSink(FileName=FILENAMEJSON))
30
svcs.append(C.Gaudi.Monitoring.MessageSvcSink())
31
32
yield
from
algs
33
yield
from
svcs
34
35
yield
C.ApplicationMgr(
36
EvtMax=5,
37
EvtSel=
"NONE"
,
38
TopAlg=algs,
39
ExtSvc=svcs,
40
)
41
42
# make sure the histogram file is not already there
43
if
os.path.exists(FILENAME):
44
os.remove(FILENAME)
45
46
47
def
check
(causes, result):
48
result[
"root_output_file"
] = FILENAME
49
50
if
not
os.path.exists(FILENAME):
51
causes.append(
"missing histogram file"
)
52
return
False
53
54
try
:
55
import
ROOT
56
57
f = ROOT.TFile.Open(FILENAME)
58
h = f.Get(
"HistoAlgo/hist"
)
59
axis = h.GetXaxis()
60
labels = list(axis.GetLabels())
61
expected = [
"a"
,
"b"
,
"c"
,
"d"
,
"e"
]
62
if
labels != expected:
63
causes.append(
"wrong axis labels"
)
64
result[
"expected_labels"
] =
", "
.join(repr(l)
for
l
in
expected)
65
result[
"found_labels"
] =
", "
.join(repr(l)
for
l
in
labels)
66
return
False
67
68
except
Exception:
69
causes.append(
"failure reading histogram file"
)
70
result[
"python_exception"
] = result.Quote(format_exc())
71
return
False
72
73
return
True
GaudiConfig2.Configurables
Definition
Configurables.py:1
axes_labels.check
check(causes, result)
Definition
axes_labels.py:47
axes_labels.config
config()
Definition
axes_labels.py:18
GaudiTestSuite
python
GaudiTests
Histograms
axes_labels.py
Generated on
for The Gaudi Framework by
1.17.0