The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
custom_axis Namespace Reference

Functions

 config ()
 
 check (causes, result)
 

Variables

str FILENAME = f"{__name__}.root"
 
str FILENAMEJSON = f"{__name__}.json"
 

Function Documentation

◆ check()

custom_axis.check ( causes,
result )

Definition at line 49 of file custom_axis.py.

49def check(causes, result):
50 result["root_output_file"] = FILENAME
51
52 if not os.path.exists(FILENAME):
53 causes.append("missing histogram file")
54 return False
55
56 try:
57 import ROOT
58
59 f = ROOT.TFile.Open(FILENAME)
60
61 h = f.Get("Alg/Categories")
62 if not h:
63 k = f.GetKey("Alg/Categories")
64 if k:
65 h = k.ReadObj()
66
67 assert h, "missing histogram"
68
69 if h.GetNbinsX() != 4:
70 causes.append("number of bins")
71 result["error"] = f"expected 4 bins, got {h.GetNbinsX()}"
72 return False
73
74 axis = h.GetXaxis()
75 labels = list(axis.GetLabels())
76 expected = ["Simple", "Complex", "Bad", "Wrong"]
77 if labels != expected:
78 causes.append("wrong axis labels")
79 result["expected_labels"] = ", ".join(repr(l) for l in expected)
80 result["found_labels"] = ", ".join(repr(l) for l in labels)
81 return False
82
83 except AssertionError as err:
84 causes.append(str(err))
85 return False
86
87 except Exception:
88 causes.append("failure reading histogram file")
89 result["python_exception"] = result.Quote(format_exc())
90 return False
91
92 return True

◆ config()

custom_axis.config ( )

Definition at line 18 of file custom_axis.py.

18def config():
20 import GaudiConfig2.Configurables.Gaudi.Tests.Histograms.CustomAxis as T
21
22 algs = []
23 tools = []
24 svcs = []
25
26 Alg = T.EnumAxisAlg
27 algs.append(Alg("Alg"))
28
29 svcs.append(C.Gaudi.Histograming.Sink.Root(FileName=FILENAME))
30 svcs.append(C.Gaudi.Monitoring.JSONSink(FileName=FILENAMEJSON))
31 svcs.append(C.Gaudi.Monitoring.MessageSvcSink())
32
33 yield from algs
34 yield from tools
35 yield from svcs
36
37 yield C.ApplicationMgr(
38 EvtMax=5,
39 EvtSel="NONE",
40 TopAlg=algs,
41 ExtSvc=svcs,
42 )
43
44 # make sure the histogram file is not already there
45 if os.path.exists(FILENAME):
46 os.remove(FILENAME)
47
48

Variable Documentation

◆ FILENAME

str custom_axis.FILENAME = f"{__name__}.root"

Definition at line 14 of file custom_axis.py.

◆ FILENAMEJSON

str custom_axis.FILENAMEJSON = f"{__name__}.json"

Definition at line 15 of file custom_axis.py.