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

Detailed Description

View in nbviewer Open in SWAN
Multidimensional models: performing fits in multiple (disjoint) ranges in one or more dimensions

#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooProdPdf.h"
#include "RooAddPdf.h"
#include "RooPolynomial.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "RooFitResult.h"
using namespace RooFit;
{
// C r e a t e 2 D p d f a n d d a t a
// -------------------------------------------
// Define observables x,y
RooRealVar x("x", "x", -10, 10);
RooRealVar y("y", "y", -10, 10);
// Construct the signal pdf gauss(x)*gauss(y)
RooRealVar mx("mx", "mx", 1, -10, 10);
RooRealVar my("my", "my", 1, -10, 10);
RooGaussian gx("gx", "gx", x, mx, 1.0);
RooGaussian gy("gy", "gy", y, my, 1.0);
RooProdPdf sig("sig", "sig", gx, gy);
// Construct the background pdf (flat in x,y)
RooPolynomial px("px", "px", x);
RooPolynomial py("py", "py", y);
RooProdPdf bkg("bkg", "bkg", px, py);
// Construct the composite model sig+bkg
RooRealVar f("f", "f", 0., 1.);
RooAddPdf model("model", "model", RooArgList(sig, bkg), f);
// Sample 10000 events in (x,y) from the model
std::unique_ptr<RooDataSet> modelData{model.generate({x, y}, 10000)};
// D e f i n e s i g n a l a n d s i d e b a n d r e g i o n s
// -------------------------------------------------------------------
// Construct the SideBand1,SideBand2,Signal regions
//
// |
// +-------------+-----------+
// | | |
// | Side | Sig |
// | Band1 | nal |
// | | |
// --+-------------+-----------+--
// | |
// | Side |
// | Band2 |
// | |
// +-------------+-----------+
// |
x.setRange("SB1", -10, +10);
y.setRange("SB1", -10, 0);
x.setRange("SB2", -10, 0);
y.setRange("SB2", 0, +10);
x.setRange("SIG", 0, +10);
y.setRange("SIG", 0, +10);
x.setRange("FULL", -10, +10);
y.setRange("FULL", -10, +10);
// P e r f o r m f i t s i n i n d i v i d u a l s i d e b a n d r e g i o n s
// -------------------------------------------------------------------------------------
// Perform fit in SideBand1 region (RooAddPdf coefficients will be interpreted in full range)
std::unique_ptr<RooFitResult> r_sb1{model.fitTo(*modelData, Range("SB1"), Save(), PrintLevel(-1))};
// Perform fit in SideBand2 region (RooAddPdf coefficients will be interpreted in full range)
std::unique_ptr<RooFitResult> r_sb2{model.fitTo(*modelData, Range("SB2"), Save(), PrintLevel(-1))};
// P e r f o r m f i t s i n j o i n t s i d e b a n d r e g i o n s
// -----------------------------------------------------------------------------
// Now perform fit to joint 'L-shaped' sideband region 'SB1|SB2'
// (RooAddPdf coefficients will be interpreted in full range)
std::unique_ptr<RooFitResult> r_sb12{model.fitTo(*modelData, Range("SB1,SB2"), Save(), PrintLevel(-1))};
// Print results for comparison
r_sb1->Print();
r_sb2->Print();
r_sb12->Print();
}
#define f(i)
Definition RSha256.hxx:104
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char mx
Efficient implementation of a sum of PDFs of the form.
Definition RooAddPdf.h:33
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
Plain Gaussian p.d.f.
Definition RooGaussian.h:24
RooPolynomial implements a polynomial p.d.f of the form.
Efficient implementation of a product of PDFs of the form.
Definition RooProdPdf.h:33
Variable that can be changed from the outside.
Definition RooRealVar.h:37
RooCmdArg Save(bool flag=true)
RooCmdArg PrintLevel(Int_t code)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
Ta Range(0, 0, 1, 1)
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'SB1' created with bounds [-10,10]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'SB1' created with bounds [-10,0]
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'SB2' created with bounds [-10,0]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'SB2' created with bounds [0,10]
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'SIG' created with bounds [0,10]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'SIG' created with bounds [0,10]
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'FULL' created with bounds [-10,10]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'FULL' created with bounds [-10,10]
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'fit_nll_model_modelData' created with bounds [-10,10]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'fit_nll_model_modelData' created with bounds [-10,0]
[#1] INFO:Fitting -- RooAbsPdf::fitTo(model) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- using CPU computation library compiled with -mavx2
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_model_modelData) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Fitting -- RooAbsPdf::fitTo(model) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_model_modelData) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'fit_nll_model_modelData_SB1' created with bounds [-10,10]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'fit_nll_model_modelData_SB1' created with bounds [-10,0]
[#1] INFO:Eval -- RooRealVar::setRange(x) new range named 'fit_nll_model_modelData_SB2' created with bounds [-10,0]
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'fit_nll_model_modelData_SB2' created with bounds [0,10]
[#1] INFO:Fitting -- RooAbsPdf::fitTo(model) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_model_modelData) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
RooFitResult: minimized FCN value: 16261.4, estimated distance to minimum: 5.06415e-07
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
f 5.1135e-01 +/- 3.58e-02
mx 9.8740e-01 +/- 4.03e-02
my 9.9305e-01 +/- 9.39e-02
RooFitResult: minimized FCN value: 7578.28, estimated distance to minimum: 3.07865e-06
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
f 5.4586e-01 +/- 4.46e-02
mx 1.1276e+00 +/- 1.10e-01
my 9.6462e-01 +/- 5.60e-02
RooFitResult: minimized FCN value: 27252.6, estimated distance to minimum: 2.25202e-06
covariance matrix quality: Full, accurate covariance matrix
Status : MINIMIZE=0 HESSE=0
Floating Parameter FinalValue +/- Error
-------------------- --------------------------
f 5.0082e-01 +/- 1.29e-02
mx 1.0100e+00 +/- 3.26e-02
my 9.6348e-01 +/- 3.31e-02
Date
July 2008
Author
Wouter Verkerke

Definition in file rf312_multirangefit.C.