1
# This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
3
# MAUS is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# MAUS is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with MAUS. If not, see <http://www.gnu.org/licenses/>.
17
Test for MapCppSimulation visualisation; we need a separate test as want to
18
reinitialise geant4 with visualisation on
20
# pylint: disable=C0103
21
# pylint: disable=R0904
28
from MapCppSimulation import MapCppSimulation
30
class MapCppSimulationVisualisationTestCase(unittest.TestCase):
32
Test for visualisation of simulation
35
def setUpClass(self): # pylint: disable=C0103, C0202
36
self.float_tolerance = 1e-9
37
self.mapper = MapCppSimulation()
38
success = self.mapper.birth(json.dumps(self.configuration))
39
self.particle = {"primary":{
40
"position":{"x":1.,"y":2.,"z":3.},
41
"momentum":{"x":4.,"y":5.,"z":6.},
46
"statistical_weight":1.
49
raise Exception('InitializeFail', 'Could not start worker')
52
def tearDownClass(self): # pylint: disable=C0103, C0202
53
success = self.mapper.death()
55
raise Exception('DestructFail', 'Could not kill worker')
58
######## tests on Process #########
59
def test_mc_vrml2file_no_event(self): # should make a vrml file
61
Check we can make a vrml file even when there is no G4 event.
63
Only supported option right now is vrml as we need this to feed into the
66
for filename in glob.glob('g4_*.wrl'):
67
os.rename(filename, os.environ['MAUS_ROOT_DIR']+'/tmp/'+filename)
71
result = self.mapper.process(json.dumps(good_event))
72
if "errors" in result:
73
raise Exception('test_mc_vis made an error')
74
if len(glob.glob('g4_*.wrl')) < 1:
75
raise Exception('test_mc_vis_no_event failed to make a VRML file')
76
for filename in glob.glob('g4_*.wrl'):
77
os.rename(filename, os.environ['MAUS_ROOT_DIR']+'/tmp/'+filename)
81
"simulation_geometry_filename":"Test.dat",
82
"maximum_number_of_steps":1000,
85
"simulation_reference_particle":{
86
"position":{"x":0.0, "y":-0.0, "z":-4700.0},
87
"momentum":{"x":0.0, "y":0.0, "z":1.0},
93
"geant4_visualisation":True,
94
"visualisation_viewer":"VRML2FILE",
95
"visualisation_theta":90.,
96
"visualisation_phi":90.,
97
"visualisation_zoom":1.,
98
"accumulate_tracks":0,
99
"default_vis_colour":{"red":0. , "green":100. ,"blue":0.},
100
"pi_plus_vis_colour":{"red":255. , "green":250. ,"blue":240.},
101
"pi_minus_vis_colour":{"red":105. , "green":105. ,"blue":105.},
102
"mu_plus_vis_colour":{"red":25. , "green":25. ,"blue":112.},
103
"mu_minus_vis_colour":{"red":135. , "green":206. ,"blue":250.},
104
"e_plus_vis_colour":{"red":250. , "green":0. ,"blue":0.},
105
"e_minus_vis_colour":{"red":250. , "green":69. ,"blue":0.},
106
"gamma_vis_colour":{"red":255. , "green":20. ,"blue":147.},
107
"neutron_vis_colour":{"red":139. , "green":69. ,"blue":19.},
108
"photon_vis_colour":{"red":255. , "green":255. ,"blue":0.},
109
"physics_model":"QGSP_BERT",
110
"physics_processes":"standard",
111
"reference_physics_processes":"mean_energy_loss",
112
"particle_decay":True,
113
"charged_pion_half_life":-1.,
114
"muon_half_life":-1.,
115
"production_threshold":0.5,
118
if __name__ == '__main__':