14from quantity_extract
import RootQuantityExtract, default_extractor
20 Various test cases for the Quantity Extractor
class
25 Test getting the quantities of a TH1d
28 h1 = ROOT.TH1D("ext_test1",
"ext_test1", 40, 0, 40.0)
34 res = rext.extract(h1)
36 self.assertIn(
"mean_x", res)
37 self.assertAlmostEqual(res[
"mean_x"], 20)
38 self.assertIn(
"mean_y", res)
39 self.assertAlmostEqual(res[
"mean_y"], 0.075)
40 self.assertIn(
"mean_y_zero_suppressed", res)
41 self.assertAlmostEqual(res[
"mean_y_zero_suppressed"], 1.0)
42 self.assertIn(
"entries", res)
46 Test getting the quantities of a TProfile
49 h1 = ROOT.TProfile("ext_test1",
"ext_test1", 40, 0, 40.0)
55 res = rext.extract(h1)
57 self.assertIn(
"mean_y", res)
58 self.assertAlmostEqual(res[
"mean_y"], 0.375)
59 self.assertIn(
"mean_y_zero_suppressed", res)
60 self.assertAlmostEqual(res[
"mean_y_zero_suppressed"], 5.0)
64 Test getting the quantities contained in a TNtuple
67 tn = ROOT.TNtuple("particle_list",
"particle_list",
"x:y:z:energy")
71 res = rext.extract(tn)
72 self.assertEqual(len(res), 4)
73 self.assertIn(
"particle_list_z", res)
74 self.assertAlmostEqual(res[
"particle_list_z"], 7.0)
77if __name__ ==
"__main__":