Exemplo n.º 1
0
    def test_write_zone(self):
        estimator = SHEstimator()
        estimator.estimator = SHGeoType.zone
        estimator.geometry = Zone()
        estimator.geometry.start = 1
        estimator.detector_type = SHDetType.dose
        estimator.particle_type = SHParticleType.all
        estimator.filename = "DH_dose"
        line1, = EstimatorWriter.get_lines(estimator)
        ref_line1 = "ZONE               1                            -1      DOSE   DH_dose"
        self.assertEqual(str(line1), ref_line1)

        estimator.geometry.stop = 300
        line1, = EstimatorWriter.get_lines(estimator)
        ref_line1 = "ZONE               1       300                  -1      DOSE   DH_dose"
        self.assertEqual(str(line1), ref_line1)

        estimator.particle_type = SHParticleType.heavy_ion
        estimator.heavy_ion_type.a = 12
        estimator.heavy_ion_type.z = 6
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line1 = "ZONE               1       300                  25      DOSE   DH_dose"
        ref_line2 = "                   6        12                                        "
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)
Exemplo n.º 2
0
    def test_write_zone(self):
        estimator = SHEstimator()
        estimator.estimator = SHGeoType.zone
        estimator.geometry = Zone()
        estimator.geometry.start = 1
        estimator.detector_type = SHDetType.dose
        estimator.particle_type = SHParticleType.all
        estimator.filename = "DH_dose"
        line1, = EstimatorWriter.get_lines(estimator)
        ref_line1 = "ZONE               1                            -1      DOSE   DH_dose"
        self.assertEqual(str(line1), ref_line1)

        estimator.geometry.stop = 300
        line1, = EstimatorWriter.get_lines(estimator)
        ref_line1 = "ZONE               1       300                  -1      DOSE   DH_dose"
        self.assertEqual(str(line1), ref_line1)

        estimator.particle_type = SHParticleType.heavy_ion
        estimator.heavy_ion_type.a = 12
        estimator.heavy_ion_type.z = 6
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line1 = "ZONE               1       300                  25      DOSE   DH_dose"
        ref_line2 = "                   6        12                                        "
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)
Exemplo n.º 3
0
    def test_write_geomap(self):
        estimator = SHEstimator()
        estimator.estimator = SHGeoType.geomap
        estimator.geometry = CarthesianMesh()
        estimator.geometry.axis[0].start = -1.0
        estimator.geometry.axis[1].start = -25.0
        estimator.geometry.axis[2].start = -15.0
        estimator.geometry.axis[0].stop = 1.0
        estimator.geometry.axis[1].stop = 25.0
        estimator.geometry.axis[2].stop = 35.0
        estimator.geometry.axis[0].nbins = 1
        estimator.geometry.axis[1].nbins = 50
        estimator.geometry.axis[2].nbins = 50
        estimator.detector_type = SHDetType.zone
        estimator.particle_type = SHParticleType.unknown
        estimator.filename = "ex_yzzon"
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line1 = "GEOMAP          -1.0     -25.0     -15.0       1.0      25.0      35.0"
        ref_line2 = "                   1        50        50         0      ZONE  ex_yzzon"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.detector_type = SHDetType.medium
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line2 = "                   1        50        50         0    MEDIUM  ex_yzzon"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.detector_type = SHDetType.rho
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line2 = "                   1        50        50         0       RHO  ex_yzzon"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)
Exemplo n.º 4
0
    def test_write_geomap(self):
        estimator = SHEstimator()
        estimator.estimator = SHGeoType.geomap
        estimator.geometry = CarthesianMesh()
        estimator.geometry.axis[0].start = -1.0
        estimator.geometry.axis[1].start = -25.0
        estimator.geometry.axis[2].start = -15.0
        estimator.geometry.axis[0].stop = 1.0
        estimator.geometry.axis[1].stop = 25.0
        estimator.geometry.axis[2].stop = 35.0
        estimator.geometry.axis[0].nbins = 1
        estimator.geometry.axis[1].nbins = 50
        estimator.geometry.axis[2].nbins = 50
        estimator.detector_type = SHDetType.zone
        estimator.particle_type = SHParticleType.unknown
        estimator.filename = "ex_yzzon"
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line1 = "GEOMAP          -1.0     -25.0     -15.0       1.0      25.0      35.0"
        ref_line2 = "                   1        50        50         0      ZONE  ex_yzzon"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.detector_type = SHDetType.medium
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line2 = "                   1        50        50         0    MEDIUM  ex_yzzon"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.detector_type = SHDetType.rho
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line2 = "                   1        50        50         0       RHO  ex_yzzon"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)
Exemplo n.º 5
0
    def test_write_cyl(self):
        estimator = SHEstimator()
        estimator.estimator = SHGeoType.cyl
        estimator.geometry = CylindricalMesh()
        estimator.geometry.axis[0].start = 0.0
        estimator.geometry.axis[1].start = 0.0
        estimator.geometry.axis[2].start = 0.0
        estimator.geometry.axis[0].stop = 10.0
        estimator.geometry.axis[1].stop = 7.0
        estimator.geometry.axis[2].stop = 30.0
        estimator.geometry.axis[0].nbins = 1
        estimator.geometry.axis[1].nbins = 1
        estimator.geometry.axis[2].nbins = 300
        estimator.detector_type = SHDetType.energy
        estimator.particle_type = SHParticleType.all
        estimator.filename = "ex_cyl"
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line1 = "CYL              0.0       0.0       0.0      10.0       7.0      30.0"
        ref_line2 = "                   1         1       300        -1    ENERGY    ex_cyl"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.detector_type = SHDetType.avg_beta
        estimator.particle_type = SHParticleType.proton
        ref_line2 = "                   1         1       300         2  AVG-BETA    ex_cyl"
        line1, line2 = EstimatorWriter.get_lines(estimator)
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.particle_type = SHParticleType.heavy_ion
        estimator.heavy_ion_type.a = 12
        estimator.heavy_ion_type.z = 6
        ref_line2 = "                   1         1       300        25  AVG-BETA    ex_cyl"
        ref_line3 = "                   6        12                                        "
        line1, line2, line3 = EstimatorWriter.get_lines(estimator)
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)
        self.assertEqual(str(line3), ref_line3)
Exemplo n.º 6
0
    def test_write_cyl(self):
        estimator = SHEstimator()
        estimator.estimator = SHGeoType.cyl
        estimator.geometry = CylindricalMesh()
        estimator.geometry.axis[0].start = 0.0
        estimator.geometry.axis[1].start = 0.0
        estimator.geometry.axis[2].start = 0.0
        estimator.geometry.axis[0].stop = 10.0
        estimator.geometry.axis[1].stop = 7.0
        estimator.geometry.axis[2].stop = 30.0
        estimator.geometry.axis[0].nbins = 1
        estimator.geometry.axis[1].nbins = 1
        estimator.geometry.axis[2].nbins = 300
        estimator.detector_type = SHDetType.energy
        estimator.particle_type = SHParticleType.all
        estimator.filename = "ex_cyl"
        line1, line2 = EstimatorWriter.get_lines(estimator)
        ref_line1 = "CYL              0.0       0.0       0.0      10.0       7.0      30.0"
        ref_line2 = "                   1         1       300        -1    ENERGY    ex_cyl"
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.detector_type = SHDetType.avg_beta
        estimator.particle_type = SHParticleType.proton
        ref_line2 = "                   1         1       300         2  AVG-BETA    ex_cyl"
        line1, line2 = EstimatorWriter.get_lines(estimator)
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)

        estimator.particle_type = SHParticleType.heavy_ion
        estimator.heavy_ion_type.a = 12
        estimator.heavy_ion_type.z = 6
        ref_line2 = "                   1         1       300        25  AVG-BETA    ex_cyl"
        ref_line3 = "                   6        12                                        "
        line1, line2, line3 = EstimatorWriter.get_lines(estimator)
        self.assertEqual(str(line1), ref_line1)
        self.assertEqual(str(line2), ref_line2)
        self.assertEqual(str(line3), ref_line3)
Exemplo n.º 7
0
 def test_write_plane_compact(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.plane
     estimator.geometry = Plane()
     estimator.geometry.set_point(x=0.0, y=0.0, z=0.0)
     estimator.geometry.set_normal(x=0.0, y=0.0, z=1.0)
     estimator.detector_type = SHDetType.counter
     estimator.particle_type = SHParticleType.proton
     estimator.filename = "NB_count2"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "PLANE            0.0       0.0       0.0       0.0       0.0       1.0"
     ref_line2 = "                                                 2   COUNTER NB_count2"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 8
0
 def test_write_plane_compact(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.plane
     estimator.geometry = Plane()
     estimator.geometry.set_point(x=0.0, y=0.0, z=0.0)
     estimator.geometry.set_normal(x=0.0, y=0.0, z=1.0)
     estimator.detector_type = SHDetType.counter
     estimator.particle_type = SHParticleType.proton
     estimator.filename = "NB_count2"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "PLANE            0.0       0.0       0.0       0.0       0.0       1.0"
     ref_line2 = "                                                 2   COUNTER NB_count2"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 9
0
 def test_write_cyl_compact(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.cyl
     estimator.geometry = CylindricalMesh()
     estimator.geometry.set_axis(axis_no=0, start=0.0, stop=10.0, nbins=1)
     estimator.geometry.set_axis(axis_no=1, start=0.0, stop=7.0, nbins=1)
     estimator.geometry.set_axis(axis_no=2, start=0.0, stop=30.0, nbins=300)
     estimator.detector_type = SHDetType.energy
     estimator.particle_type = SHParticleType.all
     estimator.filename = "ex_cyl"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "CYL              0.0       0.0       0.0      10.0       7.0      30.0"
     ref_line2 = "                   1         1       300        -1    ENERGY    ex_cyl"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 10
0
 def test_write_geomap_compact(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.geomap
     estimator.geometry = CarthesianMesh()
     estimator.geometry.set_axis(axis_no=0, start=-1.0, stop=1.0, nbins=1)
     estimator.geometry.set_axis(axis_no=1, start=-25.0, stop=25.0, nbins=50)
     estimator.geometry.set_axis(axis_no=2, start=-15.0, stop=35.0, nbins=50)
     estimator.detector_type = SHDetType.zone
     estimator.particle_type = SHParticleType.unknown
     estimator.filename = "ex_yzzon"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "GEOMAP          -1.0     -25.0     -15.0       1.0      25.0      35.0"
     ref_line2 = "                   1        50        50         0      ZONE  ex_yzzon"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 11
0
 def test_write_cyl_compact(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.cyl
     estimator.geometry = CylindricalMesh()
     estimator.geometry.set_axis(axis_no=0, start=0.0, stop=10.0, nbins=1)
     estimator.geometry.set_axis(axis_no=1, start=0.0, stop=7.0, nbins=1)
     estimator.geometry.set_axis(axis_no=2, start=0.0, stop=30.0, nbins=300)
     estimator.detector_type = SHDetType.energy
     estimator.particle_type = SHParticleType.all
     estimator.filename = "ex_cyl"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "CYL              0.0       0.0       0.0      10.0       7.0      30.0"
     ref_line2 = "                   1         1       300        -1    ENERGY    ex_cyl"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 12
0
 def test_write_plane(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.plane
     estimator.geometry = Plane()
     estimator.geometry.point_x = 0.0
     estimator.geometry.point_y = 0.0
     estimator.geometry.point_z = 0.0
     estimator.geometry.normal_x = 0.0
     estimator.geometry.normal_y = 0.0
     estimator.geometry.normal_z = 1.0
     estimator.detector_type = SHDetType.counter
     estimator.particle_type = SHParticleType.all
     estimator.filename = "NB_count1"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "PLANE            0.0       0.0       0.0       0.0       0.0       1.0"
     ref_line2 = "                                                -1   COUNTER NB_count1"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 13
0
 def test_write_plane(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.plane
     estimator.geometry = Plane()
     estimator.geometry.point_x = 0.0
     estimator.geometry.point_y = 0.0
     estimator.geometry.point_z = 0.0
     estimator.geometry.normal_x = 0.0
     estimator.geometry.normal_y = 0.0
     estimator.geometry.normal_z = 1.0
     estimator.detector_type = SHDetType.counter
     estimator.particle_type = SHParticleType.all
     estimator.filename = "NB_count1"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "PLANE            0.0       0.0       0.0       0.0       0.0       1.0"
     ref_line2 = "                                                -1   COUNTER NB_count1"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 14
0
 def test_write_msh(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.msh
     estimator.geometry = CarthesianMesh()
     estimator.geometry.axis[0].start = -5.0
     estimator.geometry.axis[1].start = -5.0
     estimator.geometry.axis[2].start = 0.0
     estimator.geometry.axis[0].stop = 5.0
     estimator.geometry.axis[1].stop = 5.0
     estimator.geometry.axis[2].stop = 30.0
     estimator.geometry.axis[0].nbins = 1
     estimator.geometry.axis[1].nbins = 1
     estimator.geometry.axis[2].nbins = 300
     estimator.detector_type = SHDetType.energy
     estimator.particle_type = SHParticleType.all
     estimator.filename = "ex_zmsh"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "MSH             -5.0      -5.0       0.0       5.0       5.0      30.0"
     ref_line2 = "                   1         1       300        -1    ENERGY   ex_zmsh"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 15
0
 def test_write_geomap_compact(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.geomap
     estimator.geometry = CarthesianMesh()
     estimator.geometry.set_axis(axis_no=0, start=-1.0, stop=1.0, nbins=1)
     estimator.geometry.set_axis(axis_no=1,
                                 start=-25.0,
                                 stop=25.0,
                                 nbins=50)
     estimator.geometry.set_axis(axis_no=2,
                                 start=-15.0,
                                 stop=35.0,
                                 nbins=50)
     estimator.detector_type = SHDetType.zone
     estimator.particle_type = SHParticleType.unknown
     estimator.filename = "ex_yzzon"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "GEOMAP          -1.0     -25.0     -15.0       1.0      25.0      35.0"
     ref_line2 = "                   1        50        50         0      ZONE  ex_yzzon"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)
Exemplo n.º 16
0
 def test_write_msh(self):
     estimator = SHEstimator()
     estimator.estimator = SHGeoType.msh
     estimator.geometry = CarthesianMesh()
     estimator.geometry.axis[0].start = -5.0
     estimator.geometry.axis[1].start = -5.0
     estimator.geometry.axis[2].start = 0.0
     estimator.geometry.axis[0].stop = 5.0
     estimator.geometry.axis[1].stop = 5.0
     estimator.geometry.axis[2].stop = 30.0
     estimator.geometry.axis[0].nbins = 1
     estimator.geometry.axis[1].nbins = 1
     estimator.geometry.axis[2].nbins = 300
     estimator.detector_type = SHDetType.energy
     estimator.particle_type = SHParticleType.all
     estimator.filename = "ex_zmsh"
     line1, line2 = EstimatorWriter.get_lines(estimator)
     ref_line1 = "MSH             -5.0      -5.0       0.0       5.0       5.0      30.0"
     ref_line2 = "                   1         1       300        -1    ENERGY   ex_zmsh"
     self.assertEqual(str(line1), ref_line1)
     self.assertEqual(str(line2), ref_line2)