from __future__ import print_function
import ROOT
x = ROOT.RooRealVar("x", "x", -10, 10)
m = ROOT.RooRealVar("m", "m", 0, -10, 10)
s = ROOT.RooRealVar("s", "s", 1, -10, 10)
gauss = ROOT.RooGaussian("g", "g", x, m, s)
p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0.0, 1.0)
poly = ROOT.RooPolynomial("p", "p", x, [p0])
f = ROOT.RooRealVar("f", "f", 0.5, 0.0, 1.0)
model = ROOT.RooAddPdf("model", "model", [gauss, poly], [f])
d = model.generate({x}, 1000)
model.fitTo(d)
params = model.getParameters({x})
params.writeToFile("rf505_asciicfg_example.txt")
params.readFromFile("rf505_asciicfg_example.txt")
params.Print("v")
configFile = ROOT.gROOT.GetTutorialDir().Data() + "/roofit/rf505_asciicfg.txt"
params.readFromFile(configFile, "", "Section2")
params.Print("v")
params.readFromFile(configFile, "READ", "Section3")
print("The following parameters of the were _not_ read from Section3: ", params.selectByAttrib("READ", False))
params.readFromFile(configFile, "", "Section4")
params.Print("v")