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
19eventinfosetter = b2.register_module('EventInfoSetter')
20# Load XML parameters
21paramloader = b2.register_module('Gearbox')
22# paramloader.param('fileName', '/geometry/Beast2_phase2.xml')
23paramloader.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
27geobuilder = b2.register_module('Geometry')
28geobuilder.log_level = b2.LogLevel.INFO
29pguninput = b2.register_module('ParticleGun')
30g4sim = b2.register_module('FullSim')
31
32eventinfosetter.param('evtNumList', [1])
33
34g4sim.param('EnableVisualization', True)
35g4sim.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
48pguninput.param('nTracks', 1)
49pguninput.param('pdgCodes', [211])
50pguninput.param('momentumParams', [2.0, 5.0])
51pguninput.param('thetaParams', [85.0, 95.0])
52pguninput.param('phiParams', [-5.0, 5.0])
53
54main = b2.create_path()
55
56main.add_module(eventinfosetter)
57main.add_module(paramloader)
58main.add_module(geobuilder)
59# Without Particle Gun there are no tracks
60main.add_module(pguninput)
61main.add_module(g4sim)
62
63b2.process(main)