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

Public Member Functions

def sortECLDigits (self, unsortedPyStoreArray)
 
def event (self)
 

Detailed Description

module which checks if two collections of ECLDigits are equal

Definition at line 88 of file ecl_packer_unpacker.py.

Member Function Documentation

◆ event()

def event (   self)
event function

Definition at line 106 of file ecl_packer_unpacker.py.

106 def event(self):
107 """
108 event function
109 """
110
111 # load the ECLDigits that were packed and unpacked
112 eclDigitsPackedUnpacked_unsorted = Belle2.PyStoreArray(unpackerOutputDatastoreName)
113 # ECLDigits direct from simulation
114 eclDigitsFromSimulation_unsorted = Belle2.PyStoreArray(eclDigitsDatastoreName)
115
116 if not len(eclDigitsFromSimulation_unsorted) == len(eclDigitsPackedUnpacked_unsorted):
117 b2.B2FATAL("Different number of ECLDigits from simulation and after packing+unpacking")
118
119 eclDigitsPackedUnpacked = self.sortECLDigits(eclDigitsPackedUnpacked_unsorted)
120 eclDigitsFromSimulation = self.sortECLDigits(eclDigitsFromSimulation_unsorted)
121
122 tc = TestCase('__init__')
123
124 # check all quantities between the direct and the packed/unpacked ECLDigits
125 for idx in range(len(eclDigitsPackedUnpacked)):
126 digit = eclDigitsFromSimulation[idx]
127 digitPackedUnpacked = eclDigitsPackedUnpacked[idx]
128
129 b2.B2DEBUG(5, 'MC digit: cellid = ' +
130 str(digit.getCellId()) +
131 ', amp = ' +
132 str(digit.getAmp()) +
133 ', time = ' +
134 str(digit.getTimeFit()) +
135 ', quality = ' +
136 str(digit.getQuality()) +
137 ', chi = ' +
138 str(digit.getChi()) +
139 '\nUnpackedDigit: cellid = ' +
140 str(digitPackedUnpacked.getCellId()) +
141 ', amp = ' +
142 str(digitPackedUnpacked.getAmp()) +
143 ', time = ' +
144 str(digitPackedUnpacked.getTimeFit()) +
145 ', quality = ' +
146 str(digitPackedUnpacked.getQuality()) +
147 ', chi = ' +
148 str(digitPackedUnpacked.getChi()))
149
150 tc.assertEqual(digit.getCellId(), digitPackedUnpacked.getCellId())
151 tc.assertEqual(digit.getAmp(), digitPackedUnpacked.getAmp())
152 tc.assertEqual(digit.getTimeFit(), digitPackedUnpacked.getTimeFit())
153 tc.assertEqual(digit.getQuality(), digitPackedUnpacked.getQuality())
154 tc.assertEqual(digit.getChi(), digitPackedUnpacked.getChi())
155
156
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ sortECLDigits()

def sortECLDigits (   self,
  unsortedPyStoreArray 
)
 use a some information to sort the ECLDigits list
    Returns a python-list containing the ECLDigits

Definition at line 93 of file ecl_packer_unpacker.py.

93 def sortECLDigits(self, unsortedPyStoreArray):
94 """ use a some information to sort the ECLDigits list
95 Returns a python-list containing the ECLDigits
96 """
97 # first convert to a python-list to be able to sort
98 py_list = [x for x in unsortedPyStoreArray]
99
100 # sort via a hierarchy of sort keys
101 return sorted(
102 py_list,
103 key=lambda x: (
104 x.getCellId()))
105

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