Belle II Software  release-08-01-10
VisualizeGeometry.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import os
13 import basf2 as b2
14 b2.logging.log_level = b2.LogLevel.WARNING
15 
16 # Set the environment variable to automatically start the VRML viewer
17 # for example http://freewrl.sourceforge.net/
18 os.environ['G4VRMLFILE_VIEWER'] = 'freewrl'
19 
20 # create path
21 main = b2.create_path()
22 # process one event
23 main.add_module('EventInfoSetter', evtNumList=[1])
24 # Load XML parameters
25 main.add_module('Gearbox')
26 # Create Geometry and show info messages for that
27 main.add_module('Geometry', logLevel=b2.LogLevel.INFO)
28 particlegun = main.add_module('ParticleGun')
29 simulation = main.add_module('FullSim')
30 
31 simulation.param('EnableVisualization', True)
32 simulation.param('UICommandsAtIdle', [
33  # Use VRML2 backend
34  '/vis/open VRML2FILE',
35  # Draw the geometry
36  '/vis/drawVolume',
37  # Draw coordinate axes at the origin with a length of 100mm in each direction
38  '/vis/scene/add/axes 0 0 0 100 mm',
39  # Draw simulated tracks
40  '/vis/scene/add/trajectories smooth',
41  '/vis/modeling/trajectories/create/drawByCharge'
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 
48 # Parameters for particle gun
49 particlegun.param('nTracks', 1)
50 particlegun.param('pdgCodes', [211])
51 particlegun.param('momentumParams', [2.0, 5.0])
52 particlegun.param('thetaParams', [85.0, 95.0])
53 particlegun.param('phiParams', [-5.0, 5.0])
54 
55 b2.process(main)