'ORGANIZATION AND SIMULTANEOUS FITS' RooFit tutorial macro #503
Reading and using a workspace
The input file for self macro is generated by rf502_wspaceread.py
import ROOT
f = ROOT.TFile("rf502_workspace_py.root")
w = f.Get("w")
x = w["x"]
model = w["model"]
data = w["modelData"]
model.Print("t")
model.fitTo(data, PrintLevel=-1)
xframe = x.frame(Title="Model and data read from workspace")
data.plotOn(xframe)
model.plotOn(xframe)
model.plotOn(xframe, Components="bkg", LineStyle="--")
model.plotOn(xframe, Components="bkg,sig2", LineStyle=":")
c = ROOT.TCanvas("rf503_wspaceread", "rf503_wspaceread", 600, 600)
ROOT.gPad.SetLeftMargin(0.15)
xframe.GetYaxis().SetTitleOffset(1.4)
xframe.Draw()
c.SaveAs("rf503_wspaceread.png")
0x737ab30 RooAddPdf::model = 1/1 [Auto,Clean]
0x75f4860/V- RooChebychev::bkg = 1 [Auto,Dirty]
0x71dfa30/V- RooRealVar::x = 5
0x76c7c20/V- RooRealVar::a0 = 0.5
0x76c8420/V- RooRealVar::a1 = 0
0x76c8e70/V- RooRealVar::bkgfrac = 0.5
0x76bd490/V- RooAddPdf::sig = 1/1 [Auto,Clean]
0x7642950/V- RooGaussian::sig1 = 1 [Auto,Dirty]
0x71dfa30/V- RooRealVar::x = 5
0x7275df0/V- RooRealVar::mean = 5
0x76c6ee0/V- RooRealVar::sigma1 = 0.5
0x7136230/V- RooRealVar::sig1frac = 0.8
0x767b5b0/V- RooGaussian::sig2 = 1 [Auto,Dirty]
0x71dfa30/V- RooRealVar::x = 5
0x7275df0/V- RooRealVar::mean = 5
0x71e0be0/V- RooRealVar::sigma2 = 1
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Minimization -- The following expressions will be evaluated in cache-and-track mode: (bkg,sig1,sig2)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) directly selected PDF components: (bkg)
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) indirectly selected PDF components: ()
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) directly selected PDF components: (bkg,sig2)
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) indirectly selected PDF components: (sig)
- Date
- February 2018
- Authors
- Clemens Lange, Wouter Verkerke (C version)
Definition in file rf503_wspaceread.py.