The Gaudi Framework  v36r6 (b1ee9983)
directories.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 
16 
17 def config():
18  import GaudiConfig2.Configurables as C
19  import GaudiConfig2.Configurables.Gaudi.Tests.Histograms.Directories as D
20 
21  algs = []
22  tools = []
23  svcs = []
24 
25  Alg = D.HistoGroupsAlg
26  algs.append(Alg("Alg"))
27 
28  svcs.append(C.Gaudi.Histograming.Sink.Root(FileName=FILENAME))
29  svcs.append(C.Gaudi.Monitoring.MessageSvcSink())
30 
31  yield from algs
32  yield from tools
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  for name in [
59  f"{component}/{histogram}"
60  for component in ["Alg", "Alg/Tool"]
61  for histogram in [
62  "Top",
63  "Group/First",
64  "Group/Second",
65  "Group/SubGroup/Third",
66  ]
67  ]:
68  h = f.Get(name)
69  assert h, f"missing histogram {name}"
70 
71  except AssertionError as err:
72  causes.append(str(err))
73  return False
74 
75  except Exception as err:
76  causes.append("failure reading histogram file")
77  result["python_exception"] = result.Quote(format_exc())
78  return False
79 
80  return True
GaudiConfig2.Configurables
Definition: Configurables.py:1
GaudiTests.Histograms.directories.config
def config()
Definition: directories.py:17
GaudiTests.Histograms.directories.check
def check(causes, result)
Definition: directories.py:47