Logo ROOT   6.18/05
Reference Guide
RooNumIntConfig.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooNumIntConfig.cxx
19\class RooNumIntConfig
20\ingroup Roofitcore
21
22RooNumIntConfig holds the configuration parameters of the various
23numeric integrators used by RooRealIntegral. RooRealIntegral and RooAbsPdf
24use this class in the (normalization) integral configuration interface
25**/
26
27#include "RooFit.h"
28#include "Riostream.h"
29
30#include "RooNumIntConfig.h"
31#include "RooArgSet.h"
32#include "RooAbsIntegrator.h"
33#include "RooNumIntFactory.h"
34#include "RooMsgService.h"
35
36#include "TClass.h"
37
38
39
40using namespace std;
41
43;
44
46
47
48////////////////////////////////////////////////////////////////////////////////
49/// Function called by atexit() handler installed by RooSentinel to
50/// cleanup global objects at end of job
51
53{
54 if (_default) {
55 delete _default ;
56 _default = 0 ;
57 }
58}
59
60
61
62////////////////////////////////////////////////////////////////////////////////
63/// Return reference to instance of default numeric integrator configuration object
64
66{
67 // Instantiate object if it doesn't exist yet
68 if (_default==0) {
71 }
72 return *_default ;
73}
74
75
76
77////////////////////////////////////////////////////////////////////////////////
78/// Constructor
79
81 _epsAbs(1e-7),
82 _epsRel(1e-7),
83 _printEvalCounter(kFALSE),
84 _method1D("method1D","1D integration method"),
85 _method2D("method2D","2D integration method"),
86 _methodND("methodND","ND integration method"),
87 _method1DOpen("method1DOpen","1D integration method in open domain"),
88 _method2DOpen("method2DOpen","2D integration method in open domain"),
89 _methodNDOpen("methodNDOpen","ND integration method in open domain")
90{
91 // Set all methods to undefined
92 // Defined methods will be registered by static initialization routines
93 // of the various numeric integrator engines
94 _method1D.defineType("N/A",0) ;
95 _method2D.defineType("N/A",0) ;
96 _methodND.defineType("N/A",0) ;
97 _method1DOpen.defineType("N/A",0) ;
98 _method2DOpen.defineType("N/A",0) ;
99 _methodNDOpen.defineType("N/A",0) ;
100}
101
102
103////////////////////////////////////////////////////////////////////////////////
104/// Destructor
105
107{
108 // Delete all configuration data
110}
111
112
113////////////////////////////////////////////////////////////////////////////////
114/// Copy constructor
115
117 TObject(other), RooPrintable(other),
118 _epsAbs(other._epsAbs),
119 _epsRel(other._epsRel),
120 _printEvalCounter(other._printEvalCounter),
121 _method1D(other._method1D),
122 _method2D(other._method2D),
123 _methodND(other._methodND),
124 _method1DOpen(other._method1DOpen),
125 _method2DOpen(other._method2DOpen),
126 _methodNDOpen(other._methodNDOpen)
127{
128 // Clone all configuration dat
129 TIterator* iter = other._configSets.MakeIterator() ;
130 RooArgSet* set ;
131 while((set=(RooArgSet*)iter->Next())) {
132 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
133 setCopy->setName(set->GetName()) ;
134 _configSets.Add(setCopy);
135 }
136 delete iter ;
137}
138
139
140////////////////////////////////////////////////////////////////////////////////
141/// Assignment operator from other RooNumIntConfig
142
144{
145 // Prevent self-assignment
146 if (&other==this) {
147 return *this ;
148 }
149
150 // Copy common properties
151 _epsAbs = other._epsAbs ;
152 _epsRel = other._epsRel ;
159
160 // Delete old integrator-specific configuration data
162
163 // Copy new integrator-specific data
164 TIterator* iter = other._configSets.MakeIterator() ;
165 RooArgSet* set ;
166 while((set=(RooArgSet*)iter->Next())) {
167 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
168 setCopy->setName(set->GetName()) ;
169 _configSets.Add(setCopy);
170 }
171 delete iter ;
172
173 return *this ;
174}
175
176
177
178////////////////////////////////////////////////////////////////////////////////
179/// Add a configuration section for a particular integrator. Integrator name and capabilities are
180/// automatically determined from instance passed as 'proto'. The defaultConfig object is associated
181/// as the default configuration for the integrator.
182
184{
185 TString name = proto->IsA()->GetName() ;
186
187 // Register integrator for appropriate dimensionalities
188 if (proto->canIntegrate1D()) {
190 if (proto->canIntegrateOpenEnded()) {
192 }
193 }
194
195 if (proto->canIntegrate2D()) {
197 if (proto->canIntegrateOpenEnded()) {
199 }
200 }
201
202 if (proto->canIntegrateND()) {
204 if (proto->canIntegrateOpenEnded()) {
206 }
207 }
208
209 // Store default configuration parameters
210 RooArgSet* config = (RooArgSet*) inDefaultConfig.snapshot() ;
211 config->setName(name) ;
212 _configSets.Add(config) ;
213
214 return kFALSE ;
215}
216
217
218
219////////////////////////////////////////////////////////////////////////////////
220/// Return section with configuration parameters for integrator with given (class) name
221
223{
224 return const_cast<RooArgSet&>((const_cast<const RooNumIntConfig*>(this)->getConfigSection(name))) ;
225}
226
227
228////////////////////////////////////////////////////////////////////////////////
229/// Retrieve configuration information specific to integrator with given name
230
232{
233 static RooArgSet dummy ;
235 if (!config) {
236 oocoutE((TObject*)0,InputArguments) << "RooNumIntConfig::getIntegrator: ERROR: no configuration stored for integrator '" << name << "'" << endl ;
237 return dummy ;
238 }
239 return *config ;
240}
241
242
243
244////////////////////////////////////////////////////////////////////////////////
245/// Set absolute convergence criteria (convergence if abs(Err)<newEpsAbs)
246
248{
249 if (newEpsAbs<0) {
250 oocoutE((TObject*)0,InputArguments) << "RooNumIntConfig::setEpsAbs: ERROR: target absolute precision must be greater or equal than zero" << endl ;
251 return ;
252 }
253 _epsAbs = newEpsAbs ;
254}
255
256
258{
259 if (!opt) {
260 return kStandard ;
261 }
262
263 TString o(opt) ;
264 o.ToLower() ;
265
266 if (o.Contains("v")) {
267 return kVerbose ;
268 }
269 return kStandard ;
270}
271
272
273
274////////////////////////////////////////////////////////////////////////////////
275/// Set relative convergence criteria (convergence if abs(Err)/abs(Int)<newEpsRel)
276
278{
279 if (newEpsRel<0) {
280 oocoutE((TObject*)0,InputArguments) << "RooNumIntConfig::setEpsRel: ERROR: target absolute precision must be greater or equal than zero" << endl ;
281 return ;
282 }
283 _epsRel = newEpsRel ;
284}
285
286
287
288////////////////////////////////////////////////////////////////////////////////
289/// Detailed printing interface
290
291void RooNumIntConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verbose, TString indent) const
292{
293 os << indent << "Requested precision: " << _epsAbs << " absolute, " << _epsRel << " relative" << endl << endl ;
294 if (_printEvalCounter) {
295 os << indent << "Printing of function evaluation counter for each integration enabled" << endl << endl ;
296 }
297
298 os << indent << "1-D integration method: " << _method1D.getLabel() ;
300 os << " (" << _method1DOpen.getLabel() << " if open-ended)" << endl ;
301 } else {
302 os << endl ;
303 }
304 os << indent << "2-D integration method: " << _method2D.getLabel() ;
306 os << " (" << _method2DOpen.getLabel() << " if open-ended)" << endl ;
307 } else {
308 os << endl ;
309 }
310 os << indent << "N-D integration method: " << _methodND.getLabel() ;
312 os << " (" << _methodNDOpen.getLabel() << " if open-ended)" << endl ;
313 } else {
314 os << endl ;
315 }
316
317 if (verbose) {
318
319 os << endl << "Available integration methods:" << endl << endl ;
321 RooArgSet* configSet ;
322 while ((configSet=(RooArgSet*)cIter->Next())) {
323
324 os << indent << "*** " << configSet->GetName() << " ***" << endl ;
325 os << indent << "Capabilities: " ;
327 if (proto->canIntegrate1D()) os << "[1-D] " ;
328 if (proto->canIntegrate2D()) os << "[2-D] " ;
329 if (proto->canIntegrateND()) os << "[N-D] " ;
330 if (proto->canIntegrateOpenEnded()) os << "[OpenEnded] " ;
331 os << endl ;
332
333 os << "Configuration: " << endl ;
334 configSet->printMultiline(os,kName|kValue) ;
335 //configSet->writeToStream(os,kFALSE) ;
336
337 const char* depName = RooNumIntFactory::instance().getDepIntegratorName(configSet->GetName()) ;
338 if (strlen(depName)>0) {
339 os << indent << "(Depends on '" << depName << "')" << endl ;
340 }
341 os << endl ;
342
343 }
344
345 delete cIter ;
346 }
347}
#define e(i)
Definition: RSha256.hxx:103
static RooMathCoreReg dummy
#define oocoutE(o, a)
Definition: RooMsgService.h:47
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition: TGX11.cxx:109
const char * proto
Definition: civetweb.c:16604
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multiline printing of collection, one line for each contained object showing the requested ...
const char * GetName() const
Returns name of object.
void setName(const char *name)
RooAbsIntegrator is the abstract interface for integrators of real-valued functions that implement th...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:134
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:39
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index.
virtual Int_t getIndex() const
Return index number of current state.
Definition: RooCategory.h:34
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:63
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
RooCategory _method1D
RooCategory _method1DOpen
void setEpsAbs(Double_t newEpsAbs)
Set absolute convergence criteria (convergence if abs(Err)<newEpsAbs)
Bool_t _printEvalCounter
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose, TString indent="") const
Detailed printing interface.
RooNumIntConfig()
Constructor.
RooLinkedList _configSets
virtual StyleOption defaultPrintStyle(Option_t *opt) const
RooCategory _methodND
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooCategory _methodNDOpen
void setEpsRel(Double_t newEpsRel)
Set relative convergence criteria (convergence if abs(Err)/abs(Int)<newEpsRel)
static RooNumIntConfig * _default
static void cleanup()
Function called by atexit() handler installed by RooSentinel to cleanup global objects at end of job.
RooCategory _method2D
Bool_t addConfigSection(const RooAbsIntegrator *proto, const RooArgSet &defaultConfig)
Add a configuration section for a particular integrator.
RooCategory _method2DOpen
RooNumIntConfig & operator=(const RooNumIntConfig &other)
Assignment operator from other RooNumIntConfig.
static RooNumIntConfig & defaultConfig()
Return reference to instance of default numeric integrator configuration object.
virtual ~RooNumIntConfig()
Destructor.
const char * getDepIntegratorName(const char *name)
Get list of class names of integrators needed by integrator named 'name'.
const RooAbsIntegrator * getProtoIntegrator(const char *name)
Return prototype integrator with given (class) name.
static RooNumIntFactory & instance()
Static method returning reference to singleton instance of factory.
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
Iterator abstract base class.
Definition: TIterator.h:30
virtual TObject * Next()=0
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
@ InputArguments
Definition: RooGlobalFunc.h:58