Belle II Software development
display.py
1#!/usr/bin/env python3
2
3
10
11#
12# Opens a .root/.sroot file and shows MCParticles,
13# SimHits and Tracks using the Display module.
14# Usage:
15# basf2 display/example/display.py -i MyInputFile.root
16#
17# Note: this file is also used by the 'b2display' command,
18# so the following is also possible:
19# b2display MyInputFile.root
20#
21# If you want custom settings for b2display, you thus only need to
22# edit this steering file.
23
24import basf2 as b2
25from ROOT import Belle2
26
27# create paths
28main = b2.create_path()
29
30# Get type of input file to decide, which input module we want to use
31input_files = Belle2.Environment.Instance().getInputFilesOverride()
32if not input_files.empty() and input_files.front().endswith(".sroot"):
33 rootinput = b2.register_module('SeqRootInput')
34else:
35 rootinput = b2.register_module('RootInput')
36
37# create geometry
38gearbox = b2.register_module('Gearbox')
39# gearbox.param('fileName', '/geometry/Beast2_phase1.xml')
40gearbox.param('fileName', 'beast/microtpc/detector.xml')
41geometry = b2.register_module('Geometry')
42# new ECL geometry contains custom objects that cannot be converted to TGeo
43# add MagneticField off B-field (also greatly speeds up startup)
44# geometry.param('excludedComponents', ['ECL'])
45
46main.add_module(rootinput)
47main.add_module(gearbox)
48main.add_module(geometry)
49
50display = b2.register_module('Display')
51# --- MC options ---
52# Should Monte Carlo info be shown? (MCParticles, SimHits)
53display.param('showMCInfo', True)
54
55# should hits always be assigned to a particle with c_PrimaryParticle flag?
56display.param('assignHitsToPrimaries', False)
57
58# show all primary MCParticles?
59display.param('showAllPrimaries', True)
60
61# show all charged MCParticles?
62display.param('showCharged', True)
63
64# show all neutral MCParticles?
65display.param('showNeutrals', True)
66
67
68# --- Intermediate options ---
69# show track candidates?
70# You most likely don't want this unless you are a tracking developer
71display.param('showRecoTracks', False)
72
73# directly show CDCHits as drift cylinders (shortened, z position = 0)
74display.param('showCDCHits', False)
75
76
77# --- Track options ---
78# show tracks, vertices, eclgammas?
79display.param('showTrackLevelObjects', True)
80
81# The options parameter is a combination of:
82# D draw detectors - draw simple detector representation (with different size)
83# for each hit
84# H draw track hits
85# M draw track markers - intersections of track with detector planes
86# P draw detector planes
87#
88# Note that you can always turn off an individual detector component or track
89# interactively by removing its checkmark in the 'Eve' tab.
90#
91# only makes sense when showTrackLevelObjects/showTrackCandidates is used
92display.param('options', 'MH') # default
93
94# --- Other options ---
95
96# save events non-interactively (without showing window)?
97display.param('automatic', False)
98
99# change to True to show the full TGeo geometry instead of simplified extract
100display.param('fullGeometry', True)
101
102# Objects which are to be hidden (can be manually re-enabled in tree view).
103# Names correspond to the object names in the 'Event'. (Note that this won't
104# work for objects somewhere deep in the tree, only for those immediately
105# below 'Event'.
106display.param('hideObjects', [])
107
108main.add_module(display)
109
110b2.process(main)
111# print(statistics(statistics.INIT))
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28