Belle II Software  release-08-01-10
VisualizeGeometry.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import os
12 import basf2 as b2
13 b2.logging.log_level = b2.LogLevel.WARNING
14 
15 # Set the environment variable to automatically start the VRML viewer
16 # for example http://freewrl.sourceforge.net/
17 os.environ['G4VRMLFILE_VIEWER'] = 'freewrl'
18 
19 eventinfosetter = b2.register_module('EventInfoSetter')
20 # Load XML parameters
21 paramloader = b2.register_module('Gearbox')
22 # paramloader.param('fileName', '/geometry/Beast2_phase2.xml')
23 paramloader.param('fileName', '/geometry/Beast2_phase1.xml')
24 # paramloader.param('fileName', '/home/igal/src/belle2/release/beast/examples/Beast2_phase1.xml')
25 # paramloader.param('fileName', '/beast/Beast2_phase1.xml')
26 # Create Geometry
27 geobuilder = b2.register_module('Geometry')
28 geobuilder.log_level = b2.LogLevel.INFO
29 pguninput = b2.register_module('ParticleGun')
30 g4sim = b2.register_module('FullSim')
31 
32 eventinfosetter.param('evtNumList', [1])
33 
34 g4sim.param('EnableVisualization', True)
35 g4sim.param('UICommandsAtIdle', ['/vis/open VRML2FILE', '/vis/drawVolume',
36  '/vis/scene/add/axes 0 0 0 31 mm',
37  '/vis/scene/add/trajectories smooth',
38  '/vis/modeling/trajectories/create/drawByCharge']) # Use VRML2 backend
39 # Draw the geometry
40 # Draw coordinate axes at the origin with a length of 100mm in each direction
41 # Draw simulated tracks
42 # Uncomment the following two lines to have yellow dots at each step boundary
43 # along the trajectory
44 # '/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true',
45 # '/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 0.5',
46 
47 # Parameters for particle gun
48 pguninput.param('nTracks', 1)
49 pguninput.param('pdgCodes', [211])
50 pguninput.param('momentumParams', [2.0, 5.0])
51 pguninput.param('thetaParams', [85.0, 95.0])
52 pguninput.param('phiParams', [-5.0, 5.0])
53 
54 main = b2.create_path()
55 
56 main.add_module(eventinfosetter)
57 main.add_module(paramloader)
58 main.add_module(geobuilder)
59 # Without Particle Gun there are no tracks
60 main.add_module(pguninput)
61 main.add_module(g4sim)
62 
63 b2.process(main)