Rf 9 0 2_Numgenconfig

Numeric algorithm tuning: configuration and customization of how MC sampling algorithms on specific p.d.f.s are executed

Author: Clemens Lange, Wouter Verkerke (C++ version)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Sunday, July 05, 2020 at 08:40 AM.

In [ ]:
import ROOT

Adjust global MC sampling strategy

Example p.d.f. for use below

In [ ]:
x = ROOT.RooRealVar("x", "x", 0, 10)
model = ROOT.RooChebychev("model", "model", x, ROOT.RooArgList(
    ROOT.RooFit.RooConst(0), ROOT.RooFit.RooConst(0.5), ROOT.RooFit.RooConst(-0.1)))

Change global strategy for 1D sampling problems without conditional observable (1st kFALSE) and without discrete observable (2nd kFALSE) from ROOT.RooFoamGenerator, ( an interface to the ROOT.TFoam MC generator with adaptive subdivisioning strategy ) to ROOT.RooAcceptReject, a plain accept/reject sampling algorithm [ ROOT.RooFit default before ROOT 5.23/04 ]

In [ ]:
ROOT.RooAbsPdf.defaultGeneratorConfig().method1D(
    ROOT.kFALSE, ROOT.kFALSE).setLabel("RooAcceptReject")

Generate 10Kevt using ROOT.RooAcceptReject

In [ ]:
data_ar = model.generate(ROOT.RooArgSet(
    x), 10000, ROOT.RooFit.Verbose(ROOT.kTRUE))
data_ar.Print()

Adjusting default config for a specific pdf

Another possibility: associate custom MC sampling configuration as default for object 'model' The kTRUE argument will install a clone of the default configuration as specialized configuration for self model if none existed so far

In [ ]:
model.specialGeneratorConfig(ROOT.kTRUE).method1D(
    ROOT.kFALSE, ROOT.kFALSE).setLabel("RooFoamGenerator")

Adjusting parameters of a specific technique

Adjust maximum number of steps of ROOT.RooIntegrator1D in the global default configuration

In [ ]:
ROOT.RooAbsPdf.defaultGeneratorConfig().getConfigSection(
    "RooAcceptReject").setRealValue("nTrial1D", 2000)

Example of how to change the parameters of a numeric integrator (Each config section is a ROOT.RooArgSet with ROOT.RooRealVars holding real-valued parameters and ROOT.RooCategories holding parameters with a finite set of options)

In [ ]:
model.specialGeneratorConfig().getConfigSection(
    "RooFoamGenerator").setRealValue("chatLevel", 1)

Generate 10Kevt using ROOT.RooFoamGenerator (FOAM verbosity increased with above chatLevel adjustment for illustration purposes)

In [ ]:
data_foam = model.generate(ROOT.RooArgSet(x), 10000, ROOT.RooFit.Verbose())
data_foam.Print()