Belle II Software light-2406-ragdoll
interactive_python.py
1#!/usr/bin/env python3
2
3
10
11
16
17from basf2 import Module, Path, process, B2INFO
18import interactive
19from ROOT import Belle2
20
21
22class MinModule(Module):
23 """
24 Example module to drop into ipython and create some objects to look at.
25 If you just want to start IPython and create PyStoreArray etc.
26 interactively in your own steering file, the 'Interactive' module
27 might be of interest.
28 """
29
30 def event(self):
31 """
32 reimplement Module::event()
33 """
34 evtmetadata = Belle2.PyStoreObj("EventMetaData") # noqa
35 particles = Belle2.PyStoreArray("MCParticles") # noqa
36 B2INFO(80 * '=')
37 B2INFO("Dropping into interactive python shell. Try:"
38 "\n print evtmetadata.obj().getEvent()"
39 "\n particles[0].Dump()"
40 "\n help(particles[0])"
41 "\nTo continue non-interactively (until next event), press Ctrl+D."
42 "\nPress Ctrl+C followed by Ctrl+D to exit basf2.")
43 B2INFO(80 * '=')
44 interactive.embed()
45
46
47main = Path()
48main.add_module('EventInfoSetter', evtNumList=[2])
49main.add_module('ParticleGun')
50main.add_module(MinModule())
51process(main)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67