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

Public Member Functions

def sort_klm_digits (self, unsortedPyStoreArray)
 
def event (self)
 

Detailed Description

module which checks if two collections of EKLMDigits and BKLMDigits are
equal

Definition at line 19 of file klm_packer_unpacker.py.

Member Function Documentation

◆ event()

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

Definition at line 47 of file klm_packer_unpacker.py.

47 def event(self):
48 """
49 load original digits and the packed/unpacked ones, sort and compare them
50 """
51
52 # direct from simulation
53 klm_digits = Belle2.PyStoreArray("KLMDigits")
54 # processed by packer and unpacker
55 klm_digits_unpacked = Belle2.PyStoreArray("KLMDigitsUnpacked")
56
57 # sort digits
58 klm_digits_sorted = self.sort_klm_digits(klm_digits)
59 klm_digits_unpacked_sorted = self.sort_klm_digits(klm_digits_unpacked)
60
61 # check the size
62 if not len(klm_digits_sorted) == len(klm_digits_unpacked_sorted):
63 basf2.B2FATAL("KLMDigits: size not equal after packing and unpacking")
64 # check all quantities between the direct and the packed/unpacked
65 for i in range(len(klm_digits_sorted)):
66
67 digit = klm_digits_sorted[i]
68 digit_unpacked = klm_digits_unpacked_sorted[i]
69
70 # check the content of the digit
71 assert digit.getSubdetector() == digit_unpacked.getSubdetector()
72 assert digit.getSection() == digit_unpacked.getSection()
73 assert digit.getSector() == digit_unpacked.getSector()
74 assert digit.getLayer() == digit_unpacked.getLayer()
75 assert digit.getPlane() == digit_unpacked.getPlane()
76 assert digit.getStrip() == digit_unpacked.getStrip()
77 assert digit.inRPC() == digit_unpacked.inRPC()
78 assert digit.getCharge() == digit_unpacked.getCharge()
79 assert digit.getCTime() == digit_unpacked.getCTime()
80 assert digit.getTDC() == digit_unpacked.getTDC()
81 assert digit.getFitStatus() == digit_unpacked.getFitStatus()
82
83
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ sort_klm_digits()

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

Definition at line 26 of file klm_packer_unpacker.py.

26 def sort_klm_digits(self, unsortedPyStoreArray):
27 """
28 Use some digit information to sort the digits
29 Returns a python-list containing the sorted digits
30 """
31
32 # first convert to a python-list to be able to sort
33 py_list = [x for x in unsortedPyStoreArray]
34
35 # sort via a hierarchy of sort keys
36 return sorted(
37 py_list,
38 key=lambda x: (
39 x.getSubdetector(),
40 x.getSection(),
41 x.getSector(),
42 x.getLayer(),
43 x.getPlane(),
44 x.getStrip())
45 )
46

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