8 from ROOT
import Belle2, gROOT
9 from ROOT
import TNtuple, TFile, TH1F, TCanvas, TGraph, gStyle
12 parser = argparse.ArgumentParser(description=
'Extracts information about the FE parameters',
13 usage=
'%(prog)s [options]')
14 parser.add_argument(
'filename', help=
'name of data file')
18 help=
'whether to print out suspicious waveforms'
22 help=
'name of the ntuple file',
26 args = parser.parse_args()
28 set_log_level(LogLevel.INFO)
32 def wf_display(waveform, run, event, suffix=""):
37 Simple event display of waveforms with feature extraction points
40 hist = TH1F(
'h',
'wf', 64 * 4, 0.0, 64.0 * 4)
42 c1 = TCanvas(
'c1',
'WF event display', 800, 800)
45 hist.SetXTitle(
"sample number")
46 hist.SetYTitle(
"sample value [ADC counts]")
47 hist.SetLabelSize(0.06,
"XY")
48 hist.SetTitleSize(0.07,
"XY")
49 gStyle.SetTitleSize(0.07,
"t")
51 c1.SetBottomMargin(0.16)
52 c1.SetRightMargin(0.04)
53 hist.SetTitleOffset(1.3,
"Y")
54 hist.SetTitleOffset(1.0,
"X")
59 fname =
'waveforms_run' + str(run) +
'_event' + str(event) +
'_chan'
61 chan = waveform.getChannel()
62 asic = waveform.getASICNumber()
63 carr = waveform.getCarrierNumber()
64 bstk = (chan // 8 // 4 // 4) % 4
65 pdfFile = pdfFile +
'-' + str(chan)
67 wf = waveform.getWaveform()
69 numSamples = waveform.getSize()
70 hist.SetBins(numSamples, 0.0, float(numSamples))
71 title =
'channel: ' + str(chan % 8) +
' asic: ' + str(asic) \
72 +
' carrier: ' + str(carr) +
' BS: ' + str(bstk) +
' win:'
73 for window
in waveform.getStorageWindows():
74 title +=
' ' + str(window)
78 if not waveform.areWindowsInOrder():
83 hist.SetBinContent(i, sample)
85 rawDigits = waveform.getRelationsWith(
"TOPRawDigits")
88 graph.SetPoint(i, raw.getSampleRise() + 0.5, raw.getValueRise0())
90 graph.SetPoint(i, raw.getSampleRise() + 1.5, raw.getValueRise1())
92 graph.SetPoint(i, raw.getSamplePeak() + 0.5, raw.getValuePeak())
94 graph.SetPoint(i, raw.getSampleFall() + 0.5, raw.getValueFall0())
96 graph.SetPoint(i, raw.getSampleFall() + 1.5, raw.getValueFall1())
99 graph.SetMarkerColor(2)
100 if raw.isPedestalJump():
101 graph.SetMarkerColor(3)
103 graph.SetMarkerColor(4)
106 title =
'WF event display:' +
' run ' + str(run) +
' event ' \
110 graph.SetMarkerStyle(24)
113 c1.SaveAs(pdfFile + suffix +
'.pdf')
118 Analyzes waveform and FE data
122 ''' Initialize the Module: open the canvas. '''
129 ":fePeak1Ht:fePeak1TDC:fePeak1Wd"
130 ":fePeakHt:fePeakTDC:fePeakWd:fePeakIntegral"
131 ":nTOPRawDigits:ch:nNarrowPeaks:nInFirstWindow:nHeight150:nOscillations")
140 self.
f = TFile.Open(args.output,
"RECREATE")
147 Event processor: get data and print to screen
150 event = evtMetaData.obj().getEvent()
151 run = evtMetaData.obj().
getRun()
153 for waveform
in waveforms:
154 chan = waveform.getChannel()
157 nInFirstWindow, nNarrowPeaks, nHeight150, nOscillations = 0, 0, 0, 0
160 wins = np.array(waveform.getStorageWindows())
161 if not np.all(wins[:-1] <= wins[1:]):
163 if False and args.plotWaveforms:
164 wf_display(waveform, run, event,
"windowOrder")
167 wf = np.array(waveform.getWaveform())
168 if False and args.plotWaveforms:
169 wf_display(waveform, run, event,
"general")
174 rawDigits = waveform.getRelationsWith(
"TOPRawDigits")
175 nTOPRawDigits = len(rawDigits)
177 if False and args.plotWaveforms
and nTOPRawDigits > 2:
179 wf_display(waveform, run, event,
"manyPeaks")
181 if False and args.plotWaveforms
and nTOPRawDigits > 3:
183 wf_display(waveform, run, event,
"tooManyPeaks")
186 fePeakHt = raw.getValuePeak()
187 fePeakTDC = raw.getSamplePeak()
188 fePeakWd = raw.getSampleFall() - raw.getSampleRise()
189 fePeakIntegral = raw.getIntegral()
193 if 0 < fePeakTDC < 65
and chan % 8 == 0:
196 if False and args.plotWaveforms:
197 wf_display(waveform, run, event,
"calPuls_firstWin")
201 if (140 < fePeakHt < 220)
and chan % 8 == 0:
202 if False and args.plotWaveforms:
203 wf_display(waveform, run, event,
"strangeADCBump_1")
205 if (300 < fePeakHt < 410)
and chan % 8 == 0:
206 if False and args.plotWaveforms:
207 wf_display(waveform, run, event,
"strangeADCBump_2")
214 if nTOPRawDigits > 1:
216 fePeak1Ht = rawDigits[1].getValuePeak()
217 fePeak1TDC = rawDigits[1].getSamplePeak()
218 fePeak1Wd = rawDigits[1].getSampleFall() - rawDigits[1].getSampleRise()
219 fePeak1Integral = rawDigits[1].getIntegral()
221 if nTOPRawDigits > 1
and fePeak1TDC < 64:
223 if False and args.plotWaveforms:
224 wf_display(waveform, run, event,
"secondPeakInFirstWindow")
227 if fePeakWd < 5
or nTOPRawDigits > 1
and fePeak1Wd < 5:
230 if False and args.plotWaveforms:
231 wf_display(waveform, run, event,
"thinpeak")
234 if 145 < fePeak1Ht < 155
and chan % 8 == 0:
237 if False and args.plotWaveforms:
238 wf_display(waveform, run, event,
"peak1Ht_is_150")
241 if nTOPRawDigits > 5
and (fePeakHt - fePeak1Ht) < 5:
246 if False and args.plotWaveforms:
247 wf_display(waveform, run, event,
"oscillations")
270 evtMetaData.obj().setEndOfData()
284 reader = register_module(
'SeqRootInput')
286 reader.param(
'inputFileName', args.filename)
287 main.add_module(reader)
290 converter = register_module(
'Convert2RawDet')
291 main.add_module(converter)
294 gearbox = register_module(
'Gearbox')
295 main.add_module(gearbox)
298 geometry = register_module(
'Geometry')
299 geometry.param(
'components', [
'TOP'])
300 main.add_module(geometry)
303 unpack = register_module(
'TOPUnpacker')
304 main.add_module(unpack)
307 topfe = register_module(
'TOPWaveformFeatureExtractor')
309 main.add_module(topfe)
313 main.add_module(drdh)