133Int_t dummy = init() ;
180 BuildConfig bc(protoPdfName,arg1,arg2,arg3,arg4,arg5,arg6) ;
181 return build(simPdfName,bc) ;
219 coutE(ObjectHandling) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: associated workspace " <<
_ws->
GetName()
221 <<
" that was designated as master index category in the build configuration" << endl ;
229 map<string,SplitRule>::iterator pdfiter ;
231 for (pdfiter = bc.
_pdfmap.begin() ; pdfiter != bc.
_pdfmap.end() ; ++pdfiter) {
236 coutE(ObjectHandling) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: associated workspace " <<
_ws->
GetName()
237 <<
" does not contain a pdf named " << pdfiter->second.GetName() << endl ;
248 map<string, pair<list<string>,
string> >::iterator pariter ;
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 ;
263 coutE(ObjectHandling) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: specified parameter " << pariter->first
264 <<
" in split is not function of p.d.f " << pdf->
GetName() << endl ;
271 list<string>::iterator catiter ;
272 for (catiter = pariter->second.first.begin() ; catiter!=pariter->second.first.end() ; ++catiter) {
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 ;
281 splitCatSet.
add(*cat) ;
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 ;
302 if (pariter->second.second.size()>0) {
304 coutE(InputArguments) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: Constrained split specified in non real-valued parameter " << farg->
GetName() << endl ;
316 list<string>::iterator misi ;
321 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
338 list<string>::iterator misi ;
343 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
358 map<string,string>::iterator riter ;
359 for (riter=bc.
_restr.begin() ; riter!=bc.
_restr.end() ; ++riter) {
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 ;
370 list<const RooCatType*> rlist ;
371 strlcpy(buf,riter->second.c_str(),4096) ;
373 char* tok = strtok(buf,
"{,}") ;
377 coutE(ObjectHandling) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: restricted build category " << cat->
GetName()
378 <<
" does not have state " << tok <<
" as specified in restriction list" << endl ;
382 rlist.push_back(ctype) ;
383 tok = strtok(0,
"{,}") ;
386 obc->
_restr[cat] = rlist ;
405 map<string,RooAbsPdf*> stateMap ;
407 map<RooAbsPdf*,ObjSplitRule>::iterator physIter = obc.
_pdfmap.begin() ;
408 while(physIter!=obc.
_pdfmap.end()) {
412 physModelSet.
add(*physModel,
kTRUE) ;
414 list<const RooCatType*>::iterator stiter ;
415 for (stiter=physIter->second._miStateList.begin() ; stiter!=physIter->second._miStateList.end() ; ++stiter) {
416 stateMap[(*stiter)->GetName()] = physModel ;
422 if (verbose)
coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: list of prototype pdfs " << physModelSet << endl ;
425 if (physCat) splitCatSet.
add(*physCat) ;
432 splitCatSetFund.
add(*scat) ;
435 splitCatSetFund.
add(*scatvars) ;
443 if (splitCatSetFund.
getSize()>1) {
444 masterSplitCat =
new RooSuperCategory(
"masterSplitCat",
"Master splitting category",splitCatSetFund) ;
448 if (verbose)
coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: list of splitting categories " << splitCatSet << endl ;
458 if (verbose)
coutI(ObjectHandling) <<
"RooSimPdfBuilder::executeBuild: processing prototype pdf " << physModel->
GetName() << endl ;
461 customizerList->
Add(physCustomizer) ;
463 map<RooAbsArg*, pair<RooArgSet,string> >::iterator splitIter ;
464 for (splitIter = obc.
_pdfmap[physModel]._paramSplitMap.begin() ; splitIter != obc.
_pdfmap[physModel]._paramSplitMap.end() ; ++splitIter) {
475 splitCat =
new RooMultiCategory(splitName.c_str(),splitName.c_str(),splitCatSetTmp) ;
481 if(splitIter->second.second.size()>0) {
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 ;
497 if (splitIter->second.second ==
type->GetName()) continue ;
500 TString splitLeafName(splitIter->first->GetName()) ;
501 splitLeafName.
Append(
"_") ;
511 fracLeafList.
add(*splitLeaf) ;
525 physCustomizer->
splitArgs(*splitIter->first,*splitCat) ;
533 if (verbose)
coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: configured customizers for all prototype pdfs" << endl ;
537 if (physCat) fitCatList.
add(*physCat) ;
544 fitCatList.
add(*scat) ;
547 fitCatList.
add(*scatvars) ;
555 string mcatname = string(simPdfName) +
"_index" ;
558 fitCat =
new RooSuperCategory(mcatname.c_str(),mcatname.c_str(),fitCatList) ;
580 if (obc.
_restr.size()>0) {
584 list<const RooCatType*> slist = obc.
_restr[splitCat] ;
589 list<const RooCatType*>::iterator sli ;
590 for (sli=slist.begin() ; sli!=slist.end() ; ++sli) {
596 if (!select) continue ;
613 if (verbose)
coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: Customizing prototype pdf " << physCustomizer->
GetName()
614 <<
" for mode " << fcState->
GetName() << endl ;
625 customizerList->
Delete() ;
626 delete customizerList ;
665 char paramBuf[4096] ;
667 strlcpy(paramBuf,paramNameList,4096) ;
668 strlcpy(catBuf,categoryNameList,4096) ;
671 list<string> catList ;
672 char* cat = strtok(catBuf,
"{,}") ;
674 catList.push_back(cat) ;
675 cat = strtok(0,
"{,}") ;
679 char* param = strtok(paramBuf,
"{,}") ;
682 param = strtok(0,
"{,}") ;
693 char paramBuf[4096] ;
695 strlcpy(paramBuf,paramNameList,4096) ;
696 strlcpy(catBuf,categoryNameList,4096) ;
699 list<string> catList ;
700 char* cat = strtok(catBuf,
"{,}") ;
702 catList.push_back(cat) ;
703 cat = strtok(0,
"{,}") ;
707 char* param = strtok(paramBuf,
"{,}") ;
709 _paramSplitMap[param] = pair<list<string>,
string>(catList,remainderStateName) ;
710 param = strtok(0,
"{,}") ;
722 list<const RooCmdArg*> cmdList ;
723 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
724 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
725 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
727 list<const RooCmdArg*>::iterator iter ;
728 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
730 if ((*iter)->opcode()==0)
continue ;
732 string name = (*iter)->opcode() ;
734 if (
name==
"SplitParam") {
735 splitParameter((*iter)->getString(0),(*iter)->getString(1)) ;
736 }
else if (
name==
"SplitParamConstrained") {
737 splitParameterConstrained((*iter)->getString(0),(*iter)->getString(1),(*iter)->getString(2)) ;
750 internalAddPdf(pdfName,
"",sr) ;
763 sr.
configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
764 internalAddPdf(pdfName,
"",sr) ;
767 list<const RooCmdArg*> cmdList ;
768 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
769 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
770 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
772 list<const RooCmdArg*>::iterator iter ;
773 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
774 if ((*iter)->opcode()==0)
continue ;
775 string name = (*iter)->opcode() ;
776 if (
name==
"Restrict") {
777 restrictBuild((*iter)->getString(0),(*iter)->getString(1)) ;
779 if (
name==
"RenameConflictNodes") {
780 _conflProtocol = *(*iter) ;
802 strlcpy(buf,miStateNameList,4096) ;
804 char* tok = strtok(buf,
",") ;
807 tok = strtok(0,
",") ;
810 _pdfmap[pdfName] = sr ;
819 _restr[catName] = stateList ;
832 _masterCatName = masterIndexCat ;
845 sr.
configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
846 internalAddPdf(pdfName,miStateList,sr) ;
856 internalAddPdf(pdfName,miStateList,sr) ;
878 map<RooAbsPdf*,ObjSplitRule>::iterator ri ;
879 for (ri = _pdfmap.begin() ; ri != _pdfmap.end() ; ++ri ) {
880 cout <<
"Splitrule for p.d.f " << ri->first->GetName() <<
" with state list " ;
881 for (std::list<const RooCatType*>::iterator misi= ri->second._miStateList.begin() ; misi!=ri->second._miStateList.end() ; ++misi) {
882 cout << (*misi)->GetName() <<
" " ;
886 map<RooAbsArg*,pair<RooArgSet,string> >::iterator csi ;
887 for (csi = ri->second._paramSplitMap.begin() ; csi != ri->second._paramSplitMap.end() ; ++csi ) {
888 if (csi->second.second.length()>0) {
889 cout <<
" parameter " << csi->first->GetName() <<
" is split with constraint in categories " << csi->second.first
890 <<
" with remainder in state " << csi->second.second << endl ;
892 cout <<
" parameter " << csi->first->GetName() <<
" is split with constraint in categories " << csi->second.first << endl ;
897 map<RooAbsCategory*,list<const RooCatType*> >::iterator riter ;
898 for (riter=_restr.begin() ; riter!=_restr.end() ; ++riter) {
899 cout <<
"Restricting build in category " << riter->first->GetName() <<
" to states " ;
900 list<const RooCatType*>::iterator i ;
901 for (i=riter->second.begin() ; i!=riter->second.end() ; ++i) {
902 if (i!=riter->second.begin()) cout <<
"," ;
903 cout << (*i)->GetName() ;
917 string tn(typeName) ;
918 if (tn==
"SIMCLONE") {
921 for (
unsigned int i=1 ; i<args.size() ; i++) {
922 if (args[i].find(
"$SplitParam(")!=0 &&
923 args[i].find(
"$SplitParamConstrained(")!=0 &&
924 args[i].find(
"$SplitRestrict(")!=0 &&
925 args[i].find(
"$Verbose(")!=0) {
926 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token %s encountered",args[i].c_str())) ;
932 for (
unsigned int i=1 ; i<args.size() ; i++) {
933 if (args[i].find(
"$SplitParam(")==0) {
935 if (subargs.size()!=2) {
936 throw string(
Form(
"Incorrect number of arguments in $SplitParam, have %d, expect 2",(
Int_t)subargs.size())) ;
939 }
else if (args[i].find(
"$SplitParamConstrained(")==0) {
941 if (subargs.size()!=3) {
942 throw string(
Form(
"Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(
Int_t)subargs.size())) ;
950 for (
unsigned int i=1 ; i<args.size() ; i++) {
951 if (args[i].find(
"$Restrict(")==0) {
953 if (subargs.size()!=2) {
954 throw string(
Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(
Int_t)subargs.size())) ;
962 for (
unsigned int i=1 ; i<args.size() ; i++) {
963 if (args[i].find(
"$Verbose(")==0) {
965 if (subargs.size()>0) {
966 verbose = atoi(subargs[0].c_str()) ;
975 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
981 }
else if (tn==
"MSIMCLONE") {
986 for (
unsigned int i=1 ; i<args.size() ; i++) {
987 if (args[i].find(
"$AddPdf(")==0) {
993 for (
unsigned int j=2 ; j<subargs.size() ; j++) {
994 if (subargs[j].find(
"$SplitParam(")==0) {
996 if (subsubargs.size()!=2) {
997 throw string(
Form(
"Incorrect number of arguments in $SplitParam, have %d, expect 2",(
Int_t)subsubargs.size())) ;
1000 }
else if (subargs[j].find(
"$SplitParamConstrained(")==0) {
1002 if (subsubargs.size()!=3) {
1003 throw string(
Form(
"Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(
Int_t)subsubargs.size())) ;
1008 mbc.
addPdf(subargs[0].c_str(),subargs[1].c_str(),sr) ;
1010 }
else if (args[i].find(
"$Restrict(")==0) {
1014 if (subargs.size()!=2) {
1015 throw string(
Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(
Int_t)subargs.size())) ;
1020 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token in MSIMCLONE: %s",args[i].c_str())) ;
1028 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
1036 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: Unknown meta-type %s requested",typeName)) ;
1039 return string(instanceName) ;
char * Form(const char *fmt,...)
typedef void((*Func_t)())
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Bool_t dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Check whether this object depends on values from an element in the serverList.
virtual TObject * clone(const char *newname=0) const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
virtual const char * getCurrentLabel() const
Return label string of current state.
TIterator * typeIterator() const
const RooCatType * lookupType(value_type index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return nullptr for no match.
RooAbsArg * first() const
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to an owning set.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
virtual const Text_t * GetName() const
Returns name of object.
RooCategory is an object to represent discrete states.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
void splitArgs(const RooArgSet &argSet, const RooAbsCategory &splitCat)
Split all arguments in 'set' into individualized clones for each defined state of 'splitCat'.
RooAbsArg * build(const char *masterCatState, Bool_t verbose=kFALSE)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
RooFracRemainder calculates the remainder fraction of a sum of RooAbsReal fraction,...
RooMultiCategory connects several RooAbsCategory objects into a single category.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
Bool_t addPdf(const RooAbsPdf &pdf, const char *catLabel)
Associate given PDF with index category state label 'catLabel'.
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
The RooWorkspace is a persistable container for RooFit projects.
RooAbsArg * fundArg(const char *name) const
Return fundamental (i.e.
RooCategory * cat(const char *name) const
Retrieve discrete variable (RooCategory) with given name. A null pointer is returned if not found.
RooAbsCategory * catfunc(const char *name) const
Retrieve discrete function (RooAbsCategory) with given name. A null pointer is returned if not found.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
const RooArgSet & components() const
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Iterator abstract base class.
virtual TObject * Next()=0
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
virtual const char * GetName() const
Returns name of object.
TString & Append(const char *cs)
RooCmdArg RenameConflictNodes(const char *suffix, Bool_t renameOrigNodes=kFALSE)
RooCmdArg Silence(Bool_t flag=kTRUE)