12 Test EventLevelClusteringInfo counting of out of time ECLCalDigits.
14 Creates 1 ECLCalDigit in each ECL detector region (FWD, Barrel, BWD).
16 The created digits cover all possible combinations of:
17 time above threshold for counting
18 time below threshold for counting
19 energy above threshold for counting
20 energy below threshold for counting
22 In order to be counted, both energy and time have to be above threshold
26 from ROOT
import Belle2
27 from unittest
import TestCase
30 from b2test_utils
import skip_test_if_light
33 b2.set_random_seed(42)
36 expectOutOfTime = {
"FWD": 0,
"BRL": 0,
"BWD": 0}
41 Add combinations of ECLCalDigits above/below threshold to be counted as out of time
46 Prepare ECLCalDigits parameters
53 aboveEnergyThresh = [
True,
False]
54 aboveTimeThresh = [
True,
False]
55 thresholdNames = [
"aboveEnergythresh",
"aboveTimethresh"]
57 thresholdsPerRegion = [dict(zip(thresholdNames, thresholds))
58 for thresholds
in itertools.product(aboveEnergyThresh, aboveTimeThresh)]
60 fwdThresholds, brlThresholds, bwdThresholds = itertools.tee(thresholdsPerRegion, 3)
62 regions = [
"FWD",
"BRL",
"BWD"]
66 for thresholds
in itertools.product(fwdThresholds, brlThresholds, bwdThresholds)]
74 """ module initialize - register ECLCalDigit in datastore """
82 Add ECLCalDigits according to self.digitParams
87 cellId = {
"FWD": 1,
"BRL": 1153,
"BWD": 7777}
89 b2.B2DEBUG(37,
"Event " + str(self.
eventCountereventCounter))
101 eclCalDigit.setCellId(cellId[region])
107 energy = digitParam[region][
"aboveEnergythresh"] * (self.
energyThreshenergyThresh + 1)
108 time = digitParam[region][
"aboveTimethresh"] * (self.
timeThreshtimeThresh + 1)
109 eclCalDigit.setEnergy(energy)
110 eclCalDigit.setTime(time)
113 newDigit = eclCalDigits.appendNew()
114 newDigit.__assign__(eclCalDigit)
117 expectOutOfTime[region] = int(digitParam[region][
"aboveEnergythresh"]
and digitParam[region][
"aboveTimethresh"])
118 b2.B2DEBUG(35, region +
": expecting " + str(expectOutOfTime[region]))
119 b2.B2DEBUG(39,
"region = " + region +
", time = " + str(time) +
", energy = " + str(energy))
127 module which checks the number of out of time digits in EventLevelClusteringInfo is as expected
136 tc = TestCase(
'__init__')
138 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTimeFWD(), expectOutOfTime[
"FWD"])
139 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTimeBarrel(), expectOutOfTime[
"BRL"])
140 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTimeBWD(), expectOutOfTime[
"BWD"])
141 tc.assertEqual(eventLevelClusteringInfo.getNECLCalDigitsOutOfTime(),
142 expectOutOfTime[
"FWD"] + expectOutOfTime[
"BRL"] + expectOutOfTime[
"BWD"])
145 main = b2.create_path()
148 eventinfosetter = b2.register_module(
'EventInfoSetter')
149 main.add_module(eventinfosetter)
151 gearbox = b2.register_module(
'Gearbox')
152 main.add_module(gearbox)
154 geometry = b2.register_module(
'Geometry', useDB=
False)
155 geometry.param(
'components', [
'ECL'])
156 main.add_module(geometry)
160 addECLCalDigits.logging.log_level = b2.LogLevel.DEBUG
161 addECLCalDigits.logging.debug_level = 10
164 eventinfosetter.param({
'evtNumList': [len(addECLCalDigits.digitParams)],
'runList': [0]})
166 ECLDigitCalibrator = b2.register_module(
'ECLDigitCalibrator')
167 main.add_module(ECLDigitCalibrator)
170 for param
in ECLDigitCalibrator.available_params():
171 if param.name ==
"backgroundEnergyCut":
172 addECLCalDigits.energyThresh = param.values
173 elif param.name ==
"backgroundTimingCut":
174 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