84 tmin =
min(f.start
for f
in data)
85 tmax =
max(f.end
for f
in data)
86 slots = 1 +
max(f.slot
for f
in data)
87 threads = sorted(list(set(f.thread
for f
in data)))
88 threadid = dict((k, v)
for v, k
in enumerate(threads))
89 ymax = len(threads)
if showThreads
else slots
91 c = ROOT.TCanvas(
'timeline',
'Timeline', width, height)
95 c.SetBottomMargin(0.1)
96 c.coord = ROOT.TH2I(
'coord',
';Time (ns)', 100, 0, tmax - tmin, ymax, 0,
98 c.coord.GetYaxis().SetTitle((
'Thread' if showThreads
else 'Slot'))
99 c.coord.GetYaxis().SetTitleOffset(0.5)
100 c.coord.GetYaxis().CenterTitle()
101 c.coord.SetStats(
False)
102 c.coord.GetYaxis().SetNdivisions(ymax)
103 c.coord.GetXaxis().CenterTitle()
113 y = (threadid[d.thread]
if showThreads
else d.slot)
115 if alg
not in colors
and len(mycolors) > 0:
116 colors[alg] = mycolors.pop(0)
117 if len(mycolors) == 0:
118 print(
"Too many algorithm to show")
125 l = ROOT.TBox(t0, y + .1, t1, y + .8)
126 l.SetFillColor(colors[alg])
129 l2 = ROOT.TBox(t0, y + .8, t1, y + .9)
130 l2.SetFillColor(evtcolors[d.event % nevtcolors])
139 for k, v
in tevt.iteritems():
140 y = ymax + bheight * v[2]
141 l = ROOT.TBox(v[0] - tmin, y + 0.2 * bheight, v[1] - tmin, y + bheight)
142 l.SetFillColor(evtcolors[k % nevtcolors])
147 c.leg = ROOT.TLegend(0.8, 0.4, 0.98, 0.9)
148 for alg, cl
in sorted(colors.iteritems(), key=operator.itemgetter(1)):
149 e = c.leg.AddEntry(
'', alg,
'F')
155 bwidth = 0.18 / nevtcolors
156 for cl
in range(nevtcolors):
160 l.SetLineColor(evtcolors[cl])
161 l.DrawLineNDC(0.807 + bwidth * cl, 0.37, 0.807 + bwidth * (cl + 1),
164 c.t1 = ROOT.TText(0.807, 0.314,
'Events')
167 c.t1.SetTextSize(0.04)
170 c.t2 = ROOT.TText(0.02, 0.92,
'Event')
173 c.t2.SetTextSize(0.03)
174 c.t2.SetTextAngle(90)
176 c.t3 = ROOT.TText(0.03, 0.922,
'Slots')
179 c.t3.SetTextSize(0.03)
180 c.t3.SetTextAngle(90)