18 from __future__
import absolute_import
19 from __future__
import print_function
23 import sys, os, project_utilities, larbatch_posix
28 sys.argv = myargv[0:1]
31 if 'TERM' in os.environ:
32 del os.environ[
'TERM']
34 ROOT.gErrorIgnoreLevel = ROOT.kError
40 warnings.filterwarnings(
'ignore', category = RuntimeWarning, message =
'creating converter.*')
53 if not os.path.exists(inputfile)
or not inputfile.endswith(
'.root'):
58 file = ROOT.TFile.Open(larbatch_posix.root_stream(inputfile))
59 if file
and file.IsOpen()
and not file.IsZombie():
64 subrun_tree = file.Get(
'SubRuns')
65 if subrun_tree
and subrun_tree.InheritsFrom(
'TTree'):
66 nsubruns = subrun_tree.GetEntriesFast()
67 tfr = ROOT.TTreeFormula(
'runs',
68 'SubRunAuxiliary.id_.run_.run_',
70 tfs = ROOT.TTreeFormula(
'subruns',
71 'SubRunAuxiliary.id_.subRun_',
73 for entry
in range(nsubruns):
74 subrun_tree.GetEntry(entry)
75 run = tfr.EvalInstance64()
76 subrun = tfs.EvalInstance64()
77 run_subrun = (run, subrun)
78 result.append(run_subrun)
84 tdir = file.Get(
'beamdata')
85 if tdir
and tdir.InheritsFrom(
'TDirectory'):
89 bnb_tree = tdir.Get(
'bnb')
90 if bnb_tree
and bnb_tree.InheritsFrom(
'TTree'):
91 nsubruns = bnb_tree.GetEntriesFast()
92 tfr = ROOT.TTreeFormula(
'runs',
'run', bnb_tree)
93 tfs = ROOT.TTreeFormula(
'subruns',
'subrun', bnb_tree)
94 for entry
in range(nsubruns):
95 bnb_tree.GetEntry(entry)
96 run = tfr.EvalInstance64()
97 subrun = tfs.EvalInstance64()
98 run_subrun = (run, subrun)
99 if run_subrun
not in result:
100 result.append(run_subrun)
104 numi_tree = tdir.Get(
'numi')
105 if numi_tree
and numi_tree.InheritsFrom(
'TTree'):
106 nsubruns = numi_tree.GetEntriesFast()
107 tfr = ROOT.TTreeFormula(
'runs',
'run', numi_tree)
108 tfs = ROOT.TTreeFormula(
'subruns',
'subrun', numi_tree)
109 for entry
in range(nsubruns):
110 numi_tree.GetEntry(entry)
111 run = tfr.EvalInstance64()
112 subrun = tfs.EvalInstance64()
113 run_subrun = (run, subrun)
114 if run_subrun
not in result:
115 result.append(run_subrun)
131 if __name__ ==
"__main__":
133 for run_subrun
in run_subruns:
134 print(run_subrun[0], run_subrun[1])
def get_subruns(inputfile)