Example #1
0
class TestProduction2Beta(test_spectrum_data.TestSpectrumData2Beta):
    def setUp(self):
        self._spectrum = Production(path)
        self._spectrum.set_parameters()
    def test_n_events(self):
        pass
    def test_label(self):
        self.assertEqual(self._spectrum._label, "0#nu#beta#beta")
    def tearDown(self):
        pass
Example #2
0
class TestProductionBackg(test_spectrum_data.TestSpectrumDataBackg):
    def setUp(self):
        path = "TeLoadedK42_r10_s0_p1.ntuple.root"
        self._spectrum = Production(path)
        self._spectrum.set_parameters()
    def test_n_events(self):
        pass
    def test_label(self):
        self.assertEqual(self._spectrum._label, "K42")
    def tearDown(self):
        pass
Example #3
0
class TestProduction(unittest.TestCase):
    def setUp(self):
        self._spectrum = Production(path)
        self._spectrum.set_parameters()
    def test_majorat_name(self):
        majorat_name = "RAT4-5_prod_decay0_2beta_Te130_0_1_0-0_3-5"
        self.assertEqual(self._spectrum._majorat_name, majorat_name)
    def test_extension(self):
        self.assertEqual(self._spectrum._ext, ".ntuple.root")
    def testMakeHistogram(self):
        hist_label = self._spectrum._label + "-Test"
        append = False
        always_remake = True
        self._spectrum.make_histogram(hist_label, append, always_remake)
        histogram = self._spectrum.get_histogram(hist_label)
        self.assertEqual(histogram.GetEntries(), 10001)
    def testAppend(self):
        hist_label = self._spectrum._label + "-Test"
        append = False
        always_remake = True
        hist_path = os.environ.get("MAJORAT_TEST")
        self._spectrum.make_histogram(hist_label, append, always_remake)
        self._spectrum.write_histograms(hist_path+"/")
        histogram = self._spectrum.get_histogram(hist_label)
        self.assertEqual(histogram.GetEntries(), 10001)
        append = True
        always_remake = False
        self._spectrum2 = Production(path2)
        self._spectrum2.set_parameters()
        bin_width = "default"
        self._spectrum2.make_histogram(hist_label, append, always_remake, 
                                       bin_width, hist_path+"/")
        histogram2 = self._spectrum2.get_histogram(hist_label)
        self.assertNotEqual(histogram.GetEntries(), histogram2.GetEntries())
        self.assertEqual(histogram2.GetEntries(), 20003)
    def tearDown(self):
        pass
    args = parser.parse_args()

    # make list of files
    file_list = []
    if args.is_directory:
        for root, dirs, files in os.walk(args.ntuple_path):
            for file in files:
                match = re.search(r".ntuple.root$", file)
                if match:
                    file_list.append(os.path.join(root, file))
    else:
        file_list.append(args.ntuple_path)
    first_file = True
    for file in file_list:
        spectrum = Production(file)
        spectrum.set_parameters()
        # make list of histogram labels
        hist_labels = [spectrum._label, 
                       spectrum._label+"-no_fv_cut"] # produced by default
        if args.reco_pos:
            hist_labels.append(spectrum._label+"-reco_pos")
        if args.nhit_energy:
            hist_labels.append(spectrum._label+"-nhit_energy")
            hist_labels.append(spectrum._label+"-reco_pos-nhit_energy")
        if args.zero_energy:
            zero_energy_labels = []
            for hist_label in hist_labels:
                hist_label += "-zero_energy"
                zero_energy_labels.append(hist_label)
            hist_labels += zero_energy_labels
        print hist_labels