~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/map/MapCppSimulation/run_visualisation_for_tests.py

  • Committer: Durga Rajaram
  • Date: 2014-07-16 15:13:05 UTC
  • mfrom: (659.1.92 cand)
  • Revision ID: durga@fnal.gov-20140716151305-q27rv1y9p03v9lks
Tags: MAUS-v0.9, MAUS-v0.9.0
MAUS-v0.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import json
26
26
import unittest
27
27
 
 
28
import maus_cpp.globals
 
29
import maus_cpp.converter
28
30
import Configuration
29
 
from MapCppSimulation import MapCppSimulation
 
31
from MAUS import MapCppSimulation
30
32
 
31
33
class MapCppSimulationVisualisationTestCase(unittest.TestCase):
32
34
    """
36
38
    def setUpClass(self): # pylint: disable=C0103, C0202
37
39
        self.float_tolerance = 1e-9
38
40
        self.mapper = MapCppSimulation()
39
 
        success = self.mapper.birth(json.dumps(self.configuration))
 
41
        if not maus_cpp.globals.has_instance():
 
42
            maus_cpp.globals.birth(json.dumps(self.configuration))
 
43
        self.mapper.birth(json.dumps(self.configuration))
40
44
        self.particle = {"primary":{
41
45
                "position":{"x":1.,"y":2.,"z":3.},
42
46
                "momentum":{"x":4.,"y":5.,"z":6.},
47
51
                "time":7.,
48
52
                "statistical_weight":1.
49
53
            }}
50
 
        if not success:
51
 
            raise Exception('InitializeFail', 'Could not start worker')
52
54
 
53
55
    @classmethod
54
56
    def tearDownClass(self): # pylint: disable=C0103, C0202
55
 
        success = self.mapper.death()
56
 
        if not success:
57
 
            raise Exception('DestructFail', 'Could not kill worker')
58
 
        self.mapper = None
 
57
        self.mapper.death()
59
58
 
60
59
    ######## tests on Process #########
61
60
    def test_mc_vrml2file(self):  # should make a vrml file
68
67
        good_event = {
69
68
            "mc_events":[self.particle,self.particle]
70
69
        }
71
 
        result = self.mapper.process(json.dumps(good_event))
 
70
        result = self.mapper.process(good_event)
 
71
        result = maus_cpp.converter.json_repr(result)
72
72
        if "errors" in result:
73
73
            raise Exception('test_mc_vis made an error')
74
74
        if len(glob.glob('g4_*.wrl')) < 1: