Logo ROOT  
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
45////////////////////////////////////////////////////////////////////////////////
46/// Return reference to instance of default numeric integrator configuration object
47
49{
51 return defaultConfig;
52}
53
54
55
56////////////////////////////////////////////////////////////////////////////////
57/// Constructor
58
60 _method1D("method1D","1D sampling method"),
61 _method1DCat("method1DCat","1D sampling method for pdfs with categories"),
62 _method1DCond("method1DCond","1D sampling method for conditional pfs"),
63 _method1DCondCat("method1DCond","1D sampling method for conditional pfs with categories"),
64 _method2D("method2D","2D sampling method"),
65 _method2DCat("method2DCat","2D sampling method for pdfs with categories"),
66 _method2DCond("method2DCond","2D sampling method for conditional pfs"),
67 _method2DCondCat("method2DCond","2D sampling method for conditional pfs with categories"),
68 _methodND("methodND","ND sampling method"),
69 _methodNDCat("methodNDCat","ND sampling method for pdfs with categories"),
70 _methodNDCond("methodNDCond","ND sampling method for conditional pfs"),
71 _methodNDCondCat("methodNDCond","ND sampling method for conditional pfs with categories")
72{
73 // Set all methods to undefined
74 // Defined methods will be registered by static initialization routines
75 // of the various numeric integrator engines
76 _method1D.defineType("N/A",0) ;
77 _method1DCat.defineType("N/A",0) ;
78 _method1DCond.defineType("N/A",0) ;
80
81 _method2D.defineType("N/A",0) ;
82 _method2DCat.defineType("N/A",0) ;
83 _method2DCond.defineType("N/A",0) ;
85
86 _methodND.defineType("N/A",0) ;
87 _methodNDCat.defineType("N/A",0) ;
88 _methodNDCond.defineType("N/A",0) ;
90}
91
92
93////////////////////////////////////////////////////////////////////////////////
94/// Destructor
95
97{
98 // Delete all configuration data
100}
101
102
103////////////////////////////////////////////////////////////////////////////////
104/// Copy constructor
105
107 TObject(other), RooPrintable(other),
108 _method1D(other._method1D),
109 _method1DCat(other._method1DCat),
110 _method1DCond(other._method1DCond),
111 _method1DCondCat(other._method1DCondCat),
112 _method2D(other._method2D),
113 _method2DCat(other._method2DCat),
114 _method2DCond(other._method2DCond),
115 _method2DCondCat(other._method2DCondCat),
116 _methodND(other._methodND),
117 _methodNDCat(other._methodNDCat),
118 _methodNDCond(other._methodNDCond),
119 _methodNDCondCat(other._methodNDCondCat)
120{
121 // Clone all configuration dat
122 TIterator* iter = other._configSets.MakeIterator() ;
123 RooArgSet* set ;
124 while((set=(RooArgSet*)iter->Next())) {
125 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
126 setCopy->setName(set->GetName()) ;
127 _configSets.Add(setCopy);
128 }
129 delete iter ;
130}
131
132
133////////////////////////////////////////////////////////////////////////////////
134/// Assignment operator from other RooNumGenConfig
135
137{
138 // Prevent self-assignment
139 if (&other==this) {
140 return *this ;
141 }
142
143 // Copy common properties
148
153
158
159 // Delete old integrator-specific configuration data
161
162 // Copy new integrator-specific data
163 TIterator* iter = other._configSets.MakeIterator() ;
164 RooArgSet* set ;
165 while((set=(RooArgSet*)iter->Next())) {
166 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
167 setCopy->setName(set->GetName()) ;
168 _configSets.Add(setCopy);
169 }
170 delete iter ;
171
172 return *this ;
173}
174
175
176
177
178////////////////////////////////////////////////////////////////////////////////
179
181{
182 if (cond && cat) return _method1DCondCat ;
183 if (cond) return _method1DCond ;
184 if (cat) return _method1DCat ;
185 return _method1D ;
186}
187
188
189
190////////////////////////////////////////////////////////////////////////////////
191
193{
194 if (cond && cat) return _method2DCondCat ;
195 if (cond) return _method2DCond ;
196 if (cat) return _method2DCat ;
197 return _method2D ;
198}
199
200
201
202////////////////////////////////////////////////////////////////////////////////
203
205{
206 if (cond && cat) return _methodNDCondCat ;
207 if (cond) return _methodNDCond ;
208 if (cat) return _methodNDCat ;
209 return _methodND ;
210}
211
212
213
214////////////////////////////////////////////////////////////////////////////////
215
217{
218 return const_cast<RooNumGenConfig*>(this)->method1D(cond,cat) ;
219}
220
221
222
223////////////////////////////////////////////////////////////////////////////////
224
226{
227 return const_cast<RooNumGenConfig*>(this)->method2D(cond,cat) ;
228}
229
230
231
232////////////////////////////////////////////////////////////////////////////////
233
235{
236 return const_cast<RooNumGenConfig*>(this)->methodND(cond,cat) ;
237}
238
239
240
241////////////////////////////////////////////////////////////////////////////////
242/// Add a configuration section for a particular integrator. Integrator name and capabilities are
243/// automatically determined from instance passed as 'proto'. The defaultConfig object is associated
244/// as the default configuration for the integrator.
245
247{
248 TString name = proto->IsA()->GetName() ;
249
250 // Register integrator for appropriate dimensionalities
251
255
256 if (proto->canSampleConditional()) {
260 }
261 if (proto->canSampleCategories()) {
265 }
266
267 if (proto->canSampleConditional() && proto->canSampleCategories()) {
271 }
272
273 // Store default configuration parameters
274 RooArgSet* config = (RooArgSet*) inDefaultConfig.snapshot() ;
275 config->setName(name) ;
276 _configSets.Add(config) ;
277
278 return kFALSE ;
279}
280
281
282
283////////////////////////////////////////////////////////////////////////////////
284/// Return section with configuration parameters for integrator with given (class) name
285
287{
288 return const_cast<RooArgSet&>((const_cast<const RooNumGenConfig*>(this)->getConfigSection(name))) ;
289}
290
291
292////////////////////////////////////////////////////////////////////////////////
293/// Retrieve configuration information specific to integrator with given name
294
296{
297 static RooArgSet dummy ;
299 if (!config) {
300 oocoutE((TObject*)0,InputArguments) << "RooNumGenConfig::getIntegrator: ERROR: no configuration stored for integrator '" << name << "'" << endl ;
301 return dummy ;
302 }
303 return *config ;
304}
305
306
307////////////////////////////////////////////////////////////////////////////////
308
310{
311 if (!opt) {
312 return kStandard ;
313 }
314
315 TString o(opt) ;
316 o.ToLower() ;
317
318 if (o.Contains("v")) {
319 return kVerbose ;
320 }
321 return kStandard ;
322}
323
324
325
326////////////////////////////////////////////////////////////////////////////////
327/// Detailed printing interface
328
329void RooNumGenConfig::printMultiline(ostream &os, Int_t /*content*/, Bool_t verbose, TString indent) const
330{
331 os << endl ;
332 os << indent << "1-D sampling method: " << _method1D.getLabel() << endl ;
334 os << " (" << _method1DCat.getLabel() << " if with categories)" << endl ;
335 }
337 os << " (" << _method1DCond.getLabel() << " if conditional)" << endl ;
338 }
340 os << " (" << _method1DCondCat.getLabel() << " if conditional with categories)" << endl ;
341 }
342 os << endl ;
343
344 os << indent << "2-D sampling method: " << _method2D.getLabel() << endl ;
346 os << " (" << _method2DCat.getLabel() << " if with categories)" << endl ;
347 }
349 os << " (" << _method2DCond.getLabel() << " if conditional)" << endl ;
350 }
352 os << " (" << _method2DCondCat.getLabel() << " if conditional with categories)" << endl ;
353 }
354 os << endl ;
355
356 os << indent << "N-D sampling method: " << _methodND.getLabel() << endl ;
358 os << " (" << _methodNDCat.getLabel() << " if with categories)" << endl ;
359 }
361 os << " (" << _methodNDCond.getLabel() << " if conditional)" << endl ;
362 }
364 os << " (" << _methodNDCondCat.getLabel() << " if conditional with categories)" << endl ;
365 }
366 os << endl ;
367
368 if (verbose) {
369
370 os << endl << "Available sampling methods:" << endl << endl ;
372 RooArgSet* configSet ;
373 while ((configSet=(RooArgSet*)cIter->Next())) {
374
375 os << indent << "*** " << configSet->GetName() << " ***" << endl ;
376 os << indent << "Capabilities: " ;
378 if (proto->canSampleConditional()) os << "[Conditional] " ;
379 if (proto->canSampleCategories()) os << "[Categories] " ;
380 os << endl ;
381
382 os << "Configuration: " << endl ;
383 configSet->printMultiline(os,kName|kValue|kTitle) ;
384 os << endl ;
385
386 }
387
388 delete cIter ;
389 }
390}
static RooMathCoreReg dummy
#define oocoutE(o, a)
Definition: RooMsgService.h:49
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: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)
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
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:134
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 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
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.
RooCategory & method1D(Bool_t cond, Bool_t cat)
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
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:68