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 [-- --play]
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 argparse
25import basf2 as b2
26from ROOT import Belle2
27
28ap = argparse.ArgumentParser()
29ap.add_argument("--play", action='store_true', help="Start event display advancing through events.")
30args = ap.parse_args()
31
32# create paths
33main = b2.create_path()
34
35# Get type of input file to decide, which input module we want to use
36input_files = Belle2.Environment.Instance().getInputFilesOverride()
37if not input_files.empty() and input_files.front().endswith(".sroot"):
38 rootinput = b2.register_module('SeqRootInput')
39else:
40 rootinput = b2.register_module('RootInput')
41
42# create geometry
43gearbox = b2.register_module('Gearbox')
44geometry = b2.register_module('Geometry')
45# new ECL geometry contains custom objects that cannot be converted to TGeo
46# add MagneticField off B-field (also greatly speeds up startup)
47geometry.param('excludedComponents', ['ECL'])
48
49main.add_module(rootinput)
50main.add_module(gearbox)
51main.add_module(geometry)
52
53display = b2.register_module('Display')
54# --- MC options ---
55# Should Monte Carlo info be shown? (MCParticles, SimHits)
56display.param('showMCInfo', True)
57
58# should hits always be assigned to a particle with c_PrimaryParticle flag?
59display.param('assignHitsToPrimaries', False)
60
61# show all primary MCParticles?
62display.param('showAllPrimaries', True)
63
64# show all charged MCParticles?
65display.param('showCharged', True)
66
67# show all neutral MCParticles?
68display.param('showNeutrals', True)
69
70
71# --- Intermediate options ---
72# show track candidates?
73# You most likely don't want this unless you are a tracking developer
74display.param('showRecoTracks', False)
75
76# directly show CDCHits as drift cylinders (shortened, z position = 0)
77display.param('showCDCHits', False)
78
79# show trigger objects?
80display.param('showTriggerObjects', False)
81
82
83# --- Track options ---
84# show tracks, vertices, eclgammas?
85display.param('showTrackLevelObjects', True)
86
87# The options parameter is a combination of:
88# D draw detectors - draw simple detector representation (with different size)
89# for each hit
90# H draw track hits
91# M draw track markers - intersections of track with detector planes
92# P draw detector planes
93#
94# Note that you can always turn off an individual detector component or track
95# interactively by removing its checkmark in the 'Eve' tab.
96#
97# only makes sense when showTrackLevelObjects/showTrackCandidates is used
98display.param('options', 'MH') # default
99
100# --- Other options ---
101
102# save events non-interactively (without showing window)?
103display.param('automatic', False)
104
105# change to True to show the full TGeo geometry instead of simplified extract
106display.param('fullGeometry', False)
107
108# set to any downloaded/created extract (=simplified geometry + 2D projections)
109# Default extract (for Phase 3) is stored in display/data
110display.param('customGeometryExtractPath', '')
111
112# Objects which are to be hidden (can be manually re-enabled in tree view).
113# Names correspond to the object names in the 'Event'. (Note that this won't
114# work for objects somewhere deep in the tree, only for those immediately
115# below 'Event'.
116display.param('hideObjects', [])
117
118# should events be advanced on startup?
119if args.play:
120 display.param('playOnStartup', True)
121
122main.add_module(display)
123
124b2.process(main)
125# print(statistics(statistics.INIT))
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28