Logo ROOT  
Reference Guide
rf503_wspaceread.C File Reference

Detailed Description

View in nbviewer Open in SWAN

Organisation and simultaneous fits: reading and using a workspace

The input file for this macro is generated by rf502_wspacewrite.C

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
0x5593c72379b0 RooAddPdf::model = 0.9 [Auto,Dirty]
0x5593c77eff40/V- RooChebychev::bkg = 0.8 [Auto,Dirty]
0x5593c6035340/V- RooRealVar::x = 5
0x5593c79aaae0/V- RooRealVar::a0 = 0.5
0x5593c79ab3a0/V- RooRealVar::a1 = 0.2
0x5593c79ac0b0/V- RooRealVar::bkgfrac = 0.5
0x5593c799e760/V- RooAddPdf::sig = 1 [Auto,Dirty]
0x5593c78e7820/V- RooGaussian::sig1 = 1 [Auto,Dirty]
0x5593c6035340/V- RooRealVar::x = 5
0x5593c5b961e0/V- RooRealVar::mean = 5
0x5593c79a9a60/V- RooRealVar::sigma1 = 0.5
0x5593c799f450/V- RooRealVar::sig1frac = 0.8
0x5593c79561e0/V- RooGaussian::sig2 = 1 [Auto,Dirty]
0x5593c6035340/V- RooRealVar::x = 5
0x5593c5b961e0/V- RooRealVar::mean = 5
0x5593c5957cb0/V- RooRealVar::sigma2 = 1
[#1] INFO:Minization -- createNLL: caching constraint set under name CONSTR_OF_PDF_model_FOR_OBS_x with 0 entries
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
[#1] INFO:Minization -- The following expressions will be evaluated in cache-and-track mode: (bkg,sig1,sig2)
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 a0 5.00000e-01 1.00000e-01 0.00000e+00 1.00000e+00
2 a1 2.00000e-01 1.00000e-01 0.00000e+00 1.00000e+00
3 bkgfrac 5.00000e-01 1.00000e-01 0.00000e+00 1.00000e+00
4 mean 5.00000e+00 1.00000e+00 0.00000e+00 1.00000e+01
5 sig1frac 8.00000e-01 1.00000e-01 0.00000e+00 1.00000e+00
**********
** 3 **SET ERR 0.5
**********
**********
** 4 **SET PRINT 1
**********
**********
** 5 **SET STR 1
**********
NOW USING STRATEGY 1: TRY TO BALANCE SPEED AGAINST RELIABILITY
**********
** 6 **MIGRAD 2500 1
**********
FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.
START MIGRAD MINIMIZATION. STRATEGY 1. CONVERGENCE WHEN EDM .LT. 1.00e-03
FCN=1962.68 FROM MIGRAD STATUS=INITIATE 14 CALLS 15 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 a0 5.00000e-01 1.00000e-01 2.01358e-01 5.55984e+00
2 a1 2.00000e-01 1.00000e-01 2.57889e-01 -1.57464e+00
3 bkgfrac 5.00000e-01 1.00000e-01 2.01358e-01 1.16417e+00
4 mean 5.00000e+00 1.00000e+00 2.01358e-01 -6.91026e+01
5 sig1frac 8.00000e-01 1.00000e-01 2.57889e-01 -2.02114e+00
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=1962.14 FROM MIGRAD STATUS=CONVERGED 92 CALLS 93 TOTAL
EDM=0.000129539 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 a0 4.38576e-01 7.35996e-02 4.50487e-03 3.73392e-02
2 a1 2.02416e-01 1.18128e-01 5.73699e-03 4.39091e-02
3 bkgfrac 5.03388e-01 3.60691e-02 1.24369e-03 4.03363e-02
4 mean 5.01610e+00 3.15061e-02 1.91674e-04 7.40455e-01
5 sig1frac 8.35115e-01 1.17067e-01 5.93647e-03 2.37022e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 5 ERR DEF=0.5
5.457e-03 1.116e-03 -2.768e-04 -2.327e-04 -9.105e-04
1.116e-03 1.438e-02 -3.249e-03 5.690e-05 -9.716e-03
-2.768e-04 -3.249e-03 1.303e-03 -5.364e-05 3.285e-03
-2.327e-04 5.690e-05 -5.364e-05 9.926e-04 -1.964e-04
-9.105e-04 -9.716e-03 3.285e-03 -1.964e-04 1.419e-02
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3 4 5
1 0.16490 1.000 0.126 -0.104 -0.100 -0.103
2 0.77006 0.126 1.000 -0.751 0.015 -0.680
3 0.82650 -0.104 -0.751 1.000 -0.047 0.764
4 0.12324 -0.100 0.015 -0.047 1.000 -0.052
5 0.78139 -0.103 -0.680 0.764 -0.052 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 2500
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=1962.14 FROM HESSE STATUS=OK 31 CALLS 124 TOTAL
EDM=0.000129401 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 a0 4.38576e-01 7.35914e-02 9.00974e-04 -1.23159e-01
2 a1 2.02416e-01 1.17686e-01 1.14740e-03 -6.37473e-01
3 bkgfrac 5.03388e-01 3.59545e-02 2.48738e-04 6.77613e-03
4 mean 5.01610e+00 3.15052e-02 3.83348e-05 3.22075e-03
5 sig1frac 8.35115e-01 1.16789e-01 1.18729e-03 7.34520e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 5 ERR DEF=0.5
5.456e-03 1.105e-03 -2.735e-04 -2.327e-04 -9.006e-04
1.105e-03 1.427e-02 -3.217e-03 5.664e-05 -9.623e-03
-2.735e-04 -3.217e-03 1.295e-03 -5.354e-05 3.261e-03
-2.327e-04 5.664e-05 -5.354e-05 9.926e-04 -1.946e-04
-9.006e-04 -9.623e-03 3.261e-03 -1.946e-04 1.412e-02
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3 4 5
1 0.16425 1.000 0.125 -0.103 -0.100 -0.103
2 0.76801 0.125 1.000 -0.748 0.015 -0.678
3 0.82527 -0.103 -0.748 1.000 -0.047 0.763
4 0.12301 -0.100 0.015 -0.047 1.000 -0.052
5 0.78016 -0.103 -0.678 0.763 -0.052 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: 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)
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooChebychev.h"
#include "RooAddPdf.h"
#include "RooWorkspace.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TFile.h"
#include "TH1.h"
using namespace RooFit;
void rf503_wspaceread()
{
// R e a d w o r k s p a c e f r o m f i l e
// -----------------------------------------------
// Open input file with workspace (generated by rf14_wspacewrite)
TFile *f = new TFile("rf502_workspace.root");
// Retrieve workspace from file
RooWorkspace *w = (RooWorkspace *)f->Get("w");
// R e t r i e v e p d f , d a t a f r o m w o r k s p a c e
// -----------------------------------------------------------------
// Retrieve x,model and data from workspace
RooRealVar *x = w->var("x");
RooAbsPdf *model = w->pdf("model");
RooAbsData *data = w->data("modelData");
// Print structure of composite p.d.f.
model->Print("t");
// F i t m o d e l t o d a t a , p l o t m o d e l
// ---------------------------------------------------------
// Fit model to data
model->fitTo(*data);
// Plot data and PDF overlaid
RooPlot *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(kDashed));
// Overlay the background+sig2 components of model with a dotted line
model->plotOn(xframe, Components("bkg,sig2"), LineStyle(kDotted));
// Draw the frame on the canvas
new TCanvas("rf503_wspaceread", "rf503_wspaceread", 600, 600);
gPad->SetLeftMargin(0.15);
xframe->GetYaxis()->SetTitleOffset(1.4);
xframe->Draw();
}
Date
07/2008
Author
Wouter Verkerke

Definition in file rf503_wspaceread.C.

RooWorkspace::data
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1368
RooWorkspace.h
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
RooChebychev.h
f
#define f(i)
Definition: RSha256.hxx:122
RooAbsData
Definition: RooAbsData.h:46
RooGaussian.h
x
Double_t x[n]
Definition: legend1.C:17
RooAddPdf.h
TCanvas.h
RooDataSet.h
TFile.h
RooFit
Definition: RooCFunction1Binding.h:29
RooAbsData::plotOn
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Definition: RooAbsData.cxx:547
RooPlot.h
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1256
RooPlot
Definition: RooPlot.h:44
RooWorkspace::pdf
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1277
RooRealVar.h
TFile
Definition: TFile.h:54
RooConstVar.h
RooWorkspace
Definition: RooWorkspace.h:43
TCanvas
Definition: TCanvas.h:23
TAxis.h
kDashed
@ kDashed
Definition: TAttLine.h:48
gPad
#define gPad
Definition: TVirtualPad.h:287
RooWorkspace::var
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1295
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooAbsPdf
Definition: RooAbsPdf.h:40
RooFit::LineStyle
RooCmdArg LineStyle(Style_t style)
Definition: RooGlobalFunc.cxx:57
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
RooRealVar
Definition: RooRealVar.h:35
RooFit::Components
RooCmdArg Components(const RooArgSet &compSet)
Definition: RooGlobalFunc.cxx:74
TH1.h
RooFit::Title
RooCmdArg Title(const char *name)
Definition: RooGlobalFunc.cxx:173
kDotted
@ kDotted
Definition: TAttLine.h:48