Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
rf503_wspaceread.py File Reference

Detailed Description

View in nbviewer Open in SWAN

'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
# Read workspace from file
# -----------------------------------------------
# Open input file with workspace (generated by rf503_wspacewrite)
f = ROOT.TFile("rf502_workspace_py.root")
# Retrieve workspace from file
w = f.Get("w")
# Retrieve pdf, data from workspace
# -----------------------------------------------------------------
# Retrieve x, and data from workspace
x = w["x"]
model = w["model"]
data = w["modelData"]
# Print structure of composite p.d.f.
# Fit model to data, plot model
# ---------------------------------------------------------
# Fit model to data
model.fitTo(data, PrintLevel=-1)
# Plot data and PDF overlaid
xframe = x.frame(Title="Model and data read from workspace")
data.plotOn(xframe)
model.plotOn(xframe)
# Overlay the background component of model with a dashed line
model.plotOn(xframe, Components="bkg", LineStyle="--")
# Overlay the background+sig2 components of model with a dotted line
model.plotOn(xframe, Components="bkg,sig2", LineStyle=":")
# Draw the frame on the canvas
c = ROOT.TCanvas("rf503_wspaceread", "rf503_wspaceread", 600, 600)
xframe.GetYaxis().SetTitleOffset(1.4)
c.SaveAs("rf503_wspaceread.png")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
0x56085820fc90 RooAddPdf::model = 1/1 [Auto,Clean]
0x560858337370/V- RooChebychev::bkg = 1 [Auto,Dirty]
0x560858063220/V- RooRealVar::x = 5
0x560854ca4df0/V- RooRealVar::a0 = 0.5
0x56085285e4a0/V- RooRealVar::a1 = 0
0x5608583e13b0/V- RooRealVar::bkgfrac = 0.5
0x5608583d65e0/V- RooAddPdf::sig = 1/1 [Auto,Clean]
0x560858362050/V- RooGaussian::sig1 = 1 [Auto,Dirty]
0x560858063220/V- RooRealVar::x = 5
0x560858013fb0/V- RooRealVar::mean = 5
0x560856426820/V- RooRealVar::sigma1 = 0.5
0x56085132fa90/V- RooRealVar::sig1frac = 0.8
0x560858374780/V- RooGaussian::sig2 = 1 [Auto,Dirty]
0x560858063220/V- RooRealVar::x = 5
0x560858013fb0/V- RooRealVar::mean = 5
0x560857e66480/V- RooRealVar::sigma2 = 1
[#1] INFO:Fitting -- RooAbsPdf::fitTo(model) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- using CPU computation library compiled with -mavx512
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_model_modelData) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#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.