Belle II Software development
SvdPackerUnpackerTestModule Class Reference
Inheritance diagram for SvdPackerUnpackerTestModule:

Public Member Functions

def sortDigits (self, unsortedPyStoreArray)
 
def event (self)
 

Detailed Description

module which ckecks if two collection of SVDShaperDigits are equal

Definition at line 21 of file svd_packer_unpacker.py.

Member Function Documentation

◆ event()

def event (   self)
 load SVDShaperDigits of the simulation and the packed/unpacked ones
and compare them

Definition at line 44 of file svd_packer_unpacker.py.

44 def event(self):
45 """ load SVDShaperDigits of the simulation and the packed/unpacked ones
46 and compare them"""
47
48 svdDigitsPackedUnpacked = Belle2.PyStoreArray(svd_digits_pack_unpack_collection)
49 # direct from simulation
50 svdDigits = Belle2.PyStoreArray("SVDShaperDigits")
51
52 svdDigits_sorted = self.sortDigits(svdDigits)
53 svdDigitsPackedUnpacked_sorted = self.sortDigits(svdDigitsPackedUnpacked)
54
55 if not len(svdDigits_sorted) == len(svdDigitsPackedUnpacked_sorted):
56 b2.B2FATAL("SVDShaperDigits count not equal after packing and unpacking")
57
58 # check all quantities between the direct and the packed/unpacked svd digits
59 for i in range(len(svdDigits_sorted)):
60
61 # sort the digits, because the packer sorts the
62 # the 32-bit frames are sorted by FADC numbers by the packer module
63 hit = svdDigits_sorted[i]
64 hitPackedUnpacked = svdDigitsPackedUnpacked_sorted[i]
65
66 # check content of the digit
67 assert hit.getTime() == hitPackedUnpacked.getTime()
68 assert hit.getIndex() == hitPackedUnpacked.getIndex()
69
70 # note: The charge will only be checked if between 0 and 255
71 # These two cases will be addressed in future SVDShaperDigits and packer/unpacker version
72 assert numpy.isclose(hit.getCharge(), hitPackedUnpacked.getCharge())
73
74 # check the VxdID information
75 assert hit.getSensorID().getID() == hitPackedUnpacked.getSensorID().getID()
76 assert hit.getSensorID().getLayerNumber() == hitPackedUnpacked.getSensorID().getLayerNumber()
77 assert hit.getSensorID().getLadderNumber() == hitPackedUnpacked.getSensorID().getLadderNumber()
78 assert hit.getSensorID().getSensorNumber() == hitPackedUnpacked.getSensorID().getSensorNumber()
79 assert hit.getSensorID().getSegmentNumber() == hitPackedUnpacked.getSensorID().getSegmentNumber()
80
81
82# to run the framework the used modules need to be registered
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ sortDigits()

def sortDigits (   self,
  unsortedPyStoreArray 
)
 use some digit information to sort the SVDShaperDigits list
    Returns a python-list containing the SVDShaperDigits

Definition at line 27 of file svd_packer_unpacker.py.

27 def sortDigits(self, unsortedPyStoreArray):
28 """ use some digit information to sort the SVDShaperDigits list
29 Returns a python-list containing the SVDShaperDigits
30 """
31
32 # first convert to a python-list to be abple to sort
33 py_list = [x for x in unsortedPyStoreArray]
34
35 # sort via a hierachy of sort keys
36 return sorted(
37 py_list,
38 key=lambda x: (
39 x.getSensorID().getLayerNumber(),
40 x.getSensorID().getLadderNumber(),
41 x.getSensorID().getSensorNumber(),
42 x.isUStrip()))
43

The documentation for this class was generated from the following file: