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