Logo ROOT  
Reference Guide
RooSimWSTool.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 /// \class RooSimWSTool
19 /// The RooSimWSTool is a tool operating on RooWorkspace objects that
20 /// can clone PDFs into a series of variations that are joined together
21 /// into a RooSimultanous PDF.
22 ///
23 /// ## Splitting a single PDF
24 /// The simplest use case is to take a workspace PDF as prototype and
25 /// "split" a parameter of that PDF into two specialized parameters
26 /// depending on a category in the dataset.
27 ///
28 /// For example, given a Gaussian
29 /// PDF \f$ G(x \,|\, m,s) \f$ we want to construct a \f$ G_a(x \,|\, m_a,s) \f$ and a \f$ G_b(x \,|\, m_b,s) \f$
30 /// with different mean parameters to be fit to a dataset with observables
31 /// \f$ (x,c) \f$ where \f$ c \f$ is a category with states 'a' and 'b'.
32 ///
33 /// Using RooSimWSTool, one can create a simultaneous PDF from \f$ G_a \f$ and \f$ G_b \f$
34 /// from \f$ G \f$ with the following commands:
35 /// ```
36 /// RooSimWSTool wst(wspace);
37 /// wst.build("G_sim", "G", SplitParam("m","c"));
38 /// ```
39 ///
40 /// #### Splitting using a product category
41 /// From this simple example one can go to builds of arbitrary complexity
42 /// by specifying multiple SplitParam arguments on multiple parameters
43 /// involving multiple splitting categories. Splits can also be performed
44 /// in the product of multiple categories, *i.e.*,
45 /// ```
46 /// wst.build("G_sim", "G", SplitParam("m","c,d"));
47 /// ```
48 /// splits the parameter \f$ m \f$ in the product of the states of \f$ c \f$ and
49 /// \f$ d \f$.
50 ///
51 /// #### Constrained split
52 /// Another possibility
53 /// is the "constrained" split, which clones the parameter for all but one state
54 /// and inserts a formula specialization in a chosen state that evaluates
55 /// to \f$ 1 - \sum_i(a_i) \f$ where \f$ a_i \f$ are all other specializations. For example,
56 /// given a category \f$ c \f$ with the states `"A","B","C","D"`, the specification
57 /// ```
58 /// SplitParamConstrained("m","c","D")
59 /// ```
60 /// will create the parameters \f$ m_A,m_B,m_C \f$ and a formula expression \f$ m_D \f$
61 /// that evaluates to \f$ (1-(m_A+m_B+m_C)) \f$. Constrained splits can also be
62 /// specified in the product of categories. In that case, the name of the
63 /// remainder state follows the syntax `"{State1;State2}"`, where `State1` and
64 /// `State2` are the state names of the two spitting categories.
65 ///
66 /// ## Splitting multiple PDFs
67 /// The examples so far deal with a single prototype PDF. It is also
68 /// possible to build with multiple prototype PDFs by specifying a
69 /// mapping between the prototype to use and the names of states of
70 /// a "master" splitting category. To specify these configurations,
71 /// an intermediate `MultiBuildConfig` must be composed with all
72 /// the necessary specifications. This, for example,
73 /// ```
74 /// RooSimWSTool::MultiBuildConfig mbc("mc");
75 /// mbc.addPdf("I","G",SplitParam("m,s","c"));
76 /// mbc.addPdf("II,III","F",SplitParam("a","c,d"));
77 /// ```
78 /// configures a build with two prototype PDFs \f$ G \f$ and \f$ F \f$.
79 /// Prototype \f$ G \f$ is used for state `"I"` of the master split category
80 /// `mc` and prototype \f$ F \f$ is used for states `"II"` and `"III"` of the
81 /// master split category `mc`. Furthermore, the parameters \f$ m,s \f$ of
82 /// prototype \f$ G \f$ are split
83 /// in category \f$ c \f$ while the parameter \f$ a \f$ of prototype \f$ F \f$ is split in
84 /// the product of the categories \f$ c \f$ and \f$ d \f$. The actual build is then
85 /// performed by passing the build configuration to RooSimWSTool, *e.g.*,
86 /// ```
87 /// wst.build("MASTER", mbc);
88 /// ```
89 /// By default, a specialisation is built for each permutation of
90 /// states of the splitting categories that are used. It is possible
91 /// to restrict the building of specialised PDFs to a subset of states
92 /// by adding a restriction on the number of states to build as follows:
93 /// ```
94 /// mbc.restrictBuild("c","A,B");
95 /// ```
96 /// The restrictBuild method can be called multiple times, but at most
97 /// once for each splitting category in use. For simple builds with a single
98 /// prototype, restriction can be specified with a Restrict() argument
99 /// on the build command line.
100 ///
101 
102 
103 #include "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 
127 using namespace std ;
128 
129 namespace {
130 
131 static Int_t init();
132 
133 Int_t dummy = init() ;
134 
135 static 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 
177 RooSimultaneous* 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 
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  TIter 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() ;
493  RooCatType* type ;
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 
529  // List all existing workspace components as prebuilt items for the customizers at this point
530  splitNodeListAll.add(_ws->components()) ;
531 
532  if (verbose) coutI(ObjectHandling) << "RooSimWSTool::executeBuild: configured customizers for all prototype pdfs" << endl ;
533 
534  // Create fit category from physCat and splitCatList ;
535  RooArgSet fitCatList ;
536  if (physCat) fitCatList.add(*physCat) ;
537 
538  // Add observables of splitCatSet members, rather than splitCatSet members directly
539  // as there may be cat->cat functions in here
540  scsiter = splitCatSet.createIterator() ;
541  while((scat=(RooAbsCategory*)scsiter->Next())) {
542  if (scat->isFundamental()) {
543  fitCatList.add(*scat) ;
544  } else {
545  RooArgSet* scatvars = scat->getVariables() ;
546  fitCatList.add(*scatvars) ;
547  delete scatvars ;
548  }
549  }
550  delete scsiter ;
551 
552 
553  TIterator* fclIter = fitCatList.createIterator() ;
554  string mcatname = string(simPdfName) + "_index" ;
555  RooAbsCategoryLValue* fitCat = 0 ;
556  if (fitCatList.getSize()>1) {
557  fitCat = new RooSuperCategory(mcatname.c_str(),mcatname.c_str(),fitCatList) ;
558  cleanupList.addOwned(*fitCat) ;
559  } else {
560  fitCat = (RooAbsCategoryLValue*) fitCatList.first() ;
561  }
562 
563  // Create master PDF
564  RooSimultaneous* simPdf = new RooSimultaneous(simPdfName,simPdfName,*fitCat) ;
565  cleanupList.addOwned(*simPdf) ;
566 
567  // Add component PDFs to master PDF
568  TIterator* fcIter = fitCat->typeIterator() ;
569 
570  RooCatType* fcState ;
571  while((fcState=(RooCatType*)fcIter->Next())) {
572  // Select fitCat state
573  fitCat->setLabel(fcState->GetName()) ;
574 
575  // Check if this fitCat state is selected
576  fclIter->Reset() ;
577  RooAbsCategory* splitCat ;
578  Bool_t select(kFALSE) ;
579  if (obc._restr.size()>0) {
580  while((splitCat=(RooAbsCategory*)fclIter->Next())) {
581  // Find selected state list
582 
583  list<const RooCatType*> slist = obc._restr[splitCat] ;
584  if (slist.empty()) {
585  continue ;
586  }
587 
588  list<const RooCatType*>::iterator sli ;
589  for (sli=slist.begin() ; sli!=slist.end() ; ++sli) {
590  if (string(splitCat->getCurrentLabel())==(*sli)->GetName()) {
591  select=kTRUE ;
592  }
593  }
594  }
595  if (!select) continue ;
596  } else {
597  select = kTRUE ;
598  }
599 
600  // Select appropriate PDF for this physCat state
601  RooCustomizer* physCustomizer ;
602  if (physCat) {
603  RooAbsPdf* pdf = stateMap[physCat->getCurrentLabel()] ;
604  if (pdf==0) {
605  continue ;
606  }
607  physCustomizer = (RooCustomizer*) customizerList->FindObject(pdf->GetName());
608  } else {
609  physCustomizer = (RooCustomizer*) customizerList->First() ;
610  }
611 
612  if (verbose) coutI(ObjectHandling) << "RooSimWSTool::executeBuild: Customizing prototype pdf " << physCustomizer->GetName()
613  << " for mode " << fcState->GetName() << endl ;
614 
615  // Customizer PDF for current state and add to master simPdf
616  RooAbsPdf* fcPdf = (RooAbsPdf*) physCustomizer->build(masterSplitCat->getCurrentLabel(),kFALSE) ;
617  simPdf->addPdf(*fcPdf,fcState->GetName()) ;
618  }
619  delete fcIter ;
620 
622 
623  // Delete customizers
624  customizerList->Delete() ;
625  delete customizerList ;
626  delete fclIter ;
627  return (RooSimultaneous*) _ws->pdf(simPdf->GetName()) ;
628 }
629 
630 
631 
632 ////////////////////////////////////////////////////////////////////////////////
633 /// Construct name of composite split
634 
635 std::string RooSimWSTool::makeSplitName(const RooArgSet& splitCatSet)
636 {
637  string name ;
638 
639  TIterator* iter = splitCatSet.createIterator() ;
640  RooAbsArg* arg ;
641  Bool_t first=kTRUE ;
642  while((arg=(RooAbsArg*)iter->Next())) {
643  if (first) {
644  first=kFALSE;
645  } else {
646  name += "," ;
647  }
648  name += arg->GetName() ;
649  }
650  delete iter ;
651 
652  return name ;
653 }
654 
655 
656 
657 
658 ////////////////////////////////////////////////////////////////////////////////
659 /// Specify that parameters names listed in paramNameList be split in (product of) category(s)
660 /// listed in categoryNameList
661 
662 void RooSimWSTool::SplitRule::splitParameter(const char* paramNameList, const char* categoryNameList)
663 {
664  char paramBuf[4096] ;
665  char catBuf[4096] ;
666  strlcpy(paramBuf,paramNameList,4096) ;
667  strlcpy(catBuf,categoryNameList,4096) ;
668 
669  // First parse category list
670  list<string> catList ;
671  char* cat = strtok(catBuf,"{,}") ;
672  while(cat) {
673  catList.push_back(cat) ;
674  cat = strtok(0,"{,}") ;
675  }
676 
677  // Now parse parameter list
678  char* param = strtok(paramBuf,"{,}") ;
679  while(param) {
680  _paramSplitMap[param] = pair<list<string>,string>(catList,"") ;
681  param = strtok(0,"{,}") ;
682  }
683 }
684 
685 
686 ////////////////////////////////////////////////////////////////////////////////
687 /// Specify that parameters names listed in paramNameList be split in constrained way in (product of) category(s)
688 /// listed in categoryNameList and that remainder fraction formula be put in state with name remainderStateName
689 
690 void RooSimWSTool::SplitRule::splitParameterConstrained(const char* paramNameList, const char* categoryNameList, const char* remainderStateName)
691 {
692  char paramBuf[4096] ;
693  char catBuf[4096] ;
694  strlcpy(paramBuf,paramNameList,4096) ;
695  strlcpy(catBuf,categoryNameList,4096) ;
696 
697  // First parse category list
698  list<string> catList ;
699  char* cat = strtok(catBuf,"{,}") ;
700  while(cat) {
701  catList.push_back(cat) ;
702  cat = strtok(0,"{,}") ;
703  }
704 
705  // Now parse parameter list
706  char* param = strtok(paramBuf,"{,}") ;
707  while(param) {
708  _paramSplitMap[param] = pair<list<string>,string>(catList,remainderStateName) ;
709  param = strtok(0,"{,}") ;
710  }
711 }
712 
713 
714 ////////////////////////////////////////////////////////////////////////////////
715 /// Construct the SplitRule object from a list of named arguments past to RooSimWSTool::build
716 /// This method parses any SplitParam and SplitParamComstrained argument in the list
717 
718 void RooSimWSTool::SplitRule::configure(const RooCmdArg& arg1,const RooCmdArg& arg2,const RooCmdArg& arg3,
719  const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
720 {
721  list<const RooCmdArg*> cmdList ;
722  cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
723  cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
724  cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
725 
726  list<const RooCmdArg*>::iterator iter ;
727  for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
728 
729  if ((*iter)->opcode()==0) continue ;
730 
731  string name = (*iter)->opcode() ;
732 
733  if (name=="SplitParam") {
734  splitParameter((*iter)->getString(0),(*iter)->getString(1)) ;
735  } else if (name=="SplitParamConstrained") {
736  splitParameterConstrained((*iter)->getString(0),(*iter)->getString(1),(*iter)->getString(2)) ;
737  }
738  }
739 }
740 
741 
742 
743 
744 ////////////////////////////////////////////////////////////////////////////////
745 /// Add prototype p.d.f pdfName to build configuration with associated split rules 'sr'
746 
748 {
749  internalAddPdf(pdfName,"",sr) ;
750 }
751 
752 
753 ////////////////////////////////////////////////////////////////////////////////
754 /// Construct build configuration from single prototype 'pdfName' and list of arguments
755 /// that can be passed to RooSimWSTool::build() method. This routine parses SplitParam()
756 /// SplitParamConstrained() and Restrict() arguments.
757 
758 RooSimWSTool::BuildConfig::BuildConfig(const char* pdfName, const RooCmdArg& arg1,const RooCmdArg& arg2,
759  const RooCmdArg& arg3,const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
760 {
761  SplitRule sr(pdfName) ;
762  sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
763  internalAddPdf(pdfName,"",sr) ;
764  _conflProtocol = RooFit::RenameConflictNodes(pdfName) ;
765 
766  list<const RooCmdArg*> cmdList ;
767  cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
768  cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
769  cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
770 
771  list<const RooCmdArg*>::iterator iter ;
772  for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
773  if ((*iter)->opcode()==0) continue ;
774  string name = (*iter)->opcode() ;
775  if (name=="Restrict") {
776  restrictBuild((*iter)->getString(0),(*iter)->getString(1)) ;
777  }
778  if (name=="RenameConflictNodes") {
779  _conflProtocol = *(*iter) ;
780  }
781  }
782 }
783 
784 
785 ////////////////////////////////////////////////////////////////////////////////
786 /// Constructor to make BuildConfig from legacy RooSimPdfBuilder configuration
787 /// Empty for now
788 
789 RooSimWSTool::BuildConfig::BuildConfig(const RooArgSet& /*legacyBuildConfig*/)
790 {
791 }
792 
793 
794 ////////////////////////////////////////////////////////////////////////////////
795 /// Internal routine to add prototype pdf 'pdfName' with list of associated master states 'miStateNameList
796 /// and split rules 'sr' to configuration
797 
798 void RooSimWSTool::BuildConfig::internalAddPdf(const char* pdfName, const char* miStateNameList,SplitRule& sr)
799 {
800  char buf[4096] ;
801  strlcpy(buf,miStateNameList,4096) ;
802 
803  char* tok = strtok(buf,",") ;
804  while(tok) {
805  sr._miStateNameList.push_back(tok) ;
806  tok = strtok(0,",") ;
807  }
808 
809  _pdfmap[pdfName] = sr ;
810 }
811 
812 
813 ////////////////////////////////////////////////////////////////////////////////
814 /// Restrict build by only considering state names in stateList for split in category catName
815 
816 void RooSimWSTool::BuildConfig::restrictBuild(const char* catName, const char* stateList)
817 {
818  _restr[catName] = stateList ;
819 }
820 
821 
822 
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Construct MultiBuildConfig for build configuration with multiple prototype p.d.f.s
826 /// masterIndexCat is the name of the master index category that decides which
827 /// prototype is used.
828 
830 {
831  _masterCatName = masterIndexCat ;
832 }
833 
834 
835 
836 ////////////////////////////////////////////////////////////////////////////////
837 /// Add protytpe p.d.f 'pdfName' to MultiBuildConfig associated with master indes states 'miStateList'. This
838 /// method parses the SplitParam() and SplitParamConstrained() arguments
839 
840 void RooSimWSTool::MultiBuildConfig::addPdf(const char* miStateList, const char* pdfName, const RooCmdArg& arg1,const RooCmdArg& arg2,
841  const RooCmdArg& arg3,const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6)
842 {
843  SplitRule sr(pdfName) ;
844  sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
845  internalAddPdf(pdfName,miStateList,sr) ;
846 }
847 
848 
849 
850 ////////////////////////////////////////////////////////////////////////////////
851 /// Add protytpe p.d.f 'pdfName' to MultiBuildConfig associated with master indes states 'miStateList'.
852 
853 void RooSimWSTool::MultiBuildConfig::addPdf(const char* miStateList, const char* pdfName, SplitRule& sr)
854 {
855  internalAddPdf(pdfName,miStateList,sr) ;
856 }
857 
858 
859 
860 
861 ////////////////////////////////////////////////////////////////////////////////
862 /// Destructor
863 
865 {
866 }
867 
868 
869 
870 
871 ////////////////////////////////////////////////////////////////////////////////
872 /// Print details of a validated build configuration
873 
875 {
876  // --- Dump contents of object build config ---
877  map<RooAbsPdf*,ObjSplitRule>::iterator ri ;
878  for (ri = _pdfmap.begin() ; ri != _pdfmap.end() ; ++ri ) {
879  cout << "Splitrule for p.d.f " << ri->first->GetName() << " with state list " ;
880  for (std::list<const RooCatType*>::iterator misi= ri->second._miStateList.begin() ; misi!=ri->second._miStateList.end() ; ++misi) {
881  cout << (*misi)->GetName() << " " ;
882  }
883  cout << endl ;
884 
885  map<RooAbsArg*,pair<RooArgSet,string> >::iterator csi ;
886  for (csi = ri->second._paramSplitMap.begin() ; csi != ri->second._paramSplitMap.end() ; ++csi ) {
887  if (csi->second.second.length()>0) {
888  cout << " parameter " << csi->first->GetName() << " is split with constraint in categories " << csi->second.first
889  << " with remainder in state " << csi->second.second << endl ;
890  } else {
891  cout << " parameter " << csi->first->GetName() << " is split with constraint in categories " << csi->second.first << endl ;
892  }
893  }
894  }
895 
896  map<RooAbsCategory*,list<const RooCatType*> >::iterator riter ;
897  for (riter=_restr.begin() ; riter!=_restr.end() ; ++riter) {
898  cout << "Restricting build in category " << riter->first->GetName() << " to states " ;
899  list<const RooCatType*>::iterator i ;
900  for (i=riter->second.begin() ; i!=riter->second.end() ; ++i) {
901  if (i!=riter->second.begin()) cout << "," ;
902  cout << (*i)->GetName() ;
903  }
904  cout << endl ;
905  }
906 
907 }
908 
909 
910 
911 
912 ////////////////////////////////////////////////////////////////////////////////
913 
914 std::string RooSimWSTool::SimWSIFace::create(RooFactoryWSTool& ft, const char* typeName, const char* instanceName, std::vector<std::string> args)
915 {
916  string tn(typeName) ;
917  if (tn=="SIMCLONE") {
918 
919  // Perform syntax check. Warn about any meta parameters other than $SplitParam, $SplitParamConstrained, $Restrict and $Verbose
920  for (unsigned int i=1 ; i<args.size() ; i++) {
921  if (args[i].find("$SplitParam(")!=0 &&
922  args[i].find("$SplitParamConstrained(")!=0 &&
923  args[i].find("$SplitRestrict(")!=0 &&
924  args[i].find("$Verbose(")!=0) {
925  throw string(Form("RooSimWSTool::SimWSIFace::create() ERROR: unknown token %s encountered",args[i].c_str())) ;
926  }
927  }
928 
929  // Make SplitRule object from $SplitParam and $SplitParamConstrained arguments
930  RooSimWSTool::SplitRule sr(args[0].c_str()) ;
931  for (unsigned int i=1 ; i<args.size() ; i++) {
932  if (args[i].find("$SplitParam(")==0) {
933  vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
934  if (subargs.size()!=2) {
935  throw string(Form("Incorrect number of arguments in $SplitParam, have %d, expect 2",(Int_t)subargs.size())) ;
936  }
937  sr.splitParameter(subargs[0].c_str(),subargs[1].c_str()) ;
938  } else if (args[i].find("$SplitParamConstrained(")==0) {
939  vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
940  if (subargs.size()!=3) {
941  throw string(Form("Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(Int_t)subargs.size())) ;
942  }
943  sr.splitParameterConstrained(subargs[0].c_str(), subargs[1].c_str(), subargs[2].c_str()) ;
944  }
945  }
946 
947  // Make BuildConfig object
948  RooSimWSTool::BuildConfig bc(args[0].c_str(),sr) ;
949  for (unsigned int i=1 ; i<args.size() ; i++) {
950  if (args[i].find("$Restrict(")==0) {
951  vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
952  if (subargs.size()!=2) {
953  throw string(Form("Incorrect number of arguments in $Restrict, have %d, expect 2",(Int_t)subargs.size())) ;
954  }
955  bc.restrictBuild(subargs[0].c_str(),subargs[1].c_str()) ;
956  }
957  }
958 
959  // Look for verbose flag
961  for (unsigned int i=1 ; i<args.size() ; i++) {
962  if (args[i].find("$Verbose(")==0) {
963  vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
964  if (subargs.size()>0) {
965  verbose = atoi(subargs[0].c_str()) ;
966  }
967  }
968  }
969 
970  // Build pdf clone
971  RooSimWSTool sct(ft.ws()) ;
972  RooAbsPdf* pdf = sct.build(instanceName,bc,verbose) ;
973  if (!pdf) {
974  throw string(Form("RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
975  }
976 
977  // Import into workspace
978  ft.ws().import(*pdf,RooFit::Silence()) ;
979 
980  } else if (tn=="MSIMCLONE") {
981 
982  // First make a multibuild config from the master index cat
983  RooSimWSTool::MultiBuildConfig mbc(args[0].c_str()) ;
984 
985  for (unsigned int i=1 ; i<args.size() ; i++) {
986  if (args[i].find("$AddPdf(")==0) {
987  // Process an add-pdf operation
988  vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
989 
990  // Make SplitRule object from $SplitParam and $SplitParamConstrained arguments
991  RooSimWSTool::SplitRule sr(subargs[1].c_str()) ;
992  for (unsigned int j=2 ; j<subargs.size() ; j++) {
993  if (subargs[j].find("$SplitParam(")==0) {
994  vector<string> subsubargs = ft.splitFunctionArgs(subargs[j].c_str()) ;
995  if (subsubargs.size()!=2) {
996  throw string(Form("Incorrect number of arguments in $SplitParam, have %d, expect 2",(Int_t)subsubargs.size())) ;
997  }
998  sr.splitParameter(subsubargs[0].c_str(),subsubargs[1].c_str()) ;
999  } else if (subargs[j].find("$SplitParamConstrained(")==0) {
1000  vector<string> subsubargs = ft.splitFunctionArgs(subargs[j].c_str()) ;
1001  if (subsubargs.size()!=3) {
1002  throw string(Form("Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(Int_t)subsubargs.size())) ;
1003  }
1004  sr.splitParameterConstrained(subsubargs[0].c_str(), subsubargs[1].c_str(), subsubargs[2].c_str()) ;
1005  }
1006  }
1007  mbc.addPdf(subargs[0].c_str(),subargs[1].c_str(),sr) ;
1008 
1009  } else if (args[i].find("$Restrict(")==0) {
1010 
1011  // Process a restrict operation
1012  vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
1013  if (subargs.size()!=2) {
1014  throw string(Form("Incorrect number of arguments in $Restrict, have %d, expect 2",(Int_t)subargs.size())) ;
1015  }
1016  mbc.restrictBuild(subargs[0].c_str(),subargs[1].c_str()) ;
1017 
1018  } else {
1019  throw string(Form("RooSimWSTool::SimWSIFace::create() ERROR: unknown token in MSIMCLONE: %s",args[i].c_str())) ;
1020  }
1021  }
1022 
1023  // Build pdf clone
1024  RooSimWSTool sct(ft.ws()) ;
1025  RooAbsPdf* pdf = sct.build(instanceName,mbc,kFALSE) ;
1026  if (!pdf) {
1027  throw string(Form("RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
1028  }
1029 
1030  // Import into workspace
1031  ft.ws().import(*pdf,RooFit::Silence()) ;
1032 
1033 
1034  } else {
1035  throw string(Form("RooSimWSTool::SimWSIFace::create() ERROR: Unknown meta-type %s requested",typeName)) ;
1036  }
1037 
1038  return string(instanceName) ;
1039 }
RooSimWSTool::BuildConfig::_restr
std::map< std::string, std::string > _restr
Definition: RooSimWSTool.h:120
RooSuperCategory.h
RooFit::RenameConflictNodes
RooCmdArg RenameConflictNodes(const char *suffix, Bool_t renameOrigNodes=kFALSE)
Definition: RooGlobalFunc.cxx:345
RooCmdArg
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
first
Definition: first.py:1
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooSimWSTool::SplitRule::configure
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...
Definition: RooSimWSTool.cxx:718
RooMsgService.h
RooAbsCollection::first
RooAbsArg * first() const
Definition: RooAbsCollection.h:236
RooCustomizer::splitArgs
void splitArgs(const RooArgSet &argSet, const RooAbsCategory &splitCat)
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'.
Definition: RooCustomizer.cxx:295
RooFit.h
RooSimultaneous.h
RooAbsCategoryLValue::setLabel
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:61
RooSimWSTool::SimWSIFace::create
std::string create(RooFactoryWSTool &ft, const char *typeName, const char *instanceName, std::vector< std::string > args)
Definition: RooSimWSTool.cxx:914
RooSimWSTool::SplitRule::splitParameterConstrained
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...
Definition: RooSimWSTool.cxx:690
TList::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:578
TList::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:470
RooSimWSTool::ObjBuildConfig::_usedSplitCats
RooArgSet _usedSplitCats
Definition: RooSimWSTool.h:177
RooSimWSTool::~RooSimWSTool
virtual ~RooSimWSTool()
Destructor.
Definition: RooSimWSTool.cxx:159
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
RooAbsArg::dependsOnValue
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
RooSimWSTool::RooSimWSTool
RooSimWSTool(RooWorkspace &ws)
Constructor of SimWSTool on given workspace.
Definition: RooSimWSTool.cxx:150
RooSimWSTool::ObjBuildConfig::_pdfmap
std::map< RooAbsPdf *, ObjSplitRule > _pdfmap
Definition: RooSimWSTool.h:174
RooSimWSTool::ObjBuildConfig::_masterCat
RooCategory * _masterCat
Definition: RooSimWSTool.h:176
RooCustomizer
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
Definition: RooCustomizer.h:35
RooWorkspace::catfunc
RooAbsCategory * catfunc(const char *name) const
Retrieve discrete function (RooAbsCategory) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1313
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooCatType::GetName
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatTypeLegacy.h:45
RooAbsCollection::remove
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
Definition: RooAbsCollection.cxx:585
RooSimWSTool::ObjBuildConfig::print
void print()
Print details of a validated build configuration.
Definition: RooSimWSTool.cxx:874
RooSimWSTool::ObjBuildConfig::_restr
std::map< RooAbsCategory *, std::list< const RooCatType * > > _restr
Definition: RooSimWSTool.h:175
coutI
#define coutI(a)
Definition: RooMsgService.h:30
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooFracRemainder.h
RooFactoryWSTool::ws
RooWorkspace & ws()
Definition: RooFactoryWSTool.h:74
TString
Basic string class.
Definition: TString.h:136
RooCustomizer::build
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...
Definition: RooCustomizer.cxx:397
RooAbsCategory::getCurrentLabel
virtual const char * getCurrentLabel() const
Return label string of current state.
Definition: RooAbsCategory.cxx:130
RooSimWSTool::_ws
RooWorkspace * _ws
Definition: RooSimWSTool.h:74
RooSimultaneous::addPdf
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
Definition: RooSimultaneous.cxx:373
bool
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
RooSimWSTool::build
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...
Definition: RooSimWSTool.cxx:177
RooSimWSTool::BuildConfig::restrictBuild
void restrictBuild(const char *catName, const char *stateList)
Restrict build by only considering state names in stateList for split in category catName.
Definition: RooSimWSTool.cxx:816
RooWorkspace::import
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.
Definition: RooWorkspace.cxx:361
RooAbsCategory
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
Definition: RooAbsCategory.h:37
TList::First
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:659
RooFactoryWSTool::registerSpecial
static void registerSpecial(const char *typeName, RooFactoryWSTool::IFace *iface)
Register foreign special objects in factory.
Definition: RooFactoryWSTool.cxx:1937
RooSimWSTool::BuildConfig
Definition: RooSimWSTool.h:103
RooFactoryWSTool::splitFunctionArgs
std::vector< std::string > splitFunctionArgs(const char *funcExpr)
Allocate and fill work buffer.
Definition: RooFactoryWSTool.cxx:1453
RooFactoryWSTool
RooFactoryWSTool is a class similar to TTree::MakeClass() that generates skeleton code for RooAbsPdf ...
Definition: RooFactoryWSTool.h:47
ws
void ws()
Definition: ws.C:66
RooFactoryWSTool.h
RooFracRemainder
RooFracRemainder calculates the remainder fraction of a sum of RooAbsReal fraction,...
Definition: RooFracRemainder.h:25
RooCustomizer.h
RooSimWSTool::ObjSplitRule::_miStateList
std::list< const RooCatType * > _miStateList
Definition: RooSimWSTool.h:159
RooMultiCategory
RooMultiCategory connects several RooAbsCategory objects into a single category.
Definition: RooMultiCategory.h:28
RooMultiCategory.h
RooAbsPdf.h
RooSimWSTool::ObjBuildConfig
Definition: RooSimWSTool.h:166
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
TGeant4Unit::sr
static constexpr double sr
Definition: TGeant4SystemOfUnits.h:144
RooWorkspace::cat
RooCategory * cat(const char *name) const
Retrieve discrete variable (RooCategory) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1304
RooAbsCollection::createIterator
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
Definition: RooAbsCollection.h:178
RooSimWSTool::BuildConfig::_masterCatName
std::string _masterCatName
Definition: RooSimWSTool.h:118
RooWorkspace::components
const RooArgSet & components() const
Definition: RooWorkspace.h:117
RooSimWSTool::validateConfig
ObjBuildConfig * validateConfig(BuildConfig &bc)
Validate build configuration.
Definition: RooSimWSTool.cxx:211
RooWorkspace::pdf
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Definition: RooWorkspace.cxx:1277
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:455
RooAbsCategory::lookupType
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.
Definition: RooAbsCategory.cxx:307
RooCategory.h
RooAbsCategory::typeIterator
TIterator * typeIterator() const
Definition: RooAbsCategory.cxx:671
RooFit::ObjectHandling
@ ObjectHandling
Definition: RooGlobalFunc.h:61
RooSimWSTool::MultiBuildConfig
Definition: RooSimWSTool.h:130
RooRealVar.h
RooWorkspace::fundArg
RooAbsArg * fundArg(const char *name) const
Return fundamental (i.e.
Definition: RooWorkspace.cxx:1354
void
typedef void((*Func_t)())
RooAbsCollection::addOwned
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:403
TIterator::Next
virtual TObject * Next()=0
RooGlobalFunc.h
RooAbsArg::isFundamental
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
RooFactoryWSTool::IFace
Definition: RooFactoryWSTool.h:139
RooSimWSTool::ObjSplitRule
Definition: RooSimWSTool.h:151
TIterator::Reset
virtual void Reset()=0
TIter::Next
TObject * Next()
Definition: TCollection.h:249
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooSimWSTool::ObjSplitRule::_paramSplitMap
std::map< RooAbsArg *, std::pair< RooArgSet, std::string > > _paramSplitMap
Definition: RooSimWSTool.h:160
RooSimWSTool::MultiBuildConfig::addPdf
void addPdf(const char *miStateList, const char *pdfName, SplitRule &sr)
Add protytpe p.d.f 'pdfName' to MultiBuildConfig associated with master indes states 'miStateList'.
Definition: RooSimWSTool.cxx:853
RooSimWSTool::BuildConfig::internalAddPdf
void internalAddPdf(const char *pdfName, const char *miStateList, SplitRule &sr)
Internal routine to add prototype pdf 'pdfName' with list of associated master states 'miStateNameLis...
Definition: RooSimWSTool.cxx:798
RooCategory
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
RooSuperCategory
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
Definition: RooSuperCategory.h:27
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
RooAbsCategory::hasLabel
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
Definition: RooAbsCategory.h:64
RooSimWSTool::SplitRule
Definition: RooSimWSTool.h:80
RooSimWSTool::SplitRule::splitParameter
void splitParameter(const char *paramList, const char *categoryList)
Specify that parameters names listed in paramNameList be split in (product of) category(s) listed in ...
Definition: RooSimWSTool.cxx:662
name
char name[80]
Definition: TGX11.cxx:110
RooAbsArg::dependsOn
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:799
RooCatType
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
Definition: RooCatTypeLegacy.h:23
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooSimWSTool::MultiBuildConfig::MultiBuildConfig
MultiBuildConfig(const char *masterIndexCat)
Construct MultiBuildConfig for build configuration with multiple prototype p.d.f.s masterIndexCat is ...
Definition: RooSimWSTool.cxx:829
TIter
Definition: TCollection.h:233
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooSimWSTool
The RooSimWSTool is a tool operating on RooWorkspace objects that can clone PDFs into a series of var...
Definition: RooSimWSTool.h:37
RooSimWSTool.h
RooAbsPdf
Definition: RooAbsPdf.h:41
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
RooSimWSTool::BuildConfig::BuildConfig
BuildConfig()
Definition: RooSimWSTool.h:116
type
int type
Definition: TGX11.cxx:121
RooFit::Silence
RooCmdArg Silence(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:296
RooAbsArg::getVariables
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2008
RooSimultaneous
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Definition: RooSimultaneous.h:37
RooSimWSTool::SimWSIFace
Definition: RooSimWSTool.h:59
RooAbsCategoryLValue
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Definition: RooAbsCategoryLValue.h:25
RooCatTypeLegacy.h
RooSimWSTool::executeBuild
RooSimultaneous * executeBuild(const char *simPdfName, ObjBuildConfig &obc, Bool_t verbose=kTRUE)
Internal build driver from validation ObjBuildConfig.
Definition: RooSimWSTool.cxx:398
RooSimWSTool::BuildConfig::_pdfmap
std::map< std::string, SplitRule > _pdfmap
Definition: RooSimWSTool.h:119
RooSimWSTool::ObjBuildConfig::_conflProtocol
RooCmdArg _conflProtocol
Definition: RooSimWSTool.h:178
RooSimWSTool::makeSplitName
std::string makeSplitName(const RooArgSet &splitCatSet)
Construct name of composite split.
Definition: RooSimWSTool.cxx:635
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:231
TList
A doubly linked list.
Definition: TList.h:44
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
int
RooSimWSTool::ObjSplitRule::~ObjSplitRule
virtual ~ObjSplitRule()
Destructor.
Definition: RooSimWSTool.cxx:864
RooSimWSTool::SplitRule::_paramSplitMap
std::map< std::string, std::pair< std::list< std::string >, std::string > > _paramSplitMap
Definition: RooSimWSTool.h:97