Logo ROOT  
Reference Guide
rf203_ranges.C File Reference

Detailed Description

View in nbviewer Open in SWAN Fitting and plotting in sub ranges.

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
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (px)
[#1] INFO:Minization -- The following expressions will be evaluated in cache-and-track mode: (gx)
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 f 5.00000e-01 1.00000e-01 0.00000e+00 1.00000e+00
2 mx 0.00000e+00 2.00000e+00 -1.00000e+01 1.00000e+01
**********
** 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 1000 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=25940.4 FROM MIGRAD STATUS=INITIATE 8 CALLS 9 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 f 5.00000e-01 1.00000e-01 2.01358e-01 -5.48446e+01
2 mx 0.00000e+00 2.00000e+00 2.01358e-01 6.82864e+02
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=25939.4 FROM MIGRAD STATUS=CONVERGED 23 CALLS 24 TOTAL
EDM=7.58337e-06 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 f 5.04406e-01 6.32281e-03 1.40982e-03 6.67377e-02
2 mx -2.16053e-02 1.77430e-02 1.97826e-04 -1.47892e+00
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
3.998e-05 3.708e-07
3.708e-07 3.148e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.00331 1.000 0.003
2 0.00331 0.003 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=25939.4 FROM HESSE STATUS=OK 10 CALLS 34 TOTAL
EDM=7.58116e-06 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 f 5.04406e-01 6.32281e-03 2.81963e-04 8.81295e-03
2 mx -2.16053e-02 1.77430e-02 3.95651e-05 -2.16053e-03
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
3.998e-05 4.063e-07
4.063e-07 3.148e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.00362 1.000 0.004
2 0.00362 0.004 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'signal' created with bounds [-3,3]
[#1] INFO:Fitting -- RooAbsOptTestStatistic::ctor(nll_model_modelData) constructing test statistic for sub-range named signal
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'NormalizationRangeForsignal' created with bounds [-10,10]
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'fit_nll_model_modelData' created with bounds [-3,3]
[#1] INFO:Fitting -- RooAbsOptTestStatistic::ctor(nll_model_modelData) fixing interpretation of coefficients of any RooAddPdf to full domain of observables
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (px)
[#1] INFO:Minization -- The following expressions will be evaluated in cache-and-track mode: (gx)
**********
** 10 **SET PRINT 1
**********
**********
** 11 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 f 5.04406e-01 6.32281e-03 0.00000e+00 1.00000e+00
2 mx -2.16053e-02 1.77430e-02 -1.00000e+01 1.00000e+01
**********
** 12 **SET ERR 0.5
**********
**********
** 13 **SET PRINT 1
**********
**********
** 14 **SET STR 1
**********
NOW USING STRATEGY 1: TRY TO BALANCE SPEED AGAINST RELIABILITY
**********
** 15 **MIGRAD 1000 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=10339.9 FROM MIGRAD STATUS=INITIATE 6 CALLS 7 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 f 5.04406e-01 6.32281e-03 1.26465e-02 2.65620e+01
2 mx -2.16053e-02 1.77430e-02 1.77431e-03 -2.76970e+00
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=10339.5 FROM MIGRAD STATUS=CONVERGED 28 CALLS 29 TOTAL
EDM=3.38795e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 f 4.90142e-01 1.61947e-02 2.27369e-03 1.69088e-02
2 mx -2.17006e-02 1.79160e-02 1.25822e-04 1.06356e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
2.624e-04 3.238e-06
3.238e-06 3.210e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.01116 1.000 0.011
2 0.01116 0.011 1.000
**********
** 16 **SET ERR 0.5
**********
**********
** 17 **SET PRINT 1
**********
**********
** 18 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=10339.5 FROM HESSE STATUS=OK 10 CALLS 39 TOTAL
EDM=3.38988e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 f 4.90142e-01 1.61948e-02 9.09474e-05 -1.97171e-02
2 mx -2.17006e-02 1.79161e-02 2.51643e-05 -2.17006e-03
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
2.624e-04 3.402e-06
3.402e-06 3.210e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.01172 1.000 0.012
2 0.01172 0.012 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) p.d.f was fitted in a subrange and no explicit NormRange() was specified. Plotting / normalising in fit range. To override, do one of the following
- Clear the automatic fit range attribute: <pdf>.setStringAttribute("fitrange", nullptr);
- Explicitly specify the plotting range: Range("<rangeName>").
- Explicitly specify where to compute the normalisation: NormRange("<rangeName>").
The default (full) range can be denoted with Range("") / NormRange("").
[#0] ERROR:Plotting -- Range 'Full' not defined for variable 'x'. Ignoring ...
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) only plotting range 'Full'
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) p.d.f. curve is normalized using explicit choice of ranges 'fit_nll_model_modelData'
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) p.d.f was fitted in a subrange and no explicit Range() and NormRange() was specified. Plotting / normalising in fit range. To override, do one of the following
- Clear the automatic fit range attribute: <pdf>.setStringAttribute("fitrange", nullptr);
- Explicitly specify the plotting range: Range("<rangeName>").
- Explicitly specify where to compute the normalisation: NormRange("<rangeName>").
The default (full) range can be denoted with Range("") / NormRange("").
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) only plotting range 'fit_nll_model_modelData'
[#1] INFO:Plotting -- RooAbsPdf::plotOn(model) p.d.f. curve is normalized using explicit choice of ranges 'fit_nll_model_modelData'
result of fit on all data
RooFitResult: minimized FCN value: 25939.4, estimated distance to minimum: 7.58116e-06
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
f 5.0441e-01 +/- 6.32e-03
mx -2.1605e-02 +/- 1.77e-02
result of fit in in signal region (note increased error on signal fraction)
RooFitResult: minimized FCN value: 10339.5, estimated distance to minimum: 3.38988e-07
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
f 4.9014e-01 +/- 1.62e-02
mx -2.1701e-02 +/- 1.79e-02
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolynomial.h"
#include "RooAddPdf.h"
#include "RooFitResult.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TH1.h"
using namespace RooFit;
{
// S e t u p m o d e l
// ---------------------
// Construct observables x
RooRealVar x("x", "x", -10, 10);
// Construct gaussx(x,mx,1)
RooRealVar mx("mx", "mx", 0, -10, 10);
RooGaussian gx("gx", "gx", x, mx, RooConst(1));
// Construct px = 1 (flat in x)
RooPolynomial px("px", "px", x);
// Construct model = f*gx + (1-f)px
RooRealVar f("f", "f", 0., 1.);
RooAddPdf model("model", "model", RooArgList(gx, px), f);
// Generated 10000 events in (x,y) from pdf model
RooDataSet *modelData = model.generate(x, 10000);
// F i t f u l l r a n g e
// ---------------------------
// Fit pdf to all data
RooFitResult *r_full = model.fitTo(*modelData, Save(kTRUE));
// F i t p a r t i a l r a n g e
// ----------------------------------
// Define "signal" range in x as [-3,3]
x.setRange("signal", -3, 3);
// Fit pdf only to data in "signal" range
RooFitResult *r_sig = model.fitTo(*modelData, Save(kTRUE), Range("signal"));
// P l o t / p r i n t r e s u l t s
// ---------------------------------------
// Make plot frame in x and add data and fitted model
RooPlot *frame = x.frame(Title("Fitting a sub range"));
modelData->plotOn(frame);
model.plotOn(frame, Range("Full"), LineStyle(kDashed), LineColor(kRed)); // Add shape in full ranged dashed
model.plotOn(frame); // By default only fitted range is shown
// Print fit results
cout << "result of fit on all data " << endl;
r_full->Print();
cout << "result of fit in in signal region (note increased error on signal fraction)" << endl;
r_sig->Print();
// Draw frame on canvas
new TCanvas("rf203_ranges", "rf203_ranges", 600, 600);
gPad->SetLeftMargin(0.15);
frame->GetYaxis()->SetTitleOffset(1.4);
frame->Draw();
return;
}
Date
July 2008
Author
Wouter Verkerke

Definition in file rf203_ranges.C.

RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAddPdf
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:32
f
#define f(i)
Definition: RSha256.hxx:104
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooGaussian.h
rf203_ranges
Definition: rf203_ranges.py:1
x
Double_t x[n]
Definition: legend1.C:17
RooGaussian
Plain Gaussian p.d.f.
Definition: RooGaussian.h:24
RooAddPdf.h
TCanvas.h
RooDataSet.h
RooFitResult
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
RooPolynomial.h
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: RooCFunction1Binding.h:29
RooPolynomial
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
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:1258
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooRealVar.h
kRed
@ kRed
Definition: Rtypes.h:66
RooFitResult.h
RooConstVar.h
RooFit::LineColor
RooCmdArg LineColor(Color_t color)
Definition: RooGlobalFunc.cxx:57
TCanvas
The Canvas class.
Definition: TCanvas.h:23
TAxis.h
RooFit::Range
RooCmdArg Range(const char *rangeName, Bool_t adjustNorm=kTRUE)
Definition: RooGlobalFunc.cxx:53
RooFitResult::Print
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooFitResult.h:66
kDashed
@ kDashed
Definition: TAttLine.h:48
gPad
#define gPad
Definition: TVirtualPad.h:287
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooFit::LineStyle
RooCmdArg LineStyle(Style_t style)
Definition: RooGlobalFunc.cxx:58
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:37
RooFit::Save
RooCmdArg Save(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:190
TH1.h
RooFit::Title
RooCmdArg Title(const char *name)
Definition: RooGlobalFunc.cxx:176
RooFit::RooConst
RooConstVar & RooConst(Double_t val)
Definition: RooGlobalFunc.cxx:347