Logo ROOT   6.16/01
Reference Guide
rs601_HLFactoryexample.C File Reference

Detailed Description

View in nbviewer Open in SWAN 'High Level Factory Example' RooStats tutorial macro #601

This tutorial shows an example of creating a simple model using the High Level model Factory.

␛[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:ObjectHandling -- RooWorkspace::exportToCint(HLFavtoryexample_ws) INFO: references to all objects in this workspace will be created in CINT in 'namespace HLFavtoryexample_ws'
[#1] INFO:Minization -- p.d.f. provides expected number of events, including extended term in likelihood.
[#1] INFO:Minization -- createNLL: caching constraint set under name CONSTR_OF_PDF_sum_FOR_OBS_mes 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: (gauss,argus)
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 argpar -2.00000e+01 9.50000e+00 -1.00000e+02 -1.00000e+00
2 mean 5.28000e+00 1.00000e-02 5.20000e+00 5.30000e+00
3 nbkg 8.00000e+02 4.00000e+02 0.00000e+00 1.00000e+04
4 nsig 2.00000e+02 1.00000e+02 0.00000e+00 1.00000e+04
5 width 2.70000e-03 8.50000e-04 1.00000e-03 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=-17788.8 FROM MIGRAD STATUS=INITIATE 20 CALLS 21 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 argpar -2.00000e+01 9.50000e+00 2.51381e-01 1.48295e+01
2 mean 5.28000e+00 1.00000e-02 2.57889e-01 1.26241e+02
3 nbkg 8.00000e+02 4.00000e+02 1.52384e-01 -2.75719e+03
4 nsig 2.00000e+02 1.00000e+02 7.39156e-02 -1.30866e+03
5 width 2.70000e-03 8.50000e-04 2.13708e-02 -5.96944e+02
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-18178.2 FROM MIGRAD STATUS=CONVERGED 127 CALLS 128 TOTAL
EDM=8.23524e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 argpar -2.28748e+01 3.42311e+00 6.81552e-03 -1.05902e-04
2 mean 5.27987e+00 2.15784e-04 4.99568e-04 1.14694e-01
3 nbkg 1.61271e+03 4.46744e+01 1.05575e-03 -2.82924e-02
4 nsig 3.87281e+02 2.77659e+01 1.13759e-03 3.18941e-02
5 width 3.01017e-03 1.99068e-04 3.69588e-04 2.63544e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 5 ERR DEF=0.5
1.174e+01 -9.561e-06 -4.054e+01 4.054e+01 2.300e-04
-9.561e-06 4.656e-08 3.241e-04 -3.248e-04 -2.699e-09
-4.054e+01 3.241e-04 1.996e+03 -3.831e+02 -2.181e-03
4.054e+01 -3.248e-04 -3.831e+02 7.710e+02 2.184e-03
2.300e-04 -2.699e-09 -2.181e-03 2.184e-03 3.963e-08
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3 4 5
1 0.47848 1.000 -0.013 -0.265 0.426 0.337
2 0.07490 -0.013 1.000 0.034 -0.054 -0.063
3 0.35856 -0.265 0.034 1.000 -0.309 -0.245
4 0.52842 0.426 -0.054 -0.309 1.000 0.395
5 0.45058 0.337 -0.063 -0.245 0.395 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 2500
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-18178.2 FROM HESSE STATUS=OK 31 CALLS 159 TOTAL
EDM=8.27129e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 argpar -2.28748e+01 3.42862e+00 2.72621e-04 5.92076e-01
2 mean 5.27987e+00 2.15791e-04 9.99136e-05 6.40145e-01
3 nbkg 1.61271e+03 4.47114e+01 4.22301e-05 -7.44300e-01
4 nsig 3.87281e+02 2.78173e+01 2.27518e-04 -1.17462e+00
5 width 3.01017e-03 1.99415e-04 1.47835e-05 -1.48105e+00
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 5 ERR DEF=0.5
1.178e+01 -9.115e-06 -4.092e+01 4.092e+01 2.327e-04
-9.115e-06 4.657e-08 3.206e-04 -3.207e-04 -2.752e-09
-4.092e+01 3.206e-04 1.999e+03 -3.865e+02 -2.207e-03
4.092e+01 -3.207e-04 -3.865e+02 7.739e+02 2.207e-03
2.327e-04 -2.752e-09 -2.207e-03 2.207e-03 3.977e-08
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3 4 5
1 0.48108 1.000 -0.012 -0.267 0.429 0.340
2 0.07539 -0.012 1.000 0.033 -0.053 -0.064
3 0.36057 -0.267 0.033 1.000 -0.311 -0.248
4 0.53093 0.429 -0.053 -0.311 1.000 0.398
5 0.45364 0.340 -0.064 -0.248 0.398 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooAbsPdf::plotOn(sum) directly selected PDF components: (argus)
[#1] INFO:Plotting -- RooAbsPdf::plotOn(sum) indirectly selected PDF components: ()
#include <fstream>
#include "TString.h"
#include "TROOT.h"
#include "RooGlobalFunc.h"
#include "RooWorkspace.h"
#include "RooRealVar.h"
#include "RooAbsPdf.h"
#include "RooDataSet.h"
#include "RooPlot.h"
// use this order for safety on library loading
using namespace RooFit;
using namespace RooStats;
using namespace std;
void rs601_HLFactoryexample() {
// --- Build the datacard and dump to file---
TString card_name("HLFavtoryexample.rs");
ofstream ofile(card_name);
ofile << "// The simplest card\n\n"
<< "gauss = Gaussian(mes[5.20,5.30],mean[5.28,5.2,5.3],width[0.0027,0.001,1]);\n"
<< "argus = ArgusBG(mes,5.291,argpar[-20,-100,-1]);\n"
<< "sum = SUM(nsig[200,0,10000]*gauss,nbkg[800,0,10000]*argus);\n\n";
ofile.close();
HLFactory hlf("HLFavtoryexample",
card_name,
false);
// --- Take elements out of the internal workspace ---
RooWorkspace* w = hlf.GetWs();
RooRealVar* mes = dynamic_cast<RooRealVar*>(w->arg("mes"));
RooAbsPdf* sum = dynamic_cast<RooAbsPdf*>(w->pdf("sum"));
RooAbsPdf* argus = dynamic_cast<RooAbsPdf*>(w->pdf("argus"));
// RooRealVar* mean = dynamic_cast<RooRealVar*>(w->arg("mean"));
// RooRealVar* argpar = dynamic_cast<RooRealVar*>(w->arg("argpar"));
// --- Generate a toyMC sample from composite PDF ---
RooDataSet *data = sum->generate(*mes,2000) ;
// --- Perform extended ML fit of composite PDF to toy data ---
sum->fitTo(*data) ;
// --- Plot toy data and composite PDF overlaid ---
RooPlot* mesframe = mes->frame() ;
data->plotOn(mesframe) ;
sum->plotOn(mesframe) ;
sum->plotOn(mesframe,Components(*argus),LineStyle(kDashed)) ;
gROOT->SetStyle("Plain");
mesframe->Draw() ;
}
@ kDashed
Definition: TAttLine.h:48
#define gROOT
Definition: TROOT.h:410
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
RooPlot * frame(const RooCmdArg &arg1, 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
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:41
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:558
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooAbsArg * arg(const char *name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Basic string class.
Definition: TString.h:131
RooCmdArg Components(const RooArgSet &compSet)
RooCmdArg LineStyle(Style_t style)
@(#)root/roostats:$Id$ Author: George Lewis, Kyle Cranmer
Definition: Asimov.h:20
STL namespace.
static long int sum(long int i)
Definition: Factory.cxx:2258
Author
Danilo Piparo

Definition in file rs601_HLFactoryexample.C.