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