12from ROOT
import Belle2, gROOT
13from ROOT
import TNtuple, TFile, TH1F, TCanvas, TGraph, gStyle
16parser = argparse.ArgumentParser(description=
'Extracts information about the FE parameters',
17 usage=
'%(prog)s [options]')
18parser.add_argument(
'filename', help=
'name of data file')
22 help=
'whether to print out suspicious waveforms'
26 help=
'name of the ntuple file',
30args = parser.parse_args()
32b2.set_log_level(b2.LogLevel.INFO)
36def wf_display(waveform, run, event, suffix=""):
41 Simple event display of waveforms with feature extraction points
44 hist = TH1F('h',
'wf', 64 * 4, 0.0, 64.0 * 4)
46 c1 = TCanvas(
'c1',
'WF event display', 800, 800)
49 hist.SetXTitle(
"sample number")
50 hist.SetYTitle(
"sample value [ADC counts]")
51 hist.SetLabelSize(0.06,
"XY")
52 hist.SetTitleSize(0.07,
"XY")
53 gStyle.SetTitleSize(0.07,
"t")
55 c1.SetBottomMargin(0.16)
56 c1.SetRightMargin(0.04)
57 hist.SetTitleOffset(1.3,
"Y")
58 hist.SetTitleOffset(1.0,
"X")
63 fname =
'waveforms_run' + str(run) +
'_event' + str(event) +
'_chan'
65 chan = waveform.getChannel()
66 asic = waveform.getASICNumber()
67 carr = waveform.getCarrierNumber()
68 bstk = (chan // 8 // 4 // 4) % 4
69 pdfFile = pdfFile +
'-' + str(chan)
71 wf = waveform.getWaveform()
73 numSamples = waveform.getSize()
74 hist.SetBins(numSamples, 0.0, float(numSamples))
75 title =
'channel: ' + str(chan % 8) +
' asic: ' + str(asic) \
76 +
' carrier: ' + str(carr) +
' BS: ' + str(bstk) +
' win:'
77 for window
in waveform.getStorageWindows():
78 title +=
' ' + str(window)
82 if not waveform.areWindowsInOrder():
87 hist.SetBinContent(i, sample)
89 rawDigits = waveform.getRelationsWith(
"TOPRawDigits")
92 graph.SetPoint(i, raw.getSampleRise() + 0.5, raw.getValueRise0())
94 graph.SetPoint(i, raw.getSampleRise() + 1.5, raw.getValueRise1())
96 graph.SetPoint(i, raw.getSamplePeak() + 0.5, raw.getValuePeak())
98 graph.SetPoint(i, raw.getSampleFall() + 0.5, raw.getValueFall0())
100 graph.SetPoint(i, raw.getSampleFall() + 1.5, raw.getValueFall1())
103 graph.SetMarkerColor(2)
104 if raw.isPedestalJump():
105 graph.SetMarkerColor(3)
107 graph.SetMarkerColor(4)
110 title =
'WF event display:' +
' run ' + str(run) +
' event ' \
114 graph.SetMarkerStyle(24)
117 c1.SaveAs(pdfFile + suffix +
'.pdf')
122 Analyzes waveform and FE data
126 ''' Initialize the Module: open the canvas. '''
133 ":fePeak1Ht:fePeak1TDC:fePeak1Wd"
134 ":fePeakHt:fePeakTDC:fePeakWd:fePeakIntegral"
135 ":nTOPRawDigits:ch:nNarrowPeaks:nInFirstWindow:nHeight150:nOscillations")
144 self.
f = TFile.Open(args.output,
"RECREATE")
151 Event processor: get data and print to screen
154 event = evtMetaData.obj().getEvent()
155 run = evtMetaData.obj().getRun()
157 for waveform
in waveforms:
158 chan = waveform.getChannel()
161 nInFirstWindow, nNarrowPeaks, nHeight150, nOscillations = 0, 0, 0, 0
164 wins = np.array(waveform.getStorageWindows())
165 if not np.all(wins[:-1] <= wins[1:]):
167 if False and args.plotWaveforms:
168 wf_display(waveform, run, event,
"windowOrder")
171 wf = np.array(waveform.getWaveform())
172 if False and args.plotWaveforms:
173 wf_display(waveform, run, event,
"general")
178 rawDigits = waveform.getRelationsWith(
"TOPRawDigits")
179 nTOPRawDigits = len(rawDigits)
181 if False and args.plotWaveforms
and nTOPRawDigits > 2:
183 wf_display(waveform, run, event,
"manyPeaks")
185 if False and args.plotWaveforms
and nTOPRawDigits > 3:
187 wf_display(waveform, run, event,
"tooManyPeaks")
190 fePeakHt = raw.getValuePeak()
191 fePeakTDC = raw.getSamplePeak()
192 fePeakWd = raw.getSampleFall() - raw.getSampleRise()
193 fePeakIntegral = raw.getIntegral()
197 if 0 < fePeakTDC < 65
and chan % 8 == 0:
200 if False and args.plotWaveforms:
201 wf_display(waveform, run, event,
"calPuls_firstWin")
205 if (140 < fePeakHt < 220)
and chan % 8 == 0:
206 if False and args.plotWaveforms:
207 wf_display(waveform, run, event,
"strangeADCBump_1")
209 if (300 < fePeakHt < 410)
and chan % 8 == 0:
210 if False and args.plotWaveforms:
211 wf_display(waveform, run, event,
"strangeADCBump_2")
218 if nTOPRawDigits > 1:
220 fePeak1Ht = rawDigits[1].getValuePeak()
221 fePeak1TDC = rawDigits[1].getSamplePeak()
222 fePeak1Wd = rawDigits[1].getSampleFall() - rawDigits[1].getSampleRise()
225 if nTOPRawDigits > 1
and fePeak1TDC < 64:
227 if False and args.plotWaveforms:
228 wf_display(waveform, run, event,
"secondPeakInFirstWindow")
231 if fePeakWd < 5
or nTOPRawDigits > 1
and fePeak1Wd < 5:
234 if False and args.plotWaveforms:
235 wf_display(waveform, run, event,
"thinpeak")
238 if 145 < fePeak1Ht < 155
and chan % 8 == 0:
241 if False and args.plotWaveforms:
242 wf_display(waveform, run, event,
"peak1Ht_is_150")
245 if nTOPRawDigits > 5
and (fePeakHt - fePeak1Ht) < 5:
250 if False and args.plotWaveforms:
251 wf_display(waveform, run, event,
"oscillations")
274 evtMetaData.obj().setEndOfData()
288b2.conditions.override_globaltags()
289b2.conditions.append_globaltag(
'online')
292main = b2.create_path()
294reader = b2.register_module(
'RootInput')
296reader.param(
'inputFileName', args.filename)
297main.add_module(reader)
300converter = b2.register_module(
'Convert2RawDet')
301main.add_module(converter)
304main.add_module(
'TOPGeometryParInitializer')
307unpack = b2.register_module(
'TOPUnpacker')
308main.add_module(unpack)
311topfe = b2.register_module(
'TOPWaveformFeatureExtractor')
313main.add_module(topfe)
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.