60#ifdef ROOFIT_LEGACY_EVAL_BACKEND
66using std::string, std::map, std::list, std::pair, std::endl, std::vector;
68#define BUFFER_SIZE 64000
130 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
157 const size_t tmpSize = strlen(stateNameList)+1;
158 std::vector<char> tmp(tmpSize);
159 strlcpy(tmp.data(),stateNameList,tmpSize) ;
161 char* tok = R__STRTOK_R(tmp.data(),
",",&save) ;
163 char* sep = strchr(tok,
'=') ;
166 Int_t id = atoi(sep+1) ;
172 tok = R__STRTOK_R(
nullptr,
",",&save) ;
185 bool isEnum(
const char* classname) {
187 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
194 bool isValidEnumValue(
const char* enumName,
const char* enumConstantName) {
197 if (!enumName)
return false;
200 if (!enumName)
return false;
203 if (theEnum->GetConstant(enumConstantName))
return true;
205 auto tmp = strstr(enumConstantName,
"::");
207 auto enumConstantNameNoScope =
tmp+2;
208 if (theEnum->GetConstant(enumConstantNameNoScope))
return true;
214 pair<list<string>,
unsigned int> ctorArgs(
const char* classname, std::size_t nPassedArgs) {
222 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
223 MethodInfo_t* func =
gInterpreter->MethodInfo_Factory(cls);
236 if (
string(classname) !=
gInterpreter->MethodInfo_TypeName(func)) {
242 int nDefaultArgs =
gInterpreter->MethodInfo_NDefaultArg(func);
243 if (nargs == nDefaultArgs) {
247 MethodArgInfo_t* arg =
gInterpreter->MethodArgInfo_Factory(func);
250 const char* argTypeName =
gInterpreter->MethodArgInfo_TypeName(arg);
251 if (nreq<2 && ((
string(
"char*") != argTypeName
253 &&
string(
"const char*") != argTypeName)) {
256 ret.push_back(argTypeName) ;
257 if(!
gInterpreter->MethodArgInfo_DefaultValue(arg)) nreq++;
264 if(
static_cast<int>(nPassedArgs) >= nargs - nDefaultArgs &&
static_cast<int>(nPassedArgs) <= nargs) {
270 return pair<list<string>,
unsigned int>(ret,nreq);
285 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not found in factory alias table, nor in ROOT class table" << endl;
294 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" does not inherit from RooAbsArg" << endl;
303 size_t start_tok = 0;
304 bool litmode =
false;
305 for (end_tok = 0; end_tok < tmp.length(); end_tok++) {
307 if (tmp[end_tok]==
'{' || tmp[end_tok]==
'(' || tmp[end_tok]==
'[') blevel++;
308 if (tmp[end_tok]==
'}' || tmp[end_tok]==
')' || tmp[end_tok]==
']') blevel--;
311 if (tmp[end_tok]==
'"' || tmp[end_tok]==
'\'') litmode = !litmode;
316 if (litmode ==
false && blevel == 0 && tmp[end_tok] ==
',') {
317 _args.push_back(tmp.substr(start_tok, end_tok - start_tok));
318 start_tok = end_tok+1;
321 _args.push_back(tmp.substr(start_tok, end_tok));
324 pair<list<string>,
unsigned int> ca = ctorArgs(className,
_args.size()+2) ;
325 if (ca.first.empty()) {
326 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR no suitable constructor found for class " << className << endl ;
333 if (
_args.size()+2<ca.second ||
_args.size()+2>ca.first.size()) {
334 if (ca.second==ca.first.size()) {
335 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid, " << className
336 <<
" expects " << ca.first.size()-2 << endl ;
339 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid " << className
340 <<
" expect number between " << ca.second-2 <<
" and " << ca.first.size()-2 << endl ;
347 string cintExpr(
Form(
"new %s(\"%s\",\"%s\"",className,objName,objName)) ;
355 list<string>::iterator ti = ca.first.begin() ; ++ti ; ++ti ;
356 for (vector<string>::iterator ai =
_args.begin() ; ai !=
_args.end() ; ++ai,++ti,++i) {
357 if ((*ti)==
"RooAbsReal&" || (*ti)==
"const RooAbsReal&" || (*ti)==
"RooAbsReal::Ref") {
359 cintExpr +=
Form(
",RooFactoryWSTool::as_FUNC(%d)",i) ;
360 }
else if ((*ti)==
"RooAbsArg&" || (*ti)==
"const RooAbsArg&") {
362 cintExpr +=
Form(
",RooFactoryWSTool::as_ARG(%d)",i) ;
363 }
else if ((*ti)==
"RooRealVar&" || (*ti)==
"const RooRealVar&") {
365 cintExpr +=
Form(
",RooFactoryWSTool::as_VAR(%d)",i) ;
366 }
else if ((*ti)==
"RooAbsRealLValue&" || (*ti)==
"const RooAbsRealLValue&") {
368 cintExpr +=
Form(
",RooFactoryWSTool::as_VARLV(%d)",i) ;
369 }
else if ((*ti)==
"RooCategory&" || (*ti)==
"const RooCategory&") {
371 cintExpr +=
Form(
",RooFactoryWSTool::as_CAT(%d)",i) ;
372 }
else if ((*ti)==
"RooAbsCategory&" || (*ti)==
"const RooAbsCategory&") {
374 cintExpr +=
Form(
",RooFactoryWSTool::as_CATFUNC(%d)",i) ;
375 }
else if ((*ti)==
"RooAbsCategoryLValue&" || (*ti)==
"const RooAbsCategoryLValue&") {
377 cintExpr +=
Form(
",RooFactoryWSTool::as_CATLV(%d)",i) ;
378 }
else if ((*ti)==
"RooAbsPdf&" || (*ti)==
"const RooAbsPdf&") {
380 cintExpr +=
Form(
",RooFactoryWSTool::as_PDF(%d)",i) ;
381 }
else if ((*ti)==
"RooResolutionModel&" || (*ti)==
"const RooResolutionModel&") {
383 cintExpr +=
Form(
",RooFactoryWSTool::as_RMODEL(%d)",i) ;
384 }
else if ((*ti)==
"RooAbsData&" || (*ti)==
"const RooAbsData&") {
386 cintExpr +=
Form(
",RooFactoryWSTool::as_DATA(%d)",i) ;
387 }
else if ((*ti)==
"RooDataSet&" || (*ti)==
"const RooDataSet&") {
389 cintExpr +=
Form(
",RooFactoryWSTool::as_DSET(%d)",i) ;
390 }
else if ((*ti)==
"RooDataHist&" || (*ti)==
"const RooDataHist&") {
392 cintExpr +=
Form(
",RooFactoryWSTool::as_DHIST(%d)",i) ;
393 }
else if ((*ti)==
"const RooArgSet&") {
395 cintExpr +=
Form(
",RooFactoryWSTool::as_SET(%d)",i) ;
396 }
else if ((*ti)==
"const RooArgList&") {
398 cintExpr +=
Form(
",RooFactoryWSTool::as_LIST(%d)",i) ;
399 }
else if ((*ti)==
"const char*") {
401 cintExpr +=
Form(
",RooFactoryWSTool::as_STRING(%d)",i) ;
402 }
else if ((*ti)==
"Int_t" || (*ti)==
"int" || (*ti)==
"bool" || (*ti)==
"bool") {
404 cintExpr +=
Form(
",RooFactoryWSTool::as_INT(%d)",i) ;
405 }
else if ((*ti)==
"double") {
407 cintExpr +=
Form(
",RooFactoryWSTool::as_DOUBLE(%d)",i) ;
408 }
else if (isEnum(ti->c_str())) {
411 if (
_args[i].find(
Form(
"%s::",className)) != string::npos) {
412 qualvalue =
_args[i] ;
414 qualvalue =
Form(
"%s::%s",className,
_args[i].c_str()) ;
416 if (isValidEnumValue(ti->c_str(),qualvalue.c_str())) {
417 cintExpr +=
Form(
",(%s)%s",ti->c_str(),qualvalue.c_str()) ;
419 throw string(
Form(
"Supplied argument %s does not represent a valid state of enum %s",
_args[i].c_str(),ti->c_str())) ;
427 if (ti->find(
"const ")==0) {
428 btype = ti->c_str()+6 ;
432 if (btype.find(
'&')) {
433 btype.erase(btype.size()-1,btype.size()) ;
440 cintExpr +=
Form(
",(%s&)RooFactoryWSTool::as_OBJ(%d)",ti->c_str(),i) ;
442 throw string(
Form(
"Required argument with name %s of type '%s' is not in the workspace",
_args[i].c_str(),ti->c_str())) ;
447 }
catch (
const string &err) {
448 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR constructing " << className <<
"::" << objName <<
": " << err << endl ;
453 cxcoutD(
ObjectHandling) <<
"RooFactoryWSTool::createArg() Construct expression is " << cintExpr << endl ;
456 if (std::unique_ptr<RooAbsArg> arg{
reinterpret_cast<RooAbsArg*
>(
gROOT->ProcessLineFast(cintExpr.c_str()))}) {
457 if (
string(className)==
"RooGenericPdf") {
458 arg->setStringAttribute(
"factory_tag",
Form(
"EXPR::%s(%s)",objName,varList)) ;
459 }
else if (
string(className)==
"RooFormulaVar") {
460 arg->setStringAttribute(
"factory_tag",
Form(
"expr::%s(%s)",objName,varList)) ;
462 arg->setStringAttribute(
"factory_tag",
Form(
"%s::%s(%s)",className,objName,varList)) ;
468 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR in CINT constructor call to create object" << endl ;
489 char* tok = R__STRTOK_R(buf,
",",&save) ;
491 char* star=strchr(tok,
'*') ;
499 tok = R__STRTOK_R(
nullptr,
",",&save) ;
501 pdfList.
add(pdfList2) ;
503 }
catch (
const string &err) {
504 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
509 RooAddPdf pdf{objName,objName,pdfList,coefList,recursiveCoefs};
510 pdf.setStringAttribute(
"factory_tag",
Form(
"SUM::%s(%s)",objName,specList)) ;
531 char* tok = R__STRTOK_R(buf,
",",&save) ;
533 char* star=strchr(tok,
'*') ;
541 tok = R__STRTOK_R(
nullptr,
",",&save) ;
543 amplList.
add(amplList2) ;
545 }
catch (
const string &err) {
546 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooRealSumPdf: " << err << endl ;
566 string regPdfList=
"{" ;
570 char* tok = R__STRTOK_R(buf,
",",&save) ;
572 char *sep = strchr(tok,
'|') ;
579 bool invCond(
false) ;
587 }
catch (
const string &err) {
588 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf Conditional argument: " << err << endl ;
595 if (regPdfList.size()>1) {
600 tok = R__STRTOK_R(
nullptr,
",",&save) ;
604 std::unique_ptr<RooProdPdf> pdf;
606 pdf = std::make_unique<RooProdPdf>(objName,objName,
asSET(regPdfList.c_str()),cmdList);
607 }
catch (
const string &err) {
608 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf input set of regular pdfs: " << err << endl ;
614 pdf->setStringAttribute(
"factory_tag",
Form(
"PROD::%s(%s)",objName,pdfList)) ;
628 map<string,RooAbsPdf*> theMap ;
633 char* tok = R__STRTOK_R(buf,
",",&save) ;
635 char* eq = strchr(tok,
'=') ;
637 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName
638 <<
" expect mapping token of form 'state=pdfName', but found '" << tok <<
"'" << endl ;
645 theMap[tok] = &
asPDF(eq+1) ;
646 }
catch (
const string &err ) {
647 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous: " << err << endl ;
651 tok = R__STRTOK_R(
nullptr,
",",&save) ;
656 std::unique_ptr<RooSimultaneous> pdf;
658 pdf = std::make_unique<RooSimultaneous>(objName,objName,theMap,
asCATLV(indexCat)) ;
659 }
catch (
const string &err) {
660 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
666 pdf->setStringAttribute(
"factory_tag",
Form(
"SIMUL::%s(%s,%s)",objName,indexCat,pdfMap)) ;
686 char* tok = R__STRTOK_R(buf,
",",&save) ;
688 char* star=strchr(tok,
'*') ;
696 tok = R__STRTOK_R(
nullptr,
",",&save) ;
699 }
catch (
const string &err) {
700 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
705 if (!sumlist2.
empty() && (sumlist1.
size()!=sumlist2.
size())) {
706 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
712 auto sum = sumlist2.
empty() ? std::make_unique<RooAddition>(objName,objName,sumlist1)
713 : std::make_unique<RooAddition>(objName,objName,sumlist1,sumlist2);
715 sum->setStringAttribute(
"factory_tag",
Form(
"sum::%s(%s)",objName,specList)) ;
832 std::vector<char> buf(strlen(expr)+1);
835 char* buftmp = buf.data();
837 if (!isspace(*expr)) {
854 }
catch (
const string &error) {
855 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERROR in parsing: " << error << endl ;
861 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed" << endl ;
867 return !out.empty() ?
ws().
arg(out) : nullptr ;
886 if (
string(token).find(
"$Alias(")==0) {
912 const size_t bufBaseSize = strlen(token)+1;
913 std::vector<char> buf_base(bufBaseSize);
914 char* buf = buf_base.data();
915 strlcpy(buf,token,bufBaseSize) ;
918 list<string> singleExpr ;
919 list<char> separator ;
921 bool litmode(
false) ;
925 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
926 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
929 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
933 if (!litmode && blevel==0 && ( (*
p)==
'=' || (*
p) ==
'|' || (*
p) ==
'*')) {
934 separator.push_back(*
p) ;
936 singleExpr.push_back(buf) ;
942 singleExpr.push_back(buf) ;
944 if (singleExpr.size()==1) {
950 list<char>::iterator ic = separator.begin() ;
951 for (list<string>::iterator ii = singleExpr.begin() ; ii!=singleExpr.end() ; ++ii) {
953 if (ic != separator.end()) {
975 if (strlen(arg)==0) {
980 if (arg[0]==
'\'' || arg[0]==
'"') {
985 const size_t bufSize = strlen(arg)+1;
986 std::vector<char> buf(bufSize);
987 strlcpy(buf.data(),arg,bufSize) ;
988 char* bufptr = buf.data();
992 vector<string> args ;
996 char* tmpx = R__STRTOK_R(buf.data(),
"([",&save) ;
997 func = tmpx ? tmpx :
"" ;
998 char*
p = R__STRTOK_R(
nullptr,
"",&save) ;
1008 bool litmode(
false) ;
1012 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1013 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1016 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1022 if (!litmode && blevel==0 && ((*
p)==
',')) {
1024 args.push_back(tok) ;
1033 if (
p>bufptr && (*(
p-1)==
')'||*(
p-1)==
']')) {
1042 p = R__STRTOK_R(
nullptr,
"",&save) ;
1044 args.push_back(tmp) ;
1052 for(
const char* pp=arg ; *pp!=0 ; pp++) {
1053 if (*pp==
'(' || *pp==
'[' || *pp==
'{') {
1059 if (strstr(func.c_str(),
"::")) {
1064 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: Class::Instance must be followed by (...)" << endl ;
1067 }
else if (func[0]!=
'$'){
1071 }
else if (lb==
'(') {
1081 static Int_t globCounter = 0 ;
1083 autoname =
Form(
"gobj%d",globCounter) ;
1085 if (!
ws().arg(autoname)) {
1089 autoname =
Form(
"%s::%s",func.c_str(),autoname.c_str()) ;
1093 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: expect either Class(...) or Instance[...]" << endl ;
1101 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: $MetaClass must be followed by (...)" << endl ;
1121 const size_t bufSize = strlen(arg)+1;
1122 std::vector<char> buf(bufSize);
1123 strlcpy(buf.data(),arg,bufSize) ;
1125 std::vector<string> args ;
1128 char* tok = buf.data()+1 ;
1129 char*
p = buf.data()+1 ;
1136 if (*
p==
'{' || *
p==
'(' || *
p==
'[') level++ ;
1137 if (*
p==
'}' || *
p==
')' || *
p==
']') level-- ;
1143 if (level==0 && ((*
p)==
',')) {
1145 args.push_back(tok) ;
1153 if (
p>buf.data() && *(
p-1)==
'}') {
1156 args.push_back(tok) ;
1161 vector<string>::iterator iter = args.begin() ;
1163 while(iter!= args.end()) {
1164 if (strlen(ret.c_str())>1) ret +=
"," ;
1188 if (args.size()!=2) {
1189 coutE(
ObjectHandling) <<
"RooFactorWSTool::processAliasExpression() ERROR $Alias() takes exactly two arguments, " << args.size() <<
" args found" << endl ;
1209 map<string,string>::iterator item =
_typeAliases.find(className) ;
1213 className = item->second.c_str() ;
1226 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not defined in ROOT class table" << endl ;
1243 for (vector<string>::iterator iter = args.begin() ; iter!=args.end() ; ++iter) {
1244 if (iter!=args.begin()) {
1271 string first = *(args.begin()) ;
1272 if (isdigit(first[0]) || first[0]==
'.' || first[0]==
'+' || first[0]==
'-') {
1275 vector<string>::iterator ai = args.begin() ;
1276 if (args.size()==1) {
1279 double xinit = atof((ai)->c_str()) ;
1281 RooRealVar tmp(func.c_str(),func.c_str(),xinit) ;
1282 tmp.setStringAttribute(
"factory_tag",
varTag(func,args).c_str()) ;
1287 }
else if (args.size()==2) {
1290 double xlo = atof((ai++)->c_str()) ;
1291 double xhi = atof(ai->c_str()) ;
1292 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1293 RooRealVar tmp(func.c_str(),func.c_str(),xlo,xhi) ;
1294 tmp.setStringAttribute(
"factory_tag",
varTag(func,args).c_str()) ;
1299 }
else if (args.size()==3) {
1302 double xinit = atof((ai++)->c_str()) ;
1303 double xlo = atof((ai++)->c_str()) ;
1304 double xhi = atof(ai->c_str()) ;
1305 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xinit = " << xinit <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1306 RooRealVar tmp(func.c_str(),func.c_str(),xinit,xlo,xhi) ;
1307 tmp.setStringAttribute(
"factory_tag",
varTag(func,args).c_str()) ;
1316 for (vector<string>::iterator ai = args.begin() ; ai!=args.end() ; ++ai) {
1317 if (!allStates.empty()) {
1345 const char *className = R__STRTOK_R(buf,
":",&save) ;
1346 const char *instName = R__STRTOK_R(
nullptr,
":",&save) ;
1347 if (!className) className =
"";
1348 if (!instName) instName =
"" ;
1353 vector<string>::iterator iter = args.begin() ;
1354 vector<string> pargv ;
1356 while(iter!=args.end()) {
1357 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1362 pargv.push_back(tmp) ;
1368 for (map<string,IFace*>::iterator ii=
hooks().begin() ; ii!=
hooks().end() ; ++ii) {
1370 if (
hooks().find(className) !=
hooks().end()) {
1372 return iface->
create(*
this, className,instName,pargv) ;
1377 return string(instName) ;
1389 vector<string>::iterator iter = args.begin() ;
1390 vector<string> pargv ;
1391 while(iter!=args.end()) {
1392 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1395 pargv.push_back(tmp) ;
1399 string ret = func+
"("+pargs+
")" ;
1411 const size_t bufSize = strlen(funcExpr)+1;
1412 std::vector<char> buf(bufSize);
1413 strlcpy(buf.data(),funcExpr,bufSize) ;
1414 char* bufptr = buf.data();
1417 vector<string> args ;
1421 char* tmpx = R__STRTOK_R(buf.data(),
"(",&save) ;
1422 func = tmpx ? tmpx :
"" ;
1423 char*
p = R__STRTOK_R(
nullptr,
"",&save) ;
1432 bool litmode(
false) ;
1436 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1437 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1440 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1446 if (!litmode && blevel==0 && ((*
p)==
',')) {
1448 args.push_back(tok) ;
1457 if (
p>bufptr && *(
p-1)==
')') {
1466 p = R__STRTOK_R(
nullptr,
"",&save) ;
1468 args.push_back(tmp) ;
1484 Int_t nParentheses(0);
1487 const char* ptr = arg ;
1489 if (*ptr==
'(') nParentheses++ ;
1490 if (*ptr==
')') nParentheses-- ;
1491 if (*ptr==
'[') nBracket++ ;
1492 if (*ptr==
']') nBracket-- ;
1493 if (*ptr==
'{') nAccolade++ ;
1494 if (*ptr==
'}') nAccolade-- ;
1497 if (nParentheses!=0) {
1498 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nParentheses>0?
"(":
")") <<
"' in expression" << endl ;
1502 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nBracket>0?
"[":
"]") <<
"' in expression" << endl ;
1506 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nAccolade>0?
"{":
"}") <<
"' in expression" << endl ;
1519 throw string(
Form(
"Need argument number %d, but only %d args are provided",idx,(
Int_t)
_of->
_args.size())) ;
1531 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1538 throw string(
Form(
"RooAbsArg named %s not found",arg)) ;
1551 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1557 throw string(
Form(
"RooAbsReal named %s not found",arg)) ;
1561 throw string(
Form(
"Object named %s is not of type RooAbsReal",arg)) ;
1574 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1575 throw string(
Form(
"Numeric literal provided for argument (%s), but lvalue is required",arg)) ;
1580 throw string(
Form(
"RooAbsRealLValue named %s not found",arg)) ;
1584 throw string(
Form(
"Object named %s is not of type RooAbsRealLValue",arg)) ;
1598 throw string(
Form(
"RooRealVar named %s not found",arg)) ;
1613 throw string(
Form(
"RooAbsPdf named %s not found",arg)) ;
1628 throw string(
Form(
"RooResolutionModel named %s not found",arg)) ;
1632 throw string(
Form(
"Object named %s is not of type RooResolutionModel",arg)) ;
1647 throw string(
Form(
"RooAbsCategory named %s not found",arg)) ;
1651 throw string(
Form(
"Object named %s is not of type RooAbsCategory",arg)) ;
1665 throw string(
Form(
"RooAbsCategoryLValue named %s not found",arg)) ;
1670 throw string(
Form(
"Object named %s is not of type RooAbsCategoryLValue",arg)) ;
1684 throw string(
Form(
"RooCategory named %s not found",arg)) ;
1715 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1720 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1722 }
else if (tok[0] ==
'\'') {
1723 tok[strlen(tok) - 1] = 0;
1731 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1734 tok = R__STRTOK_R(
nullptr,
",{}",&save) ;
1752 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1756 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1758 }
else if (tok[0] ==
'\'') {
1759 tok[strlen(tok) - 1] = 0;
1767 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1770 tok = R__STRTOK_R(
nullptr,
",{}",&save) ;
1785 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1799 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1803 throw string(
Form(
"Dataset named %s is not of type RooDataHist",arg)) ;
1816 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1820 throw string(
Form(
"Dataset named %s is not of type RooDataSet",arg)) ;
1833 throw string(
Form(
"Object named %s not found",arg)) ;
1845 static vector<string> cbuf(10) ;
1846 static unsigned int cbuf_idx = 0 ;
1849 if (arg==
nullptr || strlen(arg)==0) {
1855 cbuf[cbuf_idx].clear() ;
1856 const char*
p = arg+1 ;
1857 while(*
p && (*
p) !=
'"' && (*
p) !=
'\'' ) {
1858 cbuf[cbuf_idx] += *(
p++) ;
1860 const char* ret = cbuf[cbuf_idx].c_str() ;
1864 if (cbuf_idx==cbuf.size()) cbuf_idx=0 ;
1893 hooks()[typeName] = iface ;
1903 _hooks =
new map<string,IFace*> ;
1916 vector<string>::iterator iter = args.begin() ;
1917 vector<string> pargv ;
1918 while(iter!=args.end()) {
1919 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1922 pargv.push_back(tmp) ;
1927 string cl(typeName) ;
1931 ft.
add(instName,pargs,
false) ;
1933 }
else if (cl==
"RSUM") {
1936 ft.
add(instName,pargs,
true) ;
1938 }
else if (cl==
"ASUM") {
1943 }
else if (cl==
"PROD") {
1946 ft.
prod(instName,pargs) ;
1948 }
else if (cl==
"SIMUL") {
1951 if (pargv.size()>1) {
1952 ft.
simul(instName,pargv[0].c_str(),strchr(pargs,
',')+1) ;
1954 throw string(
Form(
"Need at least two arguments in call to SIMUL::%s, have %d: %s",instName,(
Int_t)pargv.size(),pargs)) ;
1957 }
else if (cl==
"EXPR") {
1960 if (args.size()<=2) {
1961 ft.
createArg(
"RooGenericPdf",instName,pargs) ;
1966 for (
UInt_t i=1 ; i<args.size() ; i++) {
1971 ft.
createArg(
"RooGenericPdf",instName,genargs) ;
1974 }
else if (cl==
"FCONV") {
1977 ft.
createArg(
"RooFFTConvPdf",instName,pargs) ;
1979 }
else if (cl==
"NCONV") {
1982 ft.
createArg(
"RooNumConvPdf",instName,pargs) ;
1984 }
else if (cl==
"sum") {
1989 }
else if (cl==
"prod") {
1994 }
else if (cl==
"expr") {
1997 if (args.size()<=2) {
1998 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2003 for (
UInt_t i=1 ; i<args.size() ; i++) {
2008 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2011 }
else if (cl ==
"taylorexpand") {
2017 double observablesValue(0.0);
2019 if (pargv.size() < 2)
2020 throw string(
Form(
"taylorexpand::%s, requires atleast 2 arguments (function, observables) atleast, has %d arguments", instName, (
Int_t)pargv.size()));
2025 if (pargv.size() > 3)
2026 order = atoi(pargv[3].c_str());
2027 if (pargv.size() > 2) {
2028 if (pargv[2].find(
',') != string::npos) {
2030 Form(
"taylorexpand::%s, factory syntax supports expansion only around same value for all observables", instName));
2032 observablesValue = atof(pargv[2].c_str());
2036 if (pargv.size() > 3)
2037 order = atoi(pargv[3].c_str());
2038 if (pargv.size() > 4)
2039 eps1 = atof(pargv[4].c_str());
2040 if (pargv.size() > 5)
2041 eps2 = atof(pargv[5].c_str());
2043 if (pargv.size() > 6) {
2045 Form(
"taylorexpand::%s, requires max. 6 arguments, has %d arguments", instName, (
Int_t)pargv.size()));
2051 }
else if (cl==
"nconv") {
2054 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2056#ifdef ROOFIT_LEGACY_EVAL_BACKEND
2057 }
else if (cl==
"nll") {
2060 RooNLLVar nll(instName,instName,ft.
asPDF(pargv[0].c_str()),ft.
asDATA(pargv[1].c_str()),
false) ;
2063 }
else if (cl==
"chi2") {
2070 }
else if (cl==
"profile") {
2073 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2075 }
else if (cl==
"dataobs") {
2078 std::unique_ptr<RooAbsArg> funcClone{
static_cast<RooAbsArg*
>(ft.
asARG(pargv[1].c_str()).
clone(instName))};
2084 }
else if (cl==
"int") {
2091 if (pargv.size()<2 || pargv.size()>3) {
2092 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2098 strlcpy(buf,pargv[1].c_str(),256) ;
2100 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2101 if (!intobs) intobs=
"" ;
2103 const char* range = R__STRTOK_R(
nullptr,
"",&save) ;
2104 if (!range) range=
"" ;
2106 std::unique_ptr<RooAbsReal> integral;
2107 if (pargv.size()==2) {
2108 if (range && strlen(range)) {
2114 if (range && strlen(range)) {
2121 integral->SetName(instName) ;
2124 }
else if (cl==
"deriv") {
2128 if (pargv.size()<2 || pargv.size()>3) {
2129 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2134 std::unique_ptr<RooAbsReal> derivative;
2135 if (pargv.size()==2) {
2141 derivative->
SetName(instName) ;
2144 }
else if (cl==
"cdf") {
2148 if (pargv.size()<2 || pargv.size()>3) {
2149 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2154 std::unique_ptr<RooAbsReal> cdf;
2155 if (pargv.size()==2) {
2156 cdf = std::unique_ptr<RooAbsReal>{pdf.
createCdf(ft.
asSET(pargv[1].c_str()))};
2158 cdf = std::unique_ptr<RooAbsReal>{pdf.
createCdf(ft.
asSET(pargv[1].c_str()),ft.
asSET(pargv[2].c_str()))};
2161 cdf->SetName(instName) ;
2165 }
else if (cl==
"PROJ") {
2168 if (pargv.size()!=2) {
2169 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2174 projection->
SetName(instName) ;
2178 }
else if (cl==
"set") {
2183 return string(instName) ;
2188 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2191 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.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
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.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, double eps=0.001)
Return function representing first, second or third order derivative of this function.
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 ...
Efficient implementation of a sum of PDFs of the form.
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.
Simple calculation from a binned dataset and a PDF.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
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)
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.
Represents the product of a given set of RooAbsReal objects.
Implements a PDF constructed from a sum of functions:
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.
A RooAbsArg implementing string values.
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.
RooAbsReal * function(RooStringView name) const
Retrieve function (RooAbsReal) with given name. Note that all RooAbsPdfs are also RooAbsReals....
RooAbsArg * arg(RooStringView name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
RooAbsData * data(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
bool defineSet(const char *name, const RooArgSet &aset, bool importMissing=false)
Define a named RooArgSet with given constituents.
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.
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)