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))
53 d.add(ROOT.RooArgSet(x, y, c))
75print(
"\n >> d1 has only columns x,c")
76d1 = d.reduce(ROOT.RooArgSet(x, c))
79print(
"\n >> d2 has only column y")
80d2 = d.reduce(ROOT.RooArgSet(y))
83print(
"\n >> d3 has only the points with y>5.17")
84d3 = d.reduce(
"y>5.17")
87print(
"\n >> d4 has only columns x, for data points with y>5.17")
88d4 = d.reduce(ROOT.RooArgSet(x, c),
"y>5.17")
92print(
"\n >> merge d2(y) with d1(x,c) to form d1(x,c,y)")
97print(
"\n >> append data points of d3 to d1")
107print(
">> construct dh (binned) from d(unbinned) but only take the x and y dimensions, ")
108print(
">> the category 'c' will be projected in the filling process")
116dh = ROOT.RooDataHist(
"dh",
"binned version of d", ROOT.RooArgSet(x, y), d)
119yframe = y.frame(ROOT.RooFit.Bins(10), ROOT.RooFit.Title(
120 "Operations on binned datasets"))
124print(
">> number of bins in dh : ", dh.numEntries())
125print(
">> sum of weights in dh : ", dh.sum(ROOT.kFALSE))
127print(
">> integral over histogram: ", dh.sum(ROOT.kTRUE))
132print(
">> retrieving the properties of the bin enclosing coordinate (x,y) = (0.3,20.5) bin center:")
134dh.get(ROOT.RooArgSet(x, y)).
Print(
"v")
135print(
" weight = ", dh.weight())
142print(
">> Creating 1-dimensional projection on y of dh for bins with x>0")
143dh2 = dh.reduce(ROOT.RooArgSet(y),
"x>0")
147dh2.plotOn(yframe, ROOT.RooFit.LineColor(ROOT.kRed),
148 ROOT.RooFit.MarkerColor(ROOT.kRed))
154print(
"\n >> Persisting d via ROOT I/O")
155f = ROOT.TFile(
"rf402_datahandling.root",
"RECREATE")
163c = ROOT.TCanvas(
"rf402_datahandling",
"rf402_datahandling", 600, 600)
164ROOT.gPad.SetLeftMargin(0.15)
165yframe.GetYaxis().SetTitleOffset(1.4)
168c.SaveAs(
"rf402_datahandling.png")
void Print(std::ostream &os, const OptionType &opt)