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

Public Member Functions

def sortHits (self, unsortedPyStoreArray)
 
def event (self)
 

Detailed Description

module which checks if two collection of CDCHits are equal

Definition at line 21 of file cdc_packer_unpacker.py.

Member Function Documentation

◆ event()

def event (   self)
event function

Definition at line 43 of file cdc_packer_unpacker.py.

43 def event(self):
44 """
45 event function
46 """
47
48 # load the cdcHits and the collection which results from the packer and unpacker
49 # processed by packer and unpacker
50 cdcHitsPackedUnpacked_unsorted = Belle2.PyStoreArray(cdc_hits_pack_unpack_collection)
51 # direct from simulation
52 cdcHits_unsorted = Belle2.PyStoreArray(cdc_hits)
53
54 # sort the hits, because they have been shuffled in the packing/unpacking process
55 cdcHitsPackedUnpacked = self.sortHits(cdcHitsPackedUnpacked_unsorted)
56 cdcHits = self.sortHits(cdcHits_unsorted)
57
58 if not len(cdcHits) == len(cdcHitsPackedUnpacked):
59 b2.B2FATAL("CDC Hit count not equal after packing and unpacking")
60
61 # check all quantities between the direct and the packed/unpacked CDC hit
62 for i in range(len(cdcHits)):
63 hit = cdcHits[i]
64 hitPackedUnpacked = cdcHitsPackedUnpacked[i]
65
66 assert hit.getILayer() == hitPackedUnpacked.getILayer()
67 assert hit.getISuperLayer() == hitPackedUnpacked.getISuperLayer()
68 assert hit.getIWire() == hitPackedUnpacked.getIWire()
69 assert hit.getID() == hitPackedUnpacked.getID()
70 assert hit.getTDCCount() == hitPackedUnpacked.getTDCCount()
71 assert hit.getADCCount() == hitPackedUnpacked.getADCCount()
72 assert hit.getStatus() == hitPackedUnpacked.getStatus()
73
74
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ sortHits()

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

Definition at line 27 of file cdc_packer_unpacker.py.

27 def sortHits(self, unsortedPyStoreArray):
28 """ use a some information to sort the CDCHits list
29 Returns a python-list containing the CDCHits
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 hierachy of sort keys
36 return sorted(
37 py_list,
38 key=lambda x: (
39 x.getILayer(),
40 x.getISuperLayer(),
41 x.getIWire()))
42

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