Logo ROOT  
Reference Guide
rs602_HLFactoryCombinationexample.C File Reference

Detailed Description

High Level Factory: creation of a combined model.

View in nbviewer Open in SWAN

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:ObjectHandling -- RooWorkspace::exportToCint(HLFavtoryCombinationexample_ws) INFO: references to all objects in this workspace will be created in CINT in 'namespace HLFavtoryCombinationexample_ws'
[#1] INFO:Minization -- p.d.f. provides expected number of events, including extended term in likelihood.
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
RooAbsTestStatistic::initSimMode: creating slave calculator #0 for state model1 (211 dataset entries)
RooAbsTestStatistic::initSimMode: creating slave calculator #1 for state model2 (175 dataset entries)
[#1] INFO:Fitting -- RooAbsTestStatistic::initSimMode: created 2 slave calculators.
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (flat1)
[#1] INFO:Minization -- The following expressions will be evaluated in cache-and-track mode: (gauss1)
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (flat2)
[#1] INFO:Minization -- The following expressions will be evaluated in cache-and-track mode: (gauss2)
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 mean1 5.00000e+01 1.00000e+01 0.00000e+00 1.00000e+02
2 mean2 8.00000e+01 1.00000e+01 0.00000e+00 1.00000e+02
3 nbkg1 1.00000e+02 5.00000e+01 0.00000e+00 1.00000e+03
4 nbkg2 8.00000e+01 4.00000e+01 0.00000e+00 1.00000e+03
5 nsig1 1.20000e+02 3.00000e+01 0.00000e+00 3.00000e+02
6 nsig2 9.00000e+01 4.00000e+01 0.00000e+00 4.00000e+02
**********
** 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 3000 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=199.77 FROM MIGRAD STATUS=INITIATE 24 CALLS 25 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 mean1 5.00000e+01 1.00000e+01 2.01358e-01 3.07908e+01
2 mean2 8.00000e+01 1.00000e+01 2.57889e-01 9.66677e+00
3 nbkg1 1.00000e+02 5.00000e+01 1.72186e-01 2.07463e+01
4 nbkg2 8.00000e+01 4.00000e+01 1.52384e-01 -8.44368e+00
5 nsig1 1.20000e+02 3.00000e+01 2.05758e-01 2.55303e+00
6 nsig2 9.00000e+01 4.00000e+01 2.45245e-01 -4.65857e+00
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=199.349 FROM MIGRAD STATUS=CONVERGED 92 CALLS 93 TOTAL
EDM=6.01075e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 mean1 4.98783e+01 4.26590e-01 8.34391e-05 -6.57258e-01
2 mean2 7.98952e+01 6.49972e-01 1.58369e-04 -2.57944e-01
3 nbkg1 9.18179e+01 1.06581e+01 3.55527e-04 5.08825e-02
4 nbkg2 8.25577e+01 1.03903e+01 3.59387e-04 -2.86339e-02
5 nsig1 1.19174e+02 1.18598e+01 7.72527e-04 -2.99954e-02
6 nsig2 9.24320e+01 1.08502e+01 6.13208e-04 -3.16233e-03
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 6 ERR DEF=0.5
1.820e-01 0.000e+00 9.170e-02 0.000e+00 -9.167e-02 0.000e+00
0.000e+00 4.225e-01 0.000e+00 -1.575e-02 0.000e+00 1.575e-02
9.170e-02 0.000e+00 1.136e+02 0.000e+00 -2.180e+01 0.000e+00
0.000e+00 -1.575e-02 0.000e+00 1.080e+02 0.000e+00 -2.545e+01
-9.167e-02 0.000e+00 -2.180e+01 0.000e+00 1.410e+02 0.000e+00
0.000e+00 1.575e-02 0.000e+00 -2.545e+01 0.000e+00 1.179e+02
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3 4 5 6
1 0.02504 1.000 0.000 0.020 0.000 -0.018 0.000
2 0.00292 0.000 1.000 0.000 -0.002 0.000 0.002
3 0.17311 0.020 0.000 1.000 0.000 -0.172 0.000
4 0.22552 0.000 -0.002 0.000 1.000 0.000 -0.226
5 0.17289 -0.018 0.000 -0.172 0.000 1.000 0.000
6 0.22552 0.000 0.002 0.000 -0.226 0.000 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 3000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=199.349 FROM HESSE STATUS=OK 40 CALLS 133 TOTAL
EDM=6.01118e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 mean1 4.98783e+01 4.26588e-01 1.66878e-05 -2.43458e-03
2 mean2 7.98952e+01 6.49972e-01 3.16737e-05 6.40885e-01
3 nbkg1 9.18179e+01 1.06583e+01 7.11055e-05 -9.55088e-01
4 nbkg2 8.25577e+01 1.03906e+01 7.18775e-05 -9.87923e-01
5 nsig1 1.19174e+02 1.18599e+01 1.54505e-04 -2.06982e-01
6 nsig2 9.24320e+01 1.08505e+01 1.22642e-04 -5.67873e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 6 ERR DEF=0.5
1.820e-01 0.000e+00 9.119e-02 0.000e+00 -9.117e-02 0.000e+00
0.000e+00 4.225e-01 0.000e+00 -1.684e-02 0.000e+00 1.684e-02
9.119e-02 0.000e+00 1.137e+02 0.000e+00 -2.182e+01 0.000e+00
0.000e+00 -1.684e-02 0.000e+00 1.080e+02 0.000e+00 -2.546e+01
-9.117e-02 0.000e+00 -2.182e+01 0.000e+00 1.410e+02 0.000e+00
0.000e+00 1.684e-02 0.000e+00 -2.546e+01 0.000e+00 1.179e+02
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3 4 5 6
1 0.02490 1.000 0.000 0.020 0.000 -0.018 0.000
2 0.00312 0.000 1.000 0.000 -0.002 0.000 0.002
3 0.17319 0.020 0.000 1.000 0.000 -0.172 0.000
4 0.22564 0.000 -0.002 0.000 1.000 0.000 -0.226
5 0.17297 -0.018 0.000 -0.172 0.000 1.000 0.000
6 0.22564 0.000 0.002 0.000 -0.226 0.000 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooSimultaneous::plotOn(HLFavtoryCombinationexample_sigbkg) plot on x represents a slice in the index category (HLFavtoryCombinationexample_category)
[#1] INFO:Plotting -- RooAbsReal::plotOn(sb_model1) slice variable HLFavtoryCombinationexample_category was not projected anyway
[#1] INFO:Plotting -- RooSimultaneous::plotOn(HLFavtoryCombinationexample_sigbkg) plot on x represents a slice in the index category (HLFavtoryCombinationexample_category)
[#1] INFO:Plotting -- RooAbsReal::plotOn(sb_model2) slice variable HLFavtoryCombinationexample_category was not projected anyway
#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 rs602_HLFactoryCombinationexample()
{
using namespace RooStats;
using namespace RooFit;
// create a card
TString card_name("HLFavtoryCombinationexample.rs");
ofstream ofile(card_name);
ofile << "// The simplest card for combination\n\n"
<< "gauss1 = Gaussian(x[0,100],mean1[50,0,100],4);\n"
<< "flat1 = Polynomial(x,0);\n"
<< "sb_model1 = SUM(nsig1[120,0,300]*gauss1 , nbkg1[100,0,1000]*flat1);\n"
<< "gauss2 = Gaussian(x,mean2[80,0,100],5);\n"
<< "flat2 = Polynomial(x,0);\n"
<< "sb_model2 = SUM(nsig2[90,0,400]*gauss2 , nbkg2[80,0,1000]*flat2);\n";
ofile.close();
HLFactory hlf("HLFavtoryCombinationexample", card_name, false);
hlf.AddChannel("model1", "sb_model1", "flat1");
hlf.AddChannel("model2", "sb_model2", "flat2");
auto pdf = hlf.GetTotSigBkgPdf();
auto thecat = hlf.GetTotCategory();
auto x = static_cast<RooRealVar *>(hlf.GetWs()->arg("x"));
auto data = pdf->generate(RooArgSet(*x, *thecat), Extended());
// --- Perform extended ML fit of composite PDF to toy data ---
pdf->fitTo(*data);
// --- Plot toy data and composite PDF overlaid ---
auto xframe = x->frame();
data->plotOn(xframe);
thecat->setIndex(0);
pdf->plotOn(xframe, Slice(*thecat), ProjWData(*thecat, *data));
thecat->setIndex(1);
pdf->plotOn(xframe, Slice(*thecat), ProjWData(*thecat, *data));
gROOT->SetStyle("Plain");
xframe->Draw();
}
Author
Danilo Piparo

Definition in file rs602_HLFactoryCombinationexample.C.

HLFactory.h
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
RooFit::ProjWData
RooCmdArg ProjWData(const RooAbsData &projData, Bool_t binData=kFALSE)
Definition: RooGlobalFunc.cxx:46
x
Double_t x[n]
Definition: legend1.C:17
RooStats::HLFactory
Definition: HLFactory.h:42
TString
Definition: TString.h:136
RooDataSet.h
TString.h
RooFit::Slice
RooCmdArg Slice(const RooArgSet &sliceSet)
Definition: RooGlobalFunc.cxx:39
TROOT.h
RooFit
Definition: RooCFunction1Binding.h:29
RooAbsPdf.h
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
RooRealVar.h
RooGlobalFunc.h
RooStats
Definition: Asimov.h:19
RooRealVar
Definition: RooRealVar.h:36
RooArgSet
Definition: RooArgSet.h:28
gROOT
#define gROOT
Definition: TROOT.h:406
RooFit::Extended
RooCmdArg Extended(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:155