Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rf902_numgenconfig.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roofit
3/// \notebook -nodraw
4/// Numeric algorithm tuning: configuration and customization of how MC sampling algorithms on specific pdfs are
5/// executed
6///
7/// \macro_output
8/// \macro_code
9///
10/// \date July 2008
11/// \author Wouter Verkerke
12
13#include "RooRealVar.h"
14#include "RooDataSet.h"
15#include "RooConstVar.h"
16#include "RooChebychev.h"
17#include "TCanvas.h"
18#include "TAxis.h"
19#include "RooPlot.h"
20#include "RooNumGenConfig.h"
21#include "RooArgSet.h"
22#include <iomanip>
23using namespace RooFit;
24
26{
27
28 // 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
29 // ------------------------------------------------------------------
30
31 // Example pdf for use below
32 RooRealVar x("x", "x", 0, 10);
33 RooChebychev model("model", "model", x, RooArgList(RooConst(0), RooConst(0.5), RooConst(-0.1)));
34
35 // Change global strategy for 1D sampling problems without conditional observable
36 // (1st kFALSE) and without discrete observable (2nd kFALSE) from RooFoamGenerator,
37 // ( an interface to the TFoam MC generator with adaptive subdivisioning strategy ) to RooAcceptReject,
38 // a plain accept/reject sampling algorithm [ RooFit default before ROOT 5.23/04 ]
40
41 // Generate 10Kevt using RooAcceptReject
42 RooDataSet *data_ar = model.generate(x, 10000, Verbose(kTRUE));
43 data_ar->Print();
44
45 // 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
46 // -------------------------------------------------------------------------------------
47
48 // Another possibility: associate custom MC sampling configuration as default for object 'model'
49 // The kTRUE argument will install a clone of the default configuration as specialized configuration
50 // for this model if none existed so far
51 model.specialGeneratorConfig(kTRUE)->method1D(kFALSE, kFALSE).setLabel("RooFoamGenerator");
52
53 // 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
54 // ---------------------------------------------------------------------------------------
55
56 // Adjust maximum number of steps of RooIntegrator1D in the global default configuration
57 RooAbsPdf::defaultGeneratorConfig()->getConfigSection("RooAcceptReject").setRealValue("nTrial1D", 2000);
58
59 // Example of how to change the parameters of a numeric integrator
60 // (Each config section is a RooArgSet with RooRealVars holding real-valued parameters
61 // and RooCategories holding parameters with a finite set of options)
62 model.specialGeneratorConfig()->getConfigSection("RooFoamGenerator").setRealValue("chatLevel", 1);
63
64 // Generate 10Kevt using RooFoamGenerator (FOAM verbosity increased with above chatLevel adjustment for illustration
65 // purposes)
66 RooDataSet *data_foam = model.generate(x, 10000, Verbose());
67 data_foam->Print();
68}
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
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...
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition RooAbsData.h:193
static RooNumGenConfig * defaultGeneratorConfig()
Returns the default numeric MC generator configuration for all RooAbsReals.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:21
virtual Bool_t setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
Chebychev polynomial p.d.f.
RooDataSet is a container class to hold unbinned data.
Definition RooDataSet.h:33
RooCategory & method1D(Bool_t cond, Bool_t cat)
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
RooConstVar & RooConst(Double_t val)
RooCmdArg Verbose(Bool_t flag=kTRUE)
Double_t x[n]
Definition legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...