Logo ROOT   6.16/01
Reference Guide
RooNumGenConfig.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 RooNumGenConfig.cxx
19\class RooNumGenConfig
20\ingroup Roofitcore
21
22RooNumGenConfig 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 "RooNumGenConfig.h"
31#include "RooArgSet.h"
32#include "RooAbsNumGenerator.h"
33#include "RooNumGenFactory.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 _method1D("method1D","1D sampling method"),
82 _method1DCat("method1DCat","1D sampling method for pdfs with categories"),
83 _method1DCond("method1DCond","1D sampling method for conditional pfs"),
84 _method1DCondCat("method1DCond","1D sampling method for conditional pfs with categories"),
85 _method2D("method2D","2D sampling method"),
86 _method2DCat("method2DCat","2D sampling method for pdfs with categories"),
87 _method2DCond("method2DCond","2D sampling method for conditional pfs"),
88 _method2DCondCat("method2DCond","2D sampling method for conditional pfs with categories"),
89 _methodND("methodND","ND sampling method"),
90 _methodNDCat("methodNDCat","ND sampling method for pdfs with categories"),
91 _methodNDCond("methodNDCond","ND sampling method for conditional pfs"),
92 _methodNDCondCat("methodNDCond","ND sampling method for conditional pfs with categories")
93{
94 // Set all methods to undefined
95 // Defined methods will be registered by static initialization routines
96 // of the various numeric integrator engines
97 _method1D.defineType("N/A",0) ;
98 _method1DCat.defineType("N/A",0) ;
99 _method1DCond.defineType("N/A",0) ;
101
102 _method2D.defineType("N/A",0) ;
103 _method2DCat.defineType("N/A",0) ;
104 _method2DCond.defineType("N/A",0) ;
106
107 _methodND.defineType("N/A",0) ;
108 _methodNDCat.defineType("N/A",0) ;
109 _methodNDCond.defineType("N/A",0) ;
111}
112
113
114////////////////////////////////////////////////////////////////////////////////
115/// Destructor
116
118{
119 // Delete all configuration data
121}
122
123
124////////////////////////////////////////////////////////////////////////////////
125/// Copy constructor
126
128 TObject(other), RooPrintable(other),
129 _method1D(other._method1D),
130 _method1DCat(other._method1DCat),
131 _method1DCond(other._method1DCond),
132 _method1DCondCat(other._method1DCondCat),
133 _method2D(other._method2D),
134 _method2DCat(other._method2DCat),
135 _method2DCond(other._method2DCond),
136 _method2DCondCat(other._method2DCondCat),
137 _methodND(other._methodND),
138 _methodNDCat(other._methodNDCat),
139 _methodNDCond(other._methodNDCond),
140 _methodNDCondCat(other._methodNDCondCat)
141{
142 // Clone all configuration dat
143 TIterator* iter = other._configSets.MakeIterator() ;
144 RooArgSet* set ;
145 while((set=(RooArgSet*)iter->Next())) {
146 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
147 setCopy->setName(set->GetName()) ;
148 _configSets.Add(setCopy);
149 }
150 delete iter ;
151}
152
153
154////////////////////////////////////////////////////////////////////////////////
155/// Assignment operator from other RooNumGenConfig
156
158{
159 // Prevent self-assignment
160 if (&other==this) {
161 return *this ;
162 }
163
164 // Copy common properties
169
174
179
180 // Delete old integrator-specific configuration data
182
183 // Copy new integrator-specific data
184 TIterator* iter = other._configSets.MakeIterator() ;
185 RooArgSet* set ;
186 while((set=(RooArgSet*)iter->Next())) {
187 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
188 setCopy->setName(set->GetName()) ;
189 _configSets.Add(setCopy);
190 }
191 delete iter ;
192
193 return *this ;
194}
195
196
197
198
199////////////////////////////////////////////////////////////////////////////////
200
202{
203 if (cond && cat) return _method1DCondCat ;
204 if (cond) return _method1DCond ;
205 if (cat) return _method1DCat ;
206 return _method1D ;
207}
208
209
210
211////////////////////////////////////////////////////////////////////////////////
212
214{
215 if (cond && cat) return _method2DCondCat ;
216 if (cond) return _method2DCond ;
217 if (cat) return _method2DCat ;
218 return _method2D ;
219}
220
221
222
223////////////////////////////////////////////////////////////////////////////////
224
226{
227 if (cond && cat) return _methodNDCondCat ;
228 if (cond) return _methodNDCond ;
229 if (cat) return _methodNDCat ;
230 return _methodND ;
231}
232
233
234
235////////////////////////////////////////////////////////////////////////////////
236
238{
239 return const_cast<RooNumGenConfig*>(this)->method1D(cond,cat) ;
240}
241
242
243
244////////////////////////////////////////////////////////////////////////////////
245
247{
248 return const_cast<RooNumGenConfig*>(this)->method2D(cond,cat) ;
249}
250
251
252
253////////////////////////////////////////////////////////////////////////////////
254
256{
257 return const_cast<RooNumGenConfig*>(this)->methodND(cond,cat) ;
258}
259
260
261
262////////////////////////////////////////////////////////////////////////////////
263/// Add a configuration section for a particular integrator. Integrator name and capabilities are
264/// automatically determined from instance passed as 'proto'. The defaultConfig object is associated
265/// as the default configuration for the integrator.
266
268{
269 TString name = proto->IsA()->GetName() ;
270
271 // Register integrator for appropriate dimensionalities
272
276
277 if (proto->canSampleConditional()) {
281 }
282 if (proto->canSampleCategories()) {
286 }
287
288 if (proto->canSampleConditional() && proto->canSampleCategories()) {
292 }
293
294 // Store default configuration parameters
295 RooArgSet* config = (RooArgSet*) inDefaultConfig.snapshot() ;
296 config->setName(name) ;
297 _configSets.Add(config) ;
298
299 return kFALSE ;
300}
301
302
303
304////////////////////////////////////////////////////////////////////////////////
305/// Return section with configuration parameters for integrator with given (class) name
306
308{
309 return const_cast<RooArgSet&>((const_cast<const RooNumGenConfig*>(this)->getConfigSection(name))) ;
310}
311
312
313////////////////////////////////////////////////////////////////////////////////
314/// Retrieve configuration information specific to integrator with given name
315
317{
318 static RooArgSet dummy ;
320 if (!config) {
321 oocoutE((TObject*)0,InputArguments) << "RooNumGenConfig::getIntegrator: ERROR: no configuration stored for integrator '" << name << "'" << endl ;
322 return dummy ;
323 }
324 return *config ;
325}
326
327
328////////////////////////////////////////////////////////////////////////////////
329
331{
332 if (!opt) {
333 return kStandard ;
334 }
335
336 TString o(opt) ;
337 o.ToLower() ;
338
339 if (o.Contains("v")) {
340 return kVerbose ;
341 }
342 return kStandard ;
343}
344
345
346
347////////////////////////////////////////////////////////////////////////////////
348/// Detailed printing interface
349
350void RooNumGenConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verbose, TString indent) const
351{
352 os << endl ;
353 os << indent << "1-D sampling method: " << _method1D.getLabel() << endl ;
355 os << " (" << _method1DCat.getLabel() << " if with categories)" << endl ;
356 }
358 os << " (" << _method1DCond.getLabel() << " if conditional)" << endl ;
359 }
361 os << " (" << _method1DCondCat.getLabel() << " if conditional with categories)" << endl ;
362 }
363 os << endl ;
364
365 os << indent << "2-D sampling method: " << _method2D.getLabel() << endl ;
367 os << " (" << _method2DCat.getLabel() << " if with categories)" << endl ;
368 }
370 os << " (" << _method2DCond.getLabel() << " if conditional)" << endl ;
371 }
373 os << " (" << _method2DCondCat.getLabel() << " if conditional with categories)" << endl ;
374 }
375 os << endl ;
376
377 os << indent << "N-D sampling method: " << _methodND.getLabel() << endl ;
379 os << " (" << _methodNDCat.getLabel() << " if with categories)" << endl ;
380 }
382 os << " (" << _methodNDCond.getLabel() << " if conditional)" << endl ;
383 }
385 os << " (" << _methodNDCondCat.getLabel() << " if conditional with categories)" << endl ;
386 }
387 os << endl ;
388
389 if (verbose) {
390
391 os << endl << "Available sampling methods:" << endl << endl ;
393 RooArgSet* configSet ;
394 while ((configSet=(RooArgSet*)cIter->Next())) {
395
396 os << indent << "*** " << configSet->GetName() << " ***" << endl ;
397 os << indent << "Capabilities: " ;
399 if (proto->canSampleConditional()) os << "[Conditional] " ;
400 if (proto->canSampleCategories()) os << "[Categories] " ;
401 os << endl ;
402
403 os << "Configuration: " << endl ;
404 configSet->printMultiline(os,kName|kValue|kTitle) ;
405 os << endl ;
406
407 }
408
409 delete cIter ;
410 }
411}
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
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
const char * proto
Definition: civetweb.c:16604
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multiline printin of collection, one line for each ontained object showing the requested co...
const char * GetName() const
Returns name of object.
void setName(const char *name)
Class RooAbsNumGenerator is the abstract base class for MC event generator implementations like RooAc...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
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 dir=kTRUE) const
Return an iterator over 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:62
RooNumGenConfig holds the configuration parameters of the various numeric integrators used by RooReal...
RooCategory & method2D(Bool_t cond, Bool_t cat)
RooCategory _methodND
RooCategory _methodNDCondCat
static RooNumGenConfig & defaultConfig()
Return reference to instance of default numeric integrator configuration object.
virtual ~RooNumGenConfig()
Destructor.
RooNumGenConfig()
Constructor.
RooCategory _method2D
RooCategory _method1DCondCat
RooCategory _method2DCat
RooCategory _method1DCond
RooCategory _method2DCondCat
virtual StyleOption defaultPrintStyle(Option_t *opt) const
RooCategory & methodND(Bool_t cond, Bool_t cat)
RooCategory _method1DCat
Bool_t addConfigSection(const RooAbsNumGenerator *proto, const RooArgSet &defaultConfig)
Add a configuration section for a particular integrator.
static RooNumGenConfig * _default
RooCategory & method1D(Bool_t cond, Bool_t cat)
static void cleanup()
Function called by atexit() handler installed by RooSentinel to cleanup global objects at end of job.
RooCategory _method1D
RooCategory _method2DCond
RooLinkedList _configSets
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooNumGenConfig & operator=(const RooNumGenConfig &other)
Assignment operator from other RooNumGenConfig.
RooCategory _methodNDCat
RooCategory _methodNDCond
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose, TString indent="") const
Detailed printing interface.
static RooNumGenFactory & instance()
Static method returning reference to singleton instance of factory.
const RooAbsNumGenerator * getProtoSampler(const char *name)
Return prototype integrator with given (class) name.
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
@ InputArguments
Definition: RooGlobalFunc.h:58
STL namespace.