13from ROOT
import Belle2, TCanvas, TColor, TH1F, TH2F, gStyle
21color1501 = TColor(1501, 35 / 255., 55 / 255., 59 / 255.)
22color1502 = TColor(1502, 99 / 255., 120 / 255., 173 / 255.)
23color1503 = TColor(1503, 235 / 255., 129 / 255., 27 / 255.)
24color1504 = TColor(1504, 99 / 255., 173 / 255., 132 / 255.)
25color1505 = TColor(1505, 123 / 255., 111 / 255., 37 / 255.)
27nWiresInLayer = [160, 192, 256, 320, 384]
30def set_style(hist, color=1503, marker=20):
31 hist.SetLineColor(color)
34 hist.SetMarkerStyle(marker)
36 hist.SetMarkerColor(color)
39hall = TH2F(
'all',
'all', 5, 0, 5, 384, 0, 384)
40hhit = TH2F(
'hit',
'hit', 5, 0, 5, 384, 0, 384)
41hno_ghost = TH2F(
'ng',
'hit', 5, 0, 5, 384, 0, 384)
42hghost = TH2F(
'ghost',
'hit', 5, 0, 5, 384, 0, 384)
44hlr = TH1F(
'lr',
'left right', 4, 0, 4)
45hpri = TH1F(
'pri',
'priority position', 4, 0, 4)
46hpritime = TH1F(
'pritime',
'priority time', 512, 0, 512)
47hftime = TH1F(
'found time',
'found time', 48, -35, 13)
49used = numpy.zeros(2336, numpy.int32)
50in_tsim = numpy.zeros(2336, numpy.int32)
55 Module to make some monitor plots for TSF
81 if simhit.getISuperLayer() % 2 == 0:
82 iax, iw = simhit.getISuperLayer() // 2, simhit.getIWire()
83 if simhit.getPriorityPosition() == 1:
85 if iw == nWiresInLayer[iax]:
88 in_tsim[simhit.getSegmentID()] = 1
90 ind = hit.getSegmentID()
94 iax, iw = hit.getISuperLayer() // 2, hit.getIWire()
95 if hit.getPriorityPosition() == 1:
97 if iw == nWiresInLayer[iax]:
103 hno_ghost.Fill(iax, iw)
106 hlr.Fill(hit.getLeftRight())
107 hpri.Fill(hit.getPriorityPosition())
108 hpritime.Fill(hit.priorityTime())
109 hftime.Fill(hit.foundTime())
116 b2.B2WARNING(
"The monitor module is never called.\n" +
117 "There seems to be no CDC Trigger data at all!")
119 elif hhit.GetEntries() == 0:
120 b2.B2WARNING(
"No recorded TS hits at all!")
122 elif hall.GetEntries() == 0:
123 b2.B2ERROR(
"No simulated TS hits at all!")
125 if not os.path.exists(
'monitor_plots'):
126 os.mkdir(
'monitor_plots')
127 can = TCanvas(
'can2',
'can2', 800, 700)
130 nts = [160, 192, 256, 320, 384]
143 p = hall.ProjectionY(f
'all{iax}', ibin, ibin)
144 p.SetBins(nts[iax], 0, 2 * pi)
148 q = hhit.ProjectionY(f
'hit{iax}', ibin, ibin)
149 q.SetBins(nts[iax], 0, 2 * pi)
153 g = hghost.ProjectionY(f
'ghost{iax}', ibin, ibin)
154 g.SetBins(nts[iax], 0, 2 * pi)
158 s = hno_ghost.ProjectionY(f
'ng{iax}', ibin, ibin)
159 s.SetBins(nts[iax], 0, 2 * pi)
163 r = g.Clone(f
'ghost{iax}')
164 r2 = s.Clone(f
'quong{iax}')
169 r.Divide(g, p, 1.0, 1.0,
'B')
171 r2.Divide(s, p, 1.0, 1.0,
'B')
174 for hits, name
in [(slhit,
'data TS'),
178 h.SetTitle(f
'SL{i * 2}')
179 set_style(h, 1501 + i, 20 + i)
180 if name
in [
'data TS',
'TSIM']:
182 h.Scale(1 / h.Integral(
'width'))
183 except ZeroDivisionError:
184 b2.B2WARNING(f
'Not a single hit in SL{i * 2}!')
186 height = max([g.GetMaximum()
for g
in hits])
188 h.SetMaximum(1.1 * height)
191 if h.GetTitle() !=
'SL0':
194 can.BuildLegend(.85, .76, .95, .95)
195 hits[0].SetTitle(name + f
' hit distribution in run {self.first_run}; #phi (rad)')
196 can.SaveAs(
'monitor_plots/' + name.split()[0] + f
'_ts_hits_{self.first_run:05d}.{file_type}')
198 for ratio, name
in [(quos,
'ghost rate'), (quong,
'efficiency (w.r.t. fast TSIM)')]:
199 upp = max([g.GetMaximum()
for g
in ratio])
200 low = min([g.GetMinimum()
for g
in ratio])
203 h.SetTitle(f
'SL{2 * i}')
204 h.SetMaximum(1.1 * upp)
205 h.SetMinimum(0.9 * low)
206 set_style(h, 1501 + i, 20 + i)
211 can.BuildLegend(.91, .76, .98, .95)
212 ratio[0].SetTitle(
'TSF ' + name + f
' in run {self.first_run};#phi (rad)')
213 file_name = name.split()[0]
214 can.SaveAs(f
'monitor_plots/ts_{file_name}_{self.first_run:05d}.{file_type}')
217 for h
in [hlr, hpri, hpritime, hftime]:
220 name = h.GetTitle().replace(
' ',
'_')
221 can.SaveAs(f
'monitor_plots/ghost_{name}_{self.first_run:05d}.{file_type}')
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.