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

Public Member Functions

def __init__ (self, rawhits_collection='PXDRawHits', digits_collection="PXDDigits")
 
def sortDigits (self, unsortedPyStoreArray)
 
def sortRawHits (self, unsortedPyStoreArray)
 
def event (self)
 

Public Attributes

 rawhits_collection
 the PXDRawHits
 
 digits_collection
 the PXDDigits
 

Detailed Description

Module which checks if a collection of PXDDigits and
a collection of PXDRawHits from the packing/unpacking procedure are equal.
The PXDUnpacker does not create PXDDigits but PXDRawHits and therefore these two lists
must be compared.

Definition at line 30 of file pxd_packer_unpacker.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  rawhits_collection = 'PXDRawHits',
  digits_collection = "PXDDigits" 
)
constructor

Definition at line 39 of file pxd_packer_unpacker.py.

39 def __init__(self, rawhits_collection='PXDRawHits', digits_collection="PXDDigits"):
40 """constructor"""
41 # call constructor of base class, required if you implement __init__ yourself!
42 super().__init__()
43 # and do whatever else is necessary like declaring member variables
44
45 self.rawhits_collection = rawhits_collection
46
47 self.digits_collection = digits_collection
48

Member Function Documentation

◆ event()

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

Definition at line 81 of file pxd_packer_unpacker.py.

81 def event(self):
82 """ load the PXD Digits of the simulation and the packed/unpacked ones
83 and compare them"""
84
85 # load the digits and the collection which results from the packer and unpacker
86 # processed by packer and unpacker
87 pxdRawHitsPackedUnpacked_unsorted = Belle2.PyStoreArray(self.rawhits_collection)
88 # direct from simulation
89 pxdDigits_unsorted = Belle2.PyStoreArray(self.digits_collection)
90
91 # sort the digits, because the order gets
92 # lost during the packing/unpacking process
93 pxdDigits = self.sortDigits(pxdDigits_unsorted)
94 pxdRawHitsPackedUnpacked = self.sortRawHits(pxdRawHitsPackedUnpacked_unsorted)
95
96 if not len(pxdDigits) == len(pxdRawHitsPackedUnpacked):
97 b2.B2FATAL("PXDDigits and PXDRawHits count not equal after packing and unpacking")
98
99 print(f"Comparing {len(pxdDigits)} pxd digits ")
100
101 # check all quantities between the direct and the packed/unpacked pxd digits
102 for i in range(len(pxdDigits)):
103 digit = pxdDigits[i]
104 rawHitPackedUnpacked = pxdRawHitsPackedUnpacked[i]
105
106 # compare all available quantities
107 # cannot compare frame number, because it is not availabl on PXDDigits
108 assert rawHitPackedUnpacked.getSensorID().getID() == digit.getSensorID().getID()
109 assert rawHitPackedUnpacked.getRow() == digit.getVCellID()
110 assert rawHitPackedUnpacked.getColumn() == digit.getUCellID()
111 # There are some rare cases (~ every 10th event), where the PXD Digits have a charge
112 # larger than 255 which will be clipped by the packer to 8bit (at most 255)
113 # therefor, limit the maximal charge of the digit here in the comparison
114 assert numpy.isclose(min(255.0, digit.getCharge()), rawHitPackedUnpacked.getCharge())
115
116
117# 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 a some digit information to sort the PXDDigits list
    Returns a python-list containing the PXDDigts

Definition at line 49 of file pxd_packer_unpacker.py.

49 def sortDigits(self, unsortedPyStoreArray):
50 """ use a some digit information to sort the PXDDigits list
51 Returns a python-list containing the PXDDigts
52 """
53
54 # first convert to a python-list to be abple to sort
55 py_list = [x for x in unsortedPyStoreArray]
56
57 # sort via a hierachy of sort keys
58 return sorted(
59 py_list,
60 key=lambda x: (
61 x.getSensorID(),
62 x.getVCellID(),
63 x.getUCellID()))
64

◆ sortRawHits()

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

Definition at line 65 of file pxd_packer_unpacker.py.

65 def sortRawHits(self, unsortedPyStoreArray):
66 """ use a some digit information to sort the PXDRawHits list
67 Returns a python-list containing the PXDRawHits
68 """
69
70 # first convert to a python-list to be able to sort
71 py_list = [x for x in unsortedPyStoreArray]
72
73 # sort via a hierachy of sort keys
74 return sorted(
75 py_list,
76 key=lambda x: (
77 x.getSensorID(),
78 x.getRow(),
79 x.getColumn()))
80

Member Data Documentation

◆ digits_collection

digits_collection

the PXDDigits

Definition at line 47 of file pxd_packer_unpacker.py.

◆ rawhits_collection

rawhits_collection

the PXDRawHits

Definition at line 45 of file pxd_packer_unpacker.py.


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