Belle II Software  release-05-01-25
085_module.py
1 #!/usr/bin/env python3
2 
3 import basf2 as b2
4 from ROOT import Belle2
5 
6 
7 class AccessingDataStoreModule(b2.Module):
8  def initialize(self):
9  """Create a member to access event info and the MCParticles
10  StoreArray
11  """
12  self.eventinfo = Belle2.PyStoreObj("EventMetaData")
13  self.particles = Belle2.PyStoreArray("MCParticles")
14 
15  def event(self):
16  """Print the event number and the PDG code of the MCParticle"""
17  for particle in self.particles:
18  b2.B2INFO(
19  f"We're in event {self.eventinfo.getEvent()} "
20  f"and have a particle with PDG code {particle.getPDG()}"
21  )
22 
23 
24 # create a path
25 main = b2.Path()
26 
27 # generate events
28 main.add_module("EventInfoSetter", evtNumList=[10])
29 
30 # the ParticleGun generates simple tracks
31 main.add_module("ParticleGun")
32 
33 # and add our module
34 main.add_module(AccessingDataStoreModule())
35 
36 # run the path
37 b2.process(main)
085_module.AccessingDataStoreModule.initialize
def initialize(self)
Definition: 085_module.py:8
085_module.AccessingDataStoreModule.event
def event(self)
Definition: 085_module.py:15
Belle2::PyStoreObj
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:69
085_module.AccessingDataStoreModule
Definition: 085_module.py:7
085_module.AccessingDataStoreModule.particles
particles
Definition: 085_module.py:13
Belle2::PyStoreArray
a (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:58
085_module.AccessingDataStoreModule.eventinfo
eventinfo
Definition: 085_module.py:12