Example #1
0
    def test_add_hdict(self):
        ROOT.TH1F.AddDirectory(False)
        hd1 = {}
        hd1["ttH_hbb/cat1/hblr"] = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 3)], ["btag_LR_4b_2b_logit"])
        hd1["ttH_hbb/cat2/hblr"] = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 3, 4)], ["btag_LR_4b_2b_logit"])

        hd2 = {}
        hd2["ttH_hbb/cat1/hblr"] = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 3)], ["btag_LR_4b_2b_logit"])
        hd2["ttH_hbb/cat3/hblr"] = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 3, 4)], ["btag_LR_4b_2b_logit"])

        hd = sparse.add_hdict(hd1, hd2)
        
        self.assertEqual(
            hd["ttH_hbb/cat1/hblr"].Integral(),
            hd1["ttH_hbb/cat1/hblr"].Integral() + hd2["ttH_hbb/cat1/hblr"].Integral()
        )

        self.assertEqual(
            hd["ttH_hbb/cat2/hblr"].Integral(),
            hd1["ttH_hbb/cat2/hblr"].Integral()
        )

        self.assertEqual(
            hd["ttH_hbb/cat3/hblr"].Integral(),
            hd2["ttH_hbb/cat3/hblr"].Integral()
        )
Example #2
0
 def test_save_hdict_many(self):
     ROOT.TH1F.AddDirectory(False)
     h1 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 3)], ["btag_LR_4b_2b_logit"])
     hdict = OrderedDict()
     for i in range(1000):
         hdict["ttH_hbb/cat{0}/hblr".format(i)] = h1.Clone("h{0}".format(i))
     sparse.save_hdict("test.root", hdict)
Example #3
0
    def test_save_hdict(self):
        h1 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 3)], ["btag_LR_4b_2b_logit"])
        h2 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 3, 6)], ["btag_LR_4b_2b_logit"])
        hdict = OrderedDict()
        hdict["ttH_hbb/cat1/blr/hblr"] = h1.Clone("hblr")
        hdict["ttH_hbb/cat2/blr/hblr_asd"] = h2.Clone("hblr_asd")
        sparse.save_hdict("test.root", hdict)
        
        inf = rootpy.io.File("test.root")
        h1a = inf.Get("ttH_hbb/cat1/blr/hblr")
        self.assertIsNot(h1a, None)
        self.assertEqual(h1a.Integral(), h1.Integral())

        h2a = inf.Get("ttH_hbb/cat2/blr/hblr_asd")
        self.assertIsNot(h2a, None)
        self.assertEqual(h2a.Integral(), h2.Integral())
        inf.close()
Example #4
0
 def test_save_hdict_dupe(self):
     ROOT.TH1F.AddDirectory(False)
     h1 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 3)], ["Wmass"])
     h2 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 3, 6)], ["common_bdt"])
     hdict = OrderedDict()
     hdict["data/dl_jge4_tge4/Wmass"] = h1.Clone()
     hdict["data/dl_jge4_tge4/common_bdt"] = h2.Clone()
     sparse.save_hdict("test.root", hdict)
     
     inf = rootpy.io.File("test.root")
     h1a = inf.Get("data/dl_jge4_tge4/Wmass")
     self.assertIsNot(h1a, None)
     self.assertEqual(h1a.Integral(), h1.Integral())
     
     h2a = inf.Get("data/dl_jge4_tge4/common_bdt")
     self.assertIsNot(h2a, None)
     self.assertEqual(h2a.Integral(), h2.Integral())
     inf.close()
Example #5
0
 def test_apply_cuts_project_2d(self):
     h1 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 100)], ["btag_LR_4b_2b_logit", "common_bdt"])
     #self.assertIs(type(h1), rootpy.plotting.hist.Hist2D)
     self.assertAlmostEqual(h1.Integral(), 256605.17045173675)
     self.assertEqual(h1.GetName(), "numJets__4__6__nBCSVM__1__100__btag_LR_4b_2b_logit__common_bdt")
Example #6
0
 def test_apply_cuts_project_1d(self):
     h1 = sparse.apply_cuts_project(self.hsparse, [("numJets", 4, 6), ("nBCSVM", 1, 3)], ["btag_LR_4b_2b_logit"])
     #self.assertIsInstance(h1, rootpy.plotting.hist.Hist)
     self.assertAlmostEqual(h1.Integral(), 179578.0055940163)
     self.assertEqual(h1.GetName(), "numJets__4__6__nBCSVM__1__3__btag_LR_4b_2b_logit")