10 from ROOT
import Belle2
15 """A simple module to check SVD digit fits."""
17 def __init__(self, filename='dumped_digits.txt'):
18 """Initialize the module"""
35 """ Tasks at the start of a run """
38 'EventNo Layer Ladder Sensor Side StripNo TimeTrigger ' +
39 'GoodStrip Gain Noise Width TimeShift ' +
40 'Sample0 Sample1 Sample2 Sample3 Sample4 Sample5 Charge TimeFit Chi2\n')
43 """Cycle through RecoDigit/ShaperDigit pairs and dump the corresponding data"""
47 event_number = evt_info.getEvent()
48 mode_byte = svd_evt_info.getModeByte()
51 for reco_digit
in reco_digits:
53 shaper_digit = reco_digit.getRelatedTo(
'SVDShaperDigits')
58 [layer, ladder, sensor] = self.decode(reco_digit.getRawSensorID())
59 s +=
'{event} {layer} {ladder} {sensor} {side} {strip} '.format(
64 side=(
'u' if reco_digit.isUStrip()
else 'v'),
65 strip=reco_digit.getCellID()
67 sensorID = reco_digit.getSensorID()
68 stripNo = reco_digit.getCellID()
70 triggerBin = ord(mode_byte.getTriggerBin())
71 triggerTime = 0.25 * 31.44 * (-4 + triggerBin + 0.5)
72 s +=
'{trigger:.3f} '.format(trigger=triggerTime)
74 stripNoise = self.noise_cal.getNoise(sensorID, reco_digit.isUStrip(), stripNo)
75 stripGain = 22500 / self.pulse_cal.getADCFromCharge(sensorID, reco_digit.isUStrip(), stripNo, 22500)
77 stripT0 = self.pulse_cal.getPeakTime(sensorID, reco_digit.isUStrip(), stripNo)
78 stripWidth = self.pulse_cal.getWidth(sensorID, reco_digit.isUStrip(), stripNo)
79 s +=
'{mask} {gain:.3f} {noise:.3f} {width} {delay:.3f} '.format(
88 samples = shaper_digit.getSamples()
89 for iSample
in range(6):
90 s +=
'{0} '.format(samples[iSample])
93 s +=
'{amplitude:.3f} {time:.3f} {chi2:.3f}'.format(
94 amplitude=reco_digit.getCharge(),
95 time=reco_digit.getTime(),
96 chi2=reco_digit.getChi2Ndf()
103 """ Close the output file."""
107 def decode(self, vxdid):
108 """ Utility to decode sensor IDs """
112 result.append(vxdid // f)
117 def three_test(self, digit, threshold):
118 ''' 3-samples digit test '''
121 for sample
in digit.getSamples():
124 elif sample >= threshold:
128 return (counter >= 3)