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