Logo ROOT  
Reference Guide
rf701_efficiencyfit.C File Reference

Detailed Description

View in nbviewer Open in SWAN Special pdf's: unbinned maximum likelihood fit of an efficiency eff(x) function

to a dataset D(x,cut), where cut is a category encoding a selection, of which the efficiency as function of x should be described by eff(x)

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:Minization -- RooMinimizer::optimizeConst: activating const optimization
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 a 4.00000e-01 1.00000e-01 0.00000e+00 1.00000e+00
2 c -1.00000e+00 2.00000e+00 -1.00000e+01 1.00000e+01
**********
** 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 1000 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=3887.11 FROM MIGRAD STATUS=INITIATE 8 CALLS 9 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 a 4.00000e-01 1.00000e-01 2.05758e-01 8.51804e+01
2 c -1.00000e+00 2.00000e+00 2.02430e-01 7.00873e+01
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=3886.26 FROM MIGRAD STATUS=CONVERGED 30 CALLS 31 TOTAL
EDM=2.277e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 a 3.89817e-01 8.14984e-03 6.58343e-04 -2.65715e-01
2 c -9.91750e-01 6.56208e-02 2.58326e-04 -6.57933e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
6.643e-05 -2.189e-04
-2.189e-04 4.306e-03
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.40934 1.000 -0.409
2 0.40934 -0.409 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=3886.26 FROM HESSE STATUS=OK 10 CALLS 41 TOTAL
EDM=2.27764e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 a 3.89817e-01 8.14814e-03 1.31669e-04 -2.22191e-01
2 c -9.91750e-01 6.56071e-02 5.16653e-05 -9.93383e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
6.640e-05 -2.186e-04
-2.186e-04 4.304e-03
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.40891 1.000 -0.409
2 0.40891 -0.409 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 8176 events out of 10000 total events
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooFormulaVar.h"
#include "RooProdPdf.h"
#include "RooEfficiency.h"
#include "RooPolynomial.h"
#include "RooCategory.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit;
{
// C o n s t r u c t e f f i c i e n c y f u n c t i o n e ( x )
// -------------------------------------------------------------------
// Declare variables x,mean,sigma with associated name, title, initial value and allowed range
RooRealVar x("x", "x", -10, 10);
// Efficiency function eff(x;a,b)
RooRealVar a("a", "a", 0.4, 0, 1);
RooRealVar b("b", "b", 5);
RooRealVar c("c", "c", -1, -10, 10);
RooFormulaVar effFunc("effFunc", "(1-a)+a*cos((x-c)/b)", RooArgList(a, b, c, x));
// C o n s t r u c t c o n d i t i o n a l e f f i c i e n c y p d f E ( c u t | x )
// ------------------------------------------------------------------------------------------
// Acceptance state cut (1 or 0)
RooCategory cut("cut", "cutr", { {"accept", 1}, {"reject", 0} });
// Construct efficiency pdf eff(cut|x)
RooEfficiency effPdf("effPdf", "effPdf", effFunc, cut, "accept");
// G e n e r a t e d a t a ( x , c u t ) f r o m a t o y m o d e l
// -----------------------------------------------------------------------------
// Construct global shape pdf shape(x) and product model(x,cut) = eff(cut|x)*shape(x)
// (These are _only_ needed to generate some toy MC here to be used later)
RooPolynomial shapePdf("shapePdf", "shapePdf", x, RooConst(-0.095));
RooProdPdf model("model", "model", shapePdf, Conditional(effPdf, cut));
// Generate some toy data from model
RooDataSet *data = model.generate(RooArgSet(x, cut), 10000);
// F i t c o n d i t i o n a l e f f i c i e n c y p d f t o d a t a
// --------------------------------------------------------------------------
// Fit conditional efficiency pdf to data
effPdf.fitTo(*data, ConditionalObservables(x));
// P l o t f i t t e d , d a t a e f f i c i e n c y
// --------------------------------------------------------
// Plot distribution of all events and accepted fraction of events on frame
RooPlot *frame1 = x.frame(Bins(20), Title("Data (all, accepted)"));
data->plotOn(frame1);
data->plotOn(frame1, Cut("cut==cut::accept"), MarkerColor(kRed), LineColor(kRed));
// Plot accept/reject efficiency on data overlay fitted efficiency curve
RooPlot *frame2 = x.frame(Bins(20), Title("Fitted efficiency"));
data->plotOn(frame2, Efficiency(cut)); // needs ROOT version >= 5.21
effFunc.plotOn(frame2, LineColor(kRed));
// Draw all frames on a canvas
TCanvas *ca = new TCanvas("rf701_efficiency", "rf701_efficiency", 800, 400);
ca->Divide(2);
ca->cd(1);
gPad->SetLeftMargin(0.15);
frame1->GetYaxis()->SetTitleOffset(1.6);
frame1->Draw();
ca->cd(2);
gPad->SetLeftMargin(0.15);
frame2->GetYaxis()->SetTitleOffset(1.4);
frame2->Draw();
}
Date
July 2008
Author
Wouter Verkerke

Definition in file rf701_efficiencyfit.C.

RooFormulaVar.h
c
#define c(i)
Definition: RSha256.hxx:101
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
RooFit::Bins
RooCmdArg Bins(Int_t nbin)
Definition: RooGlobalFunc.cxx:177
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooGaussian.h
x
Double_t x[n]
Definition: legend1.C:17
TPad::Divide
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition: TPad.cxx:1177
TCanvas.h
RooDataSet.h
b
#define b(i)
Definition: RSha256.hxx:100
RooPolynomial.h
RooFit::Cut
RooCmdArg Cut(const char *cutSpec)
Definition: RooGlobalFunc.cxx:81
RooFormulaVar
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
RooProdPdf.h
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: RooCFunction1Binding.h:29
RooFit::Efficiency
RooCmdArg Efficiency(const RooCategory &cat)
Definition: RooGlobalFunc.cxx:93
TCanvas::cd
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:708
RooPolynomial
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
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
a
auto * a
Definition: textangle.C:12
RooPlot.h
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1258
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooEfficiency.h
RooCategory.h
RooRealVar.h
RooFit::ConditionalObservables
RooCmdArg ConditionalObservables(const RooArgSet &set)
Definition: RooGlobalFunc.cxx:199
kRed
@ kRed
Definition: Rtypes.h:66
RooConstVar.h
RooFit::Conditional
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, Bool_t depsAreCond=kFALSE)
Definition: RooGlobalFunc.cxx:231
RooFit::LineColor
RooCmdArg LineColor(Color_t color)
Definition: RooGlobalFunc.cxx:57
TCanvas
The Canvas class.
Definition: TCanvas.h:23
RooCategory
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
TAxis.h
RooEfficiency
RooEfficiency is a PDF helper class to fit efficiencies parameterized by a supplied function F.
Definition: RooEfficiency.h:27
gPad
#define gPad
Definition: TVirtualPad.h:287
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooFit::MarkerColor
RooCmdArg MarkerColor(Color_t color)
Definition: RooGlobalFunc.cxx:88
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:37
RooProdPdf
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:37
rf701_efficiencyfit
Definition: rf701_efficiencyfit.py:1
RooFit::Title
RooCmdArg Title(const char *name)
Definition: RooGlobalFunc.cxx:176
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
RooFit::RooConst
RooConstVar & RooConst(Double_t val)
Definition: RooGlobalFunc.cxx:347