27ROOT.RooClassFactory.makePdf(
"MyPdfV1",
"x,A,B")
36ROOT.RooClassFactory.makePdf(
"MyPdfV2",
"x,A,B",
"",
"A*fabs(x)+pow(x-B,2)")
46ROOT.RooClassFactory.makePdf(
50 "A*fabs(x)+pow(x-B,2)",
53 "x:(A/2)*(pow(x.max(rangeName),2)+pow(x.min(rangeName),2))+(1./3)*(pow(x.max(rangeName)-B,3)-pow(x.min(rangeName)-B,3))",
60ROOT.gROOT.ProcessLineSync(
".x MyPdfV3.cxx+")
63a = ROOT.RooRealVar(
"a",
"a", 1)
64b = ROOT.RooRealVar(
"b",
"b", 2, -10, 10)
65y = ROOT.RooRealVar(
"y",
"y", -10, 10)
66pdf = ROOT.MyPdfV3(
"pdf",
"pdf", y, a, b)
69frame1 = y.frame(Title=
"Compiled class MyPdfV3")
70data = pdf.generate({y}, 1000)
71pdf.fitTo(data, PrintLevel=-1)
80x = ROOT.RooRealVar(
"x",
"x", -20, 20)
86alpha = ROOT.RooRealVar(
"alpha",
"alpha", 5, 0.1, 10)
87genpdf = ROOT.RooClassFactory.makePdfInstance(
"GenPdf",
"(1+0.1*fabs(x)+sin(sqrt(fabs(x*alpha+0.1))))", [x, alpha])
90data2 = genpdf.generate({x}, 50000)
93genpdf.fitTo(data2, PrintLevel=-1)
96frame2 = x.frame(Title=
"Compiled version of pdf of rf103")
101c = ROOT.TCanvas(
"rf104_classfactory",
"rf104_classfactory", 800, 400)
104ROOT.gPad.SetLeftMargin(0.15)
105frame1.GetYaxis().SetTitleOffset(1.4)
108ROOT.gPad.SetLeftMargin(0.15)
109frame2.GetYaxis().SetTitleOffset(1.4)
112c.SaveAs(
"rf104_classfactory.png")