ROOT
Version v6.28
master
v6.34
v6.32
v6.30
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
rf706_histpdf.C File Reference
Tutorials
»
RooFit Tutorials
Detailed Description
Special pdf's: histogram-based pdfs and functions
#include "
RooRealVar.h
"
#include "
RooDataSet.h
"
#include "
RooGaussian.h
"
#include "
RooPolynomial.h
"
#include "
RooHistPdf.h
"
#include "
TCanvas.h
"
#include "
TAxis.h
"
#include "
RooPlot.h
"
using namespace
RooFit
;
void
rf706_histpdf
()
{
// C r e a t e p d f f o r s a m p l i n g
// ---------------------------------------------
RooRealVar
x
(
"x"
,
"x"
, 0, 20);
RooPolynomial
p
(
"p"
,
"p"
,
x
,
RooArgList
(0.01, -0.01, 0.0004));
// C r e a t e l o w s t a t s h i s t o g r a m
// ---------------------------------------------------
// Sample 500 events from p
x
.setBins(20);
RooDataSet
*data1 =
p
.generate(
x
, 500);
// Create a binned dataset with 20 bins and 500 events
RooDataHist
*hist1 = data1->
binnedClone
();
// Represent data in dh as pdf in x
RooHistPdf
histpdf1(
"histpdf1"
,
"histpdf1"
,
x
, *hist1, 0);
// Plot unbinned data and histogram pdf overlaid
RooPlot
*frame1 =
x
.
frame
(Title(
"Low statistics histogram pdf"
), Bins(100));
data1->
plotOn
(frame1);
histpdf1.plotOn(frame1);
// C r e a t e h i g h s t a t s h i s t o g r a m
// -----------------------------------------------------
// Sample 100000 events from p
x
.setBins(10);
RooDataSet
*data2 =
p
.generate(
x
, 100000);
// Create a binned dataset with 10 bins and 100K events
RooDataHist
*hist2 = data2->
binnedClone
();
// Represent data in dh as pdf in x, apply 2nd order interpolation
RooHistPdf
histpdf2(
"histpdf2"
,
"histpdf2"
,
x
, *hist2, 2);
// Plot unbinned data and histogram pdf overlaid
RooPlot
*frame2 =
x
.
frame
(Title(
"High stats histogram pdf with interpolation"
), Bins(100));
data2->
plotOn
(frame2);
histpdf2.plotOn(frame2);
TCanvas
*
c
=
new
TCanvas
(
"rf706_histpdf"
,
"rf706_histpdf"
, 800, 400);
c
->Divide(2);
c
->cd(1);
gPad
->SetLeftMargin(0.15);
frame1->
GetYaxis
()->
SetTitleOffset
(1.4);
frame1->
Draw
();
c
->cd(2);
gPad
->SetLeftMargin(0.15);
frame2->
GetYaxis
()->
SetTitleOffset
(1.8);
frame2->
Draw
();
}
c
#define c(i)
Definition
RSha256.hxx:101
RooDataSet.h
RooGaussian.h
RooHistPdf.h
RooPlot.h
RooPolynomial.h
RooRealVar.h
TAxis.h
TCanvas.h
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
gPad
#define gPad
Definition
TVirtualPad.h:303
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:608
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition
RooArgList.h:22
RooDataHist
The RooDataHist is a container class to hold N-dimensional binned data.
Definition
RooDataHist.h:39
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition
RooDataSet.h:57
RooDataSet::binnedClone
RooDataHist * binnedClone(const char *newName=nullptr, const char *newTitle=nullptr) const
Return binned clone of this dataset.
Definition
RooDataSet.cxx:882
RooHistPdf
RooHistPdf implements a probablity density function sampled from a multidimensional histogram.
Definition
RooHistPdf.h:30
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition
RooPlot.h:43
RooPlot::frame
static RooPlot * frame(const RooAbsRealLValue &var, double xmin, double xmax, Int_t nBins)
Create a new frame for a given variable in x.
Definition
RooPlot.cxx:239
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition
RooPlot.cxx:1276
RooPlot::Draw
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
Definition
RooPlot.cxx:649
RooPolynomial
RooPolynomial implements a polynomial p.d.f of the form.
Definition
RooPolynomial.h:25
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition
RooRealVar.h:40
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition
TAttAxis.cxx:298
TCanvas
The Canvas class.
Definition
TCanvas.h:23
x
Double_t x[n]
Definition
legend1.C:17
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition
Common.h:18
rf706_histpdf
Definition
rf706_histpdf.py:1
Date
July 2008
Author
Wouter Verkerke
Definition in file
rf706_histpdf.C
.
tutorials
roofit
rf706_histpdf.C
ROOT v6-28 - Reference Guide Generated on Thu Oct 24 2024 01:50:19 (GVA Time) using Doxygen 1.9.8