Logo ROOT   6.18/05
Reference Guide
rf603_multicpu.C File Reference

Detailed Description

View in nbviewer Open in SWAN Likelihood and minimization: setting up a multi-core parallelized unbinned maximum likelihood fit

␛[1mRooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby␛[0m
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] INFO:Eval -- RooAbsTestStatistic::initMPMode: started 4 remote server process.
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 fsig 1.00000e-01 5.00000e-02 0.00000e+00 1.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 500 1
**********
FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (sig,bkg)
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (sig,bkg)
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (sig,bkg)
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (sig,bkg)
START MIGRAD MINIMIZATION. STRATEGY 1. CONVERGENCE WHEN EDM .LT. 1.00e-03
FCN=1.35338e+06 FROM MIGRAD STATUS=INITIATE 6 CALLS 7 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 fsig 1.00000e-01 5.00000e-02 1.72186e-01 -1.02596e+02
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=1.35338e+06 FROM MIGRAD STATUS=CONVERGED 16 CALLS 17 TOTAL
EDM=1.10509e-08 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 fsig 1.00271e-01 8.91444e-04 2.38484e-03 -3.54200e-02
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 1 ERR DEF=0.5
7.947e-07
[#1] INFO:Minization -- Command timer: Real time 0:00:00, CP time 0.040
[#1] INFO:Minization -- Session timer: Real time 0:00:00, CP time 0.040
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 500
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=1.35338e+06 FROM HESSE STATUS=OK 5 CALLS 22 TOTAL
EDM=1.11088e-08 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 fsig 1.00271e-01 8.91444e-04 9.53935e-05 -9.26391e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 1 ERR DEF=0.5
7.947e-07
[#1] INFO:Minization -- Command timer: Real time 0:00:00, CP time 0.000
[#1] INFO:Minization -- Session timer: Real time 0:00:00, CP time 0.040, 2 slices
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Plotting -- RooAbsReal::plotOn(model) plot on x averages using data variables (y,z)
[#1] INFO:Plotting -- RooAbsReal::plotOn(model) only the following components of the projection data will be used: (y,z)
[#1] INFO:Plotting -- RooDataWeightedAverage::ctor(modelDataWgtAvg) constructing data weighted average of function model_Norm[x] over 14497 data points of (y,z) with a total weight of 14497
[#1] INFO:Plotting -- RooDataWeightedAverage::ctor(modelDataWgtAvg) constructing data weighted average of function model_Norm[x] over 14497 data points of (y,z) with a total weight of 14497
[#1] INFO:Eval -- RooAbsTestStatistic::initMPMode: started 4 remote server process.
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (gy,gz,py,pz)
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (gy,gz,py,pz)
[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (gy,gz,py,pz)
.[#1] INFO:Minization -- The following expressions have been identified as constant and will be precalculated and cached: (gy,gz,py,pz)
................................................................................................................................................
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolynomial.h"
#include "RooAddPdf.h"
#include "RooProdPdf.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit;
{
// C r e a t e 3 D p d f a n d d a t a
// -------------------------------------------
// Create observables
RooRealVar x("x", "x", -5, 5);
RooRealVar y("y", "y", -5, 5);
RooRealVar z("z", "z", -5, 5);
// Create signal pdf gauss(x)*gauss(y)*gauss(z)
RooGaussian gx("gx", "gx", x, RooConst(0), RooConst(1));
RooGaussian gy("gy", "gy", y, RooConst(0), RooConst(1));
RooGaussian gz("gz", "gz", z, RooConst(0), RooConst(1));
RooProdPdf sig("sig", "sig", RooArgSet(gx, gy, gz));
// Create background pdf poly(x)*poly(y)*poly(z)
RooPolynomial px("px", "px", x, RooArgSet(RooConst(-0.1), RooConst(0.004)));
RooPolynomial py("py", "py", y, RooArgSet(RooConst(0.1), RooConst(-0.004)));
RooPolynomial pz("pz", "pz", z);
RooProdPdf bkg("bkg", "bkg", RooArgSet(px, py, pz));
// Create composite pdf sig+bkg
RooRealVar fsig("fsig", "signal fraction", 0.1, 0., 1.);
RooAddPdf model("model", "model", RooArgList(sig, bkg), fsig);
// Generate large dataset
RooDataSet *data = model.generate(RooArgSet(x, y, z), 200000);
// P a r a l l e l f i t t i n g
// -------------------------------
// In parallel mode the likelihood calculation is split in N pieces,
// that are calculated in parallel and added a posteriori before passing
// it back to MINUIT.
// Use four processes and time results both in wall time and CPU time
model.fitTo(*data, NumCPU(4), Timer(kTRUE));
// P a r a l l e l M C p r o j e c t i o n s
// ----------------------------------------------
// Construct signal, total likelihood projection on (y,z) observables and likelihood ratio
RooAbsPdf *sigyz = sig.createProjection(x);
RooAbsPdf *totyz = model.createProjection(x);
RooFormulaVar llratio_func("llratio", "log10(@0)-log10(@1)", RooArgList(*sigyz, *totyz));
// Calculate likelihood ratio for each event, define subset of events with high signal likelihood
data->addColumn(llratio_func);
RooDataSet *dataSel = (RooDataSet *)data->reduce(Cut("llratio>0.7"));
// Make plot frame and plot data
RooPlot *frame = x.frame(Title("Projection on X with LLratio(y,z)>0.7"), Bins(40));
dataSel->plotOn(frame);
// Perform parallel projection using MC integration of pdf using given input dataSet.
// In this mode the data-weighted average of the pdf is calculated by splitting the
// input dataset in N equal pieces and calculating in parallel the weighted average
// one each subset. The N results of those calculations are then weighted into the
// final result
// Use four processes
model.plotOn(frame, ProjWData(*dataSel), NumCPU(4));
new TCanvas("rf603_multicpu", "rf603_multicpu", 600, 600);
gPad->SetLeftMargin(0.15);
frame->GetYaxis()->SetTitleOffset(1.6);
frame->Draw();
}
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define gPad
Definition: TVirtualPad.h:286
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:381
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
Calls RooPlot* plotOn(RooPlot* frame, const RooLinkedList& cmdList) const ;.
Definition: RooAbsData.cxx:552
virtual RooAbsPdf * createProjection(const RooArgSet &iset)
Return a p.d.f that represent a projection of this p.d.f integrated over given observables.
Definition: RooAbsPdf.cxx:2979
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:29
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:27
Plain Gaussian p.d.f.
Definition: RooGaussian.h:25
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:41
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1123
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:558
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:31
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
Definition: TAttAxis.cxx:294
The Canvas class.
Definition: TCanvas.h:31
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
Template specialisation used in RooAbsArg:
RooCmdArg ProjWData(const RooAbsData &projData, Bool_t binData=kFALSE)
RooConstVar & RooConst(Double_t val)
RooCmdArg Cut(const char *cutSpec)
RooCmdArg NumCPU(Int_t nCPU, Int_t interleave=0)
RooCmdArg Timer(Bool_t flag=kTRUE)
RooCmdArg Bins(Int_t nbin)
const char * Title
Definition: TXMLSetup.cxx:67
Author
07/2008 - Wouter Verkerke

Definition in file rf603_multicpu.C.