Logo ROOT  
Reference Guide
rf303_conditional.C File Reference

Detailed Description

View in nbviewer Open in SWAN

Multidimensional models: use of tailored p.d.f as conditional p.d.fs.s

pdf = gauss(x,f(y),sx | y ) with f(y) = a0 + a1*y

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
RooDataSet::modelData[x,y] = 6850 entries
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 a0 -5.00000e-01 1.00000e+00 -5.00000e+00 5.00000e+00
2 a1 -5.00000e-01 2.00000e-01 -1.00000e+00 1.00000e+00
3 sigma 5.00000e-01 1.90000e-01 1.00000e-01 2.00000e+00
**********
** 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 1500 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=421420 FROM MIGRAD STATUS=INITIATE 12 CALLS 13 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 a0 -5.00000e-01 1.00000e+00 2.02430e-01 -7.46265e+04
2 a1 -5.00000e-01 2.00000e-01 2.35352e-01 -6.95347e+05
3 sigma 5.00000e-01 1.90000e-01 2.52163e-01 -1.29056e+06
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=9659.64 FROM MIGRAD STATUS=CONVERGED 101 CALLS 102 TOTAL
EDM=8.18253e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 a0 9.03100e-03 1.19768e-02 1.62548e-04 -2.31829e+00
2 a1 5.02815e-01 2.21631e-03 1.74026e-04 -2.33580e+00
3 sigma 9.91234e-01 8.46817e-03 6.05957e-04 -4.27913e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 3 ERR DEF=0.5
1.434e-04 1.880e-07 4.948e-08
1.880e-07 4.912e-06 8.995e-09
4.948e-08 8.995e-09 7.171e-05
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3
1 0.00710 1.000 0.007 0.000
2 0.00710 0.007 1.000 0.000
3 0.00068 0.000 0.000 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 1500
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=9659.64 FROM HESSE STATUS=OK 16 CALLS 118 TOTAL
EDM=8.17764e-05 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 a0 9.03100e-03 1.19768e-02 3.25095e-05 1.80620e-03
2 a1 5.02815e-01 2.21631e-03 3.48052e-05 2.61474e+00
3 sigma 9.91234e-01 8.46818e-03 1.21191e-04 -6.18987e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 3 ERR DEF=0.5
1.434e-04 1.880e-07 2.151e-09
1.880e-07 4.912e-06 2.334e-10
2.151e-09 2.334e-10 7.171e-05
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2 3
1 0.00708 1.000 0.007 0.000
2 0.00708 0.007 1.000 0.000
3 0.00002 0.000 0.000 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooAbsReal::plotOn(model) plot on x averages using data variables (y)
[#1] INFO:Plotting -- RooDataWeightedAverage::ctor(modelDataWgtAvg) constructing data weighted average of function model_Norm[x] over 6850 data points of (y) with a total weight of 6850
.........................................................................................................................................................................................................
[#1] INFO:Plotting -- RooAbsReal::plotOn(model) plot on x averages using data variables (y)
[#1] INFO:Plotting -- RooDataWeightedAverage::ctor(modelDataWgtAvg) constructing data weighted average of function model_Norm[x] over 100 data points of (y) with a total weight of 6850
.........................................................................................................................................................................................................
[#1] INFO:Plotting -- RooAbsReal::plotOn(model) plot on x averages using data variables (y)
[#1] INFO:Plotting -- RooDataWeightedAverage::ctor(modelDataWgtAvg) constructing data weighted average of function model_Norm[x] over 5 data points of (y) with a total weight of 6850
.................................................................................................................................................................................................................................................
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooDataHist.h"
#include "RooGaussian.h"
#include "RooPolyVar.h"
#include "RooProdPdf.h"
#include "RooPlot.h"
#include "TRandom.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TH1.h"
using namespace RooFit;
RooDataSet *makeFakeDataXY();
void rf303_conditional()
{
// S e t u p c o m p o s e d m o d e l g a u s s ( x , m ( y ) , s )
// -----------------------------------------------------------------------
// Create observables
RooRealVar x("x", "x", -10, 10);
RooRealVar y("y", "y", -10, 10);
// Create function f(y) = a0 + a1*y
RooRealVar a0("a0", "a0", -0.5, -5, 5);
RooRealVar a1("a1", "a1", -0.5, -1, 1);
RooPolyVar fy("fy", "fy", y, RooArgSet(a0, a1));
// Create gauss(x,f(y),s)
RooRealVar sigma("sigma", "width of gaussian", 0.5, 0.1, 2.0);
RooGaussian model("model", "Gaussian with shifting mean", x, fy, sigma);
// Obtain fake external experimental dataset with values for x and y
RooDataSet *expDataXY = makeFakeDataXY();
// G e n e r a t e d a t a f r o m c o n d i t i o n a l p . d . f m o d e l ( x | y )
// ---------------------------------------------------------------------------------------------
// Make subset of experimental data with only y values
RooDataSet *expDataY = (RooDataSet *)expDataXY->reduce(y);
// Generate 10000 events in x obtained from _conditional_ model(x|y) with y values taken from experimental data
RooDataSet *data = model.generate(x, ProtoData(*expDataY));
data->Print();
// F i t c o n d i t i o n a l p . d . f m o d e l ( x | y ) t o d a t a
// ---------------------------------------------------------------------------------------------
model.fitTo(*expDataXY, ConditionalObservables(y));
// P r o j e c t c o n d i t i o n a l p . d . f o n x a n d y d i m e n s i o n s
// ---------------------------------------------------------------------------------------------
// Plot x distribution of data and projection of model on x = 1/Ndata sum(data(y_i)) model(x;y_i)
RooPlot *xframe = x.frame();
expDataXY->plotOn(xframe);
model.plotOn(xframe, ProjWData(*expDataY));
// Speed up (and approximate) projection by using binned clone of data for projection
RooAbsData *binnedDataY = expDataY->binnedClone();
model.plotOn(xframe, ProjWData(*binnedDataY), LineColor(kCyan), LineStyle(kDotted));
// Show effect of projection with too coarse binning
((RooRealVar *)expDataY->get()->find("y"))->setBins(5);
RooAbsData *binnedDataY2 = expDataY->binnedClone();
model.plotOn(xframe, ProjWData(*binnedDataY2), LineColor(kRed));
// Make canvas and draw RooPlots
new TCanvas("rf303_conditional", "rf303_conditional", 600, 460);
gPad->SetLeftMargin(0.15);
xframe->GetYaxis()->SetTitleOffset(1.2);
xframe->Draw();
}
RooDataSet *makeFakeDataXY()
{
RooRealVar x("x", "x", -10, 10);
RooRealVar y("y", "y", -10, 10);
RooArgSet coord(x, y);
RooDataSet *d = new RooDataSet("d", "d", RooArgSet(x, y));
for (int i = 0; i < 10000; i++) {
Double_t tmpy = gRandom->Gaus(0, 10);
Double_t tmpx = gRandom->Gaus(0.5 * tmpy, 1);
if (fabs(tmpy) < 10 && fabs(tmpx) < 10) {
x = tmpx;
y = tmpy;
d->add(coord);
}
}
return d;
}
Date
07/2008
Author
Wouter Verkerke

Definition in file rf303_conditional.C.

RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
TRandom::Gaus
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:263
RooFit::ProjWData
RooCmdArg ProjWData(const RooAbsData &projData, Bool_t binData=kFALSE)
Definition: RooGlobalFunc.cxx:46
RooAbsData
Definition: RooAbsData.h:46
RooGaussian.h
TRandom.h
RooAbsData::Print
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooAbsData.h:177
RooAbsCollection::find
RooAbsArg * find(const char *name) const
Find object with given name in list.
Definition: RooAbsCollection.cxx:813
x
Double_t x[n]
Definition: legend1.C:17
RooGaussian
Definition: RooGaussian.h:25
TCanvas.h
RooDataSet.h
RooDataSet::get
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
Definition: RooDataSet.cxx:1038
RooPolyVar.h
ROOT::Math::fabs
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Definition: UnaryOperators.h:131
kCyan
@ kCyan
Definition: Rtypes.h:66
RooFit::ProtoData
RooCmdArg ProtoData(const RooDataSet &protoData, Bool_t randomizeOrder=kFALSE, Bool_t resample=kFALSE)
Definition: RooGlobalFunc.cxx:228
RooProdPdf.h
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
RooDataHist.h
RooPlot.h
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1256
gRandom
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
RooPlot
Definition: RooPlot.h:44
y
Double_t y[n]
Definition: legend1.C:17
RooRealVar.h
RooFit::ConditionalObservables
RooCmdArg ConditionalObservables(const RooArgSet &set)
Definition: RooGlobalFunc.cxx:196
kRed
@ kRed
Definition: Rtypes.h:66
RooPolyVar
Definition: RooPolyVar.h:28
sigma
const Double_t sigma
Definition: h1analysisProxy.h:11
RooFit::LineColor
RooCmdArg LineColor(Color_t color)
Definition: RooGlobalFunc.cxx:56
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas
Definition: TCanvas.h:23
RooAbsData::reduce
RooAbsData * reduce(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg())
Create a reduced copy of this dataset.
Definition: RooAbsData.cxx:382
TAxis.h
RooDataSet::binnedClone
RooDataHist * binnedClone(const char *newName=0, const char *newTitle=0) const
Return binned clone of this dataset.
Definition: RooDataSet.cxx:972
d
#define d(i)
Definition: RSha256.hxx:120
gPad
#define gPad
Definition: TVirtualPad.h:287
RooDataSet
Definition: RooDataSet.h:33
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooFit::LineStyle
RooCmdArg LineStyle(Style_t style)
Definition: RooGlobalFunc.cxx:57
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
TH1.h
kDotted
@ kDotted
Definition: TAttLine.h:48
RooArgSet
Definition: RooArgSet.h:28