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