12Test import for Online system root file
13with histograms in subdirs
17from ROOT
import Belle2, TFile, TH1F, gROOT
21filein =
"histino2.root"
22fileout =
'histouto2.root'
23statfile =
"statso2.txt"
25f = TFile(filein,
"RECREATE")
29h_expno = TH1F(
"expno",
"1", 1, 0, 1)
30h_runno = TH1F(
"runno",
"1", 1, 0, 1)
31h_rtype = TH1F(
"rtype",
"null", 1, 0, 1)
36h_test = TH1F(
"test",
"", 1, 0, 1)
41h_nevent = TH1F(
"Nevent",
"", 1, 0, 1)
51main = b2.create_path()
52emptypath = b2.create_path()
54dqminput = b2.register_module(
'DQMHistAnalysisInput2')
55dqminput.param(
'HistMemoryPath', filein)
56dqminput.param(
'RefreshInterval', 0)
57dqminput.param(
'StatFileName', statfile)
58dqminput.param(
"EnableRunInfo",
True)
59dqminput.if_false(emptypath)
60main.add_module(dqminput)
62main.add_module(
"DQMHistAutoCanvas")
64dqmoutput = b2.register_module(
'DQMHistAnalysisOutputFile')
65dqmoutput.param(
'OutputFolder',
'./')
66dqmoutput.param(
'Filename', fileout)
67main.add_module(dqmoutput)
72expected = [
"DQMInfo/c_info",
"DAQ/c_Nevent",
"DQMInfo/c_expno",
"DQMInfo/c_runno",
"DQMInfo/c_rtype",
"TEST/c_test"]
73b2.B2INFO(
"== resulting file content ==")
74f = TFile(fileout,
"READ")
75for k
in f.GetListOfKeys():
77 b2.B2INFO(o.ClassName(), k)
78 if o.GetName() ==
"DQMInfo/c_info":
79 if "Exp 1, Run 1, RunType null" not in o.GetTitle():
80 b2.B2ERROR(f
"Run Info not found in {o.GetName()}: {o.GetTitle()}")
81 if o.GetName()
in expected:
82 expected.remove(o.GetName())
83b2.B2INFO(
"============================")
85 b2.B2ERROR(
"missing items in outfile: ", expected)
86b2.B2INFO(
"== resulting stat content ==")
87with open(statfile,
'r')
as f:
89b2.B2INFO(
"=========================")
static Environment & Instance()
Static method to get a reference to the Environment instance.