46 def initialize(self):
47 """Create the hdf5 file and list of variable objects to be used during
48 event processing."""
49
50 import ROOT
51
52 self._varnames = [
53 str(varname) for varname in variables.variables.resolveCollections(
55 *self._variables))]
56
57 self._var_objects = [variables.variables.getVariable(n) for n in self._varnames]
58
59
60 self._evtmeta = ROOT.Belle2.PyStoreObj("EventMetaData")
61 self._evtmeta.isRequired()
62
63 self._plist = ROOT.Belle2.PyStoreObj(self._listname)
64 self._plist.isRequired()
65
66
67 self._hdf5file = tables.open_file(self._filename, mode="w", title="Belle2 Variables to HDF5")
68 if not self._hdf5file:
69 basf2.B2ERROR("Cannot create output file")
70 return
71
72 dtype = [("exp", np.int32), ("run", np.int32), ("evt", np.uint32),
73 ("prod", np.uint32), ("icand", np.uint32), ("ncand", np.uint32)]
74 for name in self._varnames:
75
76 dtype.append((name, np.float64))
77
78
79 self._dtype = dtype
80 filters = tables.Filters(complevel=1, complib='blosc:lz4', fletcher32=False)
81
82
83 with warnings.catch_warnings():
84 warnings.simplefilter("ignore")
85
86 self._table = self._hdf5file.create_table("/", self._listname, obj=np.zeros(0, dtype), filters=filters)
87