Logo ROOT  
Reference Guide
rf902_numgenconfig.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// \notebook -nodraw
4 ///
5 /// Numeric algorithm tuning: configuration and customization of how MC sampling algorithms on specific p.d.f.s are
6 /// executed
7 ///
8 /// \macro_output
9 /// \macro_code
10 ///
11 /// \date 07/2008
12 /// \author Wouter Verkerke
13 
14 #include "RooRealVar.h"
15 #include "RooDataSet.h"
16 #include "RooConstVar.h"
17 #include "RooChebychev.h"
18 #include "TCanvas.h"
19 #include "TAxis.h"
20 #include "RooPlot.h"
21 #include "RooNumGenConfig.h"
22 #include "RooArgSet.h"
23 #include <iomanip>
24 using namespace RooFit;
25 
26 void rf902_numgenconfig()
27 {
28 
29  // A d j u s t g l o b a l MC s a m p l i n g s t r a t e g y
30  // ------------------------------------------------------------------
31 
32  // Example p.d.f. for use below
33  RooRealVar x("x", "x", 0, 10);
34  RooChebychev model("model", "model", x, RooArgList(RooConst(0), RooConst(0.5), RooConst(-0.1)));
35 
36  // Change global strategy for 1D sampling problems without conditional observable
37  // (1st kFALSE) and without discrete observable (2nd kFALSE) from RooFoamGenerator,
38  // ( an interface to the TFoam MC generator with adaptive subdivisioning strategy ) to RooAcceptReject,
39  // a plain accept/reject sampling algorithm [ RooFit default before ROOT 5.23/04 ]
41 
42  // Generate 10Kevt using RooAcceptReject
43  RooDataSet *data_ar = model.generate(x, 10000, Verbose(kTRUE));
44  data_ar->Print();
45 
46  // A d j u s t i n g d e f a u l t c o n f i g f o r a s p e c i f i c p d f
47  // -------------------------------------------------------------------------------------
48 
49  // Another possibility: associate custom MC sampling configuration as default for object 'model'
50  // The kTRUE argument will install a clone of the default configuration as specialized configuration
51  // for this model if none existed so far
52  model.specialGeneratorConfig(kTRUE)->method1D(kFALSE, kFALSE).setLabel("RooFoamGenerator");
53 
54  // A d j u s t i n g p a r a m e t e r s o f a s p e c i f i c t e c h n i q u e
55  // ---------------------------------------------------------------------------------------
56 
57  // Adjust maximum number of steps of RooIntegrator1D in the global default configuration
58  RooAbsPdf::defaultGeneratorConfig()->getConfigSection("RooAcceptReject").setRealValue("nTrial1D", 2000);
59 
60  // Example of how to change the parameters of a numeric integrator
61  // (Each config section is a RooArgSet with RooRealVars holding real-valued parameters
62  // and RooCategories holding parameters with a finite set of options)
63  model.specialGeneratorConfig()->getConfigSection("RooFoamGenerator").setRealValue("chatLevel", 1);
64 
65  // Generate 10Kevt using RooFoamGenerator (FOAM verbosity increased with above chatLevel adjustment for illustration
66  // purposes)
67  RooDataSet *data_foam = model.generate(x, 10000, Verbose());
68  data_foam->Print();
69 }
RooArgSet::setRealValue
Bool_t setRealValue(const char *name, Double_t newVal=0, Bool_t verbose=kFALSE)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
Definition: RooArgSet.cxx:495
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooChebychev.h
RooArgSet.h
RooChebychev
Definition: RooChebychev.h:25
RooArgList
Definition: RooArgList.h:21
RooAbsData::Print
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooAbsData.h:177
x
Double_t x[n]
Definition: legend1.C:17
RooAbsPdf::defaultGeneratorConfig
static RooNumGenConfig * defaultGeneratorConfig()
Returns the default numeric MC generator configuration for all RooAbsReals.
Definition: RooAbsPdf.cxx:3517
TCanvas.h
RooDataSet.h
RooCategory::setLabel
virtual Bool_t setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
Definition: RooCategory.cxx:185
RooFit
Definition: RooCFunction1Binding.h:29
RooFit::Verbose
RooCmdArg Verbose(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:186
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooPlot.h
RooNumGenConfig::method1D
RooCategory & method1D(Bool_t cond, Bool_t cat)
Definition: RooNumGenConfig.cxx:180
RooRealVar.h
RooNumGenConfig::getConfigSection
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
Definition: RooNumGenConfig.cxx:295
rf902_numgenconfig
Definition: rf902_numgenconfig.py:1
RooConstVar.h
TAxis.h
RooNumGenConfig.h
RooDataSet
Definition: RooDataSet.h:33
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooRealVar
Definition: RooRealVar.h:35
RooFit::RooConst
RooConstVar & RooConst(Double_t val)
Definition: RooGlobalFunc.cxx:341