87 self.
icons[
'h1_t'] = tk.PhotoImage(
88 file = os.path.join(os.path.dirname(__file__),
'../icons',
'h1_t.gif'))
89 self.
icons[
'h2_t'] = tk.PhotoImage(
90 file = os.path.join(os.path.dirname(__file__),
'../icons',
'h2_t.gif'))
91 self.
icons[
'folder_t'] = tk.PhotoImage(
92 file = os.path.join(os.path.dirname(__file__),
'../icons',
'folder_t.gif'))
93 self.
icons[
'tfile'] = tk.PhotoImage(
94 file = os.path.join(os.path.dirname(__file__),
'../icons',
'rootdb_t.gif'))
95 self.
icons[
'tcutg'] = tk.PhotoImage(
96 file = os.path.join(os.path.dirname(__file__),
'../icons',
'bld_cut.gif'))
97 self.
icons[
'ttree'] = tk.PhotoImage(
98 file = os.path.join(os.path.dirname(__file__),
'../icons',
'ttree_t.gif'))
99 img = tk.PhotoImage(file=os.path.join(os.path.dirname(__file__),
'../icons',
'hdb_s.gif'))
100 self.
window.tk.call(
'wm',
'iconphoto',self.
window._w,img)
103 style = ROOT.TStyle(
"GRSIStyle",
"")
104 style.SetOptStat(1001111)
106 style.SetTitleColor(ROOT.kBlue)
107 style.SetStatTextColor(ROOT.kBlue)
108 style.SetFuncColor(ROOT.kRed)
109 style.SetTitleBorderSize(0)
110 style.SetOptFit(1111)
111 style.SetPadBorderSize(1)
112 style.SetPadBorderMode(1)
113 ROOT.gROOT.SetStyle(
"GRSIStyle")
114 ROOT.gROOT.ForceStyle()
118 ws = self.
window.winfo_screenwidth()
119 hs = self.
window.winfo_screenheight()
121 self.
window.geometry(
'450x850+%d+%d' % (ws-475,25))
122 self.
window.wm_title(
"hist-o-matic")
125 frame = tk.Frame(self.
window)
126 button = tk.Button(frame,
127 text=
'Load Data File',fg=
"black",bg=
"goldenrod",
129 button.pack(side=tk.LEFT)
131 button = tk.Button(frame,
132 text=
'Load Root File',fg=
"black",bg=
"goldenrod",
134 button.pack(side=tk.LEFT)
136 button = tk.Button(frame,
137 text=
'Load Window File',fg=
"black",bg=
"goldenrod",
139 button.pack(side=tk.LEFT)
141 frame.pack(fill=tk.X,expand=
False)
143 frame = tk.Frame(self.
window)
145 button = tk.Button(frame,
146 text=
'Refresh',fg=
"black",bg=
"goldenrod",
148 button.pack(side=tk.LEFT)
150 button = tk.Button(frame,
151 text=
'Reset',fg=
"black",bg=
"goldenrod",
153 button.pack(side=tk.LEFT)
155 button = tk.Button(frame,
156 text=
'Reset All',fg=
"black",bg=
"goldenrod",
158 button.pack(side=tk.LEFT)
160 button = tk.Button(frame,
161 text=
'Resort Data',fg=
"black",bg=
"goldenrod",
163 button.pack(side=tk.LEFT)
165 frame.pack(fill=tk.X,expand=
False)
167 notebook = ttk.Notebook(self.
window)
169 hist_page = ttk.Frame(notebook)
171 notebook.add(hist_page, text=
'Histograms')
173 tcut_page = ttk.Frame(notebook)
175 notebook.add(tcut_page, text=
'Gates')
177 variable_page = ttk.Frame(notebook)
179 notebook.add(variable_page, text=
'Variables')
181 notebook.pack(fill=tk.BOTH,expand=
True)
248 filemenu = tk.Menu(menubar,tearoff=0)
249 filemenu.add_command(label=
"New Canvas",command=self.
open_canvas)
250 filemenu.add_separator()
251 filemenu.add_checkbutton(label=
"Size 800 x 600",onvalue=
"800x600",
253 filemenu.add_checkbutton(label=
"Size 1200 x 600",onvalue=
"1200x600",
255 filemenu.add_checkbutton(label=
"Size 1900 x 450",onvalue=
"1900x450",
257 filemenu.add_checkbutton(label=
"Size 1900 x 900",onvalue=
"1900x900",
259 filemenu.add_separator()
261 filemenu.add_separator()
262 filemenu.add_command(label=
"Open GUI",command=self.
hello)
263 filemenu.add_command(label=
"Save GUI",command=self.
_save_gui_file)
264 filemenu.add_command(label=
"Dump ROOT Config",
266 filemenu.add_command(label=
"Dump ROOT Histograms",command=self.
_dump_root_file)
267 filemenu.add_separator()
268 filemenu.add_command(label=
"Exit",command=self.
Terminate)
269 menubar.add_cascade(label=
"File",menu=filemenu)
280 if isinstance(obj, ROOT.TKey):
281 cls = ROOT.TClass(obj.GetClassName())
285 if cls.InheritsFrom(ROOT.TH2.Class()):
286 return self.
icons[
'h2_t']
287 elif cls.InheritsFrom(ROOT.TH1.Class()):
288 return self.
icons[
'h1_t']
289 elif cls.InheritsFrom(ROOT.TFile.Class()):
290 return self.
icons[
'tfile']
291 elif cls.InheritsFrom(ROOT.TDirectory.Class()):
292 return self.
icons[
'folder_t']
293 elif cls.InheritsFrom(ROOT.TList.Class()):
294 return self.
icons[
'folder_t']
295 elif cls.InheritsFrom(ROOT.TTree.Class()):
296 return self.
icons[
'ttree']
312 refreshmenu = tk.Menu(menubar,tearoff=0)
313 refreshmenu.add_checkbutton(label=
"Off",onvalue=-1,
316 refreshmenu.add_separator()
317 refreshmenu.add_checkbutton(label=
"1 second",onvalue=1,
319 refreshmenu.add_checkbutton(label=
"2 seconds",onvalue=2,
321 refreshmenu.add_checkbutton(label=
"5 seconds",onvalue=5,
323 refreshmenu.add_checkbutton(label=
"10 seconds",onvalue=10,
325 refreshmenu.add_checkbutton(label=
"30 seconds",onvalue=30,
327 menubar.add_cascade(label=
"Refresh",menu=refreshmenu)
343 zonesmenu = tk.Menu(menubar,tearoff=0)
344 zonesmenu.add_checkbutton(label=
"1 x 1",onvalue=
'1x1',
346 zonesmenu.add_checkbutton(label=
"1 x 2",onvalue=
'1x2',
348 zonesmenu.add_checkbutton(label=
"1 x 3",onvalue=
'1x3',
350 zonesmenu.add_checkbutton(label=
"2 x 1",onvalue=
'2x1',
352 zonesmenu.add_checkbutton(label=
"2 x 2",onvalue=
'2x2',
354 zonesmenu.add_checkbutton(label=
"2 x 3",onvalue=
'2x3',
356 zonesmenu.add_checkbutton(label=
"2 x 5",onvalue=
'2x5',
358 zonesmenu.add_checkbutton(label=
"3 x 1",onvalue=
'3x1',
360 zonesmenu.add_checkbutton(label=
"3 x 2",onvalue=
'3x2',
362 zonesmenu.add_checkbutton(label=
"3 x 3",onvalue=
'3x3',
364 zonesmenu.add_checkbutton(label=
"4 x 4",onvalue=
'4x4',
366 zonesmenu.add_checkbutton(label=
"5 x 2",onvalue=
'5x2',
368 zonesmenu.add_checkbutton(label=
"8 x 3",onvalue=
'8x3',
370 zonesmenu.add_checkbutton(label=
"8 x 4",onvalue=
'8x4',
372 zonesmenu.add_checkbutton(label=
"9 x 4",onvalue=
'9x4',
374 zonesmenu.add_checkbutton(label=
"12 x 12",onvalue=
'12x12',
376 zonesmenu.add_checkbutton(label=
"13 x 13",onvalue=
'13x13',
378 menubar.add_cascade(label=
"Zones",menu=zonesmenu)
403 optstatmenu = tk.Menu(menubar,tearoff=0)
404 optstatmenu.add_checkbutton(label=
"Name",onvalue=1,variable=self.
optstat_name)
405 optstatmenu.add_checkbutton(label=
"Entries",onvalue=1,variable=self.
optstat_entries)
406 optstatmenu.add_checkbutton(label=
"Mean",onvalue=1,variable=self.
optstat_mean)
407 optstatmenu.add_checkbutton(label=
"Mean Error",onvalue=1,variable=self.
optstat_mean_err)
408 optstatmenu.add_checkbutton(label=
"RMS",onvalue=1,variable=self.
optstat_rms)
409 optstatmenu.add_checkbutton(label=
"RMS Error",onvalue=1,variable=self.
optstat_rms_err)
410 optstatmenu.add_checkbutton(label=
"Underflows",onvalue=1,variable=self.
optstat_underflow)
411 optstatmenu.add_checkbutton(label=
"Overflows",onvalue=1,variable=self.
optstat_overflow)
412 optstatmenu.add_checkbutton(label=
"Integral",onvalue=1,variable=self.
optstat_integral)
413 optstatmenu.add_checkbutton(label=
"Skew",onvalue=1,variable=self.
optstat_skew)
414 optstatmenu.add_checkbutton(label=
"Skew Error",onvalue=1,variable=self.
optstat_skew_err)
415 optstatmenu.add_checkbutton(label=
"Kurtosis",onvalue=1,variable=self.
optstat_kurt)
416 optstatmenu.add_checkbutton(label=
"Kurtosis Error",onvalue=1,variable=self.
optstat_kurt_err)
417 menubar.add_cascade(label=
"OptStats",menu=optstatmenu)
422 plotmenu = tk.Menu(menubar,tearoff=0)
423 plotmenu.add_checkbutton(label=
"New Canvas",onvalue=
'NewCanvas',
425 plotmenu.add_checkbutton(label=
"Next Pad",onvalue=
'NextPad',
427 plotmenu.add_checkbutton(label=
"Current Pad (replace)",onvalue=
'Replace',
429 plotmenu.add_checkbutton(label=
"Current Pad (overlay)",onvalue=
'Overlay',
431 menubar.add_cascade(label=
"Plot",menu=plotmenu)
456 canvas_exists = bool(filter(
None,self.
canvases))
458 if(
not canvas_exists
or not ROOT.gPad):
463 ROOT.gPad.GetCanvas().cd(0)
464 if (ROOT.gPad.GetListOfPrimitives().GetSize()==0):
465 ROOT.gPad.GetCanvas().Clear();
486 currentnumber = ROOT.gPad.GetNumber()
487 if (self.
plotlocation.get() ==
'NextPad' and currentnumber>0):
488 ROOT.gPad.GetCanvas().cd(currentnumber+1)
489 if ROOT.gPad.GetNumber() == currentnumber:
490 ROOT.gPad.GetCanvas().cd(1)
495 if hist.GetDimension() > 1:
498 hist.SetLineColor(color)
499 hist.Draw(
' '.join(opt))
576 def open_canvas(self,title="",columns=-1,rows=-1,topx=0,topy=0,width=0,height=0):
578 title =
"canvas" + str(len(self.
canvases))
580 if columns==-1
or rows==-1:
584 if width*height == 0:
586 array = map(int,array)
587 canvas = ROOT.GCanvas(title,title,0,0,array[0],array[1],
True)
589 canvas = ROOT.GCanvas(title,title,topx,topy,width,height,
True)
592 if columns*rows == 1:
596 canvas.Divide(columns,rows)
597 canvas.cd(columns*rows)