Logo ROOT   6.14/05
Reference Guide
rf902_numgenconfig.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// \notebook -nodraw
4 /// 'NUMERIC ALGORITHM TUNING' RooFit tutorial macro #902
5 ///
6 /// Configuration and customization of how MC sampling algorithms
7 /// on specific p.d.f.s are executed
8 ///
9 /// \macro_output
10 /// \macro_code
11 /// \author 07/2008 - Wouter Verkerke
12 
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 
27 void rf902_numgenconfig()
28 {
29 
30  // 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
31  // ------------------------------------------------------------------
32 
33  // Example p.d.f. for use below
34  RooRealVar x("x","x",0,10) ;
35  RooChebychev model("model","model",x,RooArgList(RooConst(0),RooConst(0.5),RooConst(-0.1))) ;
36 
37 
38  // Change global strategy for 1D sampling problems without conditional observable
39  // (1st kFALSE) and without discrete observable (2nd kFALSE) from RooFoamGenerator,
40  // ( an interface to the TFoam MC generator with adaptive subdivisioning strategy ) to RooAcceptReject,
41  // a plain accept/reject sampling algorithm [ RooFit default before ROOT 5.23/04 ]
43 
44  // Generate 10Kevt using RooAcceptReject
45  RooDataSet* data_ar = model.generate(x,10000,Verbose(kTRUE)) ;
46  data_ar->Print() ;
47 
48 
49  // 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
50  // -------------------------------------------------------------------------------------
51 
52  // Another possibility: associate custom MC sampling configuration as default for object 'model'
53  // The kTRUE argument will install a clone of the default configuration as specialized configuration
54  // for this model if none existed so far
55  model.specialGeneratorConfig(kTRUE)->method1D(kFALSE,kFALSE).setLabel("RooFoamGenerator") ;
56 
57 
58  // 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
59  // ---------------------------------------------------------------------------------------
60 
61  // Adjust maximum number of steps of RooIntegrator1D in the global default configuration
62  RooAbsPdf::defaultGeneratorConfig()->getConfigSection("RooAcceptReject").setRealValue("nTrial1D",2000) ;
63 
64 
65  // Example of how to change the parameters of a numeric integrator
66  // (Each config section is a RooArgSet with RooRealVars holding real-valued parameters
67  // and RooCategories holding parameters with a finite set of options)
68  model.specialGeneratorConfig()->getConfigSection("RooFoamGenerator").setRealValue("chatLevel",1) ;
69 
70  // Generate 10Kevt using RooFoamGenerator (FOAM verbosity increased with above chatLevel adjustment for illustration purposes)
71  RooDataSet* data_foam = model.generate(x,10000,Verbose()) ;
72  data_foam->Print() ;
73 
74 
75 }
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:547
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
Double_t x[n]
Definition: legend1.C:17
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooAbsData.h:159
static RooNumGenConfig * defaultGeneratorConfig()
Returns the default numeric MC generator configuration for all RooAbsReals.
Definition: RooAbsPdf.cxx:3203
RooCmdArg Verbose(Bool_t flag=kTRUE)
RooConstVar & RooConst(Double_t val)
Chebychev polynomial p.d.f.
Definition: RooChebychev.h:25
const Bool_t kTRUE
Definition: RtypesCore.h:87
RooCategory & method1D(Bool_t cond, Bool_t cat)