Belle II Software development
VisualizeGeometry.py
1#!/usr/bin/env python3
2
3
10
11import os
12import basf2 as b2
13b2.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/
17os.environ['G4VRMLFILE_VIEWER'] = 'freewrl'
18
19# create path
20main = b2.create_path()
21# process one event
22main.add_module('EventInfoSetter', evtNumList=[1])
23# Load XML parameters
24main.add_module('Gearbox')
25# Create Geometry and show info messages for that
26main.add_module('Geometry', logLevel=b2.LogLevel.INFO)
27particlegun = main.add_module('ParticleGun')
28simulation = main.add_module('FullSim')
29
30simulation.param('EnableVisualization', True)
31simulation.param('UICommandsAtIdle', [
32 # Use VRML2 backend
33 '/vis/open VRML2FILE',
34 # Draw the geometry
35 '/vis/drawVolume',
36 # Draw coordinate axes at the origin with a length of 100mm in each direction
37 '/vis/scene/add/axes 0 0 0 100 mm',
38 # Draw simulated tracks
39 '/vis/scene/add/trajectories smooth',
40 '/vis/modeling/trajectories/create/drawByCharge'
41 # Uncomment the following two lines to have yellow dots at each step boundary
42 # along the trajectory
43 # '/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true',
44 # '/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 0.5',
45])
46
47# Parameters for particle gun
48particlegun.param('nTracks', 1)
49particlegun.param('pdgCodes', [211])
50particlegun.param('momentumParams', [2.0, 5.0])
51particlegun.param('thetaParams', [85.0, 95.0])
52particlegun.param('phiParams', [-5.0, 5.0])
53
54b2.process(main)