Belle II Software development
WaveformAnalyzer Class Reference
Inheritance diagram for WaveformAnalyzer:

Public Member Functions

def initialize (self)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 feProps
 output ntuple
 
 nWaveForms
 number of waveforms processed
 
 nWaveFormsOutOfOrder
 number of waveforms out of order
 
 f
 object of output file
 
 plotCounter
 counts how many plots were created.
 

Detailed Description

Analyzes waveform and FE data

Definition at line 120 of file TOPFE_qualityPlots.py.

Member Function Documentation

◆ event()

def event (   self)
Event processor: get data and print to screen

Definition at line 149 of file TOPFE_qualityPlots.py.

149 def event(self):
150 '''
151 Event processor: get data and print to screen
152 '''
153 evtMetaData = Belle2.PyStoreObj('EventMetaData')
154 event = evtMetaData.obj().getEvent()
155 run = evtMetaData.obj().getRun()
156 waveforms = Belle2.PyStoreArray('TOPRawWaveforms')
157 for waveform in waveforms:
158 chan = waveform.getChannel()
159 self.nWaveForms += 1
160 # declare some counters for our ntuple
161 nInFirstWindow, nNarrowPeaks, nHeight150, nOscillations = 0, 0, 0, 0
162
163 # waveform.areWindowsInOrder is a bit too strict at the moment
164 wins = np.array(waveform.getStorageWindows())
165 if not np.all(wins[:-1] <= wins[1:]): # change false for pics
166 self.nWaveFormsOutOfOrder += 1
167 if False and args.plotWaveforms:
168 wf_display(waveform, run, event, "windowOrder")
169 self.plotCounter += 1
170
171 wf = np.array(waveform.getWaveform())
172 if False and args.plotWaveforms:
173 wf_display(waveform, run, event, "general")
174 self.plotCounter += 1
175
176 # If TOPWaveformFeatureExtractor has been run then there are extra
177 # TOPRawDigits related to this waveform
178 rawDigits = waveform.getRelationsWith("TOPRawDigits")
179 nTOPRawDigits = len(rawDigits)
180
181 if False and args.plotWaveforms and nTOPRawDigits > 2:
182 # There are at least 3 Top raw digits
183 wf_display(waveform, run, event, "manyPeaks")
184 self.plotCounter += 1
185 if False and args.plotWaveforms and nTOPRawDigits > 3:
186 # There are at least 4 TOPRawDigits
187 wf_display(waveform, run, event, "tooManyPeaks")
188 self.plotCounter += 1
189 raw = rawDigits[0]
190 fePeakHt = raw.getValuePeak()
191 fePeakTDC = raw.getSamplePeak()
192 fePeakWd = raw.getSampleFall() - raw.getSampleRise()
193 fePeakIntegral = raw.getIntegral()
194 # we are sorting the peaks. The FE should always point to the highest one
195
196 # the channel we get from the waveform encodes the asic, carrier, and the actual channel
197 if 0 < fePeakTDC < 65 and chan % 8 == 0:
198 # To see if cal pulse is in first window
199 nInFirstWindow += 1
200 if False and args.plotWaveforms:
201 wf_display(waveform, run, event, "calPuls_firstWin")
202 self.plotCounter += 1
203
204 # there are strange bumps in the ADC distribtion of the cal channels
205 if (140 < fePeakHt < 220) and chan % 8 == 0:
206 if False and args.plotWaveforms:
207 wf_display(waveform, run, event, "strangeADCBump_1")
208 self.plotCounter += 1
209 if (300 < fePeakHt < 410) and chan % 8 == 0:
210 if False and args.plotWaveforms:
211 wf_display(waveform, run, event, "strangeADCBump_2")
212 self.plotCounter += 1
213
214 fePeak1Ht = -1
215 fePeak1TDC = -1
216 fePeak1Wd = -1
217 # fePeak1Integral = -1
218 if nTOPRawDigits > 1:
219 # if there is a second TOPRawDigit then get it for our ntuple
220 fePeak1Ht = rawDigits[1].getValuePeak()
221 fePeak1TDC = rawDigits[1].getSamplePeak()
222 fePeak1Wd = rawDigits[1].getSampleFall() - rawDigits[1].getSampleRise()
223 # fePeak1Integral = rawDigits[1].getIntegral()
224
225 if nTOPRawDigits > 1 and fePeak1TDC < 64:
226 # counting the times that the second digit is found in the first window
227 if False and args.plotWaveforms:
228 wf_display(waveform, run, event, "secondPeakInFirstWindow")
229 self.plotCounter += 1
230
231 if fePeakWd < 5 or nTOPRawDigits > 1 and fePeak1Wd < 5:
232 # counting thin peaks
233 nNarrowPeaks += 1
234 if False and args.plotWaveforms:
235 wf_display(waveform, run, event, "thinpeak")
236 self.plotCounter += 1
237
238 if 145 < fePeak1Ht < 155 and chan % 8 == 0:
239 # Jan needs to write a comment about why we're doing this test
240 nHeight150 += 1
241 if False and args.plotWaveforms:
242 wf_display(waveform, run, event, "peak1Ht_is_150")
243 self.plotCounter += 1
244
245 if nTOPRawDigits > 5 and (fePeakHt - fePeak1Ht) < 5:
246 if np.mean(wf) < 10:
247 # want to count the portion of times we see this oscillation behavior
248 # guard the call to numpy.mean by the previous if statements
249 nOscillations += 1
250 if False and args.plotWaveforms:
251 wf_display(waveform, run, event, "oscillations")
252 self.plotCounter += 1
253
254 self.feProps.Fill(
255 event,
256 run,
257 fePeak1Ht,
258 fePeak1TDC,
259 fePeak1Wd,
260 fePeakHt,
261 fePeakTDC,
262 fePeakWd,
263 fePeakIntegral,
264 nTOPRawDigits,
265 chan,
266 nNarrowPeaks,
267 nInFirstWindow,
268 nHeight150,
269 nOscillations,
270 )
271
272 # only plot the first 10 figures.
273 if args.plotWaveforms and self.plotCounter >= 10:
274 evtMetaData.obj().setEndOfData()
275
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67

◆ initialize()

def initialize (   self)
 Initialize the Module: open the canvas. 

Definition at line 125 of file TOPFE_qualityPlots.py.

125 def initialize(self):
126 ''' Initialize the Module: open the canvas. '''
127
128
129 self.feProps = TNtuple(
130 "feProps",
131 "feProps",
132 "event:run"
133 ":fePeak1Ht:fePeak1TDC:fePeak1Wd"
134 ":fePeakHt:fePeakTDC:fePeakWd:fePeakIntegral"
135 ":nTOPRawDigits:ch:nNarrowPeaks:nInFirstWindow:nHeight150:nOscillations")
136
137
138 self.nWaveForms = 0
139
140
141 self.nWaveFormsOutOfOrder = 0
142
143
144 self.f = TFile.Open(args.output, "RECREATE")
145
146
147 self.plotCounter = 0
148

◆ terminate()

def terminate (   self)
End of run

Definition at line 276 of file TOPFE_qualityPlots.py.

276 def terminate(self):
277 '''End of run'''
278 self.f.WriteTObject(self.feProps)
279 self.f.Close()
280 print("# Waveforms:", self.nWaveForms)
281 print("out of order:", self.nWaveFormsOutOfOrder)
282
283
284# Set the log level to show only error and fatal messages
285# b2.set_log_level(b2.LogLevel.ERROR)
286
287# Database

Member Data Documentation

◆ f

f

object of output file

Definition at line 144 of file TOPFE_qualityPlots.py.

◆ feProps

feProps

output ntuple

Definition at line 129 of file TOPFE_qualityPlots.py.

◆ nWaveForms

nWaveForms

number of waveforms processed

Definition at line 138 of file TOPFE_qualityPlots.py.

◆ nWaveFormsOutOfOrder

nWaveFormsOutOfOrder

number of waveforms out of order

Definition at line 141 of file TOPFE_qualityPlots.py.

◆ plotCounter

plotCounter

counts how many plots were created.

Stop after 10

Definition at line 147 of file TOPFE_qualityPlots.py.


The documentation for this class was generated from the following file: