The Gaudi Framework  v36r1 (3e2fb5a8)
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  f = ROOT.TFile.Open(FILENAME)
57  for name in [
58  f"{component}/{histogram}"
59  for component in ["Alg", "Alg/Tool"] for histogram in
60  ["Top", "Group/First", "Group/Second", "Group/SubGroup/Third"]
61  ]:
62  h = f.Get(name)
63  assert h, f"missing histogram {name}"
64 
65  except AssertionError as err:
66  causes.append(str(err))
67  return False
68 
69  except Exception as err:
70  causes.append("failure reading histogram file")
71  result["python_exception"] = result.Quote(format_exc())
72  return False
73 
74  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