Logo ROOT  
Reference Guide
RooSimWSTool.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/// \class RooSimWSTool
19/// The RooSimWSTool is a tool operating on RooWorkspace objects that
20/// can clone PDFs into a series of variations that are joined together
21/// into a RooSimultanous PDF.
22///
23/// ## Splitting a single PDF
24/// The simplest use case is to take a workspace PDF as prototype and
25/// "split" a parameter of that PDF into two specialized parameters
26/// depending on a category in the dataset.
27///
28/// For example, given a Gaussian
29/// PDF \f$ G(x \,|\, m,s) \f$ we want to construct a \f$ G_a(x \,|\, m_a,s) \f$ and a \f$ G_b(x \,|\, m_b,s) \f$
30/// with different mean parameters to be fit to a dataset with observables
31/// \f$ (x,c) \f$ where \f$ c \f$ is a category with states 'a' and 'b'.
32///
33/// Using RooSimWSTool, one can create a simultaneous PDF from \f$ G_a \f$ and \f$ G_b \f$
34/// from \f$ G \f$ with the following commands:
35/// ```
36/// RooSimWSTool wst(wspace);
37/// wst.build("G_sim", "G", SplitParam("m","c"));
38/// ```
39///
40/// #### Splitting using a product category
41/// From this simple example one can go to builds of arbitrary complexity
42/// by specifying multiple SplitParam arguments on multiple parameters
43/// involving multiple splitting categories. Splits can also be performed
44/// in the product of multiple categories, *i.e.*,
45/// ```
46/// wst.build("G_sim", "G", SplitParam("m","c,d"));
47/// ```
48/// splits the parameter \f$ m \f$ in the product of the states of \f$ c \f$ and
49/// \f$ d \f$.
50///
51/// #### Constrained split
52/// Another possibility
53/// is the "constrained" split, which clones the parameter for all but one state
54/// and inserts a formula specialization in a chosen state that evaluates
55/// to \f$ 1 - \sum_i(a_i) \f$ where \f$ a_i \f$ are all other specializations. For example,
56/// given a category \f$ c \f$ with the states `"A","B","C","D"`, the specification
57/// ```
58/// SplitParamConstrained("m","c","D")
59/// ```
60/// will create the parameters \f$ m_A,m_B,m_C \f$ and a formula expression \f$ m_D \f$
61/// that evaluates to \f$ (1-(m_A+m_B+m_C)) \f$. Constrained splits can also be
62/// specified in the product of categories. In that case, the name of the
63/// remainder state follows the syntax `"{State1;State2}"`, where `State1` and
64/// `State2` are the state names of the two spitting categories.
65///
66/// ## Splitting multiple PDFs
67/// The examples so far deal with a single prototype PDF. It is also
68/// possible to build with multiple prototype PDFs by specifying a
69/// mapping between the prototype to use and the names of states of
70/// a "master" splitting category. To specify these configurations,
71/// an intermediate `MultiBuildConfig` must be composed with all
72/// the necessary specifications. This, for example,
73/// ```
74/// RooSimWSTool::MultiBuildConfig mbc("mc");
75/// mbc.addPdf("I","G",SplitParam("m,s","c"));
76/// mbc.addPdf("II,III","F",SplitParam("a","c,d"));
77/// ```
78/// configures a build with two prototype PDFs \f$ G \f$ and \f$ F \f$.
79/// Prototype \f$ G \f$ is used for state `"I"` of the master split category
80/// `mc` and prototype \f$ F \f$ is used for states `"II"` and `"III"` of the
81/// master split category `mc`. Furthermore, the parameters \f$ m,s \f$ of
82/// prototype \f$ G \f$ are split
83/// in category \f$ c \f$ while the parameter \f$ a \f$ of prototype \f$ F \f$ is split in
84/// the product of the categories \f$ c \f$ and \f$ d \f$. The actual build is then
85/// performed by passing the build configuration to RooSimWSTool, *e.g.*,
86/// ```
87/// wst.build("MASTER", mbc);
88/// ```
89/// By default, a specialisation is built for each permutation of
90/// states of the splitting categories that are used. It is possible
91/// to restrict the building of specialised PDFs to a subset of states
92/// by adding a restriction on the number of states to build as follows:
93/// ```
94/// mbc.restrictBuild("c","A,B");
95/// ```
96/// The restrictBuild method can be called multiple times, but at most
97/// once for each splitting category in use. For simple builds with a single
98/// prototype, restriction can be specified with a Restrict() argument
99/// on the build command line.
100///
101
102
103#include "RooSimWSTool.h"
104
106#include "RooMsgService.h"
107#include "RooCategory.h"
108#include "RooRealVar.h"
109#include "RooAbsPdf.h"
110#include "RooSuperCategory.h"
111#include "RooCustomizer.h"
112#include "RooMultiCategory.h"
113#include "RooSimultaneous.h"
114#include "RooGlobalFunc.h"
115#include "RooFracRemainder.h"
116#include "RooFactoryWSTool.h"
117
124;
125
126using namespace std ;
127
128namespace {
129
130static Int_t init();
131
132Int_t dummy = init() ;
133
134static Int_t init()
135{
137 RooFactoryWSTool::registerSpecial("SIMCLONE",iface) ;
138 RooFactoryWSTool::registerSpecial("MSIMCLONE",iface) ;
139 (void) dummy;
140 return 0 ;
141}
142
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Constructor of SimWSTool on given workspace. All input is taken from the workspace
147/// All output is stored in the workspace
148
150{
151}
152
153
154
155////////////////////////////////////////////////////////////////////////////////
156/// Destructor
157
159{
160}
161
162
163
164////////////////////////////////////////////////////////////////////////////////
165/// Build a RooSimultaneous PDF with name simPdfName from cloning specializations of protytpe PDF protoPdfName.
166/// <table>
167/// <tr><th> Optional Arguments <th> Effect
168/// <tr><td> SplitParam(varname, catname) <td> Split parameter(s) with given name(s) in category(s) with given names
169/// <tr><td> SplitParam(var, cat) <td> Split given parameter(s) in givem category(s)
170/// <tr><td> SplitParamConstrained(vname, cname, remainder) <td> Make constrained split in parameter(s) with given name(s) in category(s) with given names
171/// putting remainder fraction formula in state with name "remainder"
172/// <tr><td> SplitParamConstrained(var,cat,remainder) <td> Make constrained split in parameter(s) with given name(s) in category(s) with given names
173/// putting remainder fraction formula in state with name "remainder"
174/// <tr><td> Restrict(catName,stateNameList) <td> Restrict build by only considered listed state names of category with given name
175
176RooSimultaneous* RooSimWSTool::build(const char* simPdfName, const char* protoPdfName, const RooCmdArg& arg1,const RooCmdArg& arg2,
177 const RooCmdArg& arg3,const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
178{
179 BuildConfig bc(protoPdfName,arg1,arg2,arg3,arg4,arg5,arg6) ;
180 return build(simPdfName,bc) ;
181}
182
183
184
185////////////////////////////////////////////////////////////////////////////////
186/// Build a RooSimultaneous PDF with name simPdfName from cloning specializations of protytpe PDF protoPdfName.
187/// Use the provided BuildConfig or MultiBuildConfig object to configure the build
188
190{
191 ObjBuildConfig* obc = validateConfig(bc) ;
192 if (!obc) return 0 ;
193
194 if (verbose) {
195 obc->print() ;
196 }
197
198 RooSimultaneous* ret = executeBuild(simPdfName,*obc,verbose) ;
199
200 delete obc ;
201 return ret ;
202}
203
204
205
206////////////////////////////////////////////////////////////////////////////////
207/// Validate build configuration. If not syntax errors or missing objects are found,
208/// return an ObjBuildConfig in which all names are replaced with object pointers.
209
211{
212 // Create empty object version of build config
213 ObjBuildConfig* obc = new ObjBuildConfig ;
214
215 if (bc._masterCatName.length()>0) {
216 obc->_masterCat = _ws->cat(bc._masterCatName) ;
217 if (!obc->_masterCat) {
218 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: associated workspace " << _ws->GetName()
219 << " does not contain a category named " << bc._masterCatName
220 << " that was designated as master index category in the build configuration" << endl ;
221 delete obc ;
222 return 0 ;
223 }
224 } else {
225 obc->_masterCat = 0 ;
226 }
227
228 map<string,SplitRule>::iterator pdfiter ;
229 // Check that we have the p.d.f.s
230 for (pdfiter = bc._pdfmap.begin() ; pdfiter != bc._pdfmap.end() ; ++pdfiter) {
231
232 // Check that p.d.f exists
233 RooAbsPdf* pdf = _ws->pdf(pdfiter->second.GetName()) ;
234 if (!pdf) {
235 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: associated workspace " << _ws->GetName()
236 << " does not contain a pdf named " << pdfiter->second.GetName() << endl ;
237 delete obc ;
238 return 0 ;
239 }
240
241 // Create empty object version of split rule set
242 ObjSplitRule osr ;
243
244 // Convert names of parameters and splitting categories to objects in workspace, fill object split rule
245 SplitRule& sr = pdfiter->second ;
246
247 map<string, pair<list<string>,string> >::iterator pariter ;
248 for (pariter=sr._paramSplitMap.begin() ; pariter!=sr._paramSplitMap.end() ; ++pariter) {
249
250 // Check that variable with given name exists in workspace
251 RooAbsArg* farg = _ws->fundArg(pariter->first) ;
252 if (!farg) {
253 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: associated workspace " << _ws->GetName()
254 << " does not contain a variable named " << pariter->first.c_str()
255 << " as specified in splitting rule of parameter " << pariter->first << " of p.d.f " << pdf << endl ;
256 delete obc ;
257 return 0 ;
258 }
259
260 // Check that given variable is indeed related to given p.d.f
261 if (!pdf->dependsOn(*farg)) {
262 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: specified parameter " << pariter->first
263 << " in split is not function of p.d.f " << pdf->GetName() << endl ;
264 delete obc ;
265 return 0 ;
266 }
267
268
269 RooArgSet splitCatSet ;
270 list<string>::iterator catiter ;
271 for (catiter = pariter->second.first.begin() ; catiter!=pariter->second.first.end() ; ++catiter) {
272 RooAbsCategory* cat = _ws->catfunc(catiter->c_str()) ;
273 if (!cat) {
274 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: associated workspace " << _ws->GetName()
275 << " does not contain a category named " << catiter->c_str()
276 << " as specified in splitting rule of parameter " << pariter->first << " of p.d.f " << pdf << endl ;
277 delete obc ;
278 return 0 ;
279 }
280 splitCatSet.add(*cat) ;
281 }
282
283 // Check if composite splitCatSet does not contain category functions that depend on other categories used in the same split
284 TIterator* iter = splitCatSet.createIterator() ;
285 RooAbsArg* arg ;
286 while((arg=(RooAbsArg*)iter->Next())) {
287 RooArgSet tmp(splitCatSet) ;
288 tmp.remove(*arg) ;
289 if (arg->dependsOnValue(tmp)) {
290 coutE(InputArguments) << "RooSimWSTool::build(" << GetName() << ") ERROR: Ill defined split: splitting category function " << arg->GetName()
291 << " used in composite split " << splitCatSet << " of parameter " << farg->GetName() << " of pdf " << pdf->GetName()
292 << " depends on one or more of the other splitting categories in the composite split" << endl ;
293 delete obc ;
294 delete iter ;
295 return 0 ;
296 }
297 }
298 delete iter ;
299
300 // If a constrained split is specified, check that split parameter is a real-valued type
301 if (pariter->second.second.size()>0) {
302 if (!dynamic_cast<RooAbsReal*>(farg)) {
303 coutE(InputArguments) << "RooSimWSTool::build(" << GetName() << ") ERROR: Constrained split specified in non real-valued parameter " << farg->GetName() << endl ;
304 delete obc ;
305 return 0 ;
306 }
307 }
308
309 // Fill object build config with object split rule
310 osr._paramSplitMap[farg].first.add(splitCatSet) ;
311 osr._paramSplitMap[farg].second = pariter->second.second ;
312
313 // For multi-pdf configurations, check that the master index state name associated with this p.d.f exists as a state in the master category
314 if (obc->_masterCat) {
315 list<string>::iterator misi ;
316 for (misi=sr._miStateNameList.begin() ; misi!=sr._miStateNameList.end() ; ++misi) {
317 const RooCatType* ctype = obc->_masterCat->lookupType(misi->c_str(),kFALSE) ;
318 if (ctype==0) {
319 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: master index category " << obc->_masterCat->GetName()
320 << " does not have a state named " << *misi << " which was specified as state associated with p.d.f "
321 << sr.GetName() << endl ;
322 delete obc ;
323 return 0 ;
324 }
325 osr._miStateList.push_back(ctype) ;
326 }
327 }
328
329 // Add specified split cats to global list of all splitting categories
330 obc->_usedSplitCats.add(splitCatSet,kTRUE) ;
331
332 }
333 // Need to add clause here for SplitRules without any split (which can happen in MultiBuildConfigs)
334 if (sr._paramSplitMap.size()==0) {
335
336 if (obc->_masterCat) {
337 list<string>::iterator misi ;
338 for (misi=sr._miStateNameList.begin() ; misi!=sr._miStateNameList.end() ; ++misi) {
339 const RooCatType* ctype = obc->_masterCat->lookupType(misi->c_str(),kFALSE) ;
340 if (ctype==0) {
341 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: master index category " << obc->_masterCat->GetName()
342 << " does not have a state named " << *misi << " which was specified as state associated with p.d.f "
343 << sr.GetName() << endl ;
344 delete obc ;
345 return 0 ;
346 }
347 osr._miStateList.push_back(ctype) ;
348 }
349 }
350 }
351
352 obc->_pdfmap[pdf] = osr ;
353
354 }
355
356 // Check validity of build restriction specifications, if any
357 map<string,string>::iterator riter ;
358 for (riter=bc._restr.begin() ; riter!=bc._restr.end() ; ++riter) {
359 RooCategory* cat = _ws->cat(riter->first) ;
360 if (!cat) {
361 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: associated workspace " << _ws->GetName()
362 << " does not contain a category named " << riter->first
363 << " for which build was requested to be restricted to states " << riter->second << endl ;
364 delete obc ;
365 return 0 ;
366 }
367
368 char buf[4096] ;
369 list<const RooCatType*> rlist ;
370 strlcpy(buf,riter->second.c_str(),4096) ;
371
372 char* tok = strtok(buf,"{,}") ;
373 while(tok) {
374 const RooCatType* ctype = cat->lookupType(tok,kFALSE) ;
375 if (!ctype) {
376 coutE(ObjectHandling) << "RooSimWSTool::build(" << GetName() << ") ERROR: restricted build category " << cat->GetName()
377 << " does not have state " << tok << " as specified in restriction list" << endl ;
378 delete obc ;
379 return 0 ;
380 }
381 rlist.push_back(ctype) ;
382 tok = strtok(0,"{,}") ;
383 }
384
385 obc->_restr[cat] = rlist ;
386 }
387
388 return obc ;
389}
390
391
392
393
394////////////////////////////////////////////////////////////////////////////////
395/// Internal build driver from validation ObjBuildConfig.
396
398{
399 RooArgSet cleanupList ;
400
401 RooAbsCategoryLValue* physCat = obc._masterCat ;
402
403 RooArgSet physModelSet ;
404 map<string,RooAbsPdf*> stateMap ;
405
406 map<RooAbsPdf*,ObjSplitRule>::iterator physIter = obc._pdfmap.begin() ;
407 while(physIter!=obc._pdfmap.end()) {
408
409
410 RooAbsPdf* physModel = physIter->first ;
411 physModelSet.add(*physModel,kTRUE) ; // silence duplicate insertion warnings
412
413 list<const RooCatType*>::iterator stiter ;
414 for (stiter=physIter->second._miStateList.begin() ; stiter!=physIter->second._miStateList.end() ; ++stiter) {
415 stateMap[(*stiter)->GetName()] = physModel ;
416 }
417
418 // Continue with next mapping
419 ++physIter ;
420 }
421 if (verbose) coutI(ObjectHandling) << "RooSimWSTool::executeBuild: list of prototype pdfs " << physModelSet << endl ;
422
423 RooArgSet splitCatSet(obc._usedSplitCats) ;
424 if (physCat) splitCatSet.add(*physCat) ;
425
426 RooArgSet splitCatSetFund ;
427 TIterator* scsiter = splitCatSet.createIterator() ;
428 RooAbsCategory* scat ;
429 while((scat=(RooAbsCategory*)scsiter->Next())) {
430 if (scat->isFundamental()) {
431 splitCatSetFund.add(*scat) ;
432 } else {
433 RooArgSet* scatvars = scat->getVariables() ;
434 splitCatSetFund.add(*scatvars) ;
435 delete scatvars ;
436 }
437 }
438 delete scsiter ;
439
440
441 RooAbsCategoryLValue* masterSplitCat ;
442 if (splitCatSetFund.getSize()>1) {
443 masterSplitCat = new RooSuperCategory("masterSplitCat","Master splitting category",splitCatSetFund) ;
444 } else {
445 masterSplitCat = (RooAbsCategoryLValue*) splitCatSetFund.first() ;
446 }
447 if (verbose) coutI(ObjectHandling) << "RooSimWSTool::executeBuild: list of splitting categories " << splitCatSet << endl ;
448
449 RooArgSet splitNodeListOwned ; // owns all newly created components
450 RooArgSet splitNodeListAll ; // all leaf nodes, preload with ws contents to auto-connect existing specializations
451 TList* customizerList = new TList ;
452
453 // Loop over requested physics models and build components
454 TIter physMIter = physModelSet.createIterator() ;
455 RooAbsPdf* physModel ;
456 while((physModel=(RooAbsPdf*)physMIter.Next())) {
457 if (verbose) coutI(ObjectHandling) << "RooSimPdfBuilder::executeBuild: processing prototype pdf " << physModel->GetName() << endl ;
458
459 RooCustomizer* physCustomizer = new RooCustomizer(*physModel,*masterSplitCat,splitNodeListOwned,&splitNodeListAll) ;
460 customizerList->Add(physCustomizer) ;
461
462 map<RooAbsArg*, pair<RooArgSet,string> >::iterator splitIter ;
463 for (splitIter = obc._pdfmap[physModel]._paramSplitMap.begin() ; splitIter != obc._pdfmap[physModel]._paramSplitMap.end() ; ++splitIter) {
464
465 // If split is composite, first make multicategory with name 'A,B,C' and insert in WS
466
467 // Construct name of (composite) split category (function)
468 RooArgSet& splitCatSetTmp = splitIter->second.first ;
469 string splitName = makeSplitName(splitCatSetTmp) ;
470
471 // If composite split object does not exist yet, create it now
472 RooAbsCategory* splitCat = _ws->catfunc(splitName.c_str()) ;
473 if (!splitCat) {
474 splitCat = new RooMultiCategory(splitName.c_str(),splitName.c_str(),splitCatSetTmp) ;
475 cleanupList.addOwned(*splitCat) ;
476 _ws->import(*splitCat,RooFit::Silence(!verbose)) ;
477 }
478
479 // If remainder category needs to be made, create RFV of appropriate for that and insert in WS
480 if(splitIter->second.second.size()>0) {
481
482 // Check that specified split name is in fact valid
483 if (!splitCat->hasLabel(splitIter->second.second)) {
484 coutE(InputArguments) << "RooSimWSTool::executeBuild(" << GetName() << ") ERROR: name of remainder state for constrained split, '"
485 << splitIter->second.second << "' , does not match any state name of (composite) split category " << splitCat->GetName() << endl ;
486 return 0 ;
487 }
488
489 // First build manually the specializations of all non-remainder states, as the remainder state depends on these
490 RooArgSet fracLeafList ;
491 TIterator* sctiter = splitCat->typeIterator() ;
493 while((type=(RooCatType*)sctiter->Next())) {
494
495 // Skip remainder state
496 if (splitIter->second.second == type->GetName()) continue ;
497
498 // Construct name of split leaf
499 TString splitLeafName(splitIter->first->GetName()) ;
500 splitLeafName.Append("_") ;
501 splitLeafName.Append(type->GetName()) ;
502
503 // Check if split leaf already exists
504 RooAbsArg* splitLeaf = _ws->fundArg(splitLeafName) ;
505 if (!splitLeaf) {
506 // If not create it now
507 splitLeaf = (RooAbsArg*) splitIter->first->clone(splitLeafName) ;
508 _ws->import(*splitLeaf,RooFit::Silence(!verbose)) ;
509 }
510 fracLeafList.add(*splitLeaf) ;
511 }
512 delete sctiter ;
513
514
515 // Build specialization for remainder state and insert in workspace
516 RooFracRemainder* fracRem = new RooFracRemainder(Form("%s_%s",splitIter->first->GetName(),splitIter->second.second.c_str()),"Remainder fraction",fracLeafList) ;
517 cleanupList.addOwned(*fracRem) ;
518 _ws->import(*fracRem) ;
519
520 }
521
522
523 // Add split definition to customizer
524 physCustomizer->splitArgs(*splitIter->first,*splitCat) ;
525 }
526 }
527
528 // List all existing workspace components as prebuilt items for the customizers at this point
529 splitNodeListAll.add(_ws->components()) ;
530
531 if (verbose) coutI(ObjectHandling) << "RooSimWSTool::executeBuild: configured customizers for all prototype pdfs" << endl ;
532
533 // Create fit category from physCat and splitCatList ;
534 RooArgSet fitCatList ;
535 if (physCat) fitCatList.add(*physCat) ;
536
537 // Add observables of splitCatSet members, rather than splitCatSet members directly
538 // as there may be cat->cat functions in here
539 scsiter = splitCatSet.createIterator() ;
540 while((scat=(RooAbsCategory*)scsiter->Next())) {
541 if (scat->isFundamental()) {
542 fitCatList.add(*scat) ;
543 } else {
544 RooArgSet* scatvars = scat->getVariables() ;
545 fitCatList.add(*scatvars) ;
546 delete scatvars ;
547 }
548 }
549 delete scsiter ;
550
551
552 TIterator* fclIter = fitCatList.createIterator() ;
553 string mcatname = string(simPdfName) + "_index" ;
554 RooAbsCategoryLValue* fitCat = 0 ;
555 if (fitCatList.getSize()>1) {
556 fitCat = new RooSuperCategory(mcatname.c_str(),mcatname.c_str(),fitCatList) ;
557 cleanupList.addOwned(*fitCat) ;
558 } else {
559 fitCat = (RooAbsCategoryLValue*) fitCatList.first() ;
560 }
561
562 // Create master PDF
563 RooSimultaneous* simPdf = new RooSimultaneous(simPdfName,simPdfName,*fitCat) ;
564 cleanupList.addOwned(*simPdf) ;
565
566 // Add component PDFs to master PDF
567 TIterator* fcIter = fitCat->typeIterator() ;
568
569 RooCatType* fcState ;
570 while((fcState=(RooCatType*)fcIter->Next())) {
571 // Select fitCat state
572 fitCat->setLabel(fcState->GetName()) ;
573
574 // Check if this fitCat state is selected
575 fclIter->Reset() ;
576 RooAbsCategory* splitCat ;
577 Bool_t select(kFALSE) ;
578 if (obc._restr.size()>0) {
579 while((splitCat=(RooAbsCategory*)fclIter->Next())) {
580 // Find selected state list
581
582 list<const RooCatType*> slist = obc._restr[splitCat] ;
583 if (slist.empty()) {
584 continue ;
585 }
586
587 list<const RooCatType*>::iterator sli ;
588 for (sli=slist.begin() ; sli!=slist.end() ; ++sli) {
589 if (string(splitCat->getCurrentLabel())==(*sli)->GetName()) {
590 select=kTRUE ;
591 }
592 }
593 }
594 if (!select) continue ;
595 } else {
596 select = kTRUE ;
597 }
598
599 // Select appropriate PDF for this physCat state
600 RooCustomizer* physCustomizer ;
601 if (physCat) {
602 RooAbsPdf* pdf = stateMap[physCat->getCurrentLabel()] ;
603 if (pdf==0) {
604 continue ;
605 }
606 physCustomizer = (RooCustomizer*) customizerList->FindObject(pdf->GetName());
607 } else {
608 physCustomizer = (RooCustomizer*) customizerList->First() ;
609 }
610
611 if (verbose) coutI(ObjectHandling) << "RooSimWSTool::executeBuild: Customizing prototype pdf " << physCustomizer->GetName()
612 << " for mode " << fcState->GetName() << endl ;
613
614 // Customizer PDF for current state and add to master simPdf
615 RooAbsPdf* fcPdf = (RooAbsPdf*) physCustomizer->build(masterSplitCat->getCurrentLabel(),kFALSE) ;
616 simPdf->addPdf(*fcPdf,fcState->GetName()) ;
617 }
618 delete fcIter ;
619
621
622 // Delete customizers
623 customizerList->Delete() ;
624 delete customizerList ;
625 delete fclIter ;
626 return (RooSimultaneous*) _ws->pdf(simPdf->GetName()) ;
627}
628
629
630
631////////////////////////////////////////////////////////////////////////////////
632/// Construct name of composite split
633
634std::string RooSimWSTool::makeSplitName(const RooArgSet& splitCatSet)
635{
636 string name ;
637
638 TIterator* iter = splitCatSet.createIterator() ;
639 RooAbsArg* arg ;
641 while((arg=(RooAbsArg*)iter->Next())) {
642 if (first) {
644 } else {
645 name += "," ;
646 }
647 name += arg->GetName() ;
648 }
649 delete iter ;
650
651 return name ;
652}
653
654
655
656
657////////////////////////////////////////////////////////////////////////////////
658/// Specify that parameters names listed in paramNameList be split in (product of) category(s)
659/// listed in categoryNameList
660
661void RooSimWSTool::SplitRule::splitParameter(const char* paramNameList, const char* categoryNameList)
662{
663 char paramBuf[4096] ;
664 char catBuf[4096] ;
665 strlcpy(paramBuf,paramNameList,4096) ;
666 strlcpy(catBuf,categoryNameList,4096) ;
667
668 // First parse category list
669 list<string> catList ;
670 char* cat = strtok(catBuf,"{,}") ;
671 while(cat) {
672 catList.push_back(cat) ;
673 cat = strtok(0,"{,}") ;
674 }
675
676 // Now parse parameter list
677 char* param = strtok(paramBuf,"{,}") ;
678 while(param) {
679 _paramSplitMap[param] = pair<list<string>,string>(catList,"") ;
680 param = strtok(0,"{,}") ;
681 }
682}
683
684
685////////////////////////////////////////////////////////////////////////////////
686/// Specify that parameters names listed in paramNameList be split in constrained way in (product of) category(s)
687/// listed in categoryNameList and that remainder fraction formula be put in state with name remainderStateName
688
689void RooSimWSTool::SplitRule::splitParameterConstrained(const char* paramNameList, const char* categoryNameList, const char* remainderStateName)
690{
691 char paramBuf[4096] ;
692 char catBuf[4096] ;
693 strlcpy(paramBuf,paramNameList,4096) ;
694 strlcpy(catBuf,categoryNameList,4096) ;
695
696 // First parse category list
697 list<string> catList ;
698 char* cat = strtok(catBuf,"{,}") ;
699 while(cat) {
700 catList.push_back(cat) ;
701 cat = strtok(0,"{,}") ;
702 }
703
704 // Now parse parameter list
705 char* param = strtok(paramBuf,"{,}") ;
706 while(param) {
707 _paramSplitMap[param] = pair<list<string>,string>(catList,remainderStateName) ;
708 param = strtok(0,"{,}") ;
709 }
710}
711
712
713////////////////////////////////////////////////////////////////////////////////
714/// Construct the SplitRule object from a list of named arguments past to RooSimWSTool::build
715/// This method parses any SplitParam and SplitParamComstrained argument in the list
716
717void RooSimWSTool::SplitRule::configure(const RooCmdArg& arg1,const RooCmdArg& arg2,const RooCmdArg& arg3,
718 const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
719{
720 list<const RooCmdArg*> cmdList ;
721 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
722 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
723 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
724
725 list<const RooCmdArg*>::iterator iter ;
726 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
727
728 if ((*iter)->opcode()==0) continue ;
729
730 string name = (*iter)->opcode() ;
731
732 if (name=="SplitParam") {
733 splitParameter((*iter)->getString(0),(*iter)->getString(1)) ;
734 } else if (name=="SplitParamConstrained") {
735 splitParameterConstrained((*iter)->getString(0),(*iter)->getString(1),(*iter)->getString(2)) ;
736 }
737 }
738}
739
740
741
742
743////////////////////////////////////////////////////////////////////////////////
744/// Add prototype p.d.f pdfName to build configuration with associated split rules 'sr'
745
747{
748 internalAddPdf(pdfName,"",sr) ;
749}
750
751
752////////////////////////////////////////////////////////////////////////////////
753/// Construct build configuration from single prototype 'pdfName' and list of arguments
754/// that can be passed to RooSimWSTool::build() method. This routine parses SplitParam()
755/// SplitParamConstrained() and Restrict() arguments.
756
757RooSimWSTool::BuildConfig::BuildConfig(const char* pdfName, const RooCmdArg& arg1,const RooCmdArg& arg2,
758 const RooCmdArg& arg3,const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
759{
760 SplitRule sr(pdfName) ;
761 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
762 internalAddPdf(pdfName,"",sr) ;
763 _conflProtocol = RooFit::RenameConflictNodes(pdfName) ;
764
765 list<const RooCmdArg*> cmdList ;
766 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
767 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
768 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
769
770 list<const RooCmdArg*>::iterator iter ;
771 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
772 if ((*iter)->opcode()==0) continue ;
773 string name = (*iter)->opcode() ;
774 if (name=="Restrict") {
775 restrictBuild((*iter)->getString(0),(*iter)->getString(1)) ;
776 }
777 if (name=="RenameConflictNodes") {
778 _conflProtocol = *(*iter) ;
779 }
780 }
781}
782
783
784////////////////////////////////////////////////////////////////////////////////
785/// Constructor to make BuildConfig from legacy RooSimPdfBuilder configuration
786/// Empty for now
787
789{
790}
791
792
793////////////////////////////////////////////////////////////////////////////////
794/// Internal routine to add prototype pdf 'pdfName' with list of associated master states 'miStateNameList
795/// and split rules 'sr' to configuration
796
797void RooSimWSTool::BuildConfig::internalAddPdf(const char* pdfName, const char* miStateNameList,SplitRule& sr)
798{
799 char buf[4096] ;
800 strlcpy(buf,miStateNameList,4096) ;
801
802 char* tok = strtok(buf,",") ;
803 while(tok) {
804 sr._miStateNameList.push_back(tok) ;
805 tok = strtok(0,",") ;
806 }
807
808 _pdfmap[pdfName] = sr ;
809}
810
811
812////////////////////////////////////////////////////////////////////////////////
813/// Restrict build by only considering state names in stateList for split in category catName
814
815void RooSimWSTool::BuildConfig::restrictBuild(const char* catName, const char* stateList)
816{
817 _restr[catName] = stateList ;
818}
819
820
821
822
823////////////////////////////////////////////////////////////////////////////////
824/// Construct MultiBuildConfig for build configuration with multiple prototype p.d.f.s
825/// masterIndexCat is the name of the master index category that decides which
826/// prototype is used.
827
829{
830 _masterCatName = masterIndexCat ;
831}
832
833
834
835////////////////////////////////////////////////////////////////////////////////
836/// Add protytpe p.d.f 'pdfName' to MultiBuildConfig associated with master indes states 'miStateList'. This
837/// method parses the SplitParam() and SplitParamConstrained() arguments
838
839void RooSimWSTool::MultiBuildConfig::addPdf(const char* miStateList, const char* pdfName, const RooCmdArg& arg1,const RooCmdArg& arg2,
840 const RooCmdArg& arg3,const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
841{
842 SplitRule sr(pdfName) ;
843 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
844 internalAddPdf(pdfName,miStateList,sr) ;
845}
846
847
848
849////////////////////////////////////////////////////////////////////////////////
850/// Add protytpe p.d.f 'pdfName' to MultiBuildConfig associated with master indes states 'miStateList'.
851
852void RooSimWSTool::MultiBuildConfig::addPdf(const char* miStateList, const char* pdfName, SplitRule& sr)
853{
854 internalAddPdf(pdfName,miStateList,sr) ;
855}
856
857
858
859
860////////////////////////////////////////////////////////////////////////////////
861/// Destructor
862
864{
865}
866
867
868
869
870////////////////////////////////////////////////////////////////////////////////
871/// Print details of a validated build configuration
872
874{
875 // --- Dump contents of object build config ---
876 map<RooAbsPdf*,ObjSplitRule>::iterator ri ;
877 for (ri = _pdfmap.begin() ; ri != _pdfmap.end() ; ++ri ) {
878 cout << "Splitrule for p.d.f " << ri->first->GetName() << " with state list " ;
879 for (std::list<const RooCatType*>::iterator misi= ri->second._miStateList.begin() ; misi!=ri->second._miStateList.end() ; ++misi) {
880 cout << (*misi)->GetName() << " " ;
881 }
882 cout << endl ;
883
884 map<RooAbsArg*,pair<RooArgSet,string> >::iterator csi ;
885 for (csi = ri->second._paramSplitMap.begin() ; csi != ri->second._paramSplitMap.end() ; ++csi ) {
886 if (csi->second.second.length()>0) {
887 cout << " parameter " << csi->first->GetName() << " is split with constraint in categories " << csi->second.first
888 << " with remainder in state " << csi->second.second << endl ;
889 } else {
890 cout << " parameter " << csi->first->GetName() << " is split with constraint in categories " << csi->second.first << endl ;
891 }
892 }
893 }
894
895 map<RooAbsCategory*,list<const RooCatType*> >::iterator riter ;
896 for (riter=_restr.begin() ; riter!=_restr.end() ; ++riter) {
897 cout << "Restricting build in category " << riter->first->GetName() << " to states " ;
898 list<const RooCatType*>::iterator i ;
899 for (i=riter->second.begin() ; i!=riter->second.end() ; ++i) {
900 if (i!=riter->second.begin()) cout << "," ;
901 cout << (*i)->GetName() ;
902 }
903 cout << endl ;
904 }
905
906}
907
908
909
910
911////////////////////////////////////////////////////////////////////////////////
912
913std::string RooSimWSTool::SimWSIFace::create(RooFactoryWSTool& ft, const char* typeName, const char* instanceName, std::vector<std::string> args)
914{
915 string tn(typeName) ;
916 if (tn=="SIMCLONE") {
917
918 // Perform syntax check. Warn about any meta parameters other than $SplitParam, $SplitParamConstrained, $Restrict and $Verbose
919 for (unsigned int i=1 ; i<args.size() ; i++) {
920 if (args[i].find("$SplitParam(")!=0 &&
921 args[i].find("$SplitParamConstrained(")!=0 &&
922 args[i].find("$SplitRestrict(")!=0 &&
923 args[i].find("$Verbose(")!=0) {
924 throw string(Form("RooSimWSTool::SimWSIFace::create() ERROR: unknown token %s encountered",args[i].c_str())) ;
925 }
926 }
927
928 // Make SplitRule object from $SplitParam and $SplitParamConstrained arguments
929 RooSimWSTool::SplitRule sr(args[0].c_str()) ;
930 for (unsigned int i=1 ; i<args.size() ; i++) {
931 if (args[i].find("$SplitParam(")==0) {
932 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
933 if (subargs.size()!=2) {
934 throw string(Form("Incorrect number of arguments in $SplitParam, have %d, expect 2",(Int_t)subargs.size())) ;
935 }
936 sr.splitParameter(subargs[0].c_str(),subargs[1].c_str()) ;
937 } else if (args[i].find("$SplitParamConstrained(")==0) {
938 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
939 if (subargs.size()!=3) {
940 throw string(Form("Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(Int_t)subargs.size())) ;
941 }
942 sr.splitParameterConstrained(subargs[0].c_str(), subargs[1].c_str(), subargs[2].c_str()) ;
943 }
944 }
945
946 // Make BuildConfig object
947 RooSimWSTool::BuildConfig bc(args[0].c_str(),sr) ;
948 for (unsigned int i=1 ; i<args.size() ; i++) {
949 if (args[i].find("$Restrict(")==0) {
950 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
951 if (subargs.size()!=2) {
952 throw string(Form("Incorrect number of arguments in $Restrict, have %d, expect 2",(Int_t)subargs.size())) ;
953 }
954 bc.restrictBuild(subargs[0].c_str(),subargs[1].c_str()) ;
955 }
956 }
957
958 // Look for verbose flag
960 for (unsigned int i=1 ; i<args.size() ; i++) {
961 if (args[i].find("$Verbose(")==0) {
962 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
963 if (subargs.size()>0) {
964 verbose = atoi(subargs[0].c_str()) ;
965 }
966 }
967 }
968
969 // Build pdf clone
970 RooSimWSTool sct(ft.ws()) ;
971 RooAbsPdf* pdf = sct.build(instanceName,bc,verbose) ;
972 if (!pdf) {
973 throw string(Form("RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
974 }
975
976 // Import into workspace
977 ft.ws().import(*pdf,RooFit::Silence()) ;
978
979 } else if (tn=="MSIMCLONE") {
980
981 // First make a multibuild config from the master index cat
982 RooSimWSTool::MultiBuildConfig mbc(args[0].c_str()) ;
983
984 for (unsigned int i=1 ; i<args.size() ; i++) {
985 if (args[i].find("$AddPdf(")==0) {
986 // Process an add-pdf operation
987 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
988
989 // Make SplitRule object from $SplitParam and $SplitParamConstrained arguments
990 RooSimWSTool::SplitRule sr(subargs[1].c_str()) ;
991 for (unsigned int j=2 ; j<subargs.size() ; j++) {
992 if (subargs[j].find("$SplitParam(")==0) {
993 vector<string> subsubargs = ft.splitFunctionArgs(subargs[j].c_str()) ;
994 if (subsubargs.size()!=2) {
995 throw string(Form("Incorrect number of arguments in $SplitParam, have %d, expect 2",(Int_t)subsubargs.size())) ;
996 }
997 sr.splitParameter(subsubargs[0].c_str(),subsubargs[1].c_str()) ;
998 } else if (subargs[j].find("$SplitParamConstrained(")==0) {
999 vector<string> subsubargs = ft.splitFunctionArgs(subargs[j].c_str()) ;
1000 if (subsubargs.size()!=3) {
1001 throw string(Form("Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(Int_t)subsubargs.size())) ;
1002 }
1003 sr.splitParameterConstrained(subsubargs[0].c_str(), subsubargs[1].c_str(), subsubargs[2].c_str()) ;
1004 }
1005 }
1006 mbc.addPdf(subargs[0].c_str(),subargs[1].c_str(),sr) ;
1007
1008 } else if (args[i].find("$Restrict(")==0) {
1009
1010 // Process a restrict operation
1011 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
1012 if (subargs.size()!=2) {
1013 throw string(Form("Incorrect number of arguments in $Restrict, have %d, expect 2",(Int_t)subargs.size())) ;
1014 }
1015 mbc.restrictBuild(subargs[0].c_str(),subargs[1].c_str()) ;
1016
1017 } else {
1018 throw string(Form("RooSimWSTool::SimWSIFace::create() ERROR: unknown token in MSIMCLONE: %s",args[i].c_str())) ;
1019 }
1020 }
1021
1022 // Build pdf clone
1023 RooSimWSTool sct(ft.ws()) ;
1024 RooAbsPdf* pdf = sct.build(instanceName,mbc,kFALSE) ;
1025 if (!pdf) {
1026 throw string(Form("RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
1027 }
1028
1029 // Import into workspace
1030 ft.ws().import(*pdf,RooFit::Silence()) ;
1031
1032
1033 } else {
1034 throw string(Form("RooSimWSTool::SimWSIFace::create() ERROR: Unknown meta-type %s requested",typeName)) ;
1035 }
1036
1037 return string(instanceName) ;
1038}
#define coutI(a)
Definition: RooMsgService.h:30
#define coutE(a)
Definition: RooMsgService.h:33
const Bool_t kFALSE
Definition: RtypesCore.h:101
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:375
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition: TGX11.cxx:110
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition: TString.cxx:2447
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:78
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:835
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition: RooAbsArg.h:248
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2067
Bool_t dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Check whether this object depends on values from an element in the serverList.
Definition: RooAbsArg.h:108
virtual TObject * clone(const char *newname=0) const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
A space to attach TBranches.
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
virtual const char * getCurrentLabel() const
Return label string of current state.
TIterator * typeIterator() const
const RooCatType * lookupType(value_type index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return nullptr for no match.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Int_t getSize() const
Return the number of elements in the collection.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
RooAbsArg * first() const
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:63
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
const Text_t * GetName() const override
Returns name of object.
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:28
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:26
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
Definition: RooCustomizer.h:35
void splitArgs(const RooArgSet &argSet, const RooAbsCategory &splitCat)
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'.
RooAbsArg * build(const char *masterCatState, Bool_t verbose=kFALSE)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
RooFactoryWSTool is a class similar to TTree::MakeClass() that generates skeleton code for RooAbsPdf ...
RooWorkspace & ws()
static void registerSpecial(const char *typeName, RooFactoryWSTool::IFace *iface)
Register foreign special objects in factory.
std::vector< std::string > splitFunctionArgs(const char *funcExpr)
Allocate and fill work buffer.
RooFracRemainder calculates the remainder fraction of a sum of RooAbsReal fraction,...
RooMultiCategory connects several RooAbsCategory objects into a single category.
void restrictBuild(const char *catName, const char *stateList)
Restrict build by only considering state names in stateList for split in category catName.
std::map< std::string, SplitRule > _pdfmap
Definition: RooSimWSTool.h:119
std::map< std::string, std::string > _restr
Definition: RooSimWSTool.h:120
void internalAddPdf(const char *pdfName, const char *miStateList, SplitRule &sr)
Internal routine to add prototype pdf 'pdfName' with list of associated master states 'miStateNameLis...
void addPdf(const char *miStateList, const char *pdfName, SplitRule &sr)
Add protytpe p.d.f 'pdfName' to MultiBuildConfig associated with master indes states 'miStateList'.
MultiBuildConfig(const char *masterIndexCat)
Construct MultiBuildConfig for build configuration with multiple prototype p.d.f.s masterIndexCat is ...
std::map< RooAbsPdf *, ObjSplitRule > _pdfmap
Definition: RooSimWSTool.h:170
void print()
Print details of a validated build configuration.
std::map< RooAbsCategory *, std::list< const RooCatType * > > _restr
Definition: RooSimWSTool.h:171
virtual ~ObjSplitRule()
Destructor.
std::map< RooAbsArg *, std::pair< RooArgSet, std::string > > _paramSplitMap
Definition: RooSimWSTool.h:156
std::list< const RooCatType * > _miStateList
Definition: RooSimWSTool.h:155
std::string create(RooFactoryWSTool &ft, const char *typeName, const char *instanceName, std::vector< std::string > args) override
void splitParameter(const char *paramList, const char *categoryList)
Specify that parameters names listed in paramNameList be split in (product of) category(s) listed in ...
void configure(const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none())
Construct the SplitRule object from a list of named arguments past to RooSimWSTool::build This method...
void splitParameterConstrained(const char *paramNameList, const char *categoryNameList, const char *remainderStateName)
Specify that parameters names listed in paramNameList be split in constrained way in (product of) cat...
std::map< std::string, std::pair< std::list< std::string >, std::string > > _paramSplitMap
Definition: RooSimWSTool.h:97
The RooSimWSTool is a tool operating on RooWorkspace objects that can clone PDFs into a series of var...
Definition: RooSimWSTool.h:37
RooWorkspace * _ws
Definition: RooSimWSTool.h:74
RooSimWSTool(RooWorkspace &ws)
Constructor of SimWSTool on given workspace.
RooSimultaneous * build(const char *simPdfName, const char *protoPdfName, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none())
Build a RooSimultaneous PDF with name simPdfName from cloning specializations of protytpe PDF protoPd...
ObjBuildConfig * validateConfig(BuildConfig &bc)
Validate build configuration.
RooSimultaneous * executeBuild(const char *simPdfName, ObjBuildConfig &obc, Bool_t verbose=kTRUE)
Internal build driver from validation ObjBuildConfig.
std::string makeSplitName(const RooArgSet &splitCatSet)
Construct name of composite split.
~RooSimWSTool() override
Destructor.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooAbsCategory * catfunc(RooStringView name) const
Retrieve discrete function (RooAbsCategory) with given name. A null pointer is returned if not found.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooCategory * cat(RooStringView name) const
Retrieve discrete variable (RooCategory) with given name. A null pointer is returned if not found.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooAbsArg * fundArg(RooStringView name) const
Return fundamental (i.e.
const RooArgSet & components() const
Definition: RooWorkspace.h:117
TObject * Next()
Definition: TCollection.h:251
Iterator abstract base class.
Definition: TIterator.h:30
virtual void Reset()=0
virtual TObject * Next()=0
A doubly linked list.
Definition: TList.h:44
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition: TList.cxx:578
void Add(TObject *obj) override
Definition: TList.h:87
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:659
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:470
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
Basic string class.
Definition: TString.h:136
TString & Append(const char *cs)
Definition: TString.h:564
RooCmdArg RenameConflictNodes(const char *suffix, Bool_t renameOrigNodes=kFALSE)
RooCmdArg Silence(Bool_t flag=kTRUE)
void(off) SmallVectorTemplateBase< T
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.
@ InputArguments
Definition: RooGlobalFunc.h:64
@ ObjectHandling
Definition: RooGlobalFunc.h:64
static constexpr double sr
Definition: first.py:1
void ws()
Definition: ws.C:66