73 def analyze(root, level, gtrees, gbranches, doprint, sorttype):
77 keys = root.GetListOfKeys()
79 objname = key.GetName()
80 if objname
not in trees:
81 obj = root.Get(objname)
82 if obj
and obj.InheritsFrom(
'TTree'):
84 if objname ==
'Events':
91 for key
in sorted(trees.keys()):
93 nentry = tree.GetEntriesFast()
95 print(
'%s has %d entries.' % (key, nentry))
100 gtrees[key] = gtrees[key] + nentry
107 print(
'\nBranches of Events tree:\n')
119 print(
' Total bytes Zipped bytes Comp. Branch name')
120 print(
' ----------- ------------ ----- -----------')
122 branches = events.GetListOfBranches()
128 for branch
in branches:
129 branch_class = branch.GetClass().GetName()
133 if branch_class[0: 13] ==
'art::Wrapper<':
137 subbranches = branch.GetListOfBranches()
138 for subbranch
in subbranches:
139 name = subbranch.GetName()
143 if name[-4:] ==
'.obj':
144 ntot = subbranch.GetTotBytes(
"*")
145 nzip = subbranch.GetZipBytes(
"*")
146 ntotall = ntotall + ntot
147 nzipall = nzipall + nzip
150 comp = float(ntot) / float(nzip)
160 branch_tuples[branch_key] = (ntot, nzip, comp, name)
165 if name
in gbranches:
166 gbranches[name][0] = gbranches[name][0] + ntot
167 gbranches[name][1] = gbranches[name][1] + nzip
169 gbranches[name] = [ntot, nzip]
174 subsubbranches = subbranch.GetListOfBranches()
175 for subsubbranch
in subsubbranches:
176 name = subsubbranch.GetName()
177 ntot = subsubbranch.GetTotBytes(
"*")
178 nzip = subsubbranch.GetZipBytes(
"*")
181 comp = float(ntot) / float(nzip)
191 branch_tuples[branch_key] = (ntot, nzip, comp, name)
197 if name
in gbranches:
198 gbranches[name][0] = gbranches[name][0] + ntot
199 gbranches[name][1] = gbranches[name][1] + nzip
201 gbranches[name] = [ntot, nzip]
206 for branch_key
in sorted(branch_tuples.keys()):
207 branch_tuple = branch_tuples[branch_key]
208 ntot = branch_tuple[0]
209 nzip = branch_tuple[1]
210 comp = branch_tuple[2]
211 name = branch_tuple[3]
212 print(
'%14d%14d%8.2f %s' % (ntot, nzip, comp, name))
216 name =
'All branches'
219 comp = float(ntotall) / float(nzipall)
222 print(
'%14d%14d%8.2f %s' % (ntotall, nzipall, comp, name))
226 nev = events.GetEntriesFast()
228 nevtot = 1.e-6 * float(ntotall) / float(nev)
229 nevzip = 1.e-6 * float(nzipall) / float(nev)
234 print(
'%10d events.' % nev)
235 print(
'%7.2f Mb average size per event.' % nevtot)
236 print(
'%7.2f Mb average zipped size per event.' % nevzip)
238 if name
in gbranches:
239 gbranches[name][0] = gbranches[name][0] + ntotall
240 gbranches[name][1] = gbranches[name][1] + nzipall
242 gbranches[name] = [ntotall, nzipall]