10 from ROOT
import Belle2
14 from rawdata
import add_packers
15 from rawdata
import add_unpackers
17 pxd_rawhits_pack_unpack_collection =
"PXDRawHits_test"
18 pxd_rawhits_pack_unpack_collection_digits =
"PXDDigits_test"
19 pxd_rawhits_pack_unpack_collection_adc = pxd_rawhits_pack_unpack_collection +
"_adc"
20 pxd_rawhits_pack_unpack_collection_roi = pxd_rawhits_pack_unpack_collection +
"_roi"
27 Module which checks if a collection of PXDDigits and
28 a collection of PXDRawHits from the packing/unpacking procedure are equal.
29 The PXDUnpacker does not create PXDDigits but PXDRawHits and therefore these two lists
33 def __init__(self, rawhits_collection='PXDRawHits', digits_collection="PXDDigits"):
44 """ use a some digit information to sort the PXDDigits list
45 Returns a python-list containing the PXDDigts
49 py_list = [x
for x
in unsortedPyStoreArray]
60 """ use a some digit information to sort the PXDRawHits list
61 Returns a python-list containing the PXDRawHits
65 py_list = [x
for x
in unsortedPyStoreArray]
76 """ load the PXD Digits of the simulation and the packed/unpacked ones
87 pxdDigits = self.
sortDigits(pxdDigits_unsorted)
88 pxdRawHitsPackedUnpacked = self.
sortRawHits(pxdRawHitsPackedUnpacked_unsorted)
90 if not len(pxdDigits) == len(pxdRawHitsPackedUnpacked):
91 B2FATAL(
"PXDDigits and PXDRawHits count not equal after packing and unpacking")
93 print(
"Comparing %i pxd digits " % len(pxdDigits))
96 for i
in range(len(pxdDigits)):
98 rawHitPackedUnpacked = pxdRawHitsPackedUnpacked[i]
102 assert rawHitPackedUnpacked.getSensorID().
getID() == digit.getSensorID().
getID()
103 assert rawHitPackedUnpacked.getRow() == digit.getVCellID()
104 assert rawHitPackedUnpacked.getColumn() == digit.getUCellID()
108 assert numpy.isclose(min(255.0, digit.getCharge()), rawHitPackedUnpacked.getCharge())
112 particlegun = register_module(
'ParticleGun')
113 particlegun.param(
'pdgCodes', [13, -13])
114 particlegun.param(
'nTracks', 10)
117 eventinfosetter = register_module(
'EventInfoSetter')
118 eventinfosetter.param({
'evtNumList': [50]})
120 progress = register_module(
'Progress')
124 main.add_module(eventinfosetter)
125 main.add_module(particlegun)
128 set_module_parameters(main, type=
"Geometry", useDB=
False, components=[
"PXD"])
130 main.add_module(progress)
133 add_packers(main, components=[
'PXD'])
136 add_unpackers(main, components=[
'PXD'])
139 for e
in main.modules():
140 if e.name() ==
'PXDUnpacker':
141 e.param(
"PXDRawHitsName", pxd_rawhits_pack_unpack_collection)
142 e.param(
"PXDRawAdcsName", pxd_rawhits_pack_unpack_collection_adc)
143 e.param(
"PXDRawROIsName", pxd_rawhits_pack_unpack_collection_roi)
145 if e.name() ==
'PXDRawHitSorter':
146 e.param(
'rawHits', pxd_rawhits_pack_unpack_collection)
147 e.param(
'digits', pxd_rawhits_pack_unpack_collection_digits)
159 rawhits_collection=pxd_rawhits_pack_unpack_collection,
160 digits_collection=pxd_rawhits_pack_unpack_collection_digits))