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}')