Belle II Software development
read_array_example.py
1import basf2
2import ROOT # noqa
3from ROOT.Belle2 import PyStoreArray, DataStore
4
5import generators as ge
6import simulation as si
7
8
9class PXDReader(basf2.Module):
10 '''
11 Simple module that reads the content of the PyStoreArray
12 and prints a dictionary with the read values
13 '''
14
15 def initialize(self):
16 '''
17 Initialize the PyStoreArray and regiter it into the DataStore
18 '''
19
20 self.pxddigits = PyStoreArray("PXDDigits", DataStore.c_Event)
21 self.pxddigits.registerInDataStore("PXDDigits")
22
23 def event(self):
24 '''
25 Loop over the number of events and read the content of the
26 PyStoreArray into a dictionary
27 '''
28 digits = self.pxddigits.readArray()
29 print(digits)
30
31
32main = basf2.Path()
33main.add_module('EventInfoSetter', evtNumList=[1], expList=[0])
34ge.add_evtgen_generator(path=main, finalstate='mixed')
35si.add_simulation(path=main)
36main.add_module(PXDReader())
37
38basf2.process(main)
39basf2.statistics