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