75 def plot(data, showThreads=True, batch=False, nevtcolors=10, width=1200, height=500):
78 tmin = min(f.start
for f
in data)
79 tmax = max(f.end
for f
in data)
80 slots = 1 + max(f.slot
for f
in data)
81 threads = sorted(list(set(f.thread
for f
in data)))
82 threadid = dict((k, v)
for v, k
in enumerate(threads))
83 ymax = len(threads)
if showThreads
else slots
85 c = ROOT.TCanvas(
"timeline",
"Timeline", width, height)
89 c.SetBottomMargin(0.1)
90 c.coord = ROOT.TH2I(
"coord",
";Time (ns)", 100, 0, tmax - tmin, ymax, 0, ymax)
91 c.coord.GetYaxis().SetTitle((
"Thread" if showThreads
else "Slot"))
92 c.coord.GetYaxis().SetTitleOffset(0.5)
93 c.coord.GetYaxis().CenterTitle()
94 c.coord.SetStats(
False)
95 c.coord.GetYaxis().SetNdivisions(ymax)
96 c.coord.GetXaxis().CenterTitle()
106 y = threadid[d.thread]
if showThreads
else d.slot
108 if alg
not in colors
and len(mycolors) > 0:
109 colors[alg] = mycolors.pop(0)
110 if len(mycolors) == 0:
111 print(
"Too many algorithm to show")
118 l = ROOT.TBox(t0, y + 0.1, t1, y + 0.8)
119 l.SetFillColor(colors[alg])
122 l2 = ROOT.TBox(t0, y + 0.8, t1, y + 0.9)
123 l2.SetFillColor(evtcolors[d.event % nevtcolors])
132 for k, v
in tevt.items():
133 y = ymax + bheight * v[2]
134 l = ROOT.TBox(v[0] - tmin, y + 0.2 * bheight, v[1] - tmin, y + bheight)
135 l.SetFillColor(evtcolors[k % nevtcolors])
140 c.leg = ROOT.TLegend(0.8, 0.4, 0.98, 0.9)
141 for alg, cl
in sorted(colors.items(), key=operator.itemgetter(1)):
142 e = c.leg.AddEntry(
"", alg,
"F")
148 bwidth = 0.18 / nevtcolors
149 for cl
in range(nevtcolors):
153 l.SetLineColor(evtcolors[cl])
154 l.DrawLineNDC(0.807 + bwidth * cl, 0.37, 0.807 + bwidth * (cl + 1), 0.37)
156 c.t1 = ROOT.TText(0.807, 0.314,
"Events")
159 c.t1.SetTextSize(0.04)
162 c.t2 = ROOT.TText(0.02, 0.92,
"Event")
165 c.t2.SetTextSize(0.03)
166 c.t2.SetTextAngle(90)
168 c.t3 = ROOT.TText(0.03, 0.922,
"Slots")
171 c.t3.SetTextSize(0.03)
172 c.t3.SetTextAngle(90)