Пример #1
0
    def setUp(self):
        unittest.TestCase.setUp(self)

        self.ops = Options("op1")
        self.ops.detectors['det1a'] = TimeDetector()
        self.ops.detectors['det2a'] = ElectronFractionDetector()
        self.ops.detectors['det3'] = ShowersStatisticsDetector()

        self.expander = OptionsExpanderSingleDetector([TimeDetector,
                                                       ElectronFractionDetector])
Пример #2
0
    def __init__(self,
                 elastic_scattering=(0.0, 0.0),
                 cutoff_energy_inelastic=50.0,
                 cutoff_energy_bremsstrahlung=50.0):
        """
        Converter from base options to PENSHOWER options.

        During the conversion, the materials are converted to :class:`PenelopeMaterial`.
        For this, the specified elastic scattering and cutoff energies are used
        as the default values in the conversion.
        """
        _Converter.__init__(self, elastic_scattering, cutoff_energy_inelastic,
                            cutoff_energy_bremsstrahlung)

        self._expander = OptionsExpanderSingleDetector([TrajectoryDetector])
Пример #3
0
    def __init__(self,
                 elastic_scattering=(0.0, 0.0),
                 cutoff_energy_inelastic=50.0,
                 cutoff_energy_bremsstrahlung=50.0):
        """
        Converter from base options to PENEPMA options.

        During the conversion, the materials are converted to :class:`PenelopeMaterial`.
        For this, the specified elastic scattering and cutoff energies are used
        as the default values in the conversion.
        """
        _Converter.__init__(self, elastic_scattering, cutoff_energy_inelastic,
                            cutoff_energy_bremsstrahlung)

        dets = [BackscatteredElectronEnergyDetector, PhotonDepthDetector]
        self._expander = OptionsExpanderSingleDetector(dets)
Пример #4
0
class TestOptionsExpanderSingleDetector(unittest.TestCase):

    def setUp(self):
        unittest.TestCase.setUp(self)

        self.ops = Options("op1")
        self.ops.detectors['det1a'] = TimeDetector()
        self.ops.detectors['det2a'] = ElectronFractionDetector()
        self.ops.detectors['det3'] = ShowersStatisticsDetector()

        self.expander = OptionsExpanderSingleDetector([TimeDetector,
                                                       ElectronFractionDetector])

    def tearDown(self):
        unittest.TestCase.tearDown(self)

    def testexpand_noduplicates(self):
        opss = self.expander.expand(self.ops)
        self.assertEqual(1, len(opss))
        self.assertEqual(3, len(opss[0].detectors))

    def testexpand_duplicates(self):
        self.ops.detectors['det1b'] = TimeDetector()
        opss = self.expander.expand(self.ops)

        self.assertEqual(2, len(opss))

        self.assertEqual("op1+0", opss[0].name)
        self.assertEqual(3, len(opss[0].detectors))
        if 'det1a' in opss[0].detectors:
            self.assertNotIn('det1b', opss[0].detectors)
        if 'det1b' in opss[0].detectors:
            self.assertNotIn('det1a', opss[0].detectors)

        self.assertEqual("op1+1", opss[1].name)
        self.assertEqual(3, len(opss[1].detectors))
        if 'det1a' in opss[1].detectors:
            self.assertNotIn('det1b', opss[1].detectors)
        if 'det1a' in opss[1].detectors:
            self.assertNotIn('det1b', opss[1].detectors)

    def testexpand_duplicates2(self):
        self.ops.detectors['det1b'] = TimeDetector()
        self.ops.detectors['det2b'] = ElectronFractionDetector()
        opss = self.expander.expand(self.ops)

        self.assertEqual(4, len(opss))

        self.assertEqual(3, len(opss[0].detectors))
        if 'det1a' in opss[0].detectors:
            self.assertNotIn('det1b', opss[0].detectors)
        if 'det1b' in opss[0].detectors:
            self.assertNotIn('det1a', opss[0].detectors)
        if 'det2a' in opss[0].detectors:
            self.assertNotIn('det2b', opss[0].detectors)
        if 'det2b' in opss[0].detectors:
            self.assertNotIn('det2a', opss[0].detectors)

        self.assertEqual(3, len(opss[1].detectors))
        if 'det1a' in opss[1].detectors:
            self.assertNotIn('det1b', opss[1].detectors)
        if 'det1b' in opss[1].detectors:
            self.assertNotIn('det1a', opss[1].detectors)
        if 'det2a' in opss[1].detectors:
            self.assertNotIn('det2b', opss[1].detectors)
        if 'det2b' in opss[1].detectors:
            self.assertNotIn('det2a', opss[1].detectors)

        self.assertEqual(3, len(opss[0].detectors))
        if 'det1a' in opss[2].detectors:
            self.assertNotIn('det1b', opss[2].detectors)
        if 'det1b' in opss[2].detectors:
            self.assertNotIn('det1a', opss[2].detectors)
        if 'det2a' in opss[2].detectors:
            self.assertNotIn('det2b', opss[2].detectors)
        if 'det2b' in opss[2].detectors:
            self.assertNotIn('det2a', opss[2].detectors)

        self.assertEqual(3, len(opss[0].detectors))
        if 'det1a' in opss[3].detectors:
            self.assertNotIn('det1b', opss[3].detectors)
        if 'det1b' in opss[3].detectors:
            self.assertNotIn('det1a', opss[3].detectors)
        if 'det2a' in opss[3].detectors:
            self.assertNotIn('det2b', opss[3].detectors)
        if 'det2b' in opss[3].detectors:
            self.assertNotIn('det2a', opss[3].detectors)

    def testis_expandable(self):
        self.assertFalse(self.expander.is_expandable(self.ops))

        self.ops.detectors['det1b'] = TimeDetector()
        self.assertTrue(self.expander.is_expandable(self.ops))

        self.ops.detectors['det2b'] = ElectronFractionDetector()
        self.assertTrue(self.expander.is_expandable(self.ops))