Example #1
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
Example #2
0
    stack = THStack("SNO+ spectral plot", "SNO+ spectral plot")
    legend = TLegend(0.0, 0.0, 1.0, 1.0)
    legend.SetFillColor(0)
    gStyle.SetOptStat("")

    roi = roi_utils.RoIUtils("reconstructed_energy")
    livetime = defaults.ll_analysis.get("livetime")
    print "spectral_plot.__main__: livetime =", livetime

    two_nu = Production\
        (os.environ.get("MAJORAT_DATA")+\
             "/hist_RAT4-5_prod_decay0_2beta_Te130_0_4_0-0_3-5.ntuple.root")
    total_events = 3.8e6
    hist_label = two_nu._label + "-reco_pos"
    two_nu.scale_by_events(total_events*livetime, hist_label)
    two_nu_hist = two_nu.get_histogram(hist_label)
    two_nu_hist.Draw()
    two_nu_hist.SetLineWidth(2)
    two_nu_hist.SetLineColor(2)
    stack.Add(two_nu_hist)
    legend.AddEntry(two_nu_hist, two_nu_hist.GetTitle(), "l")

    solar = Production\
        (os.environ.get("MAJORAT_DATA")+\
             "/hist_RAT4-5_prod_solar_B8.ntuple.root")
    hist_label = solar._label + "-reco_pos"
    events_in_roi = 4.04
    solar.scale_by_roi_events(events_in_roi*livetime, roi)
    solar_hist = solar.get_histogram()
    solar_hist.Draw()
    solar_hist.SetLineWidth(2)