Functions | Variables
python.subruns Namespace Reference

Functions

def get_subruns (inputfile)
 

Variables

 myargv = sys.argv
 
 argv
 
 gErrorIgnoreLevel
 
 category
 
 RuntimeWarning
 
 message
 
 run_subruns = get_subruns(str(sys.argv[1]))
 

Function Documentation

def python.subruns.get_subruns (   inputfile)

Definition at line 46 of file subruns.py.

46 def get_subruns(inputfile):
47 
48  # Initialize return value to empty list.
49 
50  result = []
51 
52  # Check whether this file exists.
53  if not os.path.exists(inputfile) or not inputfile.endswith('.root'):
54  return result
55 
56  # Root checks.
57 
58  file = ROOT.TFile.Open(larbatch_posix.root_stream(inputfile))
59  if file and file.IsOpen() and not file.IsZombie():
60 
61  # Root file opened successfully.
62  # Get runs and subruns fro SubRuns tree.
63 
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_',
69  subrun_tree)
70  tfs = ROOT.TTreeFormula('subruns',
71  'SubRunAuxiliary.id_.subRun_',
72  subrun_tree)
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)
79 
80  # If previous section didn't find anything, try extracting
81  # from beam data trees.
82 
83  if len(result) == 0:
84  tdir = file.Get('beamdata')
85  if tdir and tdir.InheritsFrom('TDirectory'):
86 
87  # Look for bnb tree.
88 
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)
101 
102  # Look for numi tree.
103 
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)
116 
117  else:
118 
119  # Root file could not be opened.
120 
121  result = []
122 
123  # Sort in order of increasing run, then increasing subrun.
124 
125  result.sort()
126 
127  # Done.
128 
129  return result
130 
def get_subruns(inputfile)
Definition: subruns.py:46

Variable Documentation

python.subruns.argv

Definition at line 28 of file subruns.py.

python.subruns.category

Definition at line 40 of file subruns.py.

python.subruns.gErrorIgnoreLevel

Definition at line 34 of file subruns.py.

python.subruns.message

Definition at line 40 of file subruns.py.

python.subruns.myargv = sys.argv

Definition at line 27 of file subruns.py.

python.subruns.run_subruns = get_subruns(str(sys.argv[1]))

Definition at line 132 of file subruns.py.

python.subruns.RuntimeWarning

Definition at line 40 of file subruns.py.