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