Belle II Software  release-08-01-10
mcparticle_relations.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 from ROOT import Belle2
14 
15 b2.logging.log_level = b2.LogLevel.ERROR
16 
17 
18 class TestModule(b2.Module):
19 
20  """Test to read relations."""
21 
22  def __init__(self):
23  """constructor."""
24 
25  super(TestModule, self).__init__()
26 
27  def event(self):
28  """reimplementation of Module::event().
29 
30  access all relations from/to MCParticles,
31  any invalid indices should be caught.
32  """
33 
34  mcparticles = Belle2.PyStoreArray('MCParticles')
35  # this will generate an index internally, checking consistency
36  # (will die with a FATAL if something goes wrong)
37  from_relations = mcparticles[0].getRelationsFrom("ALL") # noqa
38  to_relations = mcparticles[0].getRelationsTo("ALL") # noqa
39 
40 
41 eventinfosetter = b2.register_module('EventInfoSetter')
42 eventinfosetter.param('evtNumList', [10])
43 
44 gearbox = b2.register_module('Gearbox')
45 geometry = b2.register_module('Geometry')
46 pgun = b2.register_module('ParticleGun')
47 g4sim = b2.register_module('FullSim')
48 # make the simulation less noisy
49 
50 main = b2.create_path()
51 
52 main.add_module(eventinfosetter)
53 main.add_module(gearbox)
54 main.add_module(geometry)
55 main.add_module(pgun)
56 main.add_module(g4sim)
57 main.add_module(TestModule())
58 
59 b2.process(main)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72