69#define BUFFER_SIZE 64000
157 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
184 const size_t tmpSize = strlen(stateNameList)+1;
185 char *tmp =
new char[tmpSize] ;
186 strlcpy(tmp,stateNameList,tmpSize) ;
188 char* tok = R__STRTOK_R(tmp,
",",&save) ;
190 char* sep = strchr(tok,
'=') ;
193 Int_t id = atoi(sep+1) ;
199 tok = R__STRTOK_R(0,
",",&save) ;
213 static bool isEnum(
const char* classname) {
215 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
222 static bool isValidEnumValue(
const char* enumName,
const char* enumConstantName) {
225 if (!enumName)
return false;
228 if (!enumName)
return false;
231 if (theEnum->GetConstant(enumConstantName))
return true;
233 auto tmp = strstr(enumConstantName,
"::");
235 auto enumConstantNameNoScope = tmp+2;
236 if (theEnum->GetConstant(enumConstantNameNoScope))
return true;
242 static pair<list<string>,
unsigned int> ctorArgs(
const char* classname,
UInt_t nMinArg) {
250 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
251 MethodInfo_t* func =
gInterpreter->MethodInfo_Factory(cls);
264 if (
string(classname) !=
gInterpreter->MethodInfo_TypeName(func)) {
270 if (nargs==0 || nargs==
gInterpreter->MethodInfo_NDefaultArg(func)) {
274 MethodArgInfo_t* arg =
gInterpreter->MethodArgInfo_Factory(func);
277 const char* argTypeName =
gInterpreter->MethodArgInfo_TypeName(arg);
278 if (nreq<2 && ((
string(
"char*") != argTypeName
280 &&
string(
"const char*") != argTypeName)) {
283 ret.push_back(argTypeName) ;
284 if(!
gInterpreter->MethodArgInfo_DefaultValue(arg)) nreq++;
289 if (ret.size()<nMinArg) {
297 return pair<list<string>,
unsigned int>(ret,nreq);
312 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not found in factory alias table, nor in ROOT class table" << endl;
321 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" does not inherit from RooAbsArg" << endl;
328 size_t blevel = 0, end_tok, start_tok = 0;
329 bool litmode =
false;
330 for (end_tok = 0; end_tok < tmp.length(); end_tok++) {
332 if (tmp[end_tok]==
'{' || tmp[end_tok]==
'(' || tmp[end_tok]==
'[') blevel++;
333 if (tmp[end_tok]==
'}' || tmp[end_tok]==
')' || tmp[end_tok]==
']') blevel--;
336 if (tmp[end_tok]==
'"' || tmp[end_tok]==
'\'') litmode = !litmode;
341 if (litmode ==
false && blevel == 0 && tmp[end_tok] ==
',') {
342 _args.push_back(tmp.substr(start_tok, end_tok - start_tok));
343 start_tok = end_tok+1;
346 _args.push_back(tmp.substr(start_tok, end_tok));
349 pair<list<string>,
unsigned int> ca = ctorArgs(className,
_args.size()+2) ;
350 if (ca.first.size()==0) {
351 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR no suitable constructor found for class " << className << endl ;
358 if (
_args.size()+2<ca.second ||
_args.size()+2>ca.first.size()) {
359 if (ca.second==ca.first.size()) {
360 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid, " << className
361 <<
" expects " << ca.first.size()-2 << endl ;
364 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid " << className
365 <<
" expect number between " << ca.second-2 <<
" and " << ca.first.size()-2 << endl ;
372 string cintExpr(
Form(
"new %s(\"%s\",\"%s\"",className,objName,objName)) ;
380 list<string>::iterator ti = ca.first.begin() ; ++ti ; ++ti ;
381 for (vector<string>::iterator ai =
_args.begin() ; ai !=
_args.end() ; ++ai,++ti,++i) {
382 if ((*ti)==
"RooAbsReal&" || (*ti)==
"const RooAbsReal&") {
384 cintExpr +=
Form(
",RooFactoryWSTool::as_FUNC(%d)",i) ;
385 }
else if ((*ti)==
"RooAbsArg&" || (*ti)==
"const RooAbsArg&") {
387 cintExpr +=
Form(
",RooFactoryWSTool::as_ARG(%d)",i) ;
388 }
else if ((*ti)==
"RooRealVar&" || (*ti)==
"const RooRealVar&") {
390 cintExpr +=
Form(
",RooFactoryWSTool::as_VAR(%d)",i) ;
391 }
else if ((*ti)==
"RooAbsRealLValue&" || (*ti)==
"const RooAbsRealLValue&") {
393 cintExpr +=
Form(
",RooFactoryWSTool::as_VARLV(%d)",i) ;
394 }
else if ((*ti)==
"RooCategory&" || (*ti)==
"const RooCategory&") {
396 cintExpr +=
Form(
",RooFactoryWSTool::as_CAT(%d)",i) ;
397 }
else if ((*ti)==
"RooAbsCategory&" || (*ti)==
"const RooAbsCategory&") {
399 cintExpr +=
Form(
",RooFactoryWSTool::as_CATFUNC(%d)",i) ;
400 }
else if ((*ti)==
"RooAbsCategoryLValue&" || (*ti)==
"const RooAbsCategoryLValue&") {
402 cintExpr +=
Form(
",RooFactoryWSTool::as_CATLV(%d)",i) ;
403 }
else if ((*ti)==
"RooAbsPdf&" || (*ti)==
"const RooAbsPdf&") {
405 cintExpr +=
Form(
",RooFactoryWSTool::as_PDF(%d)",i) ;
406 }
else if ((*ti)==
"RooResolutionModel&" || (*ti)==
"const RooResolutionModel&") {
408 cintExpr +=
Form(
",RooFactoryWSTool::as_RMODEL(%d)",i) ;
409 }
else if ((*ti)==
"RooAbsData&" || (*ti)==
"const RooAbsData&") {
411 cintExpr +=
Form(
",RooFactoryWSTool::as_DATA(%d)",i) ;
412 }
else if ((*ti)==
"RooDataSet&" || (*ti)==
"const RooDataSet&") {
414 cintExpr +=
Form(
",RooFactoryWSTool::as_DSET(%d)",i) ;
415 }
else if ((*ti)==
"RooDataHist&" || (*ti)==
"const RooDataHist&") {
417 cintExpr +=
Form(
",RooFactoryWSTool::as_DHIST(%d)",i) ;
418 }
else if ((*ti)==
"const RooArgSet&") {
420 cintExpr +=
Form(
",RooFactoryWSTool::as_SET(%d)",i) ;
421 }
else if ((*ti)==
"const RooArgList&") {
423 cintExpr +=
Form(
",RooFactoryWSTool::as_LIST(%d)",i) ;
424 }
else if ((*ti)==
"const char*") {
426 cintExpr +=
Form(
",RooFactoryWSTool::as_STRING(%d)",i) ;
427 }
else if ((*ti)==
"Int_t" || (*ti)==
"int" || (*ti)==
"Bool_t" || (*ti)==
"bool") {
429 cintExpr +=
Form(
",RooFactoryWSTool::as_INT(%d)",i) ;
430 }
else if ((*ti)==
"Double_t") {
432 cintExpr +=
Form(
",RooFactoryWSTool::as_DOUBLE(%d)",i) ;
433 }
else if (isEnum(ti->c_str())) {
436 if (
_args[i].find(
Form(
"%s::",className)) != string::npos) {
437 qualvalue =
_args[i].c_str() ;
439 qualvalue =
Form(
"%s::%s",className,
_args[i].c_str()) ;
441 if (isValidEnumValue(ti->c_str(),qualvalue.c_str())) {
442 cintExpr +=
Form(
",(%s)%s",ti->c_str(),qualvalue.c_str()) ;
444 throw string(
Form(
"Supplied argument %s does not represent a valid state of enum %s",
_args[i].c_str(),ti->c_str())) ;
452 if (ti->find(
"const ")==0) {
453 btype = ti->c_str()+6 ;
457 if (btype.find(
"&")) {
458 btype.erase(btype.size()-1,btype.size()) ;
465 cintExpr +=
Form(
",(%s&)RooFactoryWSTool::as_OBJ(%d)",ti->c_str(),i) ;
467 throw string(
Form(
"Required argument with name %s of type '%s' is not in the workspace",
_args[i].c_str(),ti->c_str())) ;
472 }
catch (
const string &err) {
473 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR constructing " << className <<
"::" << objName <<
": " << err << endl ;
478 cxcoutD(
ObjectHandling) <<
"RooFactoryWSTool::createArg() Construct expression is " << cintExpr << endl ;
484 if (
string(className)==
"RooGenericPdf") {
486 }
else if (
string(className)==
"RooFormulaVar") {
496 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR in CINT constructor call to create object" << endl ;
517 char* tok = R__STRTOK_R(buf,
",",&save) ;
519 char* star=strchr(tok,
'*') ;
527 tok = R__STRTOK_R(0,
",",&save) ;
529 pdfList.
add(pdfList2) ;
531 }
catch (
const string &err) {
532 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
559 char* tok = R__STRTOK_R(buf,
",",&save) ;
561 char* star=strchr(tok,
'*') ;
569 tok = R__STRTOK_R(0,
",",&save) ;
571 amplList.
add(amplList2) ;
573 }
catch (
const string &err) {
574 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooRealSumPdf: " << err << endl ;
594 string regPdfList=
"{" ;
598 char* tok = R__STRTOK_R(buf,
",",&save) ;
600 char *sep = strchr(tok,
'|') ;
615 }
catch (
const string &err) {
616 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf Conditional argument: " << err << endl ;
623 if (regPdfList.size()>1) {
628 tok = R__STRTOK_R(0,
",",&save) ;
634 pdf =
new RooProdPdf(objName,objName,
asSET(regPdfList.c_str()),cmdList) ;
635 }
catch (
const string &err) {
636 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf input set of regular p.d.f.s: " << err << endl ;
658 map<string,RooAbsPdf*> theMap ;
663 char* tok = R__STRTOK_R(buf,
",",&save) ;
665 char* eq = strchr(tok,
'=') ;
667 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName
668 <<
" expect mapping token of form 'state=pdfName', but found '" << tok <<
"'" << endl ;
675 theMap[tok] = &
asPDF(eq+1) ;
676 }
catch (
const string &err ) {
677 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous: " << err << endl ;
681 tok = R__STRTOK_R(0,
",",&save) ;
689 }
catch (
const string &err) {
690 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
715 char* tok = R__STRTOK_R(buf,
",",&save) ;
717 char* star=strchr(tok,
'*') ;
725 tok = R__STRTOK_R(0,
",",&save) ;
728 }
catch (
const string &err) {
729 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
735 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
748 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==
"expr") {
2043 if (args.size()<=2) {
2044 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2049 for (
UInt_t i=1 ; i<args.size() ; i++) {
2054 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2057 }
else if (cl==
"nconv") {
2060 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2062 }
else if (cl==
"nll") {
2068 }
else if (cl==
"chi2") {
2074 }
else if (cl==
"profile") {
2077 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2079 }
else if (cl==
"dataobs") {
2089 }
else if (cl==
"int") {
2096 if (pargv.size()<2 || pargv.size()>3) {
2097 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2103 strlcpy(buf,pargv[1].c_str(),256) ;
2105 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2106 if (!intobs) intobs=
"" ;
2108 const char* range = R__STRTOK_R(0,
"",&save) ;
2109 if (!range) range=
"" ;
2112 if (pargv.size()==2) {
2113 if (range && strlen(range)) {
2119 if (range && strlen(range)) {
2129 }
else if (cl==
"deriv") {
2133 if (pargv.size()<2 || pargv.size()>3) {
2134 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2140 if (pargv.size()==2) {
2146 derivative->
SetName(instName) ;
2149 }
else if (cl==
"cdf") {
2153 if (pargv.size()<2 || pargv.size()>3) {
2154 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2160 if (pargv.size()==2) {
2170 }
else if (cl==
"PROJ") {
2173 if (pargv.size()!=2) {
2174 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2179 projection->
SetName(instName) ;
2183 }
else if (cl==
"set") {
2188 return string(instName) ;
2193 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2196 return string(instName) ;
char * Form(const char *fmt,...)
typedef void((*Func_t)())
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'.
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...
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.
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 ...
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.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
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.
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 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 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 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 NormSet(const RooArgSet &nset)
RooCmdArg Silence(Bool_t flag=kTRUE)
RooConstVar & RooConst(Double_t val)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, Bool_t depsAreCond=kFALSE)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static uint64_t sum(uint64_t i)