Belle II Software  release-08-01-10
displaydata.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # This example demonstrates showing user-defined things using DisplayData
13 
14 import basf2 as b2
15 
16 from ROOT import Belle2
17 from ROOT.Math import XYZVector
18 import ROOT
19 
20 
21 class DisplayDataTest(b2.Module):
22  """Test DisplayData"""
23 
24  def initialize(self):
25  """reimplementation of Module::initialize()."""
26 
27  Belle2.PyStoreObj("DisplayData").registerInDataStore()
28 
29  def event(self):
30  """reimplementation of Module::event()."""
31 
32  displayData = Belle2.PyStoreObj("DisplayData")
33  displayData.create()
34 
35  # you can put a label at arbitrary points
36  displayData.obj().addLabel("Origin", XYZVector(0, 0, 0))
37 
38  # or simple points (grouped into sets)
39  for i in range(10):
40  displayData.obj().addPoint("set 1", XYZVector(15, 15, 10 * i))
41  for i in range(10):
42  displayData.obj().addPoint("set 2", XYZVector(10 * i, 0, 50))
43 
44  # you can add arrows
45  pos = XYZVector(0, 0, 100)
46  displayData.obj().addArrow("x", pos, pos + XYZVector(50, 0, 0))
47  displayData.obj().addArrow("y", pos, pos + XYZVector(0, 50, 0))
48  displayData.obj().addArrow("z", pos, pos + XYZVector(0, 0, 50))
49 
50  displayData.obj().addArrow("z=-2m", XYZVector(100, 100, -200), XYZVector(0, 0, -200), ROOT.kGray)
51 
52  # highlight the first MCParticle
53  mcparticles = Belle2.PyStoreArray('MCParticles')
54  part = mcparticles[0]
55  if part is not None:
56  displayData.obj().select(part)
57 
58 
59 # register necessary modules
60 eventinfosetter = b2.register_module('EventInfoSetter')
61 eventinfosetter.param('evtNumList', [500])
62 
63 
64 # create geometry
65 gearbox = b2.register_module('Gearbox')
66 geometry = b2.register_module('Geometry')
67 
68 particlegun = b2.register_module('ParticleGun')
69 particlegun.param('nTracks', 4)
70 
71 
72 # simulation
73 g4sim = b2.register_module('FullSim')
74 # make the simulation less noisy
75 g4sim.logging.log_level = b2.LogLevel.ERROR
76 
77 # create paths
78 main = b2.create_path()
79 
80 # add modules to paths
81 main.add_module(eventinfosetter)
82 
83 main.add_module(gearbox)
84 main.add_module(geometry)
85 main.add_module(particlegun)
86 # main.add_module(g4sim)
87 
88 main.add_module(DisplayDataTest())
89 
90 # default parameters
91 display = b2.register_module('Display')
92 display.param('showAllPrimaries', True)
93 main.add_module(display)
94 
95 b2.process(main)
96 print(b2.statistics)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67