42 ClassImp(RooNumGenConfig);
48 RooNumGenConfig& RooNumGenConfig::defaultConfig()
50 static RooNumGenConfig defaultConfig;
59 RooNumGenConfig::RooNumGenConfig() :
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")
76 _method1D.defineType(
"N/A",0) ;
77 _method1DCat.defineType(
"N/A",0) ;
78 _method1DCond.defineType(
"N/A",0) ;
79 _method1DCondCat.defineType(
"N/A",0) ;
81 _method2D.defineType(
"N/A",0) ;
82 _method2DCat.defineType(
"N/A",0) ;
83 _method2DCond.defineType(
"N/A",0) ;
84 _method2DCondCat.defineType(
"N/A",0) ;
86 _methodND.defineType(
"N/A",0) ;
87 _methodNDCat.defineType(
"N/A",0) ;
88 _methodNDCond.defineType(
"N/A",0) ;
89 _methodNDCondCat.defineType(
"N/A",0) ;
96 RooNumGenConfig::~RooNumGenConfig()
99 _configSets.Delete() ;
106 RooNumGenConfig::RooNumGenConfig(
const RooNumGenConfig& other) :
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)
122 TIterator* iter = other._configSets.MakeIterator() ;
124 while((set=(RooArgSet*)iter->Next())) {
125 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
126 setCopy->setName(set->GetName()) ;
127 _configSets.Add(setCopy);
136 RooNumGenConfig& RooNumGenConfig::operator=(
const RooNumGenConfig& other)
144 _method1D.setIndex(other._method1D.getIndex()) ;
145 _method1DCat.setIndex(other._method1DCat.getIndex()) ;
146 _method1DCond.setIndex(other._method1DCond.getIndex()) ;
147 _method1DCondCat.setIndex(other._method1DCondCat.getIndex()) ;
149 _method2D.setIndex(other._method2D.getIndex()) ;
150 _method2DCat.setIndex(other._method2DCat.getIndex()) ;
151 _method2DCond.setIndex(other._method2DCond.getIndex()) ;
152 _method2DCondCat.setIndex(other._method2DCondCat.getIndex()) ;
154 _methodND.setIndex(other._methodND.getIndex()) ;
155 _methodNDCat.setIndex(other._methodNDCat.getIndex()) ;
156 _methodNDCond.setIndex(other._methodNDCond.getIndex()) ;
157 _methodNDCondCat.setIndex(other._methodNDCondCat.getIndex()) ;
160 _configSets.Delete() ;
163 TIterator* iter = other._configSets.MakeIterator() ;
165 while((set=(RooArgSet*)iter->Next())) {
166 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
167 setCopy->setName(set->GetName()) ;
168 _configSets.Add(setCopy);
180 RooCategory& RooNumGenConfig::method1D(Bool_t cond, Bool_t cat)
182 if (cond && cat)
return _method1DCondCat ;
183 if (cond)
return _method1DCond ;
184 if (cat)
return _method1DCat ;
192 RooCategory& RooNumGenConfig::method2D(Bool_t cond, Bool_t cat)
194 if (cond && cat)
return _method2DCondCat ;
195 if (cond)
return _method2DCond ;
196 if (cat)
return _method2DCat ;
204 RooCategory& RooNumGenConfig::methodND(Bool_t cond, Bool_t cat)
206 if (cond && cat)
return _methodNDCondCat ;
207 if (cond)
return _methodNDCond ;
208 if (cat)
return _methodNDCat ;
216 const RooCategory& RooNumGenConfig::method1D(Bool_t cond, Bool_t cat)
const
218 return const_cast<RooNumGenConfig*
>(
this)->method1D(cond,cat) ;
225 const RooCategory& RooNumGenConfig::method2D(Bool_t cond, Bool_t cat)
const
227 return const_cast<RooNumGenConfig*
>(
this)->method2D(cond,cat) ;
234 const RooCategory& RooNumGenConfig::methodND(Bool_t cond, Bool_t cat)
const
236 return const_cast<RooNumGenConfig*
>(
this)->methodND(cond,cat) ;
246 Bool_t RooNumGenConfig::addConfigSection(
const RooAbsNumGenerator* proto,
const RooArgSet& inDefaultConfig)
248 TString name = proto->IsA()->GetName() ;
252 _method1D.defineType(name) ;
253 _method2D.defineType(name) ;
254 _methodND.defineType(name) ;
256 if (proto->canSampleConditional()) {
257 _method1DCond.defineType(name) ;
258 _method2DCond.defineType(name) ;
259 _methodNDCond.defineType(name) ;
261 if (proto->canSampleCategories()) {
262 _method1DCat.defineType(name) ;
263 _method2DCat.defineType(name) ;
264 _methodNDCat.defineType(name) ;
267 if (proto->canSampleConditional() && proto->canSampleCategories()) {
268 _method1DCondCat.defineType(name) ;
269 _method2DCondCat.defineType(name) ;
270 _methodNDCondCat.defineType(name) ;
274 RooArgSet* config = (RooArgSet*) inDefaultConfig.snapshot() ;
275 config->setName(name) ;
276 _configSets.Add(config) ;
286 RooArgSet& RooNumGenConfig::getConfigSection(
const char* name)
288 return const_cast<RooArgSet&
>((
const_cast<const RooNumGenConfig*
>(
this)->getConfigSection(name))) ;
295 const RooArgSet& RooNumGenConfig::getConfigSection(
const char* name)
const
297 static RooArgSet dummy ;
298 RooArgSet* config = (RooArgSet*) _configSets.FindObject(name) ;
300 oocoutE((TObject*)0,InputArguments) <<
"RooNumGenConfig::getIntegrator: ERROR: no configuration stored for integrator '" << name <<
"'" << endl ;
309 RooPrintable::StyleOption RooNumGenConfig::defaultPrintStyle(Option_t* opt)
const
318 if (o.Contains(
"v")) {
329 void RooNumGenConfig::printMultiline(ostream &os, Int_t , Bool_t verbose, TString indent)
const
332 os << indent <<
"1-D sampling method: " << _method1D.getLabel() << endl ;
333 if (_method1DCat.getIndex()!=_method1D.getIndex()) {
334 os <<
" (" << _method1DCat.getLabel() <<
" if with categories)" << endl ;
336 if (_method1DCond.getIndex()!=_method1D.getIndex()) {
337 os <<
" (" << _method1DCond.getLabel() <<
" if conditional)" << endl ;
339 if (_method1DCondCat.getIndex()!=_method1D.getIndex()) {
340 os <<
" (" << _method1DCondCat.getLabel() <<
" if conditional with categories)" << endl ;
344 os << indent <<
"2-D sampling method: " << _method2D.getLabel() << endl ;
345 if (_method2DCat.getIndex()!=_method2D.getIndex()) {
346 os <<
" (" << _method2DCat.getLabel() <<
" if with categories)" << endl ;
348 if (_method2DCond.getIndex()!=_method2D.getIndex()) {
349 os <<
" (" << _method2DCond.getLabel() <<
" if conditional)" << endl ;
351 if (_method2DCondCat.getIndex()!=_method2D.getIndex()) {
352 os <<
" (" << _method2DCondCat.getLabel() <<
" if conditional with categories)" << endl ;
356 os << indent <<
"N-D sampling method: " << _methodND.getLabel() << endl ;
357 if (_methodNDCat.getIndex()!=_methodND.getIndex()) {
358 os <<
" (" << _methodNDCat.getLabel() <<
" if with categories)" << endl ;
360 if (_methodNDCond.getIndex()!=_methodND.getIndex()) {
361 os <<
" (" << _methodNDCond.getLabel() <<
" if conditional)" << endl ;
363 if (_methodNDCondCat.getIndex()!=_methodND.getIndex()) {
364 os <<
" (" << _methodNDCondCat.getLabel() <<
" if conditional with categories)" << endl ;
370 os << endl <<
"Available sampling methods:" << endl << endl ;
371 TIterator* cIter = _configSets.MakeIterator() ;
372 RooArgSet* configSet ;
373 while ((configSet=(RooArgSet*)cIter->Next())) {
375 os << indent <<
"*** " << configSet->GetName() <<
" ***" << endl ;
376 os << indent <<
"Capabilities: " ;
377 const RooAbsNumGenerator* proto = RooNumGenFactory::instance().getProtoSampler(configSet->GetName()) ;
378 if (proto->canSampleConditional()) os <<
"[Conditional] " ;
379 if (proto->canSampleCategories()) os <<
"[Categories] " ;
382 os <<
"Configuration: " << endl ;
383 configSet->printMultiline(os,kName|kValue|kTitle) ;