Logo ROOT  
Reference Guide
rf504_simwstool.C File Reference

Detailed Description

View in nbviewer Open in SWAN Organisation and simultaneous fits: using RooSimWSTool to construct a simultaneous pdf that is built of variations of an input pdf

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
[#0] WARNING:InputArguments -- The parameter 's' with range [-10, 10] of the RooGaussian 'g' exceeds the safe range of (0, inf). Advise to limit its range.
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooGaussian::g
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::x
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::m
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::s
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::f
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooPolynomial::p
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::p0
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooCategory::c
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooCategory::d
Splitrule for p.d.f model with state list
parameter m is split with constraint in categories (c)
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: list of prototype pdfs (model)
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: list of splitting categories (c)
[#1] INFO:ObjectHandling -- RooSimPdfBuilder::executeBuild: processing prototype pdf model
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: configured customizers for all prototype pdfs
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: Customizing prototype pdf model for mode run1
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: Customizing prototype pdf model for mode run2
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooSimultaneous::model_sim
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model_run1
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooGaussian::g_run1
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::m_run1
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model_run2
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooGaussian::g_run2
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::m_run2
0x55a39442d200 RooSimultaneous::model_sim = 1 [Auto,Dirty]
0x55a394194fa0/V- RooAddPdf::model_run1 = 1 [Auto,Dirty]
0x55a394198ca0/V- RooGaussian::g_run1 = 1 [Auto,Dirty]
0x55a3942331f0/V- RooRealVar::m_run1 = 0
0x55a393e72720/V- RooRealVar::x = 0
0x55a3934b2f80/V- RooRealVar::s = 1
0x55a3934b36c0/V- RooRealVar::f = 0.5
0x55a3934b3e40/V- RooPolynomial::p = 1 [Auto,Dirty]
0x55a393e72720/V- RooRealVar::x = 0
0x55a393dbeb50/V- RooRealVar::p0 = 0.01
0x55a3942339a0/V- RooAddPdf::model_run2 = 1 [Auto,Dirty]
0x55a394235350/V- RooGaussian::g_run2 = 1 [Auto,Dirty]
0x55a3942364c0/V- RooRealVar::m_run2 = 0
0x55a393e72720/V- RooRealVar::x = 0
0x55a3934b2f80/V- RooRealVar::s = 1
0x55a3934b36c0/V- RooRealVar::f = 0.5
0x55a3934b3e40/V- RooPolynomial::p = 1 [Auto,Dirty]
0x55a393e72720/V- RooRealVar::x = 0
0x55a393dbeb50/V- RooRealVar::p0 = 0.01
0x55a393dade40/V- RooCategory::c = run2(idx = 1)
RooWorkspace(w) w contents
variables
---------
(c,d,f,m,m_run1,m_run2,p0,s,x)
p.d.f.s
-------
RooGaussian::g[ x=x mean=m sigma=s ] = 1
RooGaussian::g_run1[ x=x mean=m_run1 sigma=s ] = 0.011109
RooGaussian::g_run2[ x=x mean=m_run2 sigma=s ] = 0.011109
RooAddPdf::model[ f * g + [%] * p ] = 1
RooAddPdf::model_run1[ f * g_run1 + [%] * p ] = 0.505554
RooAddPdf::model_run2[ f * g_run2 + [%] * p ] = 0.505554
RooSimultaneous::model_sim[ indexCat=c run1=model_run1 run2=model_run2 ] = 0.505554
RooPolynomial::p[ x=x coefList=(p0) ] = 1
Splitrule for p.d.f model with state list
parameter p0 is split with constraint in categories (c,d)
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: list of prototype pdfs (model)
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: list of splitting categories (c,d)
[#1] INFO:ObjectHandling -- RooSimPdfBuilder::executeBuild: processing prototype pdf model
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooMultiCategory::c,d
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: configured customizers for all prototype pdfs
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: Customizing prototype pdf model for mode {run1;foo}
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: Customizing prototype pdf model for mode {run2;foo}
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: Customizing prototype pdf model for mode {run1;bar}
[#1] INFO:ObjectHandling -- RooSimWSTool::executeBuild: Customizing prototype pdf model for mode {run2;bar}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooSimultaneous::model_sim2
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooSuperCategory::model_sim2_index
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooMultiCategory::model_sim2_index_internalMultiCat
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model_{run1;foo}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooPolynomial::p_{run1;foo}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::p0_{run1;foo}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model_{run2;foo}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooPolynomial::p_{run2;foo}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::p0_{run2;foo}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model_{run1;bar}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooPolynomial::p_{run1;bar}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::p0_{run1;bar}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooAddPdf::model_{run2;bar}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooPolynomial::p_{run2;bar}
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing RooRealVar::p0_{run2;bar}
0x55a39418e510 RooSimultaneous::model_sim2 = 1 [Auto,Dirty]
0x55a39418fee0/V- RooSuperCategory::model_sim2_index = {run2;bar}(idx = 3)
[Auto,Clean]
0x55a3941429b0/VS RooMultiCategory::model_sim2_index_internalMultiCat = {run2;bar}(idx = 3)
[Auto,Clean]
0x55a393dade40/VS RooCategory::c = run2(idx = 1)
0x55a393c74120/VS RooCategory::d = bar(idx = 1)
0x55a3941915c0/V- RooAddPdf::model_{run1;foo} = 1 [Auto,Dirty]
0x55a3941855b0/V- RooPolynomial::p_{run1;foo} = 1 [Auto,Dirty]
0x55a394186660/V- RooRealVar::p0_{run1;foo} = 0.01
0x55a393e72720/V- RooRealVar::x = 0
0x55a393c72be0/V- RooGaussian::g = 1 [Auto,Dirty]
0x55a393e72720/V- RooRealVar::x = 0
0x55a393e72e60/V- RooRealVar::m = 0
0x55a3934b2f80/V- RooRealVar::s = 1
0x55a3934b36c0/V- RooRealVar::f = 0.5
0x55a394186ec0/V- RooAddPdf::model_{run2;foo} = 1 [Auto,Dirty]
0x55a394188990/V- RooPolynomial::p_{run2;foo} = 1 [Auto,Dirty]
0x55a394189a30/V- RooRealVar::p0_{run2;foo} = 0.01
0x55a393e72720/V- RooRealVar::x = 0
0x55a393c72be0/V- RooGaussian::g = 1 [Auto,Dirty]
0x55a393e72720/V- RooRealVar::x = 0
0x55a393e72e60/V- RooRealVar::m = 0
0x55a3934b2f80/V- RooRealVar::s = 1
0x55a3934b36c0/V- RooRealVar::f = 0.5
0x55a39418a290/V- RooAddPdf::model_{run1;bar} = 1 [Auto,Dirty]
0x55a394167b80/V- RooPolynomial::p_{run1;bar} = 1 [Auto,Dirty]
0x55a394168e40/V- RooRealVar::p0_{run1;bar} = 0.01
0x55a393e72720/V- RooRealVar::x = 0
0x55a393c72be0/V- RooGaussian::g = 1 [Auto,Dirty]
0x55a393e72720/V- RooRealVar::x = 0
0x55a393e72e60/V- RooRealVar::m = 0
0x55a3934b2f80/V- RooRealVar::s = 1
0x55a3934b36c0/V- RooRealVar::f = 0.5
0x55a3941695b0/V- RooAddPdf::model_{run2;bar} = 1 [Auto,Dirty]
0x55a39416b0c0/V- RooPolynomial::p_{run2;bar} = 1 [Auto,Dirty]
0x55a39416c1d0/V- RooRealVar::p0_{run2;bar} = 0.01
0x55a393e72720/V- RooRealVar::x = 0
0x55a393c72be0/V- RooGaussian::g = 1 [Auto,Dirty]
0x55a393e72720/V- RooRealVar::x = 0
0x55a393e72e60/V- RooRealVar::m = 0
0x55a3934b2f80/V- RooRealVar::s = 1
0x55a3934b36c0/V- RooRealVar::f = 0.5
#include "RooRealVar.h"
#include "RooCategory.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolynomial.h"
#include "RooAddPdf.h"
#include "RooWorkspace.h"
#include "RooSimWSTool.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TFile.h"
#include "TH1.h"
using namespace RooFit;
{
// C r e a t e m a s t e r p d f
// ---------------------------------
// Construct gauss(x,m,s)
RooRealVar x("x", "x", -10, 10);
RooRealVar m("m", "m", 0, -10, 10);
RooRealVar s("s", "s", 1, -10, 10);
RooGaussian gauss("g", "g", x, m, s);
// Construct poly(x,p0)
RooRealVar p0("p0", "p0", 0.01, 0., 1.);
RooPolynomial poly("p", "p", x, p0);
// Construct model = f*gauss(x) + (1-f)*poly(x)
RooRealVar f("f", "f", 0.5, 0., 1.);
RooAddPdf model("model", "model", RooArgSet(gauss, poly), f);
// C r e a t e c a t e g o r y o b s e r v a b l e s f o r s p l i t t i n g
// ----------------------------------------------------------------------------------
// Define two categories that can be used for splitting
RooCategory c("c", "c");
c.defineType("run1");
c.defineType("run2");
RooCategory d("d", "d");
d.defineType("foo");
d.defineType("bar");
// S e t u p S i m W S T o o l
// -----------------------------
// Import ingredients in a workspace
RooWorkspace w("w", "w");
// Make Sim builder tool
RooSimWSTool sct(w);
// B u i l d a s i m u l t a n e o u s m o d e l w i t h o n e s p l i t
// ---------------------------------------------------------------------------------
// Construct a simultaneous pdf with the following form
//
// model_run1(x) = f*gauss_run1(x,m_run1,s) + (1-f)*poly
// model_run2(x) = f*gauss_run2(x,m_run2,s) + (1-f)*poly
// simpdf(x,c) = model_run1(x) if c=="run1"
// = model_run2(x) if c=="run2"
//
// Returned pdf is owned by the workspace
RooSimultaneous *model_sim = sct.build("model_sim", "model", SplitParam("m", "c"));
// Print tree structure of model
model_sim->Print("t");
// Adjust model_sim parameters in workspace
w.var("m_run1")->setVal(-3);
w.var("m_run2")->setVal(+3);
// Print contents of workspace
w.Print("v");
// B u i l d a s i m u l t a n e o u s m o d e l w i t h p r o d u c t s p l i t
// -----------------------------------------------------------------------------------------
// Build another simultaneous pdf using a composite split in states c X d
RooSimultaneous *model_sim2 = sct.build("model_sim2", "model", SplitParam("p0", "c,d"));
// Print tree structure of this model
model_sim2->Print("t");
}
Date
July 2008
Author
Wouter Verkerke

Definition in file rf504_simwstool.C.

c
#define c(i)
Definition: RSha256.hxx:101
m
auto * m
Definition: textangle.C:8
RooWorkspace.h
RooRealVar::setVal
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:256
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
RooSimultaneous.h
RooAbsArg::Print
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:320
RooGaussian.h
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
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
TFile.h
RooPolynomial.h
RooWorkspace::import
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
Definition: RooWorkspace.cxx:361
TGeant4Unit::gauss
static constexpr double gauss
Definition: TGeant4SystemOfUnits.h:263
RooWorkspace::Print
void Print(Option_t *opts=0) const
Print contents of the workspace.
Definition: RooWorkspace.cxx:2194
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
RooPlot.h
rf504_simwstool
Definition: rf504_simwstool.py:1
RooCategory.h
RooRealVar.h
RooConstVar.h
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooCategory
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
TAxis.h
d
#define d(i)
Definition: RSha256.hxx:102
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
RooFit::SplitParam
RooCmdArg SplitParam(const char *varname, const char *catname)
Definition: RooGlobalFunc.cxx:326
RooSimWSTool
The RooSimWSTool is a tool operating on RooWorkspace objects that can clone PDFs into a series of var...
Definition: RooSimWSTool.h:37
RooSimWSTool.h
RooSimultaneous
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Definition: RooSimultaneous.h:37
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:37
TH1.h
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29