179 BuildConfig bc(protoPdfName,arg1,arg2,arg3,arg4,arg5,arg6) ;
180 return build(simPdfName,bc) ;
220 <<
" that was designated as master index category in the build configuration" << endl ;
228 map<string,SplitRule>::iterator pdfiter ;
230 for (pdfiter = bc.
_pdfmap.begin() ; pdfiter != bc.
_pdfmap.end() ; ++pdfiter) {
236 <<
" does not contain a pdf named " << pdfiter->second.GetName() << endl ;
247 map<string, pair<list<string>,
string> >::iterator pariter ;
248 for (pariter=
sr._paramSplitMap.begin() ; pariter!=
sr._paramSplitMap.end() ; ++pariter) {
254 <<
" does not contain a variable named " << pariter->first.c_str()
255 <<
" as specified in splitting rule of parameter " << pariter->first <<
" of p.d.f " << pdf << endl ;
263 <<
" in split is not function of p.d.f " << pdf->
GetName() << endl ;
270 list<string>::iterator catiter ;
271 for (catiter = pariter->second.first.begin() ; catiter!=pariter->second.first.end() ; ++catiter) {
275 <<
" does not contain a category named " << catiter->c_str()
276 <<
" as specified in splitting rule of parameter " << pariter->first <<
" of p.d.f " << pdf << endl ;
280 splitCatSet.
add(*cat) ;
287 if (arg->dependsOnValue(tmp)) {
288 coutE(
InputArguments) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: Ill defined split: splitting category function " << arg->GetName()
289 <<
" used in composite split " << splitCatSet <<
" of parameter " << farg->
GetName() <<
" of pdf " << pdf->
GetName()
290 <<
" depends on one or more of the other splitting categories in the composite split" << endl ;
297 if (pariter->second.second.size()>0) {
299 coutE(
InputArguments) <<
"RooSimWSTool::build(" <<
GetName() <<
") ERROR: Constrained split specified in non real-valued parameter " << farg->
GetName() << endl ;
311 list<string>::iterator misi ;
312 for (misi=
sr._miStateNameList.begin() ; misi!=
sr._miStateNameList.end() ; ++misi) {
316 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
317 <<
sr.GetName() << endl ;
330 if (
sr._paramSplitMap.empty()) {
333 list<string>::iterator misi ;
334 for (misi=
sr._miStateNameList.begin() ; misi!=
sr._miStateNameList.end() ; ++misi) {
338 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
339 <<
sr.GetName() << endl ;
353 map<string,string>::iterator riter ;
354 for (riter=bc.
_restr.begin() ; riter!=bc.
_restr.end() ; ++riter) {
358 <<
" does not contain a category named " << riter->first
359 <<
" for which build was requested to be restricted to states " << riter->second << endl ;
365 list<const RooCatType*> rlist ;
366 strlcpy(buf,riter->second.c_str(),4096) ;
368 char* tok = strtok(buf,
"{,}") ;
373 <<
" does not have state " << tok <<
" as specified in restriction list" << endl ;
377 rlist.push_back(ctype) ;
378 tok = strtok(0,
"{,}") ;
381 obc->
_restr[cat] = rlist ;
400 map<string,RooAbsPdf*> stateMap ;
402 map<RooAbsPdf*,ObjSplitRule>::iterator physIter = obc.
_pdfmap.begin() ;
403 while(physIter!=obc.
_pdfmap.end()) {
407 physModelSet.
add(*physModel,
true) ;
409 list<const RooCatType*>::iterator stiter ;
410 for (stiter=physIter->second._miStateList.begin() ; stiter!=physIter->second._miStateList.end() ; ++stiter) {
411 stateMap[(*stiter)->GetName()] = physModel ;
420 if (physCat) splitCatSet.
add(*physCat) ;
423 for(
auto * scat : static_range_cast<RooAbsCategory*>(splitCatSet)) {
424 if (scat->isFundamental()) {
425 splitCatSetFund.
add(*scat) ;
427 RooArgSet* scatvars = scat->getVariables() ;
428 splitCatSetFund.
add(*scatvars) ;
435 if (splitCatSetFund.
getSize()>1) {
436 masterSplitCat =
new RooSuperCategory(
"masterSplitCat",
"Master splitting category",splitCatSetFund) ;
447 for(
auto * physModel : static_range_cast<RooAbsPdf*>(physModelSet)) {
448 if (
verbose)
coutI(
ObjectHandling) <<
"RooSimPdfBuilder::executeBuild: processing prototype pdf " << physModel->GetName() << endl ;
451 customizerList->
Add(physCustomizer) ;
453 map<RooAbsArg*, pair<RooArgSet,string> >::iterator splitIter ;
454 for (splitIter = obc.
_pdfmap[physModel]._paramSplitMap.begin() ; splitIter != obc.
_pdfmap[physModel]._paramSplitMap.end() ; ++splitIter) {
465 splitCat =
new RooMultiCategory(splitName.c_str(),splitName.c_str(),splitCatSetTmp) ;
471 if(splitIter->second.second.size()>0) {
474 if (!splitCat->
hasLabel(splitIter->second.second)) {
475 coutE(
InputArguments) <<
"RooSimWSTool::executeBuild(" <<
GetName() <<
") ERROR: name of remainder state for constrained split, '"
476 << splitIter->second.second <<
"' , does not match any state name of (composite) split category " << splitCat->
GetName() << endl ;
487 if (splitIter->second.second ==
type->GetName()) continue ;
490 TString splitLeafName(splitIter->first->GetName()) ;
491 splitLeafName.
Append(
"_") ;
501 fracLeafList.
add(*splitLeaf) ;
515 physCustomizer->
splitArgs(*splitIter->first,*splitCat) ;
526 if (physCat) fitCatList.
add(*physCat) ;
530 for(
auto * scat : static_range_cast<RooAbsCategory*>(splitCatSet)) {
531 if (scat->isFundamental()) {
532 fitCatList.
add(*scat) ;
534 fitCatList.
add(*std::unique_ptr<RooArgSet>{scat->getVariables()}) ;
539 string mcatname = string(simPdfName) +
"_index" ;
542 fitCat =
new RooSuperCategory(mcatname.c_str(),mcatname.c_str(),fitCatList) ;
562 if (obc.
_restr.size()>0) {
563 for(
auto * splitCat : static_range_cast<RooAbsCategory*>(fitCatList)) {
566 list<const RooCatType*> slist = obc.
_restr[splitCat] ;
571 list<const RooCatType*>::iterator sli ;
572 for (sli=slist.begin() ; sli!=slist.end() ; ++sli) {
573 if (
string(splitCat->getCurrentLabel())==(*sli)->GetName()) {
578 if (!select) continue ;
596 <<
" for mode " << fcState->
GetName() << endl ;
607 customizerList->
Delete() ;
608 delete customizerList ;
628 name += arg->GetName() ;
643 char paramBuf[4096] ;
645 strlcpy(paramBuf,paramNameList,4096) ;
646 strlcpy(catBuf,categoryNameList,4096) ;
649 list<string> catList ;
650 char* cat = strtok(catBuf,
"{,}") ;
652 catList.push_back(cat) ;
653 cat = strtok(0,
"{,}") ;
657 char* param = strtok(paramBuf,
"{,}") ;
660 param = strtok(0,
"{,}") ;
671 char paramBuf[4096] ;
673 strlcpy(paramBuf,paramNameList,4096) ;
674 strlcpy(catBuf,categoryNameList,4096) ;
677 list<string> catList ;
678 char* cat = strtok(catBuf,
"{,}") ;
680 catList.push_back(cat) ;
681 cat = strtok(0,
"{,}") ;
685 char* param = strtok(paramBuf,
"{,}") ;
687 _paramSplitMap[param] = pair<list<string>,
string>(catList,remainderStateName) ;
688 param = strtok(0,
"{,}") ;
700 list<const RooCmdArg*> cmdList ;
701 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
702 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
703 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
705 list<const RooCmdArg*>::iterator iter ;
706 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
708 if ((*iter)->opcode()==0) continue ;
710 string name = (*iter)->opcode() ;
712 if (
name==
"SplitParam") {
713 splitParameter((*iter)->getString(0),(*iter)->getString(1)) ;
714 }
else if (
name==
"SplitParamConstrained") {
715 splitParameterConstrained((*iter)->getString(0),(*iter)->getString(1),(*iter)->getString(2)) ;
728 internalAddPdf(pdfName,
"",
sr) ;
741 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
742 internalAddPdf(pdfName,
"",
sr) ;
745 list<const RooCmdArg*> cmdList ;
746 cmdList.push_back(&arg1) ; cmdList.push_back(&arg2) ;
747 cmdList.push_back(&arg3) ; cmdList.push_back(&arg4) ;
748 cmdList.push_back(&arg5) ; cmdList.push_back(&arg6) ;
750 list<const RooCmdArg*>::iterator iter ;
751 for (iter=cmdList.begin() ; iter!=cmdList.end() ; ++iter) {
752 if ((*iter)->opcode()==0) continue ;
753 string name = (*iter)->opcode() ;
754 if (
name==
"Restrict") {
755 restrictBuild((*iter)->getString(0),(*iter)->getString(1)) ;
757 if (
name==
"RenameConflictNodes") {
758 _conflProtocol = *(*iter) ;
780 strlcpy(buf,miStateNameList,4096) ;
782 char* tok = strtok(buf,
",") ;
784 sr._miStateNameList.push_back(tok) ;
785 tok = strtok(0,
",") ;
788 _pdfmap[pdfName] =
sr ;
797 _restr[catName] = stateList ;
810 _masterCatName = masterIndexCat ;
823 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
824 internalAddPdf(pdfName,miStateList,
sr) ;
834 internalAddPdf(pdfName,miStateList,
sr) ;
856 map<RooAbsPdf*,ObjSplitRule>::iterator ri ;
857 for (ri = _pdfmap.begin() ; ri != _pdfmap.end() ; ++ri ) {
858 cout <<
"Splitrule for p.d.f " << ri->first->GetName() <<
" with state list " ;
859 for (std::list<const RooCatType*>::iterator misi= ri->second._miStateList.begin() ; misi!=ri->second._miStateList.end() ; ++misi) {
860 cout << (*misi)->GetName() <<
" " ;
864 map<RooAbsArg*,pair<RooArgSet,string> >::iterator csi ;
865 for (csi = ri->second._paramSplitMap.begin() ; csi != ri->second._paramSplitMap.end() ; ++csi ) {
866 if (csi->second.second.length()>0) {
867 cout <<
" parameter " << csi->first->GetName() <<
" is split with constraint in categories " << csi->second.first
868 <<
" with remainder in state " << csi->second.second << endl ;
870 cout <<
" parameter " << csi->first->GetName() <<
" is split with constraint in categories " << csi->second.first << endl ;
875 map<RooAbsCategory*,list<const RooCatType*> >::iterator riter ;
876 for (riter=_restr.begin() ; riter!=_restr.end() ; ++riter) {
877 cout <<
"Restricting build in category " << riter->first->GetName() <<
" to states " ;
878 list<const RooCatType*>::iterator i ;
879 for (i=riter->second.begin() ; i!=riter->second.end() ; ++i) {
880 if (i!=riter->second.begin()) cout <<
"," ;
881 cout << (*i)->GetName() ;
895 string tn(typeName) ;
896 if (tn==
"SIMCLONE") {
899 for (
unsigned int i=1 ; i<args.size() ; i++) {
900 if (args[i].find(
"$SplitParam(")!=0 &&
901 args[i].find(
"$SplitParamConstrained(")!=0 &&
902 args[i].find(
"$SplitRestrict(")!=0 &&
903 args[i].find(
"$Verbose(")!=0) {
904 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token %s encountered",args[i].c_str())) ;
910 for (
unsigned int i=1 ; i<args.size() ; i++) {
911 if (args[i].find(
"$SplitParam(")==0) {
913 if (subargs.size()!=2) {
914 throw string(
Form(
"Incorrect number of arguments in $SplitParam, have %d, expect 2",(
Int_t)subargs.size())) ;
916 sr.splitParameter(subargs[0].c_str(),subargs[1].c_str()) ;
917 }
else if (args[i].find(
"$SplitParamConstrained(")==0) {
919 if (subargs.size()!=3) {
920 throw string(
Form(
"Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(
Int_t)subargs.size())) ;
922 sr.splitParameterConstrained(subargs[0].c_str(), subargs[1].c_str(), subargs[2].c_str()) ;
928 for (
unsigned int i=1 ; i<args.size() ; i++) {
929 if (args[i].find(
"$Restrict(")==0) {
931 if (subargs.size()!=2) {
932 throw string(
Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(
Int_t)subargs.size())) ;
940 for (
unsigned int i=1 ; i<args.size() ; i++) {
941 if (args[i].find(
"$Verbose(")==0) {
943 if (subargs.size()>0) {
944 verbose = atoi(subargs[0].c_str()) ;
953 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
959 }
else if (tn==
"MSIMCLONE") {
964 for (
unsigned int i=1 ; i<args.size() ; i++) {
965 if (args[i].find(
"$AddPdf(")==0) {
971 for (
unsigned int j=2 ; j<subargs.size() ; j++) {
972 if (subargs[j].find(
"$SplitParam(")==0) {
974 if (subsubargs.size()!=2) {
975 throw string(
Form(
"Incorrect number of arguments in $SplitParam, have %d, expect 2",(
Int_t)subsubargs.size())) ;
977 sr.splitParameter(subsubargs[0].c_str(),subsubargs[1].c_str()) ;
978 }
else if (subargs[j].find(
"$SplitParamConstrained(")==0) {
980 if (subsubargs.size()!=3) {
981 throw string(
Form(
"Incorrect number of arguments in $SplitParamConstrained, have %d, expect 3",(
Int_t)subsubargs.size())) ;
983 sr.splitParameterConstrained(subsubargs[0].c_str(), subsubargs[1].c_str(), subsubargs[2].c_str()) ;
986 mbc.
addPdf(subargs[0].c_str(),subargs[1].c_str(),
sr) ;
988 }
else if (args[i].find(
"$Restrict(")==0) {
992 if (subargs.size()!=2) {
993 throw string(
Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(
Int_t)subargs.size())) ;
998 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token in MSIMCLONE: %s",args[i].c_str())) ;
1006 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
1014 throw string(
Form(
"RooSimWSTool::SimWSIFace::create() ERROR: Unknown meta-type %s requested",typeName)) ;
1017 return string(instanceName) ;
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 * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, 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=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 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.
TIterator * typeIterator() const
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 addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsArg * first() const
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.
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.
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 ...
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'.
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 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.
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
Iterator abstract base class.
virtual TObject * Next()=0
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
const char * GetName() const override
Returns name of object.
TString & Append(const char *cs)
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.
static constexpr double sr