13from __future__
import print_function
24x = ROOT.RooRealVar(
"x",
"x", -10, 10)
25y = ROOT.RooRealVar(
"y",
"y", 0, 40)
26c = ROOT.RooCategory(
"c",
"c")
27c.defineType(
"Plus", +1)
28c.defineType(
"Minus", -1)
35d = ROOT.RooDataSet(
"d",
"d", {x, y, c})
44 y.setVal(math.sqrt(1.0 * i))
77print(
"\n >> d1 has only columns x,c")
81print(
"\n >> d2 has only column y")
85print(
"\n >> d3 has only the points with y>5.17")
86d3 = d.reduce(
"y>5.17")
89print(
"\n >> d4 has only columns x, for data points with y>5.17")
90d4 = d.reduce({x, c},
"y>5.17")
94print(
"\n >> merge d2(y) with d1(x,c) to form d1(x,c,y)")
99print(
"\n >> append data points of d3 to d1")
109print(
">> construct dh (binned) from d(unbinned) but only take the x and y dimensions, ")
110print(
">> the category 'c' will be projected in the filling process")
118dh = ROOT.RooDataHist(
"dh",
"binned version of d", {x, y}, d)
121yframe = y.frame(Bins=10, Title=
"Operations on binned datasets")
125print(
">> number of bins in dh : ", dh.numEntries())
126print(
">> sum of weights in dh : ", dh.sum(
False))
128print(
">> integral over histogram: ", dh.sum(
True))
133print(
">> retrieving the properties of the bin enclosing coordinate (x,y) = (0.3,20.5) bin center:")
135dh.get({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({y},
"x>0")
148dh2.plotOn(yframe, LineColor=
"r", MarkerColor=
"r")
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")
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
void Print(GNN_Data &d, std::string txt="")