64#ifdef ROOFIT_LEGACY_EVAL_BACKEND
72#define BUFFER_SIZE 64000
160 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
187 const size_t tmpSize = strlen(stateNameList)+1;
188 std::vector<char> tmp(tmpSize);
189 strlcpy(tmp.data(),stateNameList,tmpSize) ;
191 char* tok = R__STRTOK_R(tmp.data(),
",",&save) ;
193 char* sep = strchr(tok,
'=') ;
196 Int_t id = atoi(sep+1) ;
202 tok = R__STRTOK_R(
nullptr,
",",&save) ;
215 bool isEnum(
const char* classname) {
217 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
224 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 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&" || (*ti)==
"RooAbsReal::Ref") {
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] ;
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 ;
484 if (std::unique_ptr<RooAbsArg> arg{
reinterpret_cast<RooAbsArg*
>(
gROOT->ProcessLineFast(cintExpr.c_str()))}) {
485 if (
string(className)==
"RooGenericPdf") {
486 arg->setStringAttribute(
"factory_tag",
Form(
"EXPR::%s(%s)",objName,varList)) ;
487 }
else if (
string(className)==
"RooFormulaVar") {
488 arg->setStringAttribute(
"factory_tag",
Form(
"expr::%s(%s)",objName,varList)) ;
490 arg->setStringAttribute(
"factory_tag",
Form(
"%s::%s(%s)",className,objName,varList)) ;
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(
nullptr,
",",&save) ;
529 pdfList.
add(pdfList2) ;
531 }
catch (
const string &err) {
532 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
537 RooAddPdf pdf{objName,objName,pdfList,coefList,recursiveCoefs};
538 pdf.setStringAttribute(
"factory_tag",
Form(
"SUM::%s(%s)",objName,specList)) ;
559 char* tok = R__STRTOK_R(buf,
",",&save) ;
561 char* star=strchr(tok,
'*') ;
569 tok = R__STRTOK_R(
nullptr,
",",&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,
'|') ;
607 bool invCond(
false) ;
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(
nullptr,
",",&save) ;
632 std::unique_ptr<RooProdPdf> pdf;
634 pdf = std::make_unique<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 pdfs: " << err << endl ;
642 pdf->setStringAttribute(
"factory_tag",
Form(
"PROD::%s(%s)",objName,pdfList)) ;
656 map<string,RooAbsPdf*> theMap ;
661 char* tok = R__STRTOK_R(buf,
",",&save) ;
663 char* eq = strchr(tok,
'=') ;
665 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName
666 <<
" expect mapping token of form 'state=pdfName', but found '" << tok <<
"'" << endl ;
673 theMap[tok] = &
asPDF(eq+1) ;
674 }
catch (
const string &err ) {
675 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous: " << err << endl ;
679 tok = R__STRTOK_R(
nullptr,
",",&save) ;
684 std::unique_ptr<RooSimultaneous> pdf;
686 pdf = std::make_unique<RooSimultaneous>(objName,objName,theMap,
asCATLV(indexCat)) ;
687 }
catch (
const string &err) {
688 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
694 pdf->setStringAttribute(
"factory_tag",
Form(
"SIMUL::%s(%s,%s)",objName,indexCat,pdfMap)) ;
714 char* tok = R__STRTOK_R(buf,
",",&save) ;
716 char* star=strchr(tok,
'*') ;
724 tok = R__STRTOK_R(
nullptr,
",",&save) ;
727 }
catch (
const string &err) {
728 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
734 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
740 auto sum = sumlist2.
empty() ? std::make_unique<RooAddition>(objName,objName,sumlist1)
741 : std::make_unique<RooAddition>(objName,objName,sumlist1,sumlist2);
743 sum->setStringAttribute(
"factory_tag",
Form(
"sum::%s(%s)",objName,specList)) ;
860 std::vector<char> buf(strlen(expr)+1);
863 char* buftmp = buf.data();
865 if (!isspace(*expr)) {
882 }
catch (
const string &error) {
883 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERROR in parsing: " << error << endl ;
889 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed" << endl ;
895 return !out.empty() ?
ws().
arg(out) : nullptr ;
914 if (
string(token).find(
"$Alias(")==0) {
940 const size_t bufBaseSize = strlen(token)+1;
941 std::vector<char> buf_base(bufBaseSize);
942 char* buf = buf_base.data();
943 strlcpy(buf,token,bufBaseSize) ;
946 list<string> singleExpr ;
947 list<char> separator ;
949 bool litmode(
false) ;
953 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
954 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
957 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
961 if (!litmode && blevel==0 && ( (*
p)==
'=' || (*
p) ==
'|' || (*
p) ==
'*')) {
962 separator.push_back(*
p) ;
964 singleExpr.push_back(buf) ;
970 singleExpr.push_back(buf) ;
972 if (singleExpr.size()==1) {
978 list<char>::iterator ic = separator.begin() ;
979 for (list<string>::iterator ii = singleExpr.begin() ; ii!=singleExpr.end() ; ++ii) {
981 if (ic != separator.end()) {
1003 if (strlen(arg)==0) {
1008 if (arg[0]==
'\'' || arg[0]==
'"') {
1009 return string(arg) ;
1013 const size_t bufSize = strlen(arg)+1;
1014 std::vector<char> buf(bufSize);
1015 strlcpy(buf.data(),arg,bufSize) ;
1016 char* bufptr = buf.data();
1018 string func,prefix ;
1019 vector<string> args ;
1023 char* tmpx = R__STRTOK_R(buf.data(),
"([",&save) ;
1024 func = tmpx ? tmpx :
"" ;
1025 char*
p = R__STRTOK_R(
nullptr,
"",&save) ;
1035 bool litmode(
false) ;
1039 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1040 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1043 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1049 if (!litmode && blevel==0 && ((*
p)==
',')) {
1051 args.push_back(tok) ;
1060 if (
p>bufptr && (*(
p-1)==
')'||*(
p-1)==
']')) {
1069 p = R__STRTOK_R(
nullptr,
"",&save) ;
1071 args.push_back(tmp) ;
1079 for(
const char* pp=arg ; *pp!=0 ; pp++) {
1080 if (*pp==
'(' || *pp==
'[' || *pp==
'{') {
1086 if (strstr(func.c_str(),
"::")) {
1091 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: Class::Instance must be followed by (...)" << endl ;
1094 }
else if (func[0]!=
'$'){
1098 }
else if (lb==
'(') {
1108 static Int_t globCounter = 0 ;
1110 autoname =
Form(
"gobj%d",globCounter) ;
1112 if (!
ws().arg(autoname)) {
1116 autoname =
Form(
"%s::%s",func.c_str(),autoname.c_str()) ;
1120 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: expect either Class(...) or Instance[...]" << endl ;
1128 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: $MetaClass must be followed by (...)" << endl ;
1148 const size_t bufSize = strlen(arg)+1;
1149 std::vector<char> buf(bufSize);
1150 strlcpy(buf.data(),arg,bufSize) ;
1152 std::vector<string> args ;
1155 char* tok = buf.data()+1 ;
1156 char*
p = buf.data()+1 ;
1163 if (*
p==
'{' || *
p==
'(' || *
p==
'[') level++ ;
1164 if (*
p==
'}' || *
p==
')' || *
p==
']') level-- ;
1170 if (level==0 && ((*
p)==
',')) {
1172 args.push_back(tok) ;
1180 if (
p>buf.data() && *(
p-1)==
'}') {
1183 args.push_back(tok) ;
1188 vector<string>::iterator iter = args.begin() ;
1190 while(iter!= args.end()) {
1191 if (strlen(ret.c_str())>1) ret +=
"," ;
1215 if (args.size()!=2) {
1216 coutE(
ObjectHandling) <<
"RooFactorWSTool::processAliasExpression() ERROR $Alias() takes exactly two arguments, " << args.size() <<
" args found" << endl ;
1236 map<string,string>::iterator item =
_typeAliases.find(className) ;
1240 className = item->second.c_str() ;
1253 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not defined in ROOT class table" << endl ;
1270 for (vector<string>::iterator iter = args.begin() ; iter!=args.end() ; ++iter) {
1271 if (iter!=args.begin()) {
1298 string first = *(args.begin()) ;
1302 vector<string>::iterator ai = args.begin() ;
1303 if (args.size()==1) {
1306 double xinit = atof((ai)->c_str()) ;
1308 RooRealVar tmp(func.c_str(),func.c_str(),xinit) ;
1314 }
else if (args.size()==2) {
1317 double xlo = atof((ai++)->c_str()) ;
1318 double xhi = atof(ai->c_str()) ;
1319 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1320 RooRealVar tmp(func.c_str(),func.c_str(),xlo,xhi) ;
1326 }
else if (args.size()==3) {
1329 double xinit = atof((ai++)->c_str()) ;
1330 double xlo = atof((ai++)->c_str()) ;
1331 double xhi = atof(ai->c_str()) ;
1332 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xinit = " << xinit <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1333 RooRealVar tmp(func.c_str(),func.c_str(),xinit,xlo,xhi) ;
1343 for (vector<string>::iterator ai = args.begin() ; ai!=args.end() ; ++ai) {
1344 if (!allStates.empty()) {
1372 const char *className = R__STRTOK_R(buf,
":",&save) ;
1373 const char *instName = R__STRTOK_R(
nullptr,
":",&save) ;
1374 if (!className) className =
"";
1375 if (!instName) instName =
"" ;
1380 vector<string>::iterator iter = args.begin() ;
1381 vector<string> pargv ;
1383 while(iter!=args.end()) {
1384 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1389 pargv.push_back(tmp) ;
1395 for (map<string,IFace*>::iterator ii=
hooks().begin() ; ii!=
hooks().end() ; ++ii) {
1397 if (
hooks().find(className) !=
hooks().end()) {
1399 return iface->
create(*
this, className,instName,pargv) ;
1404 return string(instName) ;
1416 vector<string>::iterator iter = args.begin() ;
1417 vector<string> pargv ;
1418 while(iter!=args.end()) {
1419 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1422 pargv.push_back(tmp) ;
1426 string ret = func+
"("+pargs+
")" ;
1438 const size_t bufSize = strlen(funcExpr)+1;
1439 std::vector<char> buf(bufSize);
1440 strlcpy(buf.data(),funcExpr,bufSize) ;
1441 char* bufptr = buf.data();
1444 vector<string> args ;
1448 char* tmpx = R__STRTOK_R(buf.data(),
"(",&save) ;
1449 func = tmpx ? tmpx :
"" ;
1450 char*
p = R__STRTOK_R(
nullptr,
"",&save) ;
1459 bool litmode(
false) ;
1463 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1464 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1467 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1473 if (!litmode && blevel==0 && ((*
p)==
',')) {
1475 args.push_back(tok) ;
1484 if (
p>bufptr && *(
p-1)==
')') {
1493 p = R__STRTOK_R(
nullptr,
"",&save) ;
1495 args.push_back(tmp) ;
1511 Int_t nParentheses(0), nBracket(0), nAccolade(0) ;
1512 const char* ptr = arg ;
1514 if (*ptr==
'(') nParentheses++ ;
1515 if (*ptr==
')') nParentheses-- ;
1516 if (*ptr==
'[') nBracket++ ;
1517 if (*ptr==
']') nBracket-- ;
1518 if (*ptr==
'{') nAccolade++ ;
1519 if (*ptr==
'}') nAccolade-- ;
1522 if (nParentheses!=0) {
1523 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nParentheses>0?
"(":
")") <<
"' in expression" << endl ;
1527 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nBracket>0?
"[":
"]") <<
"' in expression" << endl ;
1531 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nAccolade>0?
"{":
"}") <<
"' in expression" << endl ;
1544 throw string(
Form(
"Need argument number %d, but only %d args are provided",idx,(
Int_t)
_of->
_args.size())) ;
1556 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1563 throw string(
Form(
"RooAbsArg named %s not found",arg)) ;
1576 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1582 throw string(
Form(
"RooAbsReal named %s not found",arg)) ;
1586 throw string(
Form(
"Object named %s is not of type RooAbsReal",arg)) ;
1599 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1600 throw string(
Form(
"Numeric literal provided for argument (%s), but lvalue is required",arg)) ;
1605 throw string(
Form(
"RooAbsRealLValue named %s not found",arg)) ;
1609 throw string(
Form(
"Object named %s is not of type RooAbsRealLValue",arg)) ;
1623 throw string(
Form(
"RooRealVar named %s not found",arg)) ;
1638 throw string(
Form(
"RooAbsPdf named %s not found",arg)) ;
1653 throw string(
Form(
"RooResolutionModel named %s not found",arg)) ;
1657 throw string(
Form(
"Object named %s is not of type RooResolutionModel",arg)) ;
1672 throw string(
Form(
"RooAbsCategory named %s not found",arg)) ;
1676 throw string(
Form(
"Object named %s is not of type RooAbsCategory",arg)) ;
1690 throw string(
Form(
"RooAbsCategoryLValue named %s not found",arg)) ;
1695 throw string(
Form(
"Object named %s is not of type RooAbsCategoryLValue",arg)) ;
1709 throw string(
Form(
"RooCategory named %s not found",arg)) ;
1740 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1745 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1747 }
else if (tok[0] ==
'\'') {
1748 tok[strlen(tok) - 1] = 0;
1756 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1759 tok = R__STRTOK_R(
nullptr,
",{}",&save) ;
1777 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1781 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1783 }
else if (tok[0] ==
'\'') {
1784 tok[strlen(tok) - 1] = 0;
1792 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1795 tok = R__STRTOK_R(
nullptr,
",{}",&save) ;
1810 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1824 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1828 throw string(
Form(
"Dataset named %s is not of type RooDataHist",arg)) ;
1841 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1845 throw string(
Form(
"Dataset named %s is not of type RooDataSet",arg)) ;
1858 throw string(
Form(
"Object named %s not found",arg)) ;
1870 static vector<string> cbuf(10) ;
1871 static unsigned int cbuf_idx = 0 ;
1874 if (arg==
nullptr || strlen(arg)==0) {
1880 cbuf[cbuf_idx].clear() ;
1881 const char*
p = arg+1 ;
1882 while(*
p && (*
p) !=
'"' && (*
p) !=
'\'' ) {
1883 cbuf[cbuf_idx] += *(
p++) ;
1885 const char* ret = cbuf[cbuf_idx].c_str() ;
1889 if (cbuf_idx==cbuf.size()) cbuf_idx=0 ;
1918 hooks()[typeName] = iface ;
1928 _hooks =
new map<string,IFace*> ;
1941 vector<string>::iterator iter = args.begin() ;
1942 vector<string> pargv ;
1943 while(iter!=args.end()) {
1944 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1947 pargv.push_back(tmp) ;
1952 string cl(typeName) ;
1956 ft.
add(instName,pargs,
false) ;
1958 }
else if (cl==
"RSUM") {
1961 ft.
add(instName,pargs,
true) ;
1963 }
else if (cl==
"ASUM") {
1968 }
else if (cl==
"PROD") {
1971 ft.
prod(instName,pargs) ;
1973 }
else if (cl==
"SIMUL") {
1976 if (pargv.size()>1) {
1977 ft.
simul(instName,pargv[0].c_str(),strchr(pargs,
',')+1) ;
1979 throw string(
Form(
"Need at least two arguments in call to SIMUL::%s, have %d: %s",instName,(
Int_t)pargv.size(),pargs)) ;
1982 }
else if (cl==
"EXPR") {
1985 if (args.size()<=2) {
1986 ft.
createArg(
"RooGenericPdf",instName,pargs) ;
1991 for (
UInt_t i=1 ; i<args.size() ; i++) {
1996 ft.
createArg(
"RooGenericPdf",instName,genargs) ;
1999 }
else if (cl==
"FCONV") {
2002 ft.
createArg(
"RooFFTConvPdf",instName,pargs) ;
2004 }
else if (cl==
"NCONV") {
2007 ft.
createArg(
"RooNumConvPdf",instName,pargs) ;
2009 }
else if (cl==
"sum") {
2014 }
else if (cl==
"prod") {
2019 }
else if (cl==
"expr") {
2022 if (args.size()<=2) {
2023 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2028 for (
UInt_t i=1 ; i<args.size() ; i++) {
2033 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2036 }
else if (cl ==
"taylorexpand") {
2040 double eps1(1
e-6), eps2(1
e-3), observablesValue(0.0);
2042 if (pargv.size() < 2)
2043 throw string(
Form(
"taylorexpand::%s, requires atleast 2 arguments (function, observables) atleast, has %d arguments", instName, (
Int_t)pargv.size()));
2048 if (pargv.size() > 3)
2049 order = atoi(pargv[3].c_str());
2050 if (pargv.size() > 2) {
2051 if (pargv[2].find(
',') != string::npos)
2052 throw string(
Form(
"taylorexpand::%s, factory syntax supports expansion only around same value for all observables", instName));
2053 else observablesValue = atof(pargv[2].c_str());
2056 if (pargv.size() > 3)
2057 order = atoi(pargv[3].c_str());
2058 if (pargv.size() > 4)
2059 eps1 = atof(pargv[4].c_str());
2060 if (pargv.size() > 5)
2061 eps2 = atof(pargv[5].c_str());
2063 if (pargv.size() > 6)
2065 Form(
"taylorexpand::%s, requires max. 6 arguments, has %d arguments", instName, (
Int_t)pargv.size()));
2070 }
else if (cl==
"nconv") {
2073 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2075#ifdef ROOFIT_LEGACY_EVAL_BACKEND
2076 }
else if (cl==
"nll") {
2082 }
else if (cl==
"chi2") {
2089 }
else if (cl==
"profile") {
2092 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2094 }
else if (cl==
"dataobs") {
2097 std::unique_ptr<RooAbsArg> funcClone{
static_cast<RooAbsArg*
>(ft.
asARG(pargv[1].c_str()).
clone(instName))};
2103 }
else if (cl==
"int") {
2110 if (pargv.size()<2 || pargv.size()>3) {
2111 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2117 strlcpy(buf,pargv[1].c_str(),256) ;
2119 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2120 if (!intobs) intobs=
"" ;
2122 const char* range = R__STRTOK_R(
nullptr,
"",&save) ;
2123 if (!range) range=
"" ;
2125 std::unique_ptr<RooAbsReal> integral;
2126 if (pargv.size()==2) {
2127 if (range && strlen(range)) {
2133 if (range && strlen(range)) {
2140 integral->SetName(instName) ;
2143 }
else if (cl==
"deriv") {
2147 if (pargv.size()<2 || pargv.size()>3) {
2148 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2153 std::unique_ptr<RooAbsReal> derivative;
2154 if (pargv.size()==2) {
2160 derivative->
SetName(instName) ;
2163 }
else if (cl==
"cdf") {
2167 if (pargv.size()<2 || pargv.size()>3) {
2168 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2173 std::unique_ptr<RooAbsReal> cdf;
2174 if (pargv.size()==2) {
2175 cdf = std::unique_ptr<RooAbsReal>{pdf.
createCdf(ft.
asSET(pargv[1].c_str()))};
2177 cdf = std::unique_ptr<RooAbsReal>{pdf.
createCdf(ft.
asSET(pargv[1].c_str()),ft.
asSET(pargv[2].c_str()))};
2180 cdf->SetName(instName) ;
2184 }
else if (cl==
"PROJ") {
2187 if (pargv.size()!=2) {
2188 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2193 projection->
SetName(instName) ;
2197 }
else if (cl==
"set") {
2202 return string(instName) ;
2207 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2210 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.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
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=nullptr) const =0
void SetName(const char *name) override
Set the name of the TNamed.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
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.
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
RooFit::OwningPtr< 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...
Abstract base class for objects that represent a real value and implements functionality common to al...
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) 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.
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.
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=nullptr) 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< RooPolyFunc > taylorExpand(const char *name, const char *title, RooAbsReal &func, const RooArgList &observables, int order=1, std::vector< double > const &observableValues={}, double eps1=1e-6, double eps2=1e-3)
Taylor expanding given function in terms of observables around observableValues.
Efficient implementation of a product of PDFs of the form.
A RooProduct represents the product of a given set of RooAbsReal objects.
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...
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooStringVar is a RooAbsArg implementing string values.
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.
const RooArgSet * set(RooStringView name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
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.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
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.
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)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static uint64_t sum(uint64_t i)