Logo ROOT  
Reference Guide
rf103_interprfuncs.C File Reference

Detailed Description

View in nbviewer Open in SWAN Basic functionality: interpreted functions and p.d.f.s

␛[1mRooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby␛[0m
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
[#1] INFO:NumericIntegration -- RooRealIntegral::init(genpdf_Int[x]) using numeric integrator RooIntegrator1D to calculate Int(x)
[#1] INFO:NumericIntegration -- RooRealIntegral::init(genpdf_Int[x]) using numeric integrator RooIntegrator1D to calculate Int(x)
[#1] INFO:NumericIntegration -- RooRealIntegral::init(genpdf_Int[x]) using numeric integrator RooIntegrator1D to calculate Int(x)
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 alpha 5.00000e+00 9.90000e-01 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 500 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=35708.9 FROM MIGRAD STATUS=INITIATE 4 CALLS 5 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 alpha 5.00000e+00 9.90000e-01 2.01369e-01 1.02940e+02
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=35708.6 FROM MIGRAD STATUS=CONVERGED 12 CALLS 13 TOTAL
EDM=1.24247e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 alpha 4.96355e+00 4.16961e-02 1.10376e-03 -4.18389e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 1 ERR DEF=0.5
1.739e-03
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 500
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=35708.6 FROM HESSE STATUS=OK 5 CALLS 18 TOTAL
EDM=1.24183e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 alpha 4.96355e+00 4.16961e-02 2.20752e-04 -1.74664e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 1 ERR DEF=0.5
1.739e-03
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:NumericIntegration -- RooRealIntegral::init(genpdf_Int[x]) using numeric integrator RooIntegrator1D to calculate Int(x)
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 mean2 1.00000e+01 5.00000e+00 0.00000e+00 2.00000e+02
2 sigma 3.00000e+00 9.90000e-01 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=5148.93 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 mean2 1.00000e+01 5.00000e+00 1.18625e-01 -5.23438e+03
2 sigma 3.00000e+00 9.90000e-01 2.22742e-01 -7.90389e+03
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=2551.39 FROM MIGRAD STATUS=CONVERGED 59 CALLS 60 TOTAL
EDM=8.7852e-06 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 mean2 1.00100e+02 1.98019e+00 6.89576e-04 4.58015e-02
2 sigma 3.11719e+00 7.12427e-02 5.29831e-04 1.79331e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
3.922e+00 2.826e-03
2.826e-03 5.076e-03
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.02003 1.000 0.020
2 0.02003 0.020 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=2551.39 FROM HESSE STATUS=OK 10 CALLS 70 TOTAL
EDM=8.78617e-06 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 mean2 1.00100e+02 1.98016e+00 1.37915e-04 1.00004e-03
2 sigma 3.11719e+00 7.12418e-02 1.05966e-04 -4.01138e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
3.922e+00 2.730e-03
2.730e-03 5.076e-03
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.01935 1.000 0.019
2 0.01935 0.019 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
RooFitResult: minimized FCN value: 2551.39, estimated distance to minimum: 8.78617e-06
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
mean2 1.0010e+02 +/- 1.98e+00
sigma 3.1172e+00 +/- 7.12e-02
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "RooFitResult.h"
#include "RooGenericPdf.h"
#include "RooConstVar.h"
using namespace RooFit;
{
// ----------------------------------------------------
// G e n e r i c i n t e r p r e t e d p . d . f .
// ====================================================
// Declare observable x
RooRealVar x("x", "x", -20, 20);
// C o n s t r u c t g e n e r i c p d f f r o m i n t e r p r e t e d e x p r e s s i o n
// -------------------------------------------------------------------------------------------------
// To construct a proper p.d.f, the formula expression is explicitly normalized internally by dividing
// it by a numeric integral of the expression over x in the range [-20,20]
//
RooRealVar alpha("alpha", "alpha", 5, 0.1, 10);
RooGenericPdf genpdf("genpdf", "genpdf", "(1+0.1*abs(x)+sin(sqrt(abs(x*alpha+0.1))))", RooArgSet(x, alpha));
// S a m p l e , f i t a n d p l o t g e n e r i c p d f
// ---------------------------------------------------------------
// Generate a toy dataset from the interpreted p.d.f
RooDataSet *data = genpdf.generate(x, 10000);
// Fit the interpreted p.d.f to the generated data
genpdf.fitTo(*data);
// Make a plot of the data and the p.d.f overlaid
RooPlot *xframe = x.frame(Title("Interpreted expression pdf"));
data->plotOn(xframe);
genpdf.plotOn(xframe);
// -----------------------------------------------------------------------------------------------------------
// S t a n d a r d p . d . f a d j u s t w i t h i n t e r p r e t e d h e l p e r f u n c t i o n
// ==========================================================================================================
// Make a gauss(x,sqrt(mean2),sigma) from a standard RooGaussian
// C o n s t r u c t s t a n d a r d p d f w i t h f o r m u l a r e p l a c i n g p a r a m e t e r
// ------------------------------------------------------------------------------------------------------------
// Construct parameter mean2 and sigma
RooRealVar mean2("mean2", "mean^2", 10, 0, 200);
RooRealVar sigma("sigma", "sigma", 3, 0.1, 10);
// Construct interpreted function mean = sqrt(mean^2)
RooFormulaVar mean("mean", "mean", "sqrt(mean2)", mean2);
// Construct a gaussian g2(x,sqrt(mean2),sigma) ;
RooGaussian g2("g2", "h2", x, mean, sigma);
// G e n e r a t e t o y d a t a
// ---------------------------------
// Construct a separate gaussian g1(x,10,3) to generate a toy Gaussian dataset with mean 10 and width 3
RooGaussian g1("g1", "g1", x, RooConst(10), RooConst(3));
RooDataSet *data2 = g1.generate(x, 1000);
// F i t a n d p l o t t a i l o r e d s t a n d a r d p d f
// -------------------------------------------------------------------
// Fit g2 to data from g1
RooFitResult *r = g2.fitTo(*data2, Save());
r->Print();
// Plot data on frame and overlay projection of g2
RooPlot *xframe2 = x.frame(Title("Tailored Gaussian pdf"));
data2->plotOn(xframe2);
g2.plotOn(xframe2);
// Draw all frames on a canvas
TCanvas *c = new TCanvas("rf103_interprfuncs", "rf103_interprfuncs", 800, 400);
c->Divide(2);
c->cd(1);
gPad->SetLeftMargin(0.15);
xframe->GetYaxis()->SetTitleOffset(1.4);
xframe->Draw();
c->cd(2);
gPad->SetLeftMargin(0.15);
xframe2->GetYaxis()->SetTitleOffset(1.4);
xframe2->Draw();
}
ROOT::R::TRInterface & r
Definition: Object.C:4
#define c(i)
Definition: RSha256.hxx:101
#define gPad
Definition: TVirtualPad.h:286
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
Calls RooPlot* plotOn(RooPlot* frame, const RooLinkedList& cmdList) const ;.
Definition: RooAbsData.cxx:550
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:29
Plain Gaussian p.d.f.
Definition: RooGaussian.h:25
RooGenericPdf is a concrete implementation of a probability density function, which takes a RooArgLis...
Definition: RooGenericPdf.h:25
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1277
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:712
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:294
The Canvas class.
Definition: TCanvas.h:31
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition: TObject.cxx:550
const Double_t sigma
Double_t x[n]
Definition: legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
RooConstVar & RooConst(Double_t val)
RooCmdArg Save(Bool_t flag=kTRUE)
const char * Title
Definition: TXMLSetup.cxx:67
Author
07/2008 - Wouter Verkerke

Definition in file rf103_interprfuncs.C.