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