15from __future__
import print_function
26x = ROOT.RooRealVar(
"x",
"x", -10, 10)
27y = ROOT.RooRealVar(
"y",
"y", 0, 40)
28c = ROOT.RooCategory(
"c",
"c")
29c.defineType(
"Plus", +1)
30c.defineType(
"Minus", -1)
37d = ROOT.RooDataSet(
"d",
"d", ROOT.RooArgSet(x, y, c))
46 y.setVal(math.sqrt(1.0 * i))
56 d.add(ROOT.RooArgSet(x, y, c))
78print(
"\n >> d1 has only columns x,c")
79d1 = d.reduce(ROOT.RooArgSet(x, c))
82print(
"\n >> d2 has only column y")
83d2 = d.reduce(ROOT.RooArgSet(y))
86print(
"\n >> d3 has only the points with y>5.17")
87d3 = d.reduce(
"y>5.17")
90print(
"\n >> d4 has only columns x, for data points with y>5.17")
91d4 = d.reduce(ROOT.RooArgSet(x, c),
"y>5.17")
95print(
"\n >> merge d2(y) with d1(x,c) to form d1(x,c,y)")
100print(
"\n >> append data points of d3 to d1")
110print(
">> construct dh (binned) from d(unbinned) but only take the x and y dimensions, ")
111print(
">> the category 'c' will be projected in the filling process")
119dh = ROOT.RooDataHist(
"dh",
"binned version of d", ROOT.RooArgSet(x, y), d)
122yframe = y.frame(ROOT.RooFit.Bins(10), ROOT.RooFit.Title(
123 "Operations on binned datasets"))
127print(
">> number of bins in dh : ", dh.numEntries())
128print(
">> sum of weights in dh : ", dh.sum(ROOT.kFALSE))
130print(
">> integral over histogram: ", dh.sum(ROOT.kTRUE))
135print(
">> retrieving the properties of the bin enclosing coordinate (x,y) = (0.3,20.5) bin center:")
137dh.get(ROOT.RooArgSet(x, y)).
Print(
"v")
138print(
" weight = ", dh.weight())
145print(
">> Creating 1-dimensional projection on y of dh for bins with x>0")
146dh2 = dh.reduce(ROOT.RooArgSet(y),
"x>0")
150dh2.plotOn(yframe, ROOT.RooFit.LineColor(ROOT.kRed),
151 ROOT.RooFit.MarkerColor(ROOT.kRed))
157print(
"\n >> Persisting d via ROOT I/O")
158f = ROOT.TFile(
"rf402_datahandling.root",
"RECREATE")
166c = ROOT.TCanvas(
"rf402_datahandling",
"rf402_datahandling", 600, 600)
167ROOT.gPad.SetLeftMargin(0.15)
168yframe.GetYaxis().SetTitleOffset(1.4)
171c.SaveAs(
"rf402_datahandling.png")
void Print(std::ostream &os, const OptionType &opt)