Logo ROOT  
Reference Guide
rf106_plotdecoration.C File Reference

Detailed Description

View in nbviewer Open in SWAN

Basic functionality: adding boxes with parameters, statistics to RooPlots, decorating with arrows, text etc...

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 mean -3.00000e+00 2.00000e+00 -1.00000e+01 1.00000e+01
2 sigma 1.00000e+00 4.50000e-01 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=1457.87 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 mean -3.00000e+00 2.00000e+00 2.11716e-01 -2.55667e+02
2 sigma 1.00000e+00 4.50000e-01 1.63378e-01 -2.21584e+02
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=1456.09 FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL
EDM=1.47238e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 mean -2.97319e+00 3.28196e-02 9.04112e-05 1.05544e-01
2 sigma 1.03785e+00 2.32067e-02 2.10225e-04 -1.56386e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
1.077e-03 4.600e-07
4.600e-07 5.386e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.00060 1.000 0.001
2 0.00060 0.001 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=1456.09 FROM HESSE STATUS=OK 10 CALLS 42 TOTAL
EDM=1.47267e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 mean -2.97319e+00 3.28196e-02 1.80822e-05 -3.01883e-01
2 sigma 1.03785e+00 2.32067e-02 8.40899e-06 -9.45066e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
1.077e-03 1.019e-07
1.019e-07 5.386e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.00013 1.000 0.000
2 0.00013 0.000 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "TText.h"
#include "TArrow.h"
#include "TFile.h"
using namespace RooFit;
{
// S e t u p m o d e l
// ---------------------
// Create observables
RooRealVar x("x", "x", -10, 10);
// Create Gaussian
RooRealVar sigma("sigma", "sigma", 1, 0.1, 10);
RooRealVar mean("mean", "mean", -3, -10, 10);
RooGaussian gauss("gauss", "gauss", x, mean, sigma);
// Generate a sample of 1000 events with sigma=3
RooDataSet *data = gauss.generate(x, 1000);
// Fit pdf to data
gauss.fitTo(*data);
// P l o t p . d . f a n d d a t a
// -------------------------------------
// Overlay projection of gauss on data
RooPlot *frame = x.frame(Name("xframe"), Title("RooPlot with decorations"), Bins(40));
data->plotOn(frame);
gauss.plotOn(frame);
// A d d b o x w i t h p d f p a r a m e t e r s
// -----------------------------------------------------
// Left edge of box starts at 55% of Xaxis)
gauss.paramOn(frame, Layout(0.55));
// A d d b o x w i t h d a t a s t a t i s t i c s
// -------------------------------------------------------
// X size of box is from 55% to 99% of Xaxis range, top of box is at 80% of Yaxis range)
data->statOn(frame, Layout(0.55, 0.99, 0.8));
// A d d t e x t a n d a r r o w
// -----------------------------------
// Add text to frame
TText *txt = new TText(2, 100, "Signal");
txt->SetTextSize(0.04);
txt->SetTextColor(kRed);
frame->addObject(txt);
// Add arrow to frame
TArrow *arrow = new TArrow(2, 100, -1, 50, 0.01, "|>");
arrow->SetLineColor(kRed);
arrow->SetFillColor(kRed);
arrow->SetLineWidth(3);
frame->addObject(arrow);
// P e r s i s t f r a m e w i t h a l l d e c o r a t i o n s i n R O O T f i l e
// ---------------------------------------------------------------------------------------------
TFile f("rf106_plotdecoration.root", "RECREATE");
frame->Write();
f.Close();
// To read back and plot frame with all decorations in clean root session do
// root> TFile f("rf106_plotdecoration.root") ;
// root> xframe->Draw() ;
new TCanvas("rf106_plotdecoration", "rf106_plotdecoration", 600, 600);
gPad->SetLeftMargin(0.15);
frame->GetYaxis()->SetTitleOffset(1.6);
frame->Draw();
}
Date
07/2008
Author
Wouter Verkerke

Definition in file rf106_plotdecoration.C.

TArrow.h
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
f
#define f(i)
Definition: RSha256.hxx:122
RooFit::Bins
RooCmdArg Bins(Int_t nbin)
Definition: RooGlobalFunc.cxx:174
RooGaussian.h
x
Double_t x[n]
Definition: legend1.C:17
RooGaussian
Definition: RooGaussian.h:25
TCanvas.h
RooDataSet.h
TFile.h
RooPlot::addObject
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
Definition: RooPlot.cxx:422
rf106_plotdecoration
Definition: rf106_plotdecoration.py:1
RooFit::Layout
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
Definition: RooGlobalFunc.cxx:217
TGeant4Unit::gauss
static constexpr double gauss
Definition: TGeant4SystemOfUnits.h:269
RooFit
Definition: RooCFunction1Binding.h:29
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
RooFit::Name
RooCmdArg Name(const char *name)
Definition: RooGlobalFunc.cxx:62
RooPlot.h
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1256
RooPlot
Definition: RooPlot.h:44
RooRealVar.h
kRed
@ kRed
Definition: Rtypes.h:66
TFile
Definition: TFile.h:54
sigma
const Double_t sigma
Definition: h1analysisProxy.h:11
TText
Definition: TText.h:22
TCanvas
Definition: TCanvas.h:23
arrow
Definition: RArrowDS.hxx:9
TObject::Write
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:795
TAxis.h
TArrow
Definition: TArrow.h:29
gPad
#define gPad
Definition: TVirtualPad.h:287
RooDataSet
Definition: RooDataSet.h:33
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
RooRealVar
Definition: RooRealVar.h:35
RooAbsData::statOn
virtual RooPlot * statOn(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())
Add a box with statistics information to the specified frame.
Definition: RooAbsData.cxx:1165
TText.h
RooFit::Title
RooCmdArg Title(const char *name)
Definition: RooGlobalFunc.cxx:173