20 from ROOT
import Belle2
21 from unittest
import TestCase
22 from ROOT
import gRandom
26 logLevel = b2.LogLevel.INFO
27 b2.set_random_seed(42)
29 eclDigitsDatastoreName =
'ECLDigits'
30 unpackerOutputDatastoreName =
'someECLUnpackerDatastoreName'
35 Adds ECLDigits with very large/small time/amplitude values
41 amps = [0, 1, 100000, 262015]
42 times = [-2048, -100, 0, 100, 2047]
43 qualitys = [0, 1, 2, 3]
44 chis = [0, 1, 254, 511]
45 paramNames = [
"amp",
"time",
"quality",
"chi"]
47 self.
digitParamsdigitParams = [dict(zip(paramNames, params))
for params
in itertools.product(amps, times, qualitys, chis)]
56 usedCellIds = list(map(
lambda eclDigit: eclDigit.getCellId(), eclDigitsFromSimulation))
61 if (digitParam[
'quality'] != 2)
and (digitParam[
'chi'] != 0):
65 if (digitParam[
'quality'] == 2)
and (digitParam[
'time'] != 0):
69 cellId = int(gRandom.Uniform(1, 8736))
70 while cellId
in usedCellIds:
71 cellId = int(gRandom.Uniform(1, 8736))
73 usedCellIds.append(cellId)
78 eclDigit.setCellId(cellId)
79 eclDigit.setAmp(digitParam[
'amp'])
80 eclDigit.setTimeFit(digitParam[
'time'])
81 eclDigit.setQuality(digitParam[
'quality'])
82 eclDigit.setChi(digitParam[
'chi'])
85 newDigit = eclDigitsFromSimulation.appendNew()
86 newDigit.__assign__(eclDigit)
91 module which checks if two collections of ECLDigits are equal
95 """ use a some information to sort the ECLDigits list
96 Returns a python-list containing the ECLDigits
99 py_list = [x
for x
in unsortedPyStoreArray]
117 if not len(eclDigitsFromSimulation_unsorted) == len(eclDigitsPackedUnpacked_unsorted):
118 b2.B2FATAL(
"Different number of ECLDigits from simulation and after packing+unpacking")
120 eclDigitsPackedUnpacked = self.
sortECLDigitssortECLDigits(eclDigitsPackedUnpacked_unsorted)
121 eclDigitsFromSimulation = self.
sortECLDigitssortECLDigits(eclDigitsFromSimulation_unsorted)
123 tc = TestCase(
'__init__')
126 for idx
in range(len(eclDigitsPackedUnpacked)):
127 digit = eclDigitsFromSimulation[idx]
128 digitPackedUnpacked = eclDigitsPackedUnpacked[idx]
130 b2.B2DEBUG(5,
'MC digit: cellid = ' +
131 str(digit.getCellId()) +
133 str(digit.getAmp()) +
135 str(digit.getTimeFit()) +
137 str(digit.getQuality()) +
139 str(digit.getChi()) +
140 '\nUnpackedDigit: cellid = ' +
141 str(digitPackedUnpacked.getCellId()) +
143 str(digitPackedUnpacked.getAmp()) +
145 str(digitPackedUnpacked.getTimeFit()) +
147 str(digitPackedUnpacked.getQuality()) +
149 str(digitPackedUnpacked.getChi()))
151 tc.assertEqual(digit.getCellId(), digitPackedUnpacked.getCellId())
152 tc.assertEqual(digit.getAmp(), digitPackedUnpacked.getAmp())
153 tc.assertEqual(digit.getTimeFit(), digitPackedUnpacked.getTimeFit())
154 tc.assertEqual(digit.getQuality(), digitPackedUnpacked.getQuality())
155 tc.assertEqual(digit.getChi(), digitPackedUnpacked.getChi())
158 main = b2.create_path()
160 eventinfosetter = b2.register_module(
'EventInfoSetter')
161 eventinfosetter.param({
'evtNumList': [10]})
162 main.add_module(eventinfosetter)
165 particlegun = b2.register_module(
'ParticleGun')
166 particlegun.param(
'pdgCodes', [13, -13])
167 particlegun.param(
'nTracks', 10)
168 main.add_module(particlegun)
172 b2.set_module_parameters(main, type=
"Geometry", useDB=
False, components=[
"ECL"])
178 ecl_packer = b2.register_module(
'ECLPacker')
179 main.add_module(ecl_packer)
182 ecl_unpacker = b2.register_module(
'ECLUnpacker')
184 ecl_unpacker.param(
'ECLDigitsName', unpackerOutputDatastoreName)
185 main.add_module(ecl_unpacker)
189 main.add_module(eclPackUnpackerChecker, logLevel=logLevel)
Class to store ECL digitized hits (output of ECLDigi) relation to ECLHit filled in ecl/modules/eclDig...
A (simplified) python wrapper for StoreArray.
def sortECLDigits(self, unsortedPyStoreArray)
digitParams
ecl digit parameters
def add_simulation(path, components=None, bkgfiles=None, bkgOverlay=True, forceSetPXDDataReduction=False, usePXDDataReduction=True, cleanupPXDDataReduction=True, generate_2nd_cdc_hits=False, simulateT0jitter=True, isCosmics=False, FilterEvents=False, usePXDGatedMode=False, skipExperimentCheckForBG=False, save_slow_pions_in_mc=False)