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