12from __future__
import print_function
23x = ROOT.RooRealVar(
"x",
"x", -10, 10)
24y = ROOT.RooRealVar(
"y",
"y", 0, 40)
25c = ROOT.RooCategory(
"c",
"c")
26c.defineType(
"Plus", +1)
27c.defineType(
"Minus", -1)
34d = ROOT.RooDataSet(
"d",
"d", ROOT.RooArgSet(x, y, c))
43 y.setVal(math.sqrt(1.0 * i))
54 d.add(ROOT.RooArgSet(x, y, c))
76print(
"\n >> d1 has only columns x,c")
77d1 = d.reduce(ROOT.RooArgSet(x, c))
80print(
"\n >> d2 has only column y")
81d2 = d.reduce(ROOT.RooArgSet(y))
84print(
"\n >> d3 has only the points with y>5.17")
85d3 = d.reduce(
"y>5.17")
88print(
"\n >> d4 has only columns x, for data points with y>5.17")
89d4 = d.reduce(ROOT.RooArgSet(x, c),
"y>5.17")
93print(
"\n >> merge d2(y) with d1(x,c) to form d1(x,c,y)")
98print(
"\n >> append data points of d3 to d1")
108print(
">> construct dh (binned) from d(unbinned) but only take the x and y dimensions, ")
109print(
">> the category 'c' will be projected in the filling process")
117dh = ROOT.RooDataHist(
"dh",
"binned version of d", ROOT.RooArgSet(x, y), d)
120yframe = y.frame(ROOT.RooFit.Bins(10), ROOT.RooFit.Title(
121 "Operations on binned datasets"))
125print(
">> number of bins in dh : ", dh.numEntries())
126print(
">> sum of weights in dh : ", dh.sum(ROOT.kFALSE))
128print(
">> integral over histogram: ", dh.sum(ROOT.kTRUE))
133print(
">> retrieving the properties of the bin enclosing coordinate (x,y) = (0.3,20.5) bin center:")
135dh.get(ROOT.RooArgSet(x, y)).
Print(
"v")
136print(
" weight = ", dh.weight())
143print(
">> Creating 1-dimensional projection on y of dh for bins with x>0")
144dh2 = dh.reduce(ROOT.RooArgSet(y),
"x>0")
148dh2.plotOn(yframe, ROOT.RooFit.LineColor(ROOT.kRed),
149 ROOT.RooFit.MarkerColor(ROOT.kRed))
155print(
"\n >> Persisting d via ROOT I/O")
156f = ROOT.TFile(
"rf402_datahandling.root",
"RECREATE")
164c = ROOT.TCanvas(
"rf402_datahandling",
"rf402_datahandling", 600, 600)
165ROOT.gPad.SetLeftMargin(0.15)
166yframe.GetYaxis().SetTitleOffset(1.4)
169c.SaveAs(
"rf402_datahandling.png")
void Print(std::ostream &os, const OptionType &opt)