Belle II Software development
validationTestNTuple.py
1#!/usr/bin/env python3
2
3
10
11"""
12<header>
13<output>validationTestNTuple.root</output>
14<contact>Kilian Lieret, Kilian.Lieret@campus.lmu.de</contact>
15</header>
16"""
17
18
19import array
20import ROOT
21
22
23if __name__ == "__main__":
24 tfile = ROOT.TFile("validationTestNTuple.root", "RECREATE")
25
26 # Default precision
27 # =================
28
29 tntuple = ROOT.TNtuple("ntuple_test", "ntuple test", "x:y:z:k")
30
31 array_of_values = array.array("f", [23.4, 4.4, 5.12, -23.0, 12, 15, 16])
32 tntuple.Fill(array_of_values)
33
34 tntuple.SetAlias("Description", "Test default precision")
35 tntuple.SetAlias("Check", "Should display the default of 4 digits.")
36 tntuple.SetAlias("Contact", "Kilian Lieret, Kilian.Lieret@campus.lmu.de")
37 tntuple.SetAlias("MetaOptions", "shifter, some_meta_options")
38
39 tntuple.Write()
40
41 # Expert
42 # =================
43
44 tntuple = ROOT.TNtuple("ntuple_expert", "ntuple expert", "x:y:z:k")
45
46 array_of_values = array.array("f", [23.4, 4.4, 5.12, -23.0, 12, 15, 16])
47 tntuple.Fill(array_of_values)
48
49 tntuple.SetAlias("Description", "Test expert ntuple")
50 tntuple.SetAlias("Check", "Should be expert.")
51
52 tntuple.Write()
53
54 # High precision
55 # =================
56
57 tntuple_hp = ROOT.TNtuple("ntuple_test_hp", "ntuple test", "x:y:z:k")
58
59 array_of_values = array.array("f", [23.4, 4.4, 5.12, -23.0, 12, 15, 16])
60 tntuple_hp.Fill(array_of_values)
61
62 tntuple_hp.SetAlias("Description", "Test higher precision")
63 tntuple_hp.SetAlias("Check", "Should display 8 digits per float.")
64 tntuple_hp.SetAlias("Contact", "Kilian Lieret, Kilian.Lieret@campus.lmu.de")
65 tntuple_hp.SetAlias("MetaOptions", "float-precision=8")
66
67 tntuple_hp.Write()
68
69 # Long
70 # =================
71
72 variables = "l" + "o" * 200 + "ngvariable"
73 tntuple_hp = ROOT.TNtuple(
74 "ntuple_test_long_names", "ntuple test", variables
75 )
76
77 array_of_values = array.array("f", [23.4, 4.4, 5.12, -23.0, 12, 15, 16])
78 tntuple_hp.Fill(array_of_values)
79
80 tntuple_hp.SetAlias("Description", "Test loooooong ntuples")
81 tntuple_hp.SetAlias("Check", "Should display horizontal scrollbar.")
82 tntuple_hp.SetAlias("Contact", "Kilian Lieret, Kilian.Lieret@campus.lmu.de")
83
84 tntuple_hp.Write()
85
86 # Closing
87
88 tfile.Close()