178 BuildConfig bc(protoPdfName,arg1,arg2,arg3,arg4,arg5,arg6) ;
179 return build(simPdfName,bc) ;
219 <<
" that was designated as master index category in the build configuration" << endl ;
227 map<string,SplitRule>::iterator pdfiter ;
229 for (pdfiter = bc.
_pdfmap.begin() ; pdfiter != bc.
_pdfmap.end() ; ++pdfiter) {
235 <<
" does not contain a pdf named " << pdfiter->second.GetName() << endl ;
246 map<string, pair<list<string>,
string> >::iterator pariter ;
247 for (pariter=
sr._paramSplitMap.begin() ; pariter!=
sr._paramSplitMap.end() ; ++pariter) {
253 <<
" does not contain a variable named " << pariter->first.c_str()
254 <<
" as specified in splitting rule of parameter " << pariter->first <<
" of p.d.f " << pdf << endl ;
262 <<
" in split is not function of p.d.f " << pdf->
GetName() << endl ;
269 list<string>::iterator catiter ;
270 for (catiter = pariter->second.first.begin() ; catiter!=pariter->second.first.end() ; ++catiter) {
274 <<
" does not contain a category named " << catiter->c_str()
275 <<
" as specified in splitting rule of parameter " << pariter->first <<
" of p.d.f " << pdf << endl ;
279 splitCatSet.
add(*cat) ;
290 <<
" used in composite split " << splitCatSet <<
" of parameter " << farg->
GetName() <<
" of pdf " << pdf->
GetName()
291 <<
" depends on one or more of the other splitting categories in the composite split" << endl ;
300 if (pariter->second.second.size()>0) {
302 coutE(
InputArguments) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: Constrained split specified in non real-valued parameter " << farg->
GetName() << endl ;
314 list<string>::iterator misi ;
315 for (misi=
sr._miStateNameList.begin() ; misi!=
sr._miStateNameList.end() ; ++misi) {
319 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
320 <<
sr.GetName() << endl ;
333 if (
sr._paramSplitMap.size()==0) {
336 list<string>::iterator misi ;
337 for (misi=
sr._miStateNameList.begin() ; misi!=
sr._miStateNameList.end() ; ++misi) {
341 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
342 <<
sr.GetName() << endl ;
356 map<string,string>::iterator riter ;
357 for (riter=bc.
_restr.begin() ; riter!=bc.
_restr.end() ; ++riter) {
361 <<
" does not contain a category named " << riter->first
362 <<
" for which build was requested to be restricted to states " << riter->second << endl ;
368 list<const RooCatType*> rlist ;
369 strlcpy(buf,riter->second.c_str(),4096) ;
371 char* tok = strtok(buf,
"{,}") ;
376 <<
" does not have state " << tok <<
" as specified in restriction list" << endl ;
380 rlist.push_back(ctype) ;
381 tok = strtok(0,
"{,}") ;
384 obc->
_restr[cat] = rlist ;
403 map<string,RooAbsPdf*> stateMap ;
405 map<RooAbsPdf*,ObjSplitRule>::iterator physIter = obc.
_pdfmap.begin() ;
406 while(physIter!=obc.
_pdfmap.end()) {
410 physModelSet.
add(*physModel,
kTRUE) ;
412 list<const RooCatType*>::iterator stiter ;
413 for (stiter=physIter->second._miStateList.begin() ; stiter!=physIter->second._miStateList.end() ; ++stiter) {
414 stateMap[(*stiter)->GetName()] = physModel ;
423 if (physCat) splitCatSet.
add(*physCat) ;
430 splitCatSetFund.
add(*scat) ;
433 splitCatSetFund.
add(*scatvars) ;
441 if (splitCatSetFund.
getSize()>1) {
442 masterSplitCat =
new RooSuperCategory(
"masterSplitCat",
"Master splitting category",splitCatSetFund) ;
459 customizerList->
Add(physCustomizer) ;
461 map<RooAbsArg*, pair<RooArgSet,string> >::iterator splitIter ;
462 for (splitIter = obc.
_pdfmap[physModel]._paramSplitMap.begin() ; splitIter != obc.
_pdfmap[physModel]._paramSplitMap.end() ; ++splitIter) {
473 splitCat =
new RooMultiCategory(splitName.c_str(),splitName.c_str(),splitCatSetTmp) ;
479 if(splitIter->second.second.size()>0) {
482 if (!splitCat->
lookupType(splitIter->second.second.c_str())) {
483 coutE(
InputArguments) <<
"RooSimWSTool::executeBuild(" <<
GetName() <<
") ERROR: name of remainder state for constrained split, '"
484 << splitIter->second.second <<
"' , does not match any state name of (composite) split category " << splitCat->
GetName() << endl ;
490 TIterator* sctiter = splitCat->typeIterator() ;
495 if (splitIter->second.second ==
type->GetName()) continue ;
498 TString splitLeafName(splitIter->first->GetName()) ;
499 splitLeafName.
Append(
"_") ;
509 fracLeafList.
add(*splitLeaf) ;
523 physCustomizer->
splitArgs(*splitIter->first,*splitCat) ;
535 if (physCat) fitCatList.
add(*physCat) ;
542 fitCatList.
add(*scat) ;
545 fitCatList.
add(*scatvars) ;
553 string mcatname = string(simPdfName) +
"_index" ;
556 fitCat =
new RooSuperCategory(mcatname.c_str(),mcatname.c_str(),fitCatList) ;
567 TIterator* fcIter = fitCat->typeIterator() ;
578 if (obc.
_restr.size()>0) {
582 list<const RooCatType*> slist = obc.
_restr[splitCat] ;
587 list<const RooCatType*>::iterator sli ;
588 for (sli=slist.begin() ; sli!=slist.end() ; ++sli) {
589 if (
string(splitCat->
getLabel())==(*sli)->GetName()) {
594 if (!select) continue ;
612 <<
" for mode " << fcState->
GetName() << endl ;
623 customizerList->
Delete() ;
624 delete customizerList ;
663 char paramBuf[4096] ;
665 strlcpy(paramBuf,paramNameList,4096) ;
666 strlcpy(catBuf,categoryNameList,4096) ;
669 list<string> catList ;
670 char* cat = strtok(catBuf,
"{,}") ;
672 catList.push_back(cat) ;
673 cat = strtok(0,
"{,}") ;
677 char* param = strtok(paramBuf,
"{,}") ;
680 param = strtok(0,
"{,}") ;
691 char paramBuf[4096] ;
693 strlcpy(paramBuf,paramNameList,4096) ;
694 strlcpy(catBuf,categoryNameList,4096) ;
697 list<string> catList ;
698 char* cat = strtok(catBuf,
"{,}") ;
700 catList.push_back(cat) ;
701 cat = strtok(0,
"{,}") ;
705 char* param = strtok(paramBuf,
"{,}") ;
707 _paramSplitMap[param] = pair<list<string>,
string>(catList,remainderStateName) ;
708 param = strtok(0,
"{,}") ;
720 list<const RooCmdArg*> cmdList ;
721 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
722 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
723 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
725 list<const RooCmdArg*>::iterator iter ;
726 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
728 if ((*iter)->opcode()==0) continue ;
730 string name = (*iter)->opcode() ;
732 if (
name==
"SplitParam") {
733 splitParameter((*iter)->getString(0),(*iter)->getString(1)) ;
734 }
else if (
name==
"SplitParamConstrained") {
735 splitParameterConstrained((*iter)->getString(0),(*iter)->getString(1),(*iter)->getString(2)) ;
748 internalAddPdf(pdfName,
"",
sr) ;
761 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
762 internalAddPdf(pdfName,
"",
sr) ;
765 list<const RooCmdArg*> cmdList ;
766 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
767 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
768 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
770 list<const RooCmdArg*>::iterator iter ;
771 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
772 if ((*iter)->opcode()==0) continue ;
773 string name = (*iter)->opcode() ;
774 if (
name==
"Restrict") {
775 restrictBuild((*iter)->getString(0),(*iter)->getString(1)) ;
777 if (
name==
"RenameConflictNodes") {
778 _conflProtocol = *(*iter) ;
800 strlcpy(buf,miStateNameList,4096) ;
802 char* tok = strtok(buf,
",") ;
804 sr._miStateNameList.push_back(tok) ;
805 tok = strtok(0,
",") ;
808 _pdfmap[pdfName] =
sr ;
817 _restr[catName] = stateList ;
830 _masterCatName = masterIndexCat ;
843 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
844 internalAddPdf(pdfName,miStateList,
sr) ;
854 internalAddPdf(pdfName,miStateList,
sr) ;
876 map<RooAbsPdf*,ObjSplitRule>::iterator ri ;
877 for (ri = _pdfmap.begin() ; ri != _pdfmap.end() ; ++ri ) {
878 cout <<
"Splitrule for p.d.f " << ri->first->GetName() <<
" with state list " ;
879 for (std::list<const RooCatType*>::iterator misi= ri->second._miStateList.begin() ; misi!=ri->second._miStateList.end() ; ++misi) {
880 cout << (*misi)->GetName() <<
" " ;
884 map<RooAbsArg*,pair<RooArgSet,string> >::iterator csi ;
885 for (csi = ri->second._paramSplitMap.begin() ; csi != ri->second._paramSplitMap.end() ; ++csi ) {
886 if (csi->second.second.length()>0) {
887 cout <<
" parameter " << csi->first->GetName() <<
" is split with constraint in categories " << csi->second.first
888 <<
" with remainder in state " << csi->second.second << endl ;
890 cout <<
" parameter " << csi->first->GetName() <<
" is split with constraint in categories " << csi->second.first << endl ;
895 map<RooAbsCategory*,list<const RooCatType*> >::iterator riter ;
896 for (riter=_restr.begin() ; riter!=_restr.end() ; ++riter) {
897 cout <<
"Restricting build in category " << riter->first->GetName() <<
" to states " ;
898 list<const RooCatType*>::iterator i ;
899 for (i=riter->second.begin() ; i!=riter->second.end() ; ++i) {
900 if (i!=riter->second.begin()) cout <<
"," ;
901 cout << (*i)->GetName() ;
915 string tn(typeName) ;
916 if (tn==
"SIMCLONE") {
919 for (
unsigned int i=1 ; i<args.size() ; i++) {
920 if (args[i].find(
"$SplitParam(")!=0 &&
921 args[i].find(
"$SplitParamConstrained(")!=0 &&
922 args[i].find(
"$SplitRestrict(")!=0 &&
923 args[i].find(
"$Verbose(")!=0) {
924 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token %s encountered",args[i].c_str())) ;
930 for (
unsigned int i=1 ; i<args.size() ; i++) {
931 if (args[i].find(
"$SplitParam(")==0) {
933 if (subargs.size()!=2) {
934 throw string(
Form(
"Incorrect number of arguments in $SplitParam, have %d, expect 2",(
Int_t)subargs.size())) ;
936 sr.splitParameter(subargs[0].c_str(),subargs[1].c_str()) ;
937 }
else if (args[i].find(
"$SplitParamConstrained(")==0) {
939 if (subargs.size()!=3) {
940 throw string(
Form(
"Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(
Int_t)subargs.size())) ;
942 sr.splitParameterConstrained(subargs[0].c_str(), subargs[1].c_str(), subargs[2].c_str()) ;
948 for (
unsigned int i=1 ; i<args.size() ; i++) {
949 if (args[i].find(
"$Restrict(")==0) {
951 if (subargs.size()!=2) {
952 throw string(
Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(
Int_t)subargs.size())) ;
960 for (
unsigned int i=1 ; i<args.size() ; i++) {
961 if (args[i].find(
"$Verbose(")==0) {
963 if (subargs.size()>0) {
964 verbose = atoi(subargs[0].c_str()) ;
973 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
979 }
else if (tn==
"MSIMCLONE") {
984 for (
unsigned int i=1 ; i<args.size() ; i++) {
985 if (args[i].find(
"$AddPdf(")==0) {
991 for (
unsigned int j=2 ; j<subargs.size() ; j++) {
992 if (subargs[j].find(
"$SplitParam(")==0) {
994 if (subsubargs.size()!=2) {
995 throw string(
Form(
"Incorrect number of arguments in $SplitParam, have %d, expect 2",(
Int_t)subsubargs.size())) ;
997 sr.splitParameter(subsubargs[0].c_str(),subsubargs[1].c_str()) ;
998 }
else if (subargs[j].find(
"$SplitParamConstrained(")==0) {
1000 if (subsubargs.size()!=3) {
1001 throw string(
Form(
"Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(
Int_t)subsubargs.size())) ;
1003 sr.splitParameterConstrained(subsubargs[0].c_str(), subsubargs[1].c_str(), subsubargs[2].c_str()) ;
1006 mbc.
addPdf(subargs[0].c_str(),subargs[1].c_str(),
sr) ;
1008 }
else if (args[i].find(
"$Restrict(")==0) {
1012 if (subargs.size()!=2) {
1013 throw string(
Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(
Int_t)subargs.size())) ;
1018 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token in MSIMCLONE: %s",args[i].c_str())) ;
1026 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
1034 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: Unknown meta-type %s requested",typeName)) ;
1037 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 (of arbitrary type) an...
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
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_t setLabel(const char *label, Bool_t printError=kTRUE)=0
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
virtual const char * getLabel() const
Return label string of current state.
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.
RooAbsArg * first() const
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
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.
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
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 represents a fundamental (non-derived) discrete value object.
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 consolidates 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'.
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)
static constexpr double sr