Belle II Software  release-05-02-19
VisualizeGeometry.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import os
5 from basf2 import *
6 logging.log_level = LogLevel.WARNING
7 
8 # Set the environment variable to automatically start the VRML viewer
9 # for example http://freewrl.sourceforge.net/
10 os.environ['G4VRMLFILE_VIEWER'] = 'freewrl'
11 
12 # create path
13 main = create_path()
14 # process one event
15 main.add_module('EventInfoSetter', evtNumList=[1])
16 # Load XML parameters
17 main.add_module('Gearbox')
18 # Create Geometry and show info messages for that
19 main.add_module('Geometry', logLevel=LogLevel.INFO)
20 particlegun = main.add_module('ParticleGun')
21 simulation = main.add_module('FullSim')
22 
23 simulation.param('EnableVisualization', True)
24 simulation.param('UICommandsAtIdle', [
25  # Use VRML2 backend
26  '/vis/open VRML2FILE',
27  # Draw the geometry
28  '/vis/drawVolume',
29  # Draw coordinate axes at the origin with a length of 100mm in each direction
30  '/vis/scene/add/axes 0 0 0 100 mm',
31  # Draw simulated tracks
32  '/vis/scene/add/trajectories smooth',
33  '/vis/modeling/trajectories/create/drawByCharge'
34  # Uncomment the following two lines to have yellow dots at each step boundary
35  # along the trajectory
36  # '/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true',
37  # '/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 0.5',
38 ])
39 
40 # Parameters for particle gun
41 particlegun.param('nTracks', 1)
42 particlegun.param('pdgCodes', [211])
43 particlegun.param('momentumParams', [2.0, 5.0])
44 particlegun.param('thetaParams', [85.0, 95.0])
45 particlegun.param('phiParams', [-5.0, 5.0])
46 
47 process(main)