Print information about objects in a ROOT file.
def python.rootplot.rootinfo.recurse_thru_file |
( |
|
in_tfile, |
|
|
|
options, |
|
|
|
full_path = '/' |
|
) |
| |
Recursive function to find all contents in a given ROOT file
Definition at line 22 of file rootinfo.py.
23 '''Recursive function to find all contents in a given ROOT file'''
24 keys = in_tfile.GetDirectory(full_path).GetListOfKeys()
27 classname = key.GetClassName()
28 if 'TDirectory' in classname:
33 if options.name
and name != options.name:
continue
34 full_name =
'/'.
join([full_path,name])
35 obj = in_tfile.Get(full_name)
38 simple_name = full_name[2:]
39 print(
"%s" % simple_name, end=
' ')
40 for arg
in [x[2:]
for x
in sys.argv
if x.startswith(
"--")]:
41 if "classname" == arg:
42 print(
"%s" % classname, end=
' ')
43 if obj.InheritsFrom(
'TH1'):
45 print(
" %i" % obj.GetEntries(), end=
' ')
47 if obj.InheritsFrom(
'TH2'):
50 for j
in reversed(list(
range(obj.GetNbinsY()))):
53 [
str(obj.GetBinContent(i+1, j+1))
for i
in range(obj.GetNbinsX())]), end=
' ')
56 [
str(obj.GetBinContent(i+1))
for i
in range(obj.GetNbinsX())]), end=
' ')
58 if obj.InheritsFrom(
'TH2'):
59 for j
in reversed(list(
range(obj.GetNbinsY()))):
62 [
str(obj.GetBinError(i+1, j+1))
for i
in range(obj.GetNbinsX())]), end=
' ')
65 [
str(obj.GetBinError(i+1))
for i
in range(obj.GetNbinsX())]), end=
' ')
66 if "bincenter" == arg:
68 [
str(obj.GetBinCenter(i+1))
for i
in range(obj.GetNbinsX())]), end=
' ')
70 print(
" %i" % obj.GetMaximum(), end=
' ')
72 print(
" %i" % obj.GetMinimum(), end=
' ')
74 print(
" %i" % obj.GetBinContent(obj.GetNbinsX()), end=
' ')
75 if "underflow" == arg:
76 print(
" %i" % obj.GetBinContent(0), end=
' ')
77 if obj.InheritsFrom(
'TGraph'):
79 x, y = Double(0), Double(0)
82 for i
in range(obj.GetN()):
84 xvals.append(copy.copy(x))
85 yvals.append(copy.copy(y))
86 for point
in zip(xvals,yvals):
87 print(
" (%d, %d)" % point, end=
' ')
References join(), print(), FastTimerService_cff.range, str, and ComparisonHelper.zip().
Referenced by python.rootplot.rootinfo.main().