69#define BUFFER_SIZE 64000
159 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
186 const size_t tmpSize = strlen(stateNameList)+1;
187 char *tmp =
new char[tmpSize] ;
188 strlcpy(tmp,stateNameList,tmpSize) ;
190 char* tok = R__STRTOK_R(tmp,
",",&save) ;
192 char*
sep = strchr(tok,
'=') ;
201 tok = R__STRTOK_R(0,
",",&save) ;
215 static bool isEnum(
const char* classname) {
217 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
224 static bool isValidEnumValue(
const char* enumName,
const char* enumConstantName) {
227 if (!enumName)
return false;
230 if (!enumName)
return false;
233 if (theEnum->GetConstant(enumConstantName))
return true;
235 auto tmp = strstr(enumConstantName,
"::");
237 auto enumConstantNameNoScope = tmp+2;
238 if (theEnum->GetConstant(enumConstantNameNoScope))
return true;
244 static pair<list<string>,
unsigned int> ctorArgs(
const char* classname, std::size_t nPassedArgs) {
252 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
253 MethodInfo_t* func =
gInterpreter->MethodInfo_Factory(cls);
266 if (
string(classname) !=
gInterpreter->MethodInfo_TypeName(func)) {
272 int nDefaultArgs =
gInterpreter->MethodInfo_NDefaultArg(func);
273 if (nargs == nDefaultArgs) {
277 MethodArgInfo_t* arg =
gInterpreter->MethodArgInfo_Factory(func);
280 const char* argTypeName =
gInterpreter->MethodArgInfo_TypeName(arg);
281 if (nreq<2 && ((
string(
"char*") != argTypeName
283 &&
string(
"const char*") != argTypeName)) {
286 ret.push_back(argTypeName) ;
287 if(!
gInterpreter->MethodArgInfo_DefaultValue(arg)) nreq++;
294 if(
static_cast<int>(nPassedArgs) >= nargs - nDefaultArgs &&
static_cast<int>(nPassedArgs) <= nargs) {
300 return pair<list<string>,
unsigned int>(ret,nreq);
315 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not found in factory alias table, nor in ROOT class table" << endl;
324 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" does not inherit from RooAbsArg" << endl;
331 size_t blevel = 0, end_tok, start_tok = 0;
332 bool litmode =
false;
333 for (end_tok = 0; end_tok < tmp.length(); end_tok++) {
335 if (tmp[end_tok]==
'{' || tmp[end_tok]==
'(' || tmp[end_tok]==
'[') blevel++;
336 if (tmp[end_tok]==
'}' || tmp[end_tok]==
')' || tmp[end_tok]==
']') blevel--;
339 if (tmp[end_tok]==
'"' || tmp[end_tok]==
'\'') litmode = !litmode;
344 if (litmode ==
false && blevel == 0 && tmp[end_tok] ==
',') {
345 _args.push_back(tmp.substr(start_tok, end_tok - start_tok));
346 start_tok = end_tok+1;
349 _args.push_back(tmp.substr(start_tok, end_tok));
352 pair<list<string>,
unsigned int> ca = ctorArgs(className,
_args.size()+2) ;
353 if (ca.first.empty()) {
354 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR no suitable constructor found for class " << className << endl ;
361 if (
_args.size()+2<ca.second ||
_args.size()+2>ca.first.size()) {
362 if (ca.second==ca.first.size()) {
363 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid, " << className
364 <<
" expects " << ca.first.size()-2 << endl ;
367 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid " << className
368 <<
" expect number between " << ca.second-2 <<
" and " << ca.first.size()-2 << endl ;
375 string cintExpr(
Form(
"new %s(\"%s\",\"%s\"",className,objName,objName)) ;
383 list<string>::iterator ti = ca.first.begin() ; ++ti ; ++ti ;
384 for (vector<string>::iterator ai =
_args.begin() ; ai !=
_args.end() ; ++ai,++ti,++i) {
385 if ((*ti)==
"RooAbsReal&" || (*ti)==
"const RooAbsReal&") {
387 cintExpr +=
Form(
",RooFactoryWSTool::as_FUNC(%d)",i) ;
388 }
else if ((*ti)==
"RooAbsArg&" || (*ti)==
"const RooAbsArg&") {
390 cintExpr +=
Form(
",RooFactoryWSTool::as_ARG(%d)",i) ;
391 }
else if ((*ti)==
"RooRealVar&" || (*ti)==
"const RooRealVar&") {
393 cintExpr +=
Form(
",RooFactoryWSTool::as_VAR(%d)",i) ;
394 }
else if ((*ti)==
"RooAbsRealLValue&" || (*ti)==
"const RooAbsRealLValue&") {
396 cintExpr +=
Form(
",RooFactoryWSTool::as_VARLV(%d)",i) ;
397 }
else if ((*ti)==
"RooCategory&" || (*ti)==
"const RooCategory&") {
399 cintExpr +=
Form(
",RooFactoryWSTool::as_CAT(%d)",i) ;
400 }
else if ((*ti)==
"RooAbsCategory&" || (*ti)==
"const RooAbsCategory&") {
402 cintExpr +=
Form(
",RooFactoryWSTool::as_CATFUNC(%d)",i) ;
403 }
else if ((*ti)==
"RooAbsCategoryLValue&" || (*ti)==
"const RooAbsCategoryLValue&") {
405 cintExpr +=
Form(
",RooFactoryWSTool::as_CATLV(%d)",i) ;
406 }
else if ((*ti)==
"RooAbsPdf&" || (*ti)==
"const RooAbsPdf&") {
408 cintExpr +=
Form(
",RooFactoryWSTool::as_PDF(%d)",i) ;
409 }
else if ((*ti)==
"RooResolutionModel&" || (*ti)==
"const RooResolutionModel&") {
411 cintExpr +=
Form(
",RooFactoryWSTool::as_RMODEL(%d)",i) ;
412 }
else if ((*ti)==
"RooAbsData&" || (*ti)==
"const RooAbsData&") {
414 cintExpr +=
Form(
",RooFactoryWSTool::as_DATA(%d)",i) ;
415 }
else if ((*ti)==
"RooDataSet&" || (*ti)==
"const RooDataSet&") {
417 cintExpr +=
Form(
",RooFactoryWSTool::as_DSET(%d)",i) ;
418 }
else if ((*ti)==
"RooDataHist&" || (*ti)==
"const RooDataHist&") {
420 cintExpr +=
Form(
",RooFactoryWSTool::as_DHIST(%d)",i) ;
421 }
else if ((*ti)==
"const RooArgSet&") {
423 cintExpr +=
Form(
",RooFactoryWSTool::as_SET(%d)",i) ;
424 }
else if ((*ti)==
"const RooArgList&") {
426 cintExpr +=
Form(
",RooFactoryWSTool::as_LIST(%d)",i) ;
427 }
else if ((*ti)==
"const char*") {
429 cintExpr +=
Form(
",RooFactoryWSTool::as_STRING(%d)",i) ;
430 }
else if ((*ti)==
"Int_t" || (*ti)==
"int" || (*ti)==
"bool" || (*ti)==
"bool") {
432 cintExpr +=
Form(
",RooFactoryWSTool::as_INT(%d)",i) ;
433 }
else if ((*ti)==
"double") {
435 cintExpr +=
Form(
",RooFactoryWSTool::as_DOUBLE(%d)",i) ;
436 }
else if (isEnum(ti->c_str())) {
439 if (
_args[i].find(
Form(
"%s::",className)) != string::npos) {
440 qualvalue =
_args[i].c_str() ;
442 qualvalue =
Form(
"%s::%s",className,
_args[i].c_str()) ;
444 if (isValidEnumValue(ti->c_str(),qualvalue.c_str())) {
445 cintExpr +=
Form(
",(%s)%s",ti->c_str(),qualvalue.c_str()) ;
447 throw string(
Form(
"Supplied argument %s does not represent a valid state of enum %s",
_args[i].c_str(),ti->c_str())) ;
455 if (ti->find(
"const ")==0) {
456 btype = ti->c_str()+6 ;
460 if (btype.find(
"&")) {
461 btype.erase(btype.size()-1,btype.size()) ;
468 cintExpr +=
Form(
",(%s&)RooFactoryWSTool::as_OBJ(%d)",ti->c_str(),i) ;
470 throw string(
Form(
"Required argument with name %s of type '%s' is not in the workspace",
_args[i].c_str(),ti->c_str())) ;
475 }
catch (
const string &err) {
476 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR constructing " << className <<
"::" << objName <<
": " << err << endl ;
481 cxcoutD(
ObjectHandling) <<
"RooFactoryWSTool::createArg() Construct expression is " << cintExpr << endl ;
487 if (
string(className)==
"RooGenericPdf") {
489 }
else if (
string(className)==
"RooFormulaVar") {
499 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR in CINT constructor call to create object" << endl ;
520 char* tok = R__STRTOK_R(buf,
",",&save) ;
522 char* star=strchr(tok,
'*') ;
530 tok = R__STRTOK_R(0,
",",&save) ;
532 pdfList.
add(pdfList2) ;
534 }
catch (
const string &err) {
535 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
540 RooAddPdf pdf{objName,objName,pdfList,coefList,recursiveCoefs};
541 pdf.setStringAttribute(
"factory_tag",
Form(
"SUM::%s(%s)",objName,specList)) ;
562 char* tok = R__STRTOK_R(buf,
",",&save) ;
564 char* star=strchr(tok,
'*') ;
572 tok = R__STRTOK_R(0,
",",&save) ;
574 amplList.
add(amplList2) ;
576 }
catch (
const string &err) {
577 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooRealSumPdf: " << err << endl ;
597 string regPdfList=
"{" ;
601 char* tok = R__STRTOK_R(buf,
",",&save) ;
603 char *
sep = strchr(tok,
'|') ;
610 bool invCond(
false) ;
618 }
catch (
const string &err) {
619 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf Conditional argument: " << err << endl ;
626 if (regPdfList.size()>1) {
631 tok = R__STRTOK_R(0,
",",&save) ;
635 std::unique_ptr<RooProdPdf> pdf;
637 pdf = std::make_unique<RooProdPdf>(objName,objName,
asSET(regPdfList.c_str()),cmdList);
638 }
catch (
const string &err) {
639 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf input set of regular pdfs: " << err << endl ;
645 pdf->setStringAttribute(
"factory_tag",
Form(
"PROD::%s(%s)",objName,pdfList)) ;
659 map<string,RooAbsPdf*> theMap ;
664 char* tok = R__STRTOK_R(buf,
",",&save) ;
666 char* eq = strchr(tok,
'=') ;
668 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName
669 <<
" expect mapping token of form 'state=pdfName', but found '" << tok <<
"'" << endl ;
676 theMap[tok] = &
asPDF(eq+1) ;
677 }
catch (
const string &err ) {
678 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous: " << err << endl ;
682 tok = R__STRTOK_R(0,
",",&save) ;
687 std::unique_ptr<RooSimultaneous> pdf;
689 pdf = std::make_unique<RooSimultaneous>(objName,objName,theMap,
asCATLV(indexCat)) ;
690 }
catch (
const string &err) {
691 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
697 pdf->setStringAttribute(
"factory_tag",
Form(
"SIMUL::%s(%s,%s)",objName,indexCat,pdfMap)) ;
717 char* tok = R__STRTOK_R(buf,
",",&save) ;
719 char* star=strchr(tok,
'*') ;
727 tok = R__STRTOK_R(0,
",",&save) ;
730 }
catch (
const string &err) {
731 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
737 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
743 auto sum = sumlist2.
empty() ? std::make_unique<RooAddition>(objName,objName,sumlist1)
744 : std::make_unique<RooAddition>(objName,objName,sumlist1,sumlist2);
746 sum->setStringAttribute(
"factory_tag",
Form(
"sum::%s(%s)",objName,specList)) ;
863 char* buf =
new char[strlen(expr)+1] ;
868 if (!isspace(*expr)) {
885 }
catch (
const string &error) {
886 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERROR in parsing: " << error << endl ;
892 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed" << endl ;
902 return out.size() ?
ws().
arg(out.c_str()) : 0 ;
921 if (
string(token).find(
"$Alias(")==0) {
947 const size_t bufBaseSize = strlen(token)+1;
948 char* buf_base =
new char[bufBaseSize] ;
949 char* buf = buf_base ;
950 strlcpy(buf,token,bufBaseSize) ;
953 list<string> singleExpr ;
956 bool litmode(
false) ;
960 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
961 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
964 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
968 if (!litmode && blevel==0 && ( (*
p)==
'=' || (*
p) ==
'|' || (*
p) ==
'*')) {
971 singleExpr.push_back(buf) ;
977 singleExpr.push_back(buf) ;
979 if (singleExpr.size()==1) {
986 list<char>::iterator ic =
separator.begin() ;
987 for (list<string>::iterator ii = singleExpr.begin() ; ii!=singleExpr.end() ; ++ii) {
1012 if (strlen(arg)==0) {
1017 if (arg[0]==
'\'' || arg[0]==
'"') {
1018 return string(arg) ;
1022 const size_t bufSize = strlen(arg)+1;
1023 char* buf =
new char[bufSize] ;
1024 strlcpy(buf,arg,bufSize) ;
1025 char* bufptr = buf ;
1027 string func,prefix ;
1028 vector<string> args ;
1032 char* tmpx = R__STRTOK_R(buf,
"([",&save) ;
1033 func = tmpx ? tmpx :
"" ;
1034 char*
p = R__STRTOK_R(0,
"",&save) ;
1045 bool litmode(
false) ;
1049 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1050 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1053 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1059 if (!litmode && blevel==0 && ((*
p)==
',')) {
1061 args.push_back(tok) ;
1070 if (
p>bufptr && (*(
p-1)==
')'||*(
p-1)==
']')) {
1079 p = R__STRTOK_R(0,
"",&save) ;
1081 args.push_back(tmp) ;
1092 for(
const char* pp=arg ; *pp!=0 ; pp++) {
1093 if (*pp==
'(' || *pp==
'[' || *pp==
'{') {
1099 if (strstr(func.c_str(),
"::")) {
1104 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: Class::Instance must be followed by (...)" << endl ;
1107 }
else if (func[0]!=
'$'){
1111 }
else if (lb==
'(') {
1121 static Int_t globCounter = 0 ;
1123 autoname =
Form(
"gobj%d",globCounter) ;
1125 if (!
ws().arg(autoname.c_str())) {
1129 autoname =
Form(
"%s::%s",func.c_str(),autoname.c_str()) ;
1133 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: expect either Class(...) or Instance[...]" << endl ;
1141 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: $MetaClass must be followed by (...)" << endl ;
1161 const size_t bufSize = strlen(arg)+1;
1162 char* buf =
new char[bufSize] ;
1163 strlcpy(buf,arg,bufSize) ;
1165 vector<string> args ;
1176 if (*
p==
'{' || *
p==
'(' || *
p==
'[') level++ ;
1177 if (*
p==
'}' || *
p==
')' || *
p==
']') level-- ;
1183 if (level==0 && ((*
p)==
',')) {
1185 args.push_back(tok) ;
1193 if (
p>buf && *(
p-1)==
'}') {
1196 args.push_back(tok) ;
1204 vector<string>::iterator iter = args.begin() ;
1206 while(iter!= args.end()) {
1207 if (strlen(ret.c_str())>1) ret +=
"," ;
1231 if (args.size()!=2) {
1232 coutE(
ObjectHandling) <<
"RooFactorWSTool::processAliasExpression() ERROR $Alias() takes exactly two arguments, " << args.size() <<
" args found" << endl ;
1252 map<string,string>::iterator item =
_typeAliases.find(className) ;
1256 className = item->second.c_str() ;
1269 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not defined in ROOT class table" << endl ;
1286 for (vector<string>::iterator iter = args.begin() ; iter!=args.end() ; ++iter) {
1287 if (iter!=args.begin()) {
1314 string first = *(args.begin()) ;
1318 vector<string>::iterator ai = args.begin() ;
1319 if (args.size()==1) {
1322 double xinit = atof((ai)->c_str()) ;
1324 RooRealVar tmp(func.c_str(),func.c_str(),xinit) ;
1330 }
else if (args.size()==2) {
1333 double xlo = atof((ai++)->c_str()) ;
1334 double xhi = atof(ai->c_str()) ;
1335 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1336 RooRealVar tmp(func.c_str(),func.c_str(),xlo,xhi) ;
1342 }
else if (args.size()==3) {
1345 double xinit = atof((ai++)->c_str()) ;
1346 double xlo = atof((ai++)->c_str()) ;
1347 double xhi = atof(ai->c_str()) ;
1348 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xinit = " << xinit <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1349 RooRealVar tmp(func.c_str(),func.c_str(),xinit,xlo,xhi) ;
1359 for (vector<string>::iterator ai = args.begin() ; ai!=args.end() ; ++ai) {
1360 if (allStates.size()>0) {
1388 const char *className = R__STRTOK_R(buf,
":",&save) ;
1389 const char *instName = R__STRTOK_R(0,
":",&save) ;
1390 if (!className) className =
"";
1391 if (!instName) instName =
"" ;
1396 vector<string>::iterator iter = args.begin() ;
1397 vector<string> pargv ;
1399 while(iter!=args.end()) {
1400 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1405 pargv.push_back(tmp) ;
1411 for (map<string,IFace*>::iterator ii=
hooks().begin() ; ii!=
hooks().end() ; ++ii) {
1413 if (
hooks().find(className) !=
hooks().end()) {
1415 return iface->
create(*
this, className,instName,pargv) ;
1420 return string(instName) ;
1432 vector<string>::iterator iter = args.begin() ;
1433 vector<string> pargv ;
1434 while(iter!=args.end()) {
1435 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1438 pargv.push_back(tmp) ;
1442 string ret = func+
"("+pargs+
")" ;
1454 const size_t bufSize = strlen(funcExpr)+1;
1455 char* buf =
new char[bufSize] ;
1456 strlcpy(buf,funcExpr,bufSize) ;
1457 char* bufptr = buf ;
1460 vector<string> args ;
1464 char* tmpx = R__STRTOK_R(buf,
"(",&save) ;
1465 func = tmpx ? tmpx :
"" ;
1466 char*
p = R__STRTOK_R(0,
"",&save) ;
1476 bool litmode(
false) ;
1480 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1481 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1484 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1490 if (!litmode && blevel==0 && ((*
p)==
',')) {
1492 args.push_back(tok) ;
1501 if (
p>bufptr && *(
p-1)==
')') {
1510 p = R__STRTOK_R(0,
"",&save) ;
1512 args.push_back(tmp) ;
1531 Int_t nParentheses(0), nBracket(0), nAccolade(0) ;
1532 const char* ptr = arg ;
1534 if (*ptr==
'(') nParentheses++ ;
1535 if (*ptr==
')') nParentheses-- ;
1536 if (*ptr==
'[') nBracket++ ;
1537 if (*ptr==
']') nBracket-- ;
1538 if (*ptr==
'{') nAccolade++ ;
1539 if (*ptr==
'}') nAccolade-- ;
1542 if (nParentheses!=0) {
1543 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nParentheses>0?
"(":
")") <<
"' in expression" << endl ;
1547 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nBracket>0?
"[":
"]") <<
"' in expression" << endl ;
1551 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nAccolade>0?
"{":
"}") <<
"' in expression" << endl ;
1564 throw string(
Form(
"Need argument number %d, but only %d args are provided",idx,(
Int_t)
_of->
_args.size())) ;
1576 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1583 throw string(
Form(
"RooAbsArg named %s not found",arg)) ;
1596 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1602 throw string(
Form(
"RooAbsReal named %s not found",arg)) ;
1606 throw string(
Form(
"Object named %s is not of type RooAbsReal",arg)) ;
1619 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1620 throw string(
Form(
"Numeric literal provided for argument (%s), but lvalue is required",arg)) ;
1625 throw string(
Form(
"RooAbsRealLValue named %s not found",arg)) ;
1629 throw string(
Form(
"Object named %s is not of type RooAbsRealLValue",arg)) ;
1643 throw string(
Form(
"RooRealVar named %s not found",arg)) ;
1658 throw string(
Form(
"RooAbsPdf named %s not found",arg)) ;
1673 throw string(
Form(
"RooResolutionModel named %s not found",arg)) ;
1677 throw string(
Form(
"Object named %s is not of type RooResolutionModel",arg)) ;
1692 throw string(
Form(
"RooAbsCategory named %s not found",arg)) ;
1696 throw string(
Form(
"Object named %s is not of type RooAbsCategory",arg)) ;
1710 throw string(
Form(
"RooAbsCategoryLValue named %s not found",arg)) ;
1715 throw string(
Form(
"Object named %s is not of type RooAbsCategoryLValue",arg)) ;
1729 throw string(
Form(
"RooCategory named %s not found",arg)) ;
1760 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1765 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1767 }
else if (tok[0] ==
'\'') {
1768 tok[strlen(tok) - 1] = 0;
1776 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1779 tok = R__STRTOK_R(0,
",{}",&save) ;
1797 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1801 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1803 }
else if (tok[0] ==
'\'') {
1804 tok[strlen(tok) - 1] = 0;
1812 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1815 tok = R__STRTOK_R(0,
",{}",&save) ;
1830 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1844 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1848 throw string(
Form(
"Dataset named %s is not of type RooDataHist",arg)) ;
1861 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1865 throw string(
Form(
"Dataset named %s is not of type RooDataSet",arg)) ;
1878 throw string(
Form(
"Object named %s not found",arg)) ;
1890 static vector<string> cbuf(10) ;
1891 static unsigned int cbuf_idx = 0 ;
1894 if (arg==0 || strlen(arg)==0) {
1900 cbuf[cbuf_idx].clear() ;
1901 const char*
p = arg+1 ;
1902 while(*
p && (*
p) !=
'"' && (*
p) !=
'\'' ) {
1903 cbuf[cbuf_idx] += *(
p++) ;
1905 const char* ret = cbuf[cbuf_idx].c_str() ;
1909 if (cbuf_idx==cbuf.size()) cbuf_idx=0 ;
1938 hooks()[typeName] = iface ;
1948 _hooks =
new map<string,IFace*> ;
1961 vector<string>::iterator iter = args.begin() ;
1962 vector<string> pargv ;
1963 while(iter!=args.end()) {
1964 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1967 pargv.push_back(tmp) ;
1972 string cl(typeName) ;
1976 ft.
add(instName,pargs,
false) ;
1978 }
else if (cl==
"RSUM") {
1981 ft.
add(instName,pargs,
true) ;
1983 }
else if (cl==
"ASUM") {
1988 }
else if (cl==
"PROD") {
1991 ft.
prod(instName,pargs) ;
1993 }
else if (cl==
"SIMUL") {
1996 if (pargv.size()>1) {
1997 ft.
simul(instName,pargv[0].c_str(),strchr(pargs,
',')+1) ;
1999 throw string(
Form(
"Need at least two arguments in call to SIMUL::%s, have %d: %s",instName,(
Int_t)pargv.size(),pargs)) ;
2002 }
else if (cl==
"EXPR") {
2005 if (args.size()<=2) {
2006 ft.
createArg(
"RooGenericPdf",instName,pargs) ;
2011 for (
UInt_t i=1 ; i<args.size() ; i++) {
2016 ft.
createArg(
"RooGenericPdf",instName,genargs) ;
2019 }
else if (cl==
"FCONV") {
2022 ft.
createArg(
"RooFFTConvPdf",instName,pargs) ;
2024 }
else if (cl==
"NCONV") {
2027 ft.
createArg(
"RooNumConvPdf",instName,pargs) ;
2029 }
else if (cl==
"sum") {
2034 }
else if (cl==
"prod") {
2039 }
else if (cl ==
"lagrangianmorph") {
2041 const std::array<std::string,4> funcArgs{{
"fileName",
"observableName",
"couplings",
"folders"}};
2042 map<string,string> mapped_inputs;
2044 for (
unsigned int i=1 ; i<pargv.size() ; i++) {
2045 if (pargv[i].find(
"$fileName(")!=0 &&
2046 pargv[i].find(
"$observableName(")!=0 &&
2047 pargv[i].find(
"$couplings(")!=0 &&
2048 pargv[i].find(
"$folders(")!=0 &&
2049 pargv[i].find(
"$NewPhysics(")!=0) {
2050 throw string(
Form(
"%s::create() ERROR: unknown token %s encountered",instName, pargv[i].c_str())) ;
2057 for (
unsigned int i=0 ; i<pargv.size() ; i++) {
2058 if (pargv[i].find(
"$NewPhysics(")==0) {
2060 for(
const auto& subarg: subargs) {
2064 char *tok = R__STRTOK_R(buf,
"=", &save);
2065 vector<string> parts;
2067 parts.push_back(
string(tok));
2068 tok = R__STRTOK_R(0,
"=", &save);
2070 if (parts.size() == 2){
2071 ft.
ws().
arg(parts[0].c_str())->
setAttribute(
"NewPhysics",atoi(parts[1].c_str()));
2073 else throw string(
Form(
"%s::create() ERROR: unknown token %s encountered, check input provided for %s",instName,subarg.c_str(), pargv[i].c_str()));
2078 if (subargs.size()==1){
2080 for(
auto const& param : funcArgs){
2081 if(pargv[i].find(param)!=string::npos) mapped_inputs[param]=subargs[0];
2084 else throw string(
Form(
"Incorrect number of arguments in %s, have %d, expect 1",pargv[i].c_str(),(
Int_t)subargs.size())) ;
2087 for(
auto const& param : funcArgs){
2088 if(strlen(pargsmorph) > 0) strlcat(pargsmorph,
",",
BUFFER_SIZE);
2089 strlcat(pargsmorph, mapped_inputs[param].c_str(),
BUFFER_SIZE);
2091 ft.
createArg(
"RooLagrangianMorphFunc",instName, pargsmorph);
2093 }
else if (cl==
"expr") {
2096 if (args.size()<=2) {
2097 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2102 for (
UInt_t i=1 ; i<args.size() ; i++) {
2107 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2110 }
else if (cl ==
"taylorexpand") {
2114 double eps1(1
e-6), eps2(1
e-3), observablesValue(0.0);
2116 if (pargv.size() < 2)
2117 throw string(
Form(
"taylorexpand::%s, requires atleast 2 arguments (function, observables) atleast, has %d arguments", instName, (
Int_t)pargv.size()));
2122 if (pargv.size() > 3)
2123 order = atoi(pargv[3].c_str());
2124 if (pargv.size() > 2) {
2125 if (pargv[2].find(
",") != string::npos)
2126 throw string(
Form(
"taylorexpand::%s, factory syntax supports expansion only around same value for all observables", instName));
2127 else observablesValue = atof(pargv[2].c_str());
2130 if (pargv.size() > 3)
2131 order = atoi(pargv[3].c_str());
2132 if (pargv.size() > 4)
2133 eps1 = atof(pargv[4].c_str());
2134 if (pargv.size() > 5)
2135 eps2 = atof(pargv[5].c_str());
2137 if (pargv.size() > 6)
2139 Form(
"taylorexpand::%s, requires max. 6 arguments, has %d arguments", instName, (
Int_t)pargv.size()));
2144 }
else if (cl==
"nconv") {
2147 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2149 }
else if (cl==
"nll") {
2155 }
else if (cl==
"chi2") {
2161 }
else if (cl==
"profile") {
2164 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2166 }
else if (cl==
"dataobs") {
2176 }
else if (cl==
"int") {
2183 if (pargv.size()<2 || pargv.size()>3) {
2184 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2190 strlcpy(buf,pargv[1].c_str(),256) ;
2192 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2193 if (!intobs) intobs=
"" ;
2195 const char* range = R__STRTOK_R(0,
"",&save) ;
2196 if (!range) range=
"" ;
2198 std::unique_ptr<RooAbsReal> integral;
2199 if (pargv.size()==2) {
2200 if (range && strlen(range)) {
2206 if (range && strlen(range)) {
2213 integral->SetName(instName) ;
2216 }
else if (cl==
"deriv") {
2220 if (pargv.size()<2 || pargv.size()>3) {
2221 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2226 std::unique_ptr<RooAbsReal> derivative;
2227 if (pargv.size()==2) {
2233 derivative->
SetName(instName) ;
2236 }
else if (cl==
"cdf") {
2240 if (pargv.size()<2 || pargv.size()>3) {
2241 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2246 std::unique_ptr<RooAbsReal> cdf;
2247 if (pargv.size()==2) {
2257 }
else if (cl==
"PROJ") {
2260 if (pargv.size()!=2) {
2261 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2266 projection->
SetName(instName) ;
2270 }
else if (cl==
"set") {
2275 return string(instName) ;
2280 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2283 return string(instName) ;
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 property
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...
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
void SetName(const char *name) override
Set the name of the TNamed.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
virtual TObject * clone(const char *newname=0) const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
A space to attach TBranches.
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.
RooAbsData is the common abstract base class for binned and unbinned datasets.
RooAbsReal * createCdf(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Create a cumulative distribution function of this p.d.f in terms of the observables listed in iset.
virtual RooAbsPdf * createProjection(const RooArgSet &iset)
Return a p.d.f that represent a projection of this p.d.f integrated over given observables.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, 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(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, double eps=0.001)
Return function representing first, second or third order derivative of this function.
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCategory is an object to represent discrete states.
bool defineType(const std::string &label)
Define a state with given name.
RooChi2Var implements a simple calculation from a binned dataset and a PDF.
The RooDataHist is a container class to hold N-dimensional binned data.
RooDataSet is a container class to hold unbinned data.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
void Delete(Option_t *o=0) override
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
static std::unique_ptr< RooAbsReal > taylorExpand(const char *name, const char *title, RooAbsReal &func, const RooAbsCollection &observables, std::vector< double > const &observableValues, int order=1, double eps1=1e-6, double eps2=1e-3)
RooProdPdf is an efficient implementation of a product of PDFs of the form.
A RooProduct represents the product of a given set of RooAbsReal objects.
The class RooRealSumPdf implements a PDF constructed from a sum of functions:
RooRealVar represents a variable that can be changed from the outside.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooStringVar is a RooAbsArg implementing string values.
The RooWorkspace is a persistable container for RooFit projects.
TObject * obj(RooStringView name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
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.
bool cancelTransaction()
Cancel an ongoing import transaction.
bool startTransaction()
Open an import transaction operations.
RooAbsArg * arg(RooStringView name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
RooAbsData * data(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
const RooArgSet * set(const char *name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
bool defineSet(const char *name, const RooArgSet &aset, bool importMissing=false)
Define a named RooArgSet with given constituents.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, bool depsAreCond=false)
RooConstVar & RooConst(double val)
RooCmdArg Silence(bool flag=true)
RooCmdArg NormSet(Args_t &&... argsOrArgSet)
void(off) SmallVectorTemplateBase< T
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static constexpr double s
static uint64_t sum(uint64_t i)