14 from ROOT
import Belle2, TCanvas, TColor, TH1F, TH2F, gStyle
22 color1501 = TColor(1501, 35 / 255., 55 / 255., 59 / 255.)
23 color1502 = TColor(1502, 99 / 255., 120 / 255., 173 / 255.)
24 color1503 = TColor(1503, 235 / 255., 129 / 255., 27 / 255.)
25 color1504 = TColor(1504, 99 / 255., 173 / 255., 132 / 255.)
26 color1505 = TColor(1505, 123 / 255., 111 / 255., 37 / 255.)
28 nWiresInLayer = [160, 192, 256, 320, 384]
31 def set_style(hist, color=1503, marker=20):
32 hist.SetLineColor(color)
35 hist.SetMarkerStyle(marker)
37 hist.SetMarkerColor(color)
40 hall = TH2F(
'all',
'all', 5, 0, 5, 384, 0, 384)
41 hhit = TH2F(
'hit',
'hit', 5, 0, 5, 384, 0, 384)
42 hno_ghost = TH2F(
'ng',
'hit', 5, 0, 5, 384, 0, 384)
43 hghost = TH2F(
'ghost',
'hit', 5, 0, 5, 384, 0, 384)
45 hlr = TH1F(
'lr',
'left right', 4, 0, 4)
46 hpri = TH1F(
'pri',
'priority position', 4, 0, 4)
47 hpritime = TH1F(
'pritime',
'priority time', 512, 0, 512)
48 hftime = TH1F(
'found time',
'found time', 48, -35, 13)
50 used = numpy.zeros(2336, numpy.int)
51 in_tsim = numpy.zeros(2336, numpy.int)
56 Module to make some monitor plots for TSF
81 for simhit
in self.
simhitssimhits:
82 if simhit.getISuperLayer() % 2 == 0:
83 iax, iw = simhit.getISuperLayer() // 2, simhit.getIWire()
84 if simhit.getPriorityPosition() == 1:
86 if iw == nWiresInLayer[iax]:
89 in_tsim[simhit.getSegmentID()] = 1
90 for hit
in self.
tshitstshits:
91 ind = hit.getSegmentID()
95 iax, iw = hit.getISuperLayer() // 2, hit.getIWire()
96 if hit.getPriorityPosition() == 1:
98 if iw == nWiresInLayer[iax]:
104 hno_ghost.Fill(iax, iw)
107 hlr.Fill(hit.getLeftRight())
108 hpri.Fill(hit.getPriorityPosition())
109 hpritime.Fill(hit.priorityTime())
110 hftime.Fill(hit.foundTime())
117 b2.B2WARNING(
"The monitor module is never called.\n" +
118 "There seems to be no CDC Trigger data at all!")
120 elif hhit.GetEntries() == 0:
121 b2.B2WARNING(
"No recorded TS hits at all!")
123 elif hall.GetEntries() == 0:
124 b2.B2ERROR(
"No simulated TS hits at all!")
126 if not os.path.exists(
'monitor_plots'):
127 os.mkdir(
'monitor_plots')
128 can = TCanvas(
'can2',
'can2', 800, 700)
131 nts = [160, 192, 256, 320, 384]
144 p = hall.ProjectionY(
'all{}'.format(iax), ibin, ibin)
145 p.SetBins(nts[iax], 0, 2 * pi)
149 q = hhit.ProjectionY(
'hit{}'.format(iax), ibin, ibin)
150 q.SetBins(nts[iax], 0, 2 * pi)
154 g = hghost.ProjectionY(
'ghost{}'.format(iax), ibin, ibin)
155 g.SetBins(nts[iax], 0, 2 * pi)
159 s = hno_ghost.ProjectionY(
'ng{}'.format(iax), ibin, ibin)
160 s.SetBins(nts[iax], 0, 2 * pi)
164 r = g.Clone(
'ghost{}'.format(iax))
165 r2 = s.Clone(
'quong{}'.format(iax))
170 r.Divide(g, p, 1.0, 1.0,
'B')
172 r2.Divide(s, p, 1.0, 1.0,
'B')
175 for hits, name
in [(slhit,
'data TS'),
179 h.SetTitle(f
'SL{i * 2}')
180 set_style(h, 1501 + i, 20 + i)
181 if name
in [
'data TS',
'TSIM']:
183 h.Scale(1 / h.Integral(
'width'))
184 except ZeroDivisionError:
185 b2.B2WARNING(f
'Not a single hit in SL{i * 2}!')
187 height = max([g.GetMaximum()
for g
in hits])
189 h.SetMaximum(1.1 * height)
192 if h.GetTitle() !=
'SL0':
195 can.BuildLegend(.85, .76, .95, .95)
196 hits[0].SetTitle(name +
' hit distribution in run {}; #phi (rad)'.format(
198 can.SaveAs(
'monitor_plots/' + name.split()[0] +
199 '_ts_hits_{:05d}.{}'.format(self.
first_runfirst_run, file_type))
201 for ratio, name
in [(quos,
'ghost rate'), (quong,
'efficiency (w.r.t. fast TSIM)')]:
202 upp = max([g.GetMaximum()
for g
in ratio])
203 low = min([g.GetMinimum()
for g
in ratio])
206 h.SetTitle(
'SL{}'.format(2 * i))
207 h.SetMaximum(1.1 * upp)
208 h.SetMinimum(0.9 * low)
209 set_style(h, 1501 + i, 20 + i)
214 can.BuildLegend(.91, .76, .98, .95)
215 ratio[0].SetTitle(
'TSF ' + name +
' in run {};#phi (rad)'.format(
217 file_name = name.split()[0]
218 can.SaveAs(
'monitor_plots/ts_{}_{:05d}.{}'.format(file_name, self.
first_runfirst_run, file_type))
221 for h
in [hlr, hpri, hpritime, hftime]:
224 name = h.GetTitle().replace(
' ',
'_')
225 can.SaveAs(
'monitor_plots/ghost_{}_{:05d}.{}'.format(name, self.
first_runfirst_run, file_type))
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.
static ExpRun getRun(std::map< ExpRun, std::pair< double, double >> runs, double t)
Get exp number + run number from time.