ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
D3PDSizeSummary.Filestats Class Reference
Collaboration diagram for D3PDSizeSummary.Filestats:

Public Member Functions

def __init__ (self, fname, treename=None)
 
def get_treename (self)
 
def get_branchgroup (self, b)
 
def get_stats (self)
 
def scan_branches (self)
 
def print_stats_text (self)
 
def draw_pie (self)
 

Public Attributes

 fname
 
 treename
 
 branchgroups
 
 file_size
 
 rfile
 
 tree
 
 nev
 

Detailed Description

Definition at line 172 of file D3PDSizeSummary.py.

Constructor & Destructor Documentation

◆ __init__()

def D3PDSizeSummary.Filestats.__init__ (   self,
  fname,
  treename = None 
)

Definition at line 173 of file D3PDSizeSummary.py.

173  def __init__ (self, fname, treename = None):
174  self.fname = fname
175  self.treename = treename
176  self.branchgroups = {}
177  self.get_stats()
178  return
179 
180 

Member Function Documentation

◆ draw_pie()

def D3PDSizeSummary.Filestats.draw_pie (   self)

Definition at line 251 of file D3PDSizeSummary.py.

251  def draw_pie (self):
252 
253  if options.debug:
254  print "Number of branch groups:", len(self.branchgroups)
255  print "Values of branch groups:", list(self.branchgroups.keys())
256 
257  blist = self.branchgroups.values()
258  blist.sort (lambda a, b: int(b.filebytes - a.filebytes))
259  pie = ROOT.TPie("BranchPie", "", len(self.branchgroups))
260  for i, bgroup in enumerate( blist ):
261  bginfo = bgroup.get_dict(self.nev)
262 
263  if options.debug:
264  print "Branch group #%d, named %s with size %f = %f%%" % (i , bginfo['name'], (float(bgroup.filebytes) / 1024 / self.nev ), (100. * float(bgroup.filebytes) / float(self.file_size)) )
265 
266  pie.SetEntryLabel(i, bginfo['name'])
267  pie.SetEntryVal (i, (100. * float(bgroup.filebytes) / float(self.file_size)) )
268  pie.SetEntryFillColor(i, i+2)
269 
270 
271  c1 = ROOT.TCanvas( 'c1' , 'c1' )
272 
273  pie.SetCircle(.5,.45,.2)
274  pie.SetLabelFormat("#splitline{%txt}{(%perc)}")
275  pie.SetLabelFormat("%txt")
276  pie.SetRadius(0.2)
277  pie.SetTextSize(0.03)
278  pie.SetCircle(0.4808696, 0.7940109, 0.2)
279  pie.SetValueFormat("%4.2f")
280  pie.SetLabelFormat("%txt")
281  pie.SetPercentFormat("%3.1f")
282  pie.SetLabelsOffset(0.005)
283  pie.SetAngularOffset(265.2655)
284  leg = ROOT.TLegend(0.05580866, 0.06554878, 0.785877, 0.4512195)
285  for i, bgroup in enumerate( blist ):
286  if ( (float(bgroup.filebytes) / float(self.file_size)) > 0.05):
287  pie.SetEntryRadiusOffset(i,.07)
288  bginfo = bgroup.get_dict(self.nev)
289  leg.AddEntry( pie.GetSlice(i), "%s : %1.1lf%%" % (bginfo['name'] , 100. * float(bgroup.filebytes) / float(self.file_size)) , "f" )
290  else:
291  pie.SetEntryLabel(i,"")
292 
293  leg.SetFillColor(0);
294  leg.SetFillStyle(0);
295 
296  pie.Draw("3d")
297  leg.Draw();
298 
299  c1.SaveAs(options.filename + "." + options.extension)
300 
301 
302 
303 
304 

◆ get_branchgroup()

def D3PDSizeSummary.Filestats.get_branchgroup (   self,
  b 
)

Definition at line 190 of file D3PDSizeSummary.py.

190  def get_branchgroup (self, b):
191  bname = b.GetName()
192  ll = bname.split ('_')
193  if bname in ['RunNumber',
194  'EventNumber',
195  'timestamp',
196  'timestamp_ns',
197  'lbn',
198  'bcid',
199  'detmask0',
200  'detmask1',
201  'collcand']:
202  gname = 'EventInfo'
203  elif len(ll) > 1:
204  gname = ll[0]
205  elif (bname.endswith ('Error') or bname.endswith ('Flags')):
206  gname = 'DetFlags'
207  else:
208  gname = bname
209  group = self.branchgroups.get (gname)
210  if not group:
211  group = Branchgroup (gname)
212  self.branchgroups[gname] = group
213  return group
214 
215 

◆ get_stats()

def D3PDSizeSummary.Filestats.get_stats (   self)

Definition at line 216 of file D3PDSizeSummary.py.

216  def get_stats (self):
217  self.file_size = os.stat(self.fname).st_size
218  self.rfile = ROOT.TFile.Open (self.fname)
219  self.get_treename()
220  if self.treename == None:
221  raise Exception ("Can't find tree name in file.")
222  self.tree = self.rfile.Get (self.treename)
223  if not self.tree:
224  raise Exception ("Can't find tree " + self.treename + " in file.")
225  self.nev = self.tree.GetEntries()
226  self.scan_branches()
227  return
228 
229 

◆ get_treename()

def D3PDSizeSummary.Filestats.get_treename (   self)

Definition at line 181 of file D3PDSizeSummary.py.

181  def get_treename (self):
182  if self.treename: return
183  for kk in self.rfile.GetListOfKeys():
184  if (kk.GetClassName() == 'TTree' and
185  kk.GetName() != 'CollectionTree'):
186  self.treename = kk.GetName()
187  return
188 
189 

◆ print_stats_text()

def D3PDSizeSummary.Filestats.print_stats_text (   self)

Definition at line 237 of file D3PDSizeSummary.py.

237  def print_stats_text (self):
238  print "Number of events:", self.nev
239  print "File size: %dk" % int(float(self.file_size)/1024 + 0.5)
240  print "Overall size/event: %.1fk" % (float(self.file_size) / self.nev / 1024)
241 
242  bl = self.branchgroups.values()
243  bl.sort (lambda a, b: int(b.filebytes - a.filebytes))
244  Branchgroup.print_header()
245  for bg in bl:
246  bg.print_stats (self.nev)
247  Branchgroup.print_trailer()
248  return
249 
250 

◆ scan_branches()

def D3PDSizeSummary.Filestats.scan_branches (   self)

Definition at line 230 of file D3PDSizeSummary.py.

230  def scan_branches (self):
231  for b in self.tree.GetListOfBranches():
232  bg = self.get_branchgroup (b)
233  bg.add (b)
234  return
235 
236 

Member Data Documentation

◆ branchgroups

D3PDSizeSummary.Filestats.branchgroups

Definition at line 176 of file D3PDSizeSummary.py.

◆ file_size

D3PDSizeSummary.Filestats.file_size

Definition at line 217 of file D3PDSizeSummary.py.

◆ fname

D3PDSizeSummary.Filestats.fname

Definition at line 174 of file D3PDSizeSummary.py.

◆ nev

D3PDSizeSummary.Filestats.nev

Definition at line 225 of file D3PDSizeSummary.py.

◆ rfile

D3PDSizeSummary.Filestats.rfile

Definition at line 218 of file D3PDSizeSummary.py.

◆ tree

D3PDSizeSummary.Filestats.tree

Definition at line 222 of file D3PDSizeSummary.py.

◆ treename

D3PDSizeSummary.Filestats.treename

Definition at line 175 of file D3PDSizeSummary.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
readCCLHist.float
float
Definition: readCCLHist.py:83