Exemple #1
0
    def test_simulate_detector_mips_no_interaction(self, mock_expovariate):
        p = np.array([10e6])
        theta = np.array([0.])

        # force no interaction
        mock_expovariate.side_effect = [1e6, 1e3]
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)

        # no interaction because after projected depth
        mock_expovariate.side_effect = [4, 5]
        theta = np.array([1])
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)

        # interactions are to late because of max depth
        mock_expovariate.side_effect = [120, 125]
        theta = np.array([1.555])  # projected depth would be 126 cm
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)

        # no interaction with multiple inclined gammas each with to long
        # interaction depth.
        # test mostly to prevent accidental growing of depth in loop
        n = 30
        mock_expovariate.side_effect = [4, 5] * n
        p = np.array([10e6] * n)
        theta = np.array([1.] * n)  # projected depth would be 126 cm
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)
Exemple #2
0
    def test_simulate_detector_mips_no_interaction(self, mock_expovariate):
        p = np.array([10e6])
        theta = np.array([0.])

        # force no interaction
        mock_expovariate.side_effect = [1e6, 1e3]
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)

        # no interaction because after projected depth
        mock_expovariate.side_effect = [4, 5]
        theta = np.array([1])
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)

        # interactions are to late because of max depth
        mock_expovariate.side_effect = [120, 125]
        theta = np.array([1.555])  # projected depth would be 126 cm
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)

        # no interaction with multiple inclined gammas each with to long
        # interaction depth.
        # test mostly to prevent accidental growing of depth in loop
        n = 30
        mock_expovariate.side_effect = [4, 5] * n
        p = np.array([10e6] * n)
        theta = np.array([1.] * n)  # projected depth would be 126 cm
        self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)
Exemple #3
0
    def test_simulate_detector_mips_gammas_pair(self, mock_l_compton, mock_l_pair, mock_compton):
        # Force pair production
        mock_l_compton.return_value = 1e50
        mock_l_pair.return_value = 1e-3

        mock_compton.return_value = 42.
        energies = np.array([10., 7.])  # MeV
        p = energies * 1e6  # eV
        theta = np.array([0.])

        for _ in range(100):
            mips = gammas.simulate_detector_mips_gammas(p, theta)
            self.assertFalse(mock_compton.called)
            self.assertLessEqual(mips, gammas.MAX_E)

        # not enough energy for pair production
        energies = np.array([0.5, 0.7])  # MeV
        p = energies * 1e6  # eV
        theta = np.array([0., 0.])
        for _ in range(100):
            self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)
Exemple #4
0
    def test_simulate_detector_mips_gammas_compton(self, mock_l_compton, mock_l_pair, mock_compton):
        # Force compton scattering
        mock_l_compton.return_value = 1e-3
        mock_l_pair.return_value = 1e50

        mock_compton.return_value = 1.
        p = np.array([10])
        theta = np.array([0.])

        mips = gammas.simulate_detector_mips_gammas(p, theta)
        mock_compton.assert_called_once_with(10. / 1e6)
        self.assertLessEqual(mips, gammas.MAX_E)
Exemple #5
0
    def test_simulate_detector_mips_gammas_pair(self, mock_l_compton, mock_l_pair, mock_compton):
        # Force pair production
        mock_l_compton.return_value = 1e50
        mock_l_pair.return_value = 1e-3

        mock_compton.return_value = 42.
        energies = np.array([10., 7.])  # MeV
        p = energies * 1e6  # eV
        theta = np.array([0.])

        for _ in range(100):
            mips = gammas.simulate_detector_mips_gammas(p, theta)
            self.assertFalse(mock_compton.called)
            self.assertLessEqual(mips, gammas.MAX_E)

        # not enough energy for pair production
        energies = np.array([0.5, 0.7])  # MeV
        p = energies * 1e6  # eV
        theta = np.array([0., 0.])
        for _ in range(100):
            self.assertEqual(gammas.simulate_detector_mips_gammas(p, theta), 0)
Exemple #6
0
    def test_simulate_detector_mips_gammas_compton(self, mock_l_compton, mock_l_pair, mock_compton):
        # Force compton scattering
        mock_l_compton.return_value = 1e-3
        mock_l_pair.return_value = 1e50

        mock_compton.return_value = 1.
        p = np.array([10])
        theta = np.array([0.])

        mips = gammas.simulate_detector_mips_gammas(p, theta)
        mock_compton.assert_called_once_with(10. / 1e6)
        self.assertLessEqual(mips, gammas.MAX_E)