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

Public Member Functions

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

Detailed Description

module which ckecks if two collections of TOPDigits are equal

Definition at line 19 of file top_packer_unpacker.py.

Member Function Documentation

◆ event()

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

Definition at line 43 of file top_packer_unpacker.py.

43 def event(self):
44 """
45 load original TOPDigits and the packed/unpacked ones, sort and compare them
46 """
47
48 # direct from simulation
49 digits = Belle2.PyStoreArray("TOPDigits")
50 # processed by packer and unpacker
51 digitsUnpacked = Belle2.PyStoreArray("TOPDigitsUnpacked")
52
53 # sort digits
54 digits_sorted = self.sortDigits(digits)
55 digitsUnpacked_sorted = self.sortDigits(digitsUnpacked)
56
57 # check the sizes
58 if not len(digits_sorted) == len(digitsUnpacked_sorted):
59 print('size: ', len(digits_sorted), len(digitsUnpacked_sorted))
60 b2.B2FATAL("TOPDigits: size not equal after packing and unpacking")
61
62 # check all quantities between the direct and the packed/unpacked
63 precision = 0.0001 # precision for floats (e.g. in [ns])
64 for i in range(len(digits_sorted)):
65
66 digit = digits_sorted[i]
67 digitUnpacked = digitsUnpacked_sorted[i]
68
69 # check the content of the digit
70 assert digit.getModuleID() == digitUnpacked.getModuleID()
71 assert digit.getPixelID() == digitUnpacked.getPixelID()
72 assert digit.getChannel() == digitUnpacked.getChannel()
73 assert digit.getRawTime() == digitUnpacked.getRawTime()
74 assert abs(digit.getTime() - digitUnpacked.getTime()) < precision
75 assert abs(digit.getTimeError() - digitUnpacked.getTimeError()) < precision
76 assert digit.getPulseHeight() == digitUnpacked.getPulseHeight()
77 assert abs(digit.getPulseWidth() - digitUnpacked.getPulseWidth()) < precision
78 # assert digit.getIntegral() == digitUnpacked.getIntegral()
79 assert digit.getFirstWindow() == digitUnpacked.getFirstWindow()
80 assert digit.getHitQuality() == digitUnpacked.getHitQuality()
81 assert digit.getStatus() == digitUnpacked.getStatus()
82 assert digit.isChargeShare() == digitUnpacked.isChargeShare()
83 assert digit.isPrimaryChargeShare() == digitUnpacked.isPrimaryChargeShare()
84
85
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 top_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.getChannel(),
40 x.getRawTime())
41 )
42

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