8ROOT.PyConfig.IgnoreCommandLineOptions =
True
10from .util
import increment_name
33 for cut
in self.
cuts.values():
38 for name, cut
in self.
cuts.items():
40 for i
in xrange(cut.GetN()):
41 points.append((cut.GetX()[i], cut.GetY()[i]))
43 pattern = {
'name':name,
48 output.append(pattern)
52 for pattern
in patterns:
53 cut = ROOT.TCutG(pattern[
'name'],len(pattern[
'points']))
54 cut.SetVarX(pattern[
'varx'])
55 cut.SetVarY(pattern[
'vary'])
56 for i,(x,y)
in enumerate(pattern[
'points']):
62 cutg = ROOT.gROOT.GetListOfSpecials().FindObject(
'CUTG')
74 xf = cutg.GetX()[npoints-1]
75 yf = cutg.GetY()[npoints-1]
82 gchain = ROOT.gFragment
84 if not gchain
or gchain.GetEntries()==0:
87 for branch
in gchain.GetListOfBranches():
88 cls_name = branch.GetName()
89 cls = getattr(ROOT, cls_name)
91 top = self.
tree.insert(
'',
'end',
92 cls_name, text=cls_name)
93 self.
tree.insert(top,
'end',
94 '{}/Draw PID'.format(cls_name),
99 for key
in tfile.GetListOfKeys():
100 if key.GetClassName()==
'TCutG':
101 self.
AddCut(key.ReadObj())
105 full_name =
'{}/{}'.format(det_type,name)
if det_type
is not None else name
106 cut.SetLineColor(ROOT.kRed)
108 self.
cuts[full_name] = cut
116 self.
tree.insert(parent,
'end', full_name, text=name, values=
'2D Cut',
117 image = self.
main.icons[
'tcutg'])
124 ROOT.gROOT.SetEditorMode(
'CutG')
131 ROOT.gROOT.GetListOfSpecials().Remove(cutg)
134 for prim
in ROOT.gPad.GetListOfPrimitives():
135 if isinstance(prim, ROOT.TH2):
136 title = prim.GetName()
137 det_type = title[:title.index(
'_')]
142 self.
AddCut(cutg, det_type)
152 cuts = self.
tree.selection()
156 tcutg = self.
cuts[cutname]
159 xmin = min(newcut.GetX()[i]
for i
in range(newcut.GetN()))
160 xmax = max(newcut.GetX()[i]
for i
in range(newcut.GetN()))
161 xshift = 0.5*(xmax-xmin)
162 for i
in range(newcut.GetN()):
163 newcut.GetX()[i] += xshift
177 frame = tk.Frame(parent)
178 tk.Label(frame, text=
'Name:').pack(side=tk.LEFT)
179 tk.Entry(frame, textvariable=self.
next_name).pack(side=tk.LEFT)
180 frame.pack(fill=tk.X,expand=
False)
182 frame = tk.Frame(parent)
183 tk.Button(frame, text=
'Make Gate', fg=
"black",bg=
"light goldenrod", command=self.
StartCut).pack(side=tk.LEFT)
184 tk.Button(frame, text=
'Save Gate', fg=
"black",bg=
"light goldenrod", command=self.
SaveCut).pack(side=tk.LEFT)
185 tk.Button(frame, text=
'Copy Gate',fg=
"black",bg=
"light goldenrod", command=self.
CopyCut).pack(side=tk.LEFT)
186 tk.Button(frame, text=
'Delete Gate',fg=
"black",bg=
"firebrick", command=self.
DeleteCut).pack(side=tk.LEFT)
187 frame.pack(fill=tk.X,expand=
False)
190 self.
tree = ttk.Treeview(parent, columns=(
'type',))
191 self.
tree.column(
'type', width=50, anchor=
'e')
192 self.
tree.heading(
'type', text=
'Type')
193 self.
tree.pack(fill=tk.BOTH,expand=
True)
203 selection = event.widget.selection()[0]
204 if selection
in self.
cuts:
207 if selection.endswith(
'Draw PID'):
208 cls_name = selection[:selection.index(
'/')]
211 except AttributeError:
212 print 'You did not implement {}::DrawPID.\nPlease do so.'.format(cls_name)
if(hist &&fragment->TriggerId< 0) hist -> Fill(fragment->GetCharge(0))
__init__(self, main, frame)
_load_tcut_patterns(self, patterns)
TreeView_OnDoubleClick(self, event)
AddCut(self, cut, det_type=None)
_MakeNaming(self, parent)
_MakeTreeView(self, parent)