14 <contact>Kilian Lieret, Kilian.Lieret@campus.lmu.de</contact>
16 This file contains example for generating validation plots using python
36 basf2.set_random_seed(1337)
38 tfile = TFile(
"examplePython.root",
"RECREATE")
39 tntuple = TNtuple(
"ntuple_test",
"ntuple test",
"x:y:z:k")
41 prefix =
"examplePython"
43 array_of_values = array.array(
"f", [23.4, 4.4, 5.12, -23.0])
44 tntuple.Fill(array_of_values)
48 r"This is a description test. "
49 r"Lorem ipsum sit dolor amet. We also support $\LaTeX$! "
50 "\n <br> \n For example, here is the infamous "
51 "Einstein-Pythagoras-theorem: \n "
52 r"$$a^2 + b^2 = \frac{E}{m}$$ "
53 "\n Of course, you can also "
54 r"do other things, like $\theta = 90^\circ$ or $D^- "
55 r"\rightarrow D^0 \pi^- \pi^+$. "
56 "\n Sometimes it is necessary to escape commands "
57 "with a double backslash, "
58 r"because e.g. \\theta will be interpreted as [tab]heta.",
60 tntuple.SetAlias(
"Check",
"This is the check text.")
61 tntuple.SetAlias(
"Contact",
"Name of the contact person.")
62 tntuple.SetAlias(
"MetaOptions",
"some_meta_options")
68 gausH = TH1F(
"gaus_histogram", prefix +
" Gaus Histogram", 100, -3, 3)
69 gausH.FillRandom(
"gaus", 5000)
71 gausH.GetListOfFunctions().Add(TNamed(
"Description",
"xlog"))
72 gausH.GetListOfFunctions().Add(TNamed(
"Check",
"Gaus Histogram Check"))
73 gausH.GetListOfFunctions().Add(TNamed(
"Contact",
"Gaus Histogram Contact"))
74 gausH.GetListOfFunctions().Add(TNamed(
"MetaOptions",
"logx, nostats"))
78 gausH = TH1F(
"exp_histogram", prefix +
" Exp Histogram", 100, 0, 10)
80 exp_fn = TF1(
"exp_fn",
"exp(-x)", 0, 10)
81 gausH.FillRandom(
"exp_fn", 5000)
83 gausH.GetListOfFunctions().Add(TNamed(
"Description",
"Expert Validation Plot"))
84 gausH.GetListOfFunctions().Add(TNamed(
"Check",
"Exp Histogram Check"))
85 gausH.GetListOfFunctions().Add(TNamed(
"Contact",
"Exp Histogram Contact"))
86 gausH.GetListOfFunctions().Add(TNamed(
"MetaOptions",
"logy, nostats, C"))
91 hist2d = TH2F(
"example_2d_histogram",
"example_2d_title", 60, -3, 3, 60, -3, 3)
94 cov = [[1, 0], [0, 1]]
95 for i
in range(10000):
96 x, y = np.random.multivariate_normal(mean, cov)
99 hist2d.GetListOfFunctions().Add(TNamed(
"Description",
"Some 2D Histogram"))
100 hist2d.GetListOfFunctions().Add(TNamed(
"Check",
"Check For Something"))
101 hist2d.GetListOfFunctions().Add(TNamed(
"Contact",
"Contact Someone"))
102 hist2d.GetListOfFunctions().Add(TNamed(
"MetaOptions",
"contz"))
107 gaus_passed = TH1F(
"gaus_passed",
"gaus_passed", 50, -0.5, 49.5)
108 gaus_total = TH1F(
"gaus_total",
"gaus_total", 50, -0.5, 49.5)
110 for i
in range(5000):
112 ratio = float(i) / 5000.0
113 passed = gRandom.Uniform(ratio * 0.45, 1.0)
114 pos = gRandom.Uniform(ratio * 30.0, 49.5)
118 gaus_passed.Fill(pos)
120 teff = TEfficiency(gaus_passed, gaus_total)
121 teff.SetName(
"TEfficiency")
122 teff.GetListOfFunctions().Add(
123 TNamed(
"Description",
"Efficiency plot of something")
125 teff.GetListOfFunctions().Add(TNamed(
"Check",
"Check For Something"))
126 teff.GetListOfFunctions().Add(TNamed(
"Contact",
"Contact Someone"))
127 teff.GetListOfFunctions().Add(TNamed(
"MetaOptions",
""))
132 graph_err = TGraphErrors()
137 ratio = float(i) / 50.0
138 passed = gRandom.Uniform(ratio * 0.45, 1.0)
141 graph_err.SetPoint(i, i + 1.0, passed)
143 graph_err.SetName(
"TGraphErrors")
144 graph_err.GetListOfFunctions().Add(
145 TNamed(
"Description",
"TGraphErrors plot of something")
147 graph_err.GetListOfFunctions().Add(TNamed(
"Check",
"Check For Something"))
148 graph_err.GetListOfFunctions().Add(TNamed(
"Contact",
"Contact Someone"))
149 graph_err.GetListOfFunctions().Add(TNamed(
"MetaOptions",
""))