Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rf804_mcstudy_constr.C File Reference

Detailed Description

View in nbviewer Open in SWAN Validation and MC studies: using RooMCStudy on models with constrains

␛[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
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 495
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 490
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 485
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 480
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 475
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 470
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 465
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 460
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 455
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 450
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 445
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 440
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 435
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 430
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 425
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 420
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 415
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 410
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 405
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 400
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 395
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 390
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 385
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 380
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 375
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 370
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 365
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 360
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 355
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 350
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 345
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 340
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 335
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 330
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 325
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 320
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 315
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 310
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 305
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 300
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 295
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 290
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 285
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 280
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 275
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 270
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 265
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 260
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 255
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 250
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 245
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 240
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 235
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 230
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 225
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 220
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 215
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 210
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 205
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 200
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 195
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 190
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 185
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 180
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 175
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 170
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 165
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 160
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 155
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 150
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 145
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 140
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 135
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 130
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 125
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 120
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 115
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 110
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 105
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 100
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 95
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 90
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 85
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 80
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 75
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 70
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 65
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 60
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 55
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 50
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 45
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 40
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 35
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 30
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 25
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 20
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 15
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 10
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 5
[#0] PROGRESS:Generation -- RooMCStudy::run: sample 0
[#1] INFO:NumericIntegration -- RooRealIntegral::init(pullGauss_Int[fpull]) using numeric integrator RooIntegrator1D to calculate Int(fpull)
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:NumericIntegration -- RooRealIntegral::init(pullGauss_Int[fpull]) using numeric integrator RooIntegrator1D to calculate Int(fpull)
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolynomial.h"
#include "RooAddPdf.h"
#include "RooProdPdf.h"
#include "RooMCStudy.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TH1.h"
using namespace RooFit;
void rf804_mcstudy_constr()
{
// C r e a t e m o d e l w i t h p a r a m e t e r c o n s t r a i n t
// ---------------------------------------------------------------------------
// Observable
RooRealVar x("x", "x", -10, 10);
// Signal component
RooRealVar m("m", "m", 0, -10, 10);
RooRealVar s("s", "s", 2, 0.1, 10);
RooGaussian g("g", "g", x, m, s);
// Background component
RooPolynomial p("p", "p", x);
// Composite model
RooRealVar f("f", "f", 0.4, 0., 1.);
RooAddPdf sum("sum", "sum", RooArgSet(g, p), f);
// Construct constraint on parameter f
RooGaussian fconstraint("fconstraint", "fconstraint", f, RooConst(0.7), RooConst(0.1));
// Multiply constraint with pdf
RooProdPdf sumc("sumc", "sum with constraint", RooArgSet(sum, fconstraint));
// S e t u p t o y s t u d y w i t h m o d e l
// ---------------------------------------------------
// Perform toy study with internal constraint on f
RooMCStudy mcs(sumc, x, Constrain(f), Silence(), Binned(), FitOptions(PrintLevel(-1)));
// Run 500 toys of 2000 events.
// Before each toy is generated, a value for the f is sampled from the constraint pdf and
// that value is used for the generation of that toy.
mcs.generateAndFit(500, 2000);
// Make plot of distribution of generated value of f parameter
TH1 *h_f_gen = mcs.fitParDataSet().createHistogram("f_gen", -40);
// Make plot of distribution of fitted value of f parameter
RooPlot *frame1 = mcs.plotParam(f, Bins(40));
frame1->SetTitle("Distribution of fitted f values");
// Make plot of pull distribution on f
RooPlot *frame2 = mcs.plotPull(f, Bins(40), FitGauss());
frame1->SetTitle("Distribution of f pull values");
TCanvas *c = new TCanvas("rf804_mcstudy_constr", "rf804_mcstudy_constr", 1200, 400);
c->Divide(3);
c->cd(1);
gPad->SetLeftMargin(0.15);
h_f_gen->GetYaxis()->SetTitleOffset(1.4);
h_f_gen->Draw();
c->cd(2);
gPad->SetLeftMargin(0.15);
frame1->GetYaxis()->SetTitleOffset(1.4);
frame1->Draw();
c->cd(3);
gPad->SetLeftMargin(0.15);
frame2->GetYaxis()->SetTitleOffset(1.4);
frame2->Draw();
}
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define gPad
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition RooAddPdf.h:32
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:29
Plain Gaussian p.d.f.
Definition RooGaussian.h:24
RooMCStudy is a helper class to facilitate Monte Carlo studies such as 'goodness-of-fit' studies,...
Definition RooMCStudy.h:32
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:44
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
Definition RooPlot.cxx:1242
TAxis * GetYaxis() const
Definition RooPlot.cxx:1263
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition RooPlot.cxx:691
RooPolynomial implements a polynomial p.d.f of the form.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition RooProdPdf.h:37
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition TAttAxis.cxx:293
The Canvas class.
Definition TCanvas.h:23
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
TAxis * GetYaxis()
Definition TH1.h:321
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition TH1.cxx:3073
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
auto * m
Definition textangle.C:8
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345
Date
July 2008
Author
Wouter Verkerke

Definition in file rf804_mcstudy_constr.C.