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