71#define BUFFER_SIZE 64000
161 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
188 const size_t tmpSize = strlen(stateNameList)+1;
189 char *tmp =
new char[tmpSize] ;
190 strlcpy(tmp,stateNameList,tmpSize) ;
192 char* tok = R__STRTOK_R(tmp,
",",&save) ;
194 char* sep = strchr(tok,
'=') ;
197 Int_t id = atoi(sep+1) ;
203 tok = R__STRTOK_R(0,
",",&save) ;
217 static bool isEnum(
const char* classname) {
219 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
226 static bool isValidEnumValue(
const char* enumName,
const char* enumConstantName) {
229 if (!enumName)
return false;
232 if (!enumName)
return false;
235 if (theEnum->GetConstant(enumConstantName))
return true;
237 auto tmp = strstr(enumConstantName,
"::");
239 auto enumConstantNameNoScope = tmp+2;
240 if (theEnum->GetConstant(enumConstantNameNoScope))
return true;
246 static pair<list<string>,
unsigned int> ctorArgs(
const char* classname,
UInt_t nMinArg) {
254 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
255 MethodInfo_t* func =
gInterpreter->MethodInfo_Factory(cls);
268 if (
string(classname) !=
gInterpreter->MethodInfo_TypeName(func)) {
274 if (nargs==0 || nargs==
gInterpreter->MethodInfo_NDefaultArg(func)) {
278 MethodArgInfo_t* arg =
gInterpreter->MethodArgInfo_Factory(func);
281 const char* argTypeName =
gInterpreter->MethodArgInfo_TypeName(arg);
282 if (nreq<2 && ((
string(
"char*") != argTypeName
284 &&
string(
"const char*") != argTypeName)) {
287 ret.push_back(argTypeName) ;
288 if(!
gInterpreter->MethodArgInfo_DefaultValue(arg)) nreq++;
293 if (ret.size()<nMinArg) {
301 return pair<list<string>,
unsigned int>(ret,nreq);
316 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not found in factory alias table, nor in ROOT class table" << endl;
325 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" does not inherit from RooAbsArg" << endl;
332 size_t blevel = 0, end_tok, start_tok = 0;
333 bool litmode =
false;
334 for (end_tok = 0; end_tok < tmp.length(); end_tok++) {
336 if (tmp[end_tok]==
'{' || tmp[end_tok]==
'(' || tmp[end_tok]==
'[') blevel++;
337 if (tmp[end_tok]==
'}' || tmp[end_tok]==
')' || tmp[end_tok]==
']') blevel--;
340 if (tmp[end_tok]==
'"' || tmp[end_tok]==
'\'') litmode = !litmode;
345 if (litmode ==
false && blevel == 0 && tmp[end_tok] ==
',') {
346 _args.push_back(tmp.substr(start_tok, end_tok - start_tok));
347 start_tok = end_tok+1;
350 _args.push_back(tmp.substr(start_tok, end_tok));
353 pair<list<string>,
unsigned int> ca = ctorArgs(className,
_args.size()+2) ;
354 if (ca.first.size()==0) {
355 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR no suitable constructor found for class " << className << endl ;
362 if (
_args.size()+2<ca.second ||
_args.size()+2>ca.first.size()) {
363 if (ca.second==ca.first.size()) {
364 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid, " << className
365 <<
" expects " << ca.first.size()-2 << endl ;
368 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid " << className
369 <<
" expect number between " << ca.second-2 <<
" and " << ca.first.size()-2 << endl ;
376 string cintExpr(
Form(
"new %s(\"%s\",\"%s\"",className,objName,objName)) ;
384 list<string>::iterator ti = ca.first.begin() ; ++ti ; ++ti ;
385 for (vector<string>::iterator ai =
_args.begin() ; ai !=
_args.end() ; ++ai,++ti,++i) {
386 if ((*ti)==
"RooAbsReal&" || (*ti)==
"const RooAbsReal&") {
388 cintExpr +=
Form(
",RooFactoryWSTool::as_FUNC(%d)",i) ;
389 }
else if ((*ti)==
"RooAbsArg&" || (*ti)==
"const RooAbsArg&") {
391 cintExpr +=
Form(
",RooFactoryWSTool::as_ARG(%d)",i) ;
392 }
else if ((*ti)==
"RooRealVar&" || (*ti)==
"const RooRealVar&") {
394 cintExpr +=
Form(
",RooFactoryWSTool::as_VAR(%d)",i) ;
395 }
else if ((*ti)==
"RooAbsRealLValue&" || (*ti)==
"const RooAbsRealLValue&") {
397 cintExpr +=
Form(
",RooFactoryWSTool::as_VARLV(%d)",i) ;
398 }
else if ((*ti)==
"RooCategory&" || (*ti)==
"const RooCategory&") {
400 cintExpr +=
Form(
",RooFactoryWSTool::as_CAT(%d)",i) ;
401 }
else if ((*ti)==
"RooAbsCategory&" || (*ti)==
"const RooAbsCategory&") {
403 cintExpr +=
Form(
",RooFactoryWSTool::as_CATFUNC(%d)",i) ;
404 }
else if ((*ti)==
"RooAbsCategoryLValue&" || (*ti)==
"const RooAbsCategoryLValue&") {
406 cintExpr +=
Form(
",RooFactoryWSTool::as_CATLV(%d)",i) ;
407 }
else if ((*ti)==
"RooAbsPdf&" || (*ti)==
"const RooAbsPdf&") {
409 cintExpr +=
Form(
",RooFactoryWSTool::as_PDF(%d)",i) ;
410 }
else if ((*ti)==
"RooResolutionModel&" || (*ti)==
"const RooResolutionModel&") {
412 cintExpr +=
Form(
",RooFactoryWSTool::as_RMODEL(%d)",i) ;
413 }
else if ((*ti)==
"RooAbsData&" || (*ti)==
"const RooAbsData&") {
415 cintExpr +=
Form(
",RooFactoryWSTool::as_DATA(%d)",i) ;
416 }
else if ((*ti)==
"RooDataSet&" || (*ti)==
"const RooDataSet&") {
418 cintExpr +=
Form(
",RooFactoryWSTool::as_DSET(%d)",i) ;
419 }
else if ((*ti)==
"RooDataHist&" || (*ti)==
"const RooDataHist&") {
421 cintExpr +=
Form(
",RooFactoryWSTool::as_DHIST(%d)",i) ;
422 }
else if ((*ti)==
"const RooArgSet&") {
424 cintExpr +=
Form(
",RooFactoryWSTool::as_SET(%d)",i) ;
425 }
else if ((*ti)==
"const RooArgList&") {
427 cintExpr +=
Form(
",RooFactoryWSTool::as_LIST(%d)",i) ;
428 }
else if ((*ti)==
"const char*") {
430 cintExpr +=
Form(
",RooFactoryWSTool::as_STRING(%d)",i) ;
431 }
else if ((*ti)==
"Int_t" || (*ti)==
"int" || (*ti)==
"Bool_t" || (*ti)==
"bool") {
433 cintExpr +=
Form(
",RooFactoryWSTool::as_INT(%d)",i) ;
434 }
else if ((*ti)==
"Double_t") {
436 cintExpr +=
Form(
",RooFactoryWSTool::as_DOUBLE(%d)",i) ;
437 }
else if (isEnum(ti->c_str())) {
440 if (
_args[i].find(
Form(
"%s::",className)) != string::npos) {
441 qualvalue =
_args[i].c_str() ;
443 qualvalue =
Form(
"%s::%s",className,
_args[i].c_str()) ;
445 if (isValidEnumValue(ti->c_str(),qualvalue.c_str())) {
446 cintExpr +=
Form(
",(%s)%s",ti->c_str(),qualvalue.c_str()) ;
448 throw string(
Form(
"Supplied argument %s does not represent a valid state of enum %s",
_args[i].c_str(),ti->c_str())) ;
456 if (ti->find(
"const ")==0) {
457 btype = ti->c_str()+6 ;
461 if (btype.find(
"&")) {
462 btype.erase(btype.size()-1,btype.size()) ;
469 cintExpr +=
Form(
",(%s&)RooFactoryWSTool::as_OBJ(%d)",ti->c_str(),i) ;
471 throw string(
Form(
"Required argument with name %s of type '%s' is not in the workspace",
_args[i].c_str(),ti->c_str())) ;
476 }
catch (
const string &err) {
477 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR constructing " << className <<
"::" << objName <<
": " << err << endl ;
482 cxcoutD(
ObjectHandling) <<
"RooFactoryWSTool::createArg() Construct expression is " << cintExpr << endl ;
488 if (
string(className)==
"RooGenericPdf") {
490 }
else if (
string(className)==
"RooFormulaVar") {
500 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR in CINT constructor call to create object" << endl ;
521 char* tok = R__STRTOK_R(buf,
",",&save) ;
523 char* star=strchr(tok,
'*') ;
531 tok = R__STRTOK_R(0,
",",&save) ;
533 pdfList.
add(pdfList2) ;
535 }
catch (
const string &err) {
536 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
541 RooAddPdf pdf{objName,objName,pdfList,coefList,recursiveCoefs};
542 pdf.setStringAttribute(
"factory_tag",
Form(
"SUM::%s(%s)",objName,specList)) ;
563 char* tok = R__STRTOK_R(buf,
",",&save) ;
565 char* star=strchr(tok,
'*') ;
573 tok = R__STRTOK_R(0,
",",&save) ;
575 amplList.
add(amplList2) ;
577 }
catch (
const string &err) {
578 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooRealSumPdf: " << err << endl ;
598 string regPdfList=
"{" ;
602 char* tok = R__STRTOK_R(buf,
",",&save) ;
604 char *sep = strchr(tok,
'|') ;
619 }
catch (
const string &err) {
620 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf Conditional argument: " << err << endl ;
627 if (regPdfList.size()>1) {
632 tok = R__STRTOK_R(0,
",",&save) ;
636 std::unique_ptr<RooProdPdf> pdf;
638 pdf = std::make_unique<RooProdPdf>(objName,objName,
asSET(regPdfList.c_str()),cmdList);
639 }
catch (
const string &err) {
640 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf input set of regular p.d.f.s: " << err << endl ;
646 pdf->setStringAttribute(
"factory_tag",
Form(
"PROD::%s(%s)",objName,pdfList)) ;
660 map<string,RooAbsPdf*> theMap ;
665 char* tok = R__STRTOK_R(buf,
",",&save) ;
667 char* eq = strchr(tok,
'=') ;
669 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName
670 <<
" expect mapping token of form 'state=pdfName', but found '" << tok <<
"'" << endl ;
677 theMap[tok] = &
asPDF(eq+1) ;
678 }
catch (
const string &err ) {
679 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous: " << err << endl ;
683 tok = R__STRTOK_R(0,
",",&save) ;
688 std::unique_ptr<RooSimultaneous> pdf;
690 pdf = std::make_unique<RooSimultaneous>(objName,objName,theMap,
asCATLV(indexCat)) ;
691 }
catch (
const string &err) {
692 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
698 pdf->setStringAttribute(
"factory_tag",
Form(
"SIMUL::%s(%s,%s)",objName,indexCat,pdfMap)) ;
718 char* tok = R__STRTOK_R(buf,
",",&save) ;
720 char* star=strchr(tok,
'*') ;
728 tok = R__STRTOK_R(0,
",",&save) ;
731 }
catch (
const string &err) {
732 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
738 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
744 auto sum = sumlist2.
empty() ? std::make_unique<RooAddition>(objName,objName,sumlist1)
745 : std::make_unique<RooAddition>(objName,objName,sumlist1,sumlist2);
747 sum->setStringAttribute(
"factory_tag",
Form(
"sum::%s(%s)",objName,specList)) ;
864 char* buf =
new char[strlen(expr)+1] ;
869 if (!isspace(*expr)) {
886 }
catch (
const string &error) {
887 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERROR in parsing: " << error << endl ;
893 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed" << endl ;
903 return out.size() ?
ws().
arg(out.c_str()) : 0 ;
922 if (
string(token).find(
"$Alias(")==0) {
948 const size_t bufBaseSize = strlen(token)+1;
949 char* buf_base =
new char[bufBaseSize] ;
950 char* buf = buf_base ;
951 strlcpy(buf,token,bufBaseSize) ;
954 list<string> singleExpr ;
955 list<char> separator ;
961 if (*p==
'{' || *p==
'(' || *p==
'[') blevel++ ;
962 if (*p==
'}' || *p==
')' || *p==
']') blevel-- ;
965 if (*p==
'"' || *p==
'\'') litmode = !litmode ;
969 if (!litmode && blevel==0 && ( (*p)==
'=' || (*p) ==
'|' || (*p) ==
'*')) {
970 separator.push_back(*p) ;
972 singleExpr.push_back(buf) ;
978 singleExpr.push_back(buf) ;
980 if (singleExpr.size()==1) {
987 list<char>::iterator ic = separator.begin() ;
988 for (list<string>::iterator ii = singleExpr.begin() ; ii!=singleExpr.end() ; ++ii) {
990 if (ic != separator.end()) {
1013 if (strlen(arg)==0) {
1018 if (arg[0]==
'\'' || arg[0]==
'"') {
1019 return string(arg) ;
1023 const size_t bufSize = strlen(arg)+1;
1024 char* buf =
new char[bufSize] ;
1025 strlcpy(buf,arg,bufSize) ;
1026 char* bufptr = buf ;
1028 string func,prefix ;
1029 vector<string> args ;
1033 char* tmpx = R__STRTOK_R(buf,
"([",&save) ;
1034 func = tmpx ? tmpx :
"" ;
1035 char* p = R__STRTOK_R(0,
"",&save) ;
1050 if (*p==
'{' || *p==
'(' || *p==
'[') blevel++ ;
1051 if (*p==
'}' || *p==
')' || *p==
']') blevel-- ;
1054 if (*p==
'"' || *p==
'\'') litmode = !litmode ;
1060 if (!litmode && blevel==0 && ((*p)==
',')) {
1062 args.push_back(tok) ;
1071 if (p>bufptr && (*(p-1)==
')'||*(p-1)==
']')) {
1080 p = R__STRTOK_R(0,
"",&save) ;
1082 args.push_back(tmp) ;
1093 for(
const char* pp=arg ; *pp!=0 ; pp++) {
1094 if (*pp==
'(' || *pp==
'[' || *pp==
'{') {
1100 if (strstr(func.c_str(),
"::")) {
1105 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: Class::Instance must be followed by (...)" << endl ;
1108 }
else if (func[0]!=
'$'){
1112 }
else if (lb==
'(') {
1122 static Int_t globCounter = 0 ;
1124 autoname =
Form(
"gobj%d",globCounter) ;
1126 if (!
ws().arg(autoname.c_str())) {
1130 autoname =
Form(
"%s::%s",func.c_str(),autoname.c_str()) ;
1134 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: expect either Class(...) or Instance[...]" << endl ;
1142 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: $MetaClass must be followed by (...)" << endl ;
1162 const size_t bufSize = strlen(arg)+1;
1163 char* buf =
new char[bufSize] ;
1164 strlcpy(buf,arg,bufSize) ;
1166 vector<string> args ;
1177 if (*p==
'{' || *p==
'(' || *p==
'[') level++ ;
1178 if (*p==
'}' || *p==
')' || *p==
']') level-- ;
1184 if (level==0 && ((*p)==
',')) {
1186 args.push_back(tok) ;
1194 if (p>buf && *(p-1)==
'}') {
1197 args.push_back(tok) ;
1205 vector<string>::iterator iter = args.begin() ;
1207 while(iter!= args.end()) {
1208 if (strlen(ret.c_str())>1) ret +=
"," ;
1232 if (args.size()!=2) {
1233 coutE(
ObjectHandling) <<
"RooFactorWSTool::processAliasExpression() ERROR $Alias() takes exactly two arguments, " << args.size() <<
" args found" << endl ;
1253 map<string,string>::iterator item =
_typeAliases.find(className) ;
1257 className = item->second.c_str() ;
1270 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not defined in ROOT class table" << endl ;
1287 for (vector<string>::iterator iter = args.begin() ; iter!=args.end() ; ++iter) {
1288 if (iter!=args.begin()) {
1315 string first = *(args.begin()) ;
1319 vector<string>::iterator ai = args.begin() ;
1320 if (args.size()==1) {
1323 Double_t xinit = atof((ai)->c_str()) ;
1325 RooRealVar tmp(func.c_str(),func.c_str(),xinit) ;
1331 }
else if (args.size()==2) {
1334 Double_t xlo = atof((ai++)->c_str()) ;
1336 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1337 RooRealVar tmp(func.c_str(),func.c_str(),xlo,xhi) ;
1343 }
else if (args.size()==3) {
1346 Double_t xinit = atof((ai++)->c_str()) ;
1347 Double_t xlo = atof((ai++)->c_str()) ;
1349 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xinit = " << xinit <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1350 RooRealVar tmp(func.c_str(),func.c_str(),xinit,xlo,xhi) ;
1360 for (vector<string>::iterator ai = args.begin() ; ai!=args.end() ; ++ai) {
1361 if (allStates.size()>0) {
1389 const char *className = R__STRTOK_R(buf,
":",&save) ;
1390 const char *instName = R__STRTOK_R(0,
":",&save) ;
1391 if (!className) className =
"";
1392 if (!instName) instName =
"" ;
1397 vector<string>::iterator iter = args.begin() ;
1398 vector<string> pargv ;
1400 while(iter!=args.end()) {
1401 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1406 pargv.push_back(tmp) ;
1412 for (map<string,IFace*>::iterator ii=
hooks().begin() ; ii!=
hooks().end() ; ++ii) {
1414 if (
hooks().find(className) !=
hooks().end()) {
1416 return iface->
create(*
this, className,instName,pargv) ;
1421 return string(instName) ;
1433 vector<string>::iterator iter = args.begin() ;
1434 vector<string> pargv ;
1435 while(iter!=args.end()) {
1436 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1439 pargv.push_back(tmp) ;
1443 string ret = func+
"("+pargs+
")" ;
1455 const size_t bufSize = strlen(funcExpr)+1;
1456 char* buf =
new char[bufSize] ;
1457 strlcpy(buf,funcExpr,bufSize) ;
1458 char* bufptr = buf ;
1461 vector<string> args ;
1465 char* tmpx = R__STRTOK_R(buf,
"(",&save) ;
1466 func = tmpx ? tmpx :
"" ;
1467 char* p = R__STRTOK_R(0,
"",&save) ;
1481 if (*p==
'{' || *p==
'(' || *p==
'[') blevel++ ;
1482 if (*p==
'}' || *p==
')' || *p==
']') blevel-- ;
1485 if (*p==
'"' || *p==
'\'') litmode = !litmode ;
1491 if (!litmode && blevel==0 && ((*p)==
',')) {
1493 args.push_back(tok) ;
1502 if (p>bufptr && *(p-1)==
')') {
1511 p = R__STRTOK_R(0,
"",&save) ;
1513 args.push_back(tmp) ;
1532 Int_t nParentheses(0), nBracket(0), nAccolade(0) ;
1533 const char* ptr = arg ;
1535 if (*ptr==
'(') nParentheses++ ;
1536 if (*ptr==
')') nParentheses-- ;
1537 if (*ptr==
'[') nBracket++ ;
1538 if (*ptr==
']') nBracket-- ;
1539 if (*ptr==
'{') nAccolade++ ;
1540 if (*ptr==
'}') nAccolade-- ;
1543 if (nParentheses!=0) {
1544 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nParentheses>0?
"(":
")") <<
"' in expression" << endl ;
1548 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nBracket>0?
"[":
"]") <<
"' in expression" << endl ;
1552 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nAccolade>0?
"{":
"}") <<
"' in expression" << endl ;
1565 throw string(
Form(
"Need argument number %d, but only %d args are provided",idx,(
Int_t)
_of->
_args.size())) ;
1577 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1584 throw string(
Form(
"RooAbsArg named %s not found",arg)) ;
1597 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1603 throw string(
Form(
"RooAbsReal named %s not found",arg)) ;
1607 throw string(
Form(
"Object named %s is not of type RooAbsReal",arg)) ;
1620 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1621 throw string(
Form(
"Numeric literal provided for argument (%s), but lvalue is required",arg)) ;
1626 throw string(
Form(
"RooAbsRealLValue named %s not found",arg)) ;
1630 throw string(
Form(
"Object named %s is not of type RooAbsRealLValue",arg)) ;
1644 throw string(
Form(
"RooRealVar named %s not found",arg)) ;
1659 throw string(
Form(
"RooAbsPdf named %s not found",arg)) ;
1674 throw string(
Form(
"RooResolutionModel named %s not found",arg)) ;
1678 throw string(
Form(
"Object named %s is not of type RooResolutionModel",arg)) ;
1693 throw string(
Form(
"RooAbsCategory named %s not found",arg)) ;
1697 throw string(
Form(
"Object named %s is not of type RooAbsCategory",arg)) ;
1711 throw string(
Form(
"RooAbsCategoryLValue named %s not found",arg)) ;
1716 throw string(
Form(
"Object named %s is not of type RooAbsCategoryLValue",arg)) ;
1730 throw string(
Form(
"RooCategory named %s not found",arg)) ;
1761 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1766 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1768 }
else if (tok[0] ==
'\'') {
1769 tok[strlen(tok) - 1] = 0;
1777 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1780 tok = R__STRTOK_R(0,
",{}",&save) ;
1798 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1802 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1804 }
else if (tok[0] ==
'\'') {
1805 tok[strlen(tok) - 1] = 0;
1813 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1816 tok = R__STRTOK_R(0,
",{}",&save) ;
1831 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1845 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1849 throw string(
Form(
"Dataset named %s is not of type RooDataHist",arg)) ;
1862 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1866 throw string(
Form(
"Dataset named %s is not of type RooDataSet",arg)) ;
1879 throw string(
Form(
"Object named %s not found",arg)) ;
1891 static vector<string> cbuf(10) ;
1892 static unsigned int cbuf_idx = 0 ;
1895 if (arg==0 || strlen(arg)==0) {
1901 cbuf[cbuf_idx].clear() ;
1902 const char* p = arg+1 ;
1903 while(*p && (*p) !=
'"' && (*p) !=
'\'' ) {
1904 cbuf[cbuf_idx] += *(p++) ;
1906 const char* ret = cbuf[cbuf_idx].c_str() ;
1910 if (cbuf_idx==cbuf.size()) cbuf_idx=0 ;
1939 hooks()[typeName] = iface ;
1949 _hooks =
new map<string,IFace*> ;
1962 vector<string>::iterator iter = args.begin() ;
1963 vector<string> pargv ;
1964 while(iter!=args.end()) {
1965 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1968 pargv.push_back(tmp) ;
1973 string cl(typeName) ;
1979 }
else if (cl==
"RSUM") {
1984 }
else if (cl==
"ASUM") {
1989 }
else if (cl==
"PROD") {
1992 ft.
prod(instName,pargs) ;
1994 }
else if (cl==
"SIMUL") {
1997 if (pargv.size()>1) {
1998 ft.
simul(instName,pargv[0].c_str(),strchr(pargs,
',')+1) ;
2000 throw string(
Form(
"Need at least two arguments in call to SIMUL::%s, have %d: %s",instName,(
Int_t)pargv.size(),pargs)) ;
2003 }
else if (cl==
"EXPR") {
2006 if (args.size()<=2) {
2007 ft.
createArg(
"RooGenericPdf",instName,pargs) ;
2012 for (
UInt_t i=1 ; i<args.size() ; i++) {
2017 ft.
createArg(
"RooGenericPdf",instName,genargs) ;
2020 }
else if (cl==
"FCONV") {
2023 ft.
createArg(
"RooFFTConvPdf",instName,pargs) ;
2025 }
else if (cl==
"NCONV") {
2028 ft.
createArg(
"RooNumConvPdf",instName,pargs) ;
2030 }
else if (cl==
"sum") {
2035 }
else if (cl==
"prod") {
2040 }
else if (cl ==
"lagrangianmorph") {
2042 const std::array<std::string,4> funcArgs{{
"fileName",
"observableName",
"couplings",
"folders"}};
2043 map<string,string> mapped_inputs;
2045 for (
unsigned int i=1 ; i<pargv.size() ; i++) {
2046 if (pargv[i].find(
"$fileName(")!=0 &&
2047 pargv[i].find(
"$observableName(")!=0 &&
2048 pargv[i].find(
"$couplings(")!=0 &&
2049 pargv[i].find(
"$folders(")!=0 &&
2050 pargv[i].find(
"$NewPhysics(")!=0) {
2051 throw string(
Form(
"%s::create() ERROR: unknown token %s encountered",instName, pargv[i].c_str())) ;
2058 for (
unsigned int i=0 ; i<pargv.size() ; i++) {
2059 if (pargv[i].find(
"$NewPhysics(")==0) {
2061 for(
const auto& subarg: subargs) {
2065 char *tok = R__STRTOK_R(buf,
"=", &save);
2066 vector<string> parts;
2068 parts.push_back(
string(tok));
2069 tok = R__STRTOK_R(0,
"=", &save);
2071 if (parts.size() == 2){
2072 ft.
ws().
arg(parts[0].c_str())->
setAttribute(
"NewPhysics",atoi(parts[1].c_str()));
2074 else throw string(
Form(
"%s::create() ERROR: unknown token %s encountered, check input provided for %s",instName,subarg.c_str(), pargv[i].c_str()));
2079 if (subargs.size()==1){
2081 for(
auto const& param : funcArgs){
2082 if(pargv[i].find(param)!=string::npos) mapped_inputs[param]=subargs[0];
2085 else throw string(
Form(
"Incorrect number of arguments in %s, have %d, expect 1",pargv[i].c_str(),(
Int_t)subargs.size())) ;
2088 for(
auto const& param : funcArgs){
2089 if(strlen(pargsmorph) > 0) strlcat(pargsmorph,
",",
BUFFER_SIZE);
2090 strlcat(pargsmorph, mapped_inputs[param].c_str(),
BUFFER_SIZE);
2092 ft.
createArg(
"RooLagrangianMorphFunc",instName, pargsmorph);
2094 }
else if (cl==
"expr") {
2097 if (args.size()<=2) {
2098 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2103 for (
UInt_t i=1 ; i<args.size() ; i++) {
2108 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2111 }
else if (cl ==
"taylorexpand") {
2115 double eps1(1
e-6), eps2(1
e-3), observablesValue(0.0);
2117 if (pargv.size() < 2)
2118 throw string(
Form(
"taylorexpand::%s, requires atleast 2 arguments (function, observables) atleast, has %d arguments", instName, (
Int_t)pargv.size()));
2123 if (pargv.size() > 3)
2124 order = atoi(pargv[3].c_str());
2125 if (pargv.size() > 2) {
2126 if (pargv[2].find(
",") != string::npos)
2127 throw string(
Form(
"taylorexpand::%s, factory syntax supports expansion only around same value for all observables", instName));
2128 else observablesValue = atof(pargv[2].c_str());
2131 if (pargv.size() > 3)
2132 order = atoi(pargv[3].c_str());
2133 if (pargv.size() > 4)
2134 eps1 = atof(pargv[4].c_str());
2135 if (pargv.size() > 5)
2136 eps2 = atof(pargv[5].c_str());
2138 if (pargv.size() > 6)
2140 Form(
"taylorexpand::%s, requires max. 6 arguments, has %d arguments", instName, (
Int_t)pargv.size()));
2145 }
else if (cl==
"nconv") {
2148 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2150 }
else if (cl==
"nll") {
2156 }
else if (cl==
"chi2") {
2162 }
else if (cl==
"profile") {
2165 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2167 }
else if (cl==
"dataobs") {
2177 }
else if (cl==
"int") {
2184 if (pargv.size()<2 || pargv.size()>3) {
2185 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2191 strlcpy(buf,pargv[1].c_str(),256) ;
2193 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2194 if (!intobs) intobs=
"" ;
2196 const char* range = R__STRTOK_R(0,
"",&save) ;
2197 if (!range) range=
"" ;
2199 std::unique_ptr<RooAbsReal> integral;
2200 if (pargv.size()==2) {
2201 if (range && strlen(range)) {
2207 if (range && strlen(range)) {
2214 integral->SetName(instName) ;
2217 }
else if (cl==
"deriv") {
2221 if (pargv.size()<2 || pargv.size()>3) {
2222 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2227 std::unique_ptr<RooAbsReal> derivative;
2228 if (pargv.size()==2) {
2234 derivative->
SetName(instName) ;
2237 }
else if (cl==
"cdf") {
2241 if (pargv.size()<2 || pargv.size()>3) {
2242 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2247 std::unique_ptr<RooAbsReal> cdf;
2248 if (pargv.size()==2) {
2258 }
else if (cl==
"PROJ") {
2261 if (pargv.size()!=2) {
2262 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2267 projection->
SetName(instName) ;
2271 }
else if (cl==
"set") {
2276 return string(instName) ;
2281 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2284 return string(instName) ;
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
char * Form(const char *fmt,...)
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 setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
virtual TObject * clone(const char *newname=0) const =0
void SetName(const char *name)
Set the name of the TNamed.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
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_t 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)
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.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
RooAbsArg * fundArg(const char *name) const
Return fundamental (i.e.
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.
Bool_t commitTransaction()
Bool_t startTransaction()
Open an import transaction operations.
RooCategory * cat(const char *name) const
Retrieve discrete variable (RooCategory) with given name. A null pointer is returned if not found.
RooAbsArg * arg(const char *name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
Bool_t defineSet(const char *name, const RooArgSet &aset, Bool_t importMissing=kFALSE)
Define a named RooArgSet with given constituents.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Bool_t cancelTransaction()
Cancel an ongoing import transaction.
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...
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t InheritsFrom(const char *cl) const
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)
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * GetName() const
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 Silence(Bool_t flag=kTRUE)
RooConstVar & RooConst(Double_t val)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, Bool_t depsAreCond=kFALSE)
RooCmdArg NormSet(Args_t &&... argsOrArgSet)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static uint64_t sum(uint64_t i)