56 def plot(data, showThreads=True, batch=False, nevtcolors=10, width=1200, height=500):
59 tmin = min(f.start
for f
in data)
60 tmax = max(f.end
for f
in data)
61 slots = 1+max(f.slot
for f
in data)
62 threads = sorted(list(set(f.thread
for f
in data)))
63 threadid = dict((k,v)
for v,k
in enumerate(threads))
64 ymax = len(threads)
if showThreads
else slots
66 c = ROOT.TCanvas(
'timeline',
'Timeline',width,height)
70 c.SetBottomMargin(0.1)
71 c.coord = ROOT.TH2I(
'coord',
';Time (ns)',100,0,tmax-tmin,ymax,0,ymax)
72 c.coord.GetYaxis().SetTitle((
'Thread' if showThreads
else 'Slot'))
73 c.coord.GetYaxis().SetTitleOffset(0.5)
74 c.coord.GetYaxis().CenterTitle()
75 c.coord.SetStats(
False)
76 c.coord.GetYaxis().SetNdivisions(ymax)
77 c.coord.GetXaxis().CenterTitle()
87 y = (threadid[d.thread]
if showThreads
else d.slot)
89 if alg
not in colors
and len(mycolors)>0:
90 colors[alg] = mycolors.pop(0)
92 print "Too many algorithm to show" 99 l = ROOT.TBox(t0, y+.1, t1, y+.8)
100 l.SetFillColor(colors[alg])
103 l2 = ROOT.TBox(t0, y+.8, t1, y+.9)
104 l2.SetFillColor(evtcolors[d.event % nevtcolors])
113 for k,v
in tevt.iteritems():
114 y = ymax+bheight*v[2]
115 l = ROOT.TBox(v[0]-tmin,y+0.2*bheight,v[1]-tmin,y+bheight)
116 l.SetFillColor(evtcolors[k % nevtcolors])
121 c.leg = ROOT.TLegend(0.8,0.4,0.98,0.9)
122 for alg,cl
in sorted(colors.iteritems(),key=operator.itemgetter(1)):
123 e = c.leg.AddEntry(
'',alg,
'F')
129 bwidth = 0.18 / nevtcolors
130 for cl
in range(nevtcolors):
134 l.SetLineColor(evtcolors[cl])
135 l.DrawLineNDC(0.807+bwidth*cl,0.37,0.807+bwidth*(cl+1),0.37)
137 c.t1 = ROOT.TText(0.807,0.314,
'Events')
140 c.t1.SetTextSize(0.04)
143 c.t2 = ROOT.TText(0.02,0.92,
'Event')
146 c.t2.SetTextSize(0.03)
147 c.t2.SetTextAngle(90)
149 c.t3 = ROOT.TText(0.03,0.922,
'Slots')
152 c.t3.SetTextSize(0.03)
153 c.t3.SetTextAngle(90)
158 if not batch: raw_input()
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
def plot(data, showThreads=True, batch=False, nevtcolors=10, width=1200, height=500)
def setPalette(nevts, nevtcolors)