119 ClassImp(RooSimWSTool);
120 ClassImp(RooSimWSTool::BuildConfig);
121 ClassImp(RooSimWSTool::MultiBuildConfig);
122 ClassImp(RooSimWSTool::SplitRule);
123 ClassImp(RooSimWSTool::ObjBuildConfig);
124 ClassImp(RooSimWSTool::ObjSplitRule);
127 using namespace std ;
132 static Int_t dummy = init() ;
136 RooFactoryWSTool::IFace* iface =
new RooSimWSTool::SimWSIFace ;
137 RooFactoryWSTool::registerSpecial(
"SIMCLONE",iface) ;
138 RooFactoryWSTool::registerSpecial(
"MSIMCLONE",iface) ;
148 RooSimWSTool::RooSimWSTool(RooWorkspace& ws) : _ws(&ws)
157 RooSimWSTool::~RooSimWSTool()
175 RooSimultaneous* RooSimWSTool::build(
const char* simPdfName,
const char* protoPdfName,
const RooCmdArg& arg1,
const RooCmdArg& arg2,
176 const RooCmdArg& arg3,
const RooCmdArg& arg4,
const RooCmdArg& arg5,
const RooCmdArg& arg6)
178 BuildConfig bc(protoPdfName,arg1,arg2,arg3,arg4,arg5,arg6) ;
179 return build(simPdfName,bc) ;
188 RooSimultaneous* RooSimWSTool::build(
const char* simPdfName,BuildConfig& bc, Bool_t verbose)
190 ObjBuildConfig* obc = validateConfig(bc) ;
197 RooSimultaneous* ret = executeBuild(simPdfName,*obc,verbose) ;
209 RooSimWSTool::ObjBuildConfig* RooSimWSTool::validateConfig(BuildConfig& bc)
212 ObjBuildConfig* obc =
new ObjBuildConfig ;
214 if (bc._masterCatName.length()>0) {
215 obc->_masterCat = _ws->cat(bc._masterCatName.c_str()) ;
216 if (!obc->_masterCat) {
217 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: associated workspace " << _ws->GetName()
218 <<
" does not contain a category named " << bc._masterCatName
219 <<
" that was designated as master index category in the build configuration" << endl ;
224 obc->_masterCat = 0 ;
227 map<string,SplitRule>::iterator pdfiter ;
229 for (pdfiter = bc._pdfmap.begin() ; pdfiter != bc._pdfmap.end() ; ++pdfiter) {
232 RooAbsPdf* pdf = _ws->pdf(pdfiter->second.GetName()) ;
234 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: associated workspace " << _ws->GetName()
235 <<
" does not contain a pdf named " << pdfiter->second.GetName() << endl ;
244 SplitRule& sr = pdfiter->second ;
246 map<string, pair<list<string>,
string> >::iterator pariter ;
247 for (pariter=sr._paramSplitMap.begin() ; pariter!=sr._paramSplitMap.end() ; ++pariter) {
250 RooAbsArg* farg = _ws->fundArg(pariter->first.c_str()) ;
252 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: associated workspace " << _ws->GetName()
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 ;
260 if (!pdf->dependsOn(*farg)) {
261 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: specified parameter " << pariter->first
262 <<
" in split is not function of p.d.f " << pdf->GetName() << endl ;
268 RooArgSet splitCatSet ;
269 list<string>::iterator catiter ;
270 for (catiter = pariter->second.first.begin() ; catiter!=pariter->second.first.end() ; ++catiter) {
271 RooAbsCategory* cat = _ws->catfunc(catiter->c_str()) ;
273 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: associated workspace " << _ws->GetName()
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) ;
283 TIterator* iter = splitCatSet.createIterator() ;
285 while((arg=(RooAbsArg*)iter->Next())) {
286 RooArgSet tmp(splitCatSet) ;
288 if (arg->dependsOnValue(tmp)) {
289 coutE(InputArguments) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: Ill defined split: splitting category function " << arg->GetName()
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) {
301 if (!dynamic_cast<RooAbsReal*>(farg)) {
302 coutE(InputArguments) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: Constrained split specified in non real-valued parameter " << farg->GetName() << endl ;
309 osr._paramSplitMap[farg].first.add(splitCatSet) ;
310 osr._paramSplitMap[farg].second = pariter->second.second ;
313 if (obc->_masterCat) {
314 list<string>::iterator misi ;
315 for (misi=sr._miStateNameList.begin() ; misi!=sr._miStateNameList.end() ; ++misi) {
316 const RooCatType* ctype = obc->_masterCat->lookupType(misi->c_str(),kFALSE) ;
318 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: master index category " << obc->_masterCat->GetName()
319 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
320 << sr.GetName() << endl ;
324 osr._miStateList.push_back(ctype) ;
329 obc->_usedSplitCats.add(splitCatSet,kTRUE) ;
333 if (sr._paramSplitMap.size()==0) {
335 if (obc->_masterCat) {
336 list<string>::iterator misi ;
337 for (misi=sr._miStateNameList.begin() ; misi!=sr._miStateNameList.end() ; ++misi) {
338 const RooCatType* ctype = obc->_masterCat->lookupType(misi->c_str(),kFALSE) ;
340 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: master index category " << obc->_masterCat->GetName()
341 <<
" does not have a state named " << *misi <<
" which was specified as state associated with p.d.f "
342 << sr.GetName() << endl ;
346 osr._miStateList.push_back(ctype) ;
351 obc->_pdfmap[pdf] = osr ;
356 map<string,string>::iterator riter ;
357 for (riter=bc._restr.begin() ; riter!=bc._restr.end() ; ++riter) {
358 RooCategory* cat = _ws->cat(riter->first.c_str()) ;
360 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: associated workspace " << _ws->GetName()
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,
"{,}") ;
373 const RooCatType* ctype = cat->lookupType(tok,kFALSE) ;
375 coutE(ObjectHandling) <<
"RooSimWSTool::build(" << GetName() <<
") ERROR: restricted build category " << cat->GetName()
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 ;
396 RooSimultaneous* RooSimWSTool::executeBuild(
const char* simPdfName, ObjBuildConfig& obc, Bool_t verbose)
398 RooArgSet cleanupList ;
400 RooAbsCategoryLValue* physCat = obc._masterCat ;
402 RooArgSet physModelSet ;
403 map<string,RooAbsPdf*> stateMap ;
405 map<RooAbsPdf*,ObjSplitRule>::iterator physIter = obc._pdfmap.begin() ;
406 while(physIter!=obc._pdfmap.end()) {
409 RooAbsPdf* physModel = physIter->first ;
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 ;
420 if (verbose) coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: list of prototype pdfs " << physModelSet << endl ;
422 RooArgSet splitCatSet(obc._usedSplitCats) ;
423 if (physCat) splitCatSet.add(*physCat) ;
425 RooArgSet splitCatSetFund ;
426 TIterator* scsiter = splitCatSet.createIterator() ;
427 RooAbsCategory* scat ;
428 while((scat=(RooAbsCategory*)scsiter->Next())) {
429 if (scat->isFundamental()) {
430 splitCatSetFund.add(*scat) ;
432 RooArgSet* scatvars = scat->getVariables() ;
433 splitCatSetFund.add(*scatvars) ;
440 RooAbsCategoryLValue* masterSplitCat ;
441 if (splitCatSetFund.getSize()>1) {
442 masterSplitCat =
new RooSuperCategory(
"masterSplitCat",
"Master splitting category",splitCatSetFund) ;
444 masterSplitCat = (RooAbsCategoryLValue*) splitCatSetFund.first() ;
446 if (verbose) coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: list of splitting categories " << splitCatSet << endl ;
448 RooArgSet splitNodeListOwned ;
449 RooArgSet splitNodeListAll ;
450 TList* customizerList =
new TList ;
453 TIterator* physMIter = physModelSet.createIterator() ;
454 RooAbsPdf* physModel ;
455 while((physModel=(RooAbsPdf*)physMIter->Next())) {
456 if (verbose) coutI(ObjectHandling) <<
"RooSimPdfBuilder::executeBuild: processing prototype pdf " << physModel->GetName() << endl ;
458 RooCustomizer* physCustomizer =
new RooCustomizer(*physModel,*masterSplitCat,splitNodeListOwned,&splitNodeListAll) ;
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) {
467 RooArgSet& splitCatSetTmp = splitIter->second.first ;
468 string splitName = makeSplitName(splitCatSetTmp) ;
471 RooAbsCategory* splitCat = _ws->catfunc(splitName.c_str()) ;
473 splitCat =
new RooMultiCategory(splitName.c_str(),splitName.c_str(),splitCatSetTmp) ;
474 cleanupList.addOwned(*splitCat) ;
475 _ws->import(*splitCat,RooFit::Silence(!verbose)) ;
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 ;
489 RooArgSet fracLeafList ;
490 TIterator* sctiter = splitCat->typeIterator() ;
492 while((type=(RooCatType*)sctiter->Next())) {
495 if (splitIter->second.second == type->GetName())
continue ;
498 TString splitLeafName(splitIter->first->GetName()) ;
499 splitLeafName.Append(
"_") ;
500 splitLeafName.Append(type->GetName()) ;
503 RooAbsArg* splitLeaf = _ws->fundArg(splitLeafName) ;
506 splitLeaf = (RooAbsArg*) splitIter->first->clone(splitLeafName) ;
507 _ws->import(*splitLeaf,RooFit::Silence(!verbose)) ;
509 fracLeafList.add(*splitLeaf) ;
515 RooFracRemainder* fracRem =
new RooFracRemainder(Form(
"%s_%s",splitIter->first->GetName(),splitIter->second.second.c_str()),
"Remainder fraction",fracLeafList) ;
516 cleanupList.addOwned(*fracRem) ;
517 _ws->import(*fracRem) ;
523 physCustomizer->splitArgs(*splitIter->first,*splitCat) ;
529 splitNodeListAll.add(_ws->components()) ;
531 if (verbose) coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: configured customizers for all prototype pdfs" << endl ;
534 RooArgSet fitCatList ;
535 if (physCat) fitCatList.add(*physCat) ;
539 scsiter = splitCatSet.createIterator() ;
540 while((scat=(RooAbsCategory*)scsiter->Next())) {
541 if (scat->isFundamental()) {
542 fitCatList.add(*scat) ;
544 RooArgSet* scatvars = scat->getVariables() ;
545 fitCatList.add(*scatvars) ;
552 TIterator* fclIter = fitCatList.createIterator() ;
553 string mcatname = string(simPdfName) +
"_index" ;
554 RooAbsCategoryLValue* fitCat = 0 ;
555 if (fitCatList.getSize()>1) {
556 fitCat =
new RooSuperCategory(mcatname.c_str(),mcatname.c_str(),fitCatList) ;
557 cleanupList.addOwned(*fitCat) ;
559 fitCat = (RooAbsCategoryLValue*) fitCatList.first() ;
563 RooSimultaneous* simPdf =
new RooSimultaneous(simPdfName,simPdfName,*fitCat) ;
564 cleanupList.addOwned(*simPdf) ;
567 TIterator* fcIter = fitCat->typeIterator() ;
569 RooCatType* fcState ;
570 while((fcState=(RooCatType*)fcIter->Next())) {
572 fitCat->setLabel(fcState->GetName()) ;
576 RooAbsCategory* splitCat ;
577 Bool_t select(kFALSE) ;
578 if (obc._restr.size()>0) {
579 while((splitCat=(RooAbsCategory*)fclIter->Next())) {
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 ;
600 RooCustomizer* physCustomizer ;
602 RooAbsPdf* pdf = stateMap[physCat->getLabel()] ;
606 physCustomizer = (RooCustomizer*) customizerList->FindObject(pdf->GetName());
608 physCustomizer = (RooCustomizer*) customizerList->First() ;
611 if (verbose) coutI(ObjectHandling) <<
"RooSimWSTool::executeBuild: Customizing prototype pdf " << physCustomizer->GetName()
612 <<
" for mode " << fcState->GetName() << endl ;
615 RooAbsPdf* fcPdf = (RooAbsPdf*) physCustomizer->build(masterSplitCat->getLabel(),kFALSE) ;
616 simPdf->addPdf(*fcPdf,fcState->GetName()) ;
620 _ws->import(*simPdf,obc._conflProtocol,RooFit::Silence(!verbose)) ;
623 customizerList->Delete() ;
624 delete customizerList ;
626 return (RooSimultaneous*) _ws->pdf(simPdf->GetName()) ;
634 std::string RooSimWSTool::makeSplitName(
const RooArgSet& splitCatSet)
638 TIterator* iter = splitCatSet.createIterator() ;
641 while((arg=(RooAbsArg*)iter->Next())) {
647 name += arg->GetName() ;
661 void RooSimWSTool::SplitRule::splitParameter(
const char* paramNameList,
const char* categoryNameList)
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,
"{,}") ;
679 _paramSplitMap[param] = pair<list<string>,
string>(catList,
"") ;
680 param = strtok(0,
"{,}") ;
689 void RooSimWSTool::SplitRule::splitParameterConstrained(
const char* paramNameList,
const char* categoryNameList,
const char* remainderStateName)
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,
"{,}") ;
717 void RooSimWSTool::SplitRule::configure(
const RooCmdArg& arg1,
const RooCmdArg& arg2,
const RooCmdArg& arg3,
718 const RooCmdArg& arg4,
const RooCmdArg& arg5,
const RooCmdArg& arg6)
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)) ;
746 RooSimWSTool::BuildConfig::BuildConfig(
const char* pdfName, SplitRule& sr)
748 internalAddPdf(pdfName,
"",sr) ;
757 RooSimWSTool::BuildConfig::BuildConfig(
const char* pdfName,
const RooCmdArg& arg1,
const RooCmdArg& arg2,
758 const RooCmdArg& arg3,
const RooCmdArg& arg4,
const RooCmdArg& arg5,
const RooCmdArg& arg6)
760 SplitRule sr(pdfName) ;
761 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
762 internalAddPdf(pdfName,
"",sr) ;
763 _conflProtocol = RooFit::RenameConflictNodes(pdfName) ;
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) ;
788 RooSimWSTool::BuildConfig::BuildConfig(
const RooArgSet& )
797 void RooSimWSTool::BuildConfig::internalAddPdf(
const char* pdfName,
const char* miStateNameList,SplitRule& sr)
800 strlcpy(buf,miStateNameList,4096) ;
802 char* tok = strtok(buf,
",") ;
804 sr._miStateNameList.push_back(tok) ;
805 tok = strtok(0,
",") ;
808 _pdfmap[pdfName] = sr ;
815 void RooSimWSTool::BuildConfig::restrictBuild(
const char* catName,
const char* stateList)
817 _restr[catName] = stateList ;
828 RooSimWSTool::MultiBuildConfig::MultiBuildConfig(
const char* masterIndexCat)
830 _masterCatName = masterIndexCat ;
839 void RooSimWSTool::MultiBuildConfig::addPdf(
const char* miStateList,
const char* pdfName,
const RooCmdArg& arg1,
const RooCmdArg& arg2,
840 const RooCmdArg& arg3,
const RooCmdArg& arg4,
const RooCmdArg& arg5,
const RooCmdArg& arg6)
842 SplitRule sr(pdfName) ;
843 sr.configure(arg1,arg2,arg3,arg4,arg5,arg6) ;
844 internalAddPdf(pdfName,miStateList,sr) ;
852 void RooSimWSTool::MultiBuildConfig::addPdf(
const char* miStateList,
const char* pdfName, SplitRule& sr)
854 internalAddPdf(pdfName,miStateList,sr) ;
863 RooSimWSTool::ObjSplitRule::~ObjSplitRule()
873 void RooSimWSTool::ObjBuildConfig::print()
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() ;
913 std::string RooSimWSTool::SimWSIFace::create(RooFactoryWSTool& ft,
const char* typeName,
const char* instanceName, std::vector<std::string> args)
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())) ;
929 RooSimWSTool::SplitRule sr(args[0].c_str()) ;
930 for (
unsigned int i=1 ; i<args.size() ; i++) {
931 if (args[i].find(
"$SplitParam(")==0) {
932 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
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) {
938 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
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()) ;
947 RooSimWSTool::BuildConfig bc(args[0].c_str(),sr) ;
948 for (
unsigned int i=1 ; i<args.size() ; i++) {
949 if (args[i].find(
"$Restrict(")==0) {
950 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
951 if (subargs.size()!=2) {
952 throw string(Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(Int_t)subargs.size())) ;
954 bc.restrictBuild(subargs[0].c_str(),subargs[1].c_str()) ;
959 Bool_t verbose(kFALSE) ;
960 for (
unsigned int i=1 ; i<args.size() ; i++) {
961 if (args[i].find(
"$Verbose(")==0) {
962 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
963 if (subargs.size()>0) {
964 verbose = atoi(subargs[0].c_str()) ;
970 RooSimWSTool sct(ft.ws()) ;
971 RooAbsPdf* pdf = sct.build(instanceName,bc,verbose) ;
973 throw string(Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
977 ft.ws().import(*pdf,RooFit::Silence()) ;
979 }
else if (tn==
"MSIMCLONE") {
982 RooSimWSTool::MultiBuildConfig mbc(args[0].c_str()) ;
984 for (
unsigned int i=1 ; i<args.size() ; i++) {
985 if (args[i].find(
"$AddPdf(")==0) {
987 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
990 RooSimWSTool::SplitRule sr(subargs[1].c_str()) ;
991 for (
unsigned int j=2 ; j<subargs.size() ; j++) {
992 if (subargs[j].find(
"$SplitParam(")==0) {
993 vector<string> subsubargs = ft.splitFunctionArgs(subargs[j].c_str()) ;
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) {
999 vector<string> subsubargs = ft.splitFunctionArgs(subargs[j].c_str()) ;
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) {
1011 vector<string> subargs = ft.splitFunctionArgs(args[i].c_str()) ;
1012 if (subargs.size()!=2) {
1013 throw string(Form(
"Incorrect number of arguments in $Restrict, have %d, expect 2",(Int_t)subargs.size())) ;
1015 mbc.restrictBuild(subargs[0].c_str(),subargs[1].c_str()) ;
1018 throw string(Form(
"RooSimWSTool::SimWSIFace::create() ERROR: unknown token in MSIMCLONE: %s",args[i].c_str())) ;
1023 RooSimWSTool sct(ft.ws()) ;
1024 RooAbsPdf* pdf = sct.build(instanceName,mbc,kFALSE) ;
1026 throw string(Form(
"RooSimWSTool::SimWSIFace::create() error in RooSimWSTool::build() for %s",instanceName)) ;
1030 ft.ws().import(*pdf,RooFit::Silence()) ;
1034 throw string(Form(
"RooSimWSTool::SimWSIFace::create() ERROR: Unknown meta-type %s requested",typeName)) ;
1037 return string(instanceName) ;