13 Test EventLevelClusteringInfo counting of out of time ECLCalDigits.
15 Creates 1 ECLCalDigit in each ECL detector region (FWD, Barrel, BWD).
17 The created digits cover all possible combinations of:
18 time above threshold for counting
19 time below threshold for counting
20 energy above threshold for counting
21 energy below threshold for counting
23 In order to be counted, both energy and time have to be above threshold
27 from ROOT
import Belle2
28 from unittest
import TestCase
31 from b2test_utils
import skip_test_if_light
34 b2.set_random_seed(42)
37 expectOutOfTime = {
"FWD": 0,
"BRL": 0,
"BWD": 0}
42 Add combinations of ECLCalDigits above/below threshold to be counted as out of time
47 Prepare ECLCalDigits parameters
54 aboveEnergyThresh = [
True,
False]
55 aboveTimeThresh = [
True,
False]
56 thresholdNames = [
"aboveEnergythresh",
"aboveTimethresh"]
58 thresholdsPerRegion = [dict(zip(thresholdNames, thresholds))
59 for thresholds
in itertools.product(aboveEnergyThresh, aboveTimeThresh)]
61 fwdThresholds, brlThresholds, bwdThresholds = itertools.tee(thresholdsPerRegion, 3)
63 regions = [
"FWD",
"BRL",
"BWD"]
67 for thresholds
in itertools.product(fwdThresholds, brlThresholds, bwdThresholds)]
75 """ module initialize - register ECLCalDigit in datastore """
83 Add ECLCalDigits according to self.digitParams
88 cellId = {
"FWD": 1,
"BRL": 1153,
"BWD": 7777}
90 b2.B2DEBUG(37,
"Event " + str(self.
eventCountereventCounter))
102 eclCalDigit.setCellId(cellId[region])
108 energy = digitParam[region][
"aboveEnergythresh"] * (self.
energyThreshenergyThresh + 1)
109 time = digitParam[region][
"aboveTimethresh"] * (self.
timeThreshtimeThresh + 1)
110 eclCalDigit.setEnergy(energy)
111 eclCalDigit.setTime(time)
114 newDigit = eclCalDigits.appendNew()
115 newDigit.__assign__(eclCalDigit)
118 expectOutOfTime[region] = int(digitParam[region][
"aboveEnergythresh"]
and digitParam[region][
"aboveTimethresh"])
119 b2.B2DEBUG(35, region +
": expecting " + str(expectOutOfTime[region]))
120 b2.B2DEBUG(39,
"region = " + region +
", time = " + str(time) +
", energy = " + str(energy))
128 module which checks the number of out of time digits in EventLevelClusteringInfo is as expected
137 tc = TestCase(
'__init__')
139 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTimeFWD(), expectOutOfTime[
"FWD"])
140 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTimeBarrel(), expectOutOfTime[
"BRL"])
141 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTimeBWD(), expectOutOfTime[
"BWD"])
142 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTime(),
143 expectOutOfTime[
"FWD"] + expectOutOfTime[
"BRL"] + expectOutOfTime[
"BWD"])
146 main = b2.create_path()
149 eventinfosetter = b2.register_module(
'EventInfoSetter')
150 main.add_module(eventinfosetter)
152 gearbox = b2.register_module(
'Gearbox')
153 main.add_module(gearbox)
155 geometry = b2.register_module(
'Geometry', useDB=
False)
156 geometry.param(
'components', [
'ECL'])
157 main.add_module(geometry)
161 addECLCalDigits.logging.log_level = b2.LogLevel.DEBUG
162 addECLCalDigits.logging.debug_level = 10
165 eventinfosetter.param({
'evtNumList': [len(addECLCalDigits.digitParams)],
'runList': [0]})
167 ECLDigitCalibrator = b2.register_module(
'ECLDigitCalibrator')
168 main.add_module(ECLDigitCalibrator)
171 for param
in ECLDigitCalibrator.available_params():
172 if param.name ==
"backgroundEnergyCut":
173 addECLCalDigits.energyThresh = param.values
174 elif param.name ==
"backgroundTimingCut":
175 addECLCalDigits.timeThresh = param.values
Class to store calibrated ECLDigits: ECLCalDigits.
a (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.
eclCalDigits
ECLCalDigits datastore.
digitParams
parameters to create custom ECLCalDigits
eventCounter
count number of times event method is called (each time use different combinations of ECLCalDigits
timeThresh
default time threshold
energyThresh
default energy threshold