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

Public Member Functions

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

Detailed Description

module which ckecks if two collections of ARICHDigits are equal

Definition at line 19 of file arich_packer_unpacker.py.

Member Function Documentation

◆ event()

def event (   self)
load original ARICHDigits and the packed/unpacked ones, sort and compare them

Definition at line 42 of file arich_packer_unpacker.py.

42 def event(self):
43 """
44 load original ARICHDigits and the packed/unpacked ones, sort and compare them
45 """
46
47 # direct from simulation
48 digits = Belle2.PyStoreArray("ARICHDigits")
49 # processed by packer and unpacker
50 digitsUnpacked = Belle2.PyStoreArray("ARICHDigitsUnpacked")
51
52 # sort digits
53 digits_sorted = self.sortDigits(digits)
54 digitsUnpacked_sorted = self.sortDigits(digitsUnpacked)
55
56 # check the sizes
57 if not len(digits_sorted) == len(digitsUnpacked_sorted):
58 b2.B2FATAL("ARICHDigits: size not equal after packing and unpacking")
59
60 # check all quantities between the direct and the packed/unpacked
61 for i in range(len(digits_sorted)):
62
63 digit = digits_sorted[i]
64 digitUnpacked = digitsUnpacked_sorted[i]
65
66 # check the content of the digit
67 assert digit.getModuleID() == digitUnpacked.getModuleID()
68 assert digit.getChannelID() == digitUnpacked.getChannelID()
69 assert digit.getBitmap() == digitUnpacked.getBitmap()
70
71
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ sortDigits()

def sortDigits (   self,
  unsortedPyStoreArray 
)
Use some digit information to sort the digits
Returns a python-list containing the sorted digits

Definition at line 25 of file arich_packer_unpacker.py.

25 def sortDigits(self, unsortedPyStoreArray):
26 """
27 Use some digit information to sort the digits
28 Returns a python-list containing the sorted digits
29 """
30
31 # first convert to a python-list to be able to sort
32 py_list = [x for x in unsortedPyStoreArray]
33
34 # sort via a hierachy of sort keys
35 return sorted(
36 py_list,
37 key=lambda x: (
38 x.getModuleID(),
39 x.getChannelID())
40 )
41

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