69#define BUFFER_SIZE 64000
159 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
186 const size_t tmpSize = strlen(stateNameList)+1;
187 char *tmp =
new char[tmpSize] ;
188 strlcpy(tmp,stateNameList,tmpSize) ;
190 char* tok = R__STRTOK_R(tmp,
",",&save) ;
192 char*
sep = strchr(tok,
'=') ;
201 tok = R__STRTOK_R(0,
",",&save) ;
215 static bool isEnum(
const char* classname) {
217 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
224 static bool isValidEnumValue(
const char* enumName,
const char* enumConstantName) {
227 if (!enumName)
return false;
230 if (!enumName)
return false;
233 if (theEnum->GetConstant(enumConstantName))
return true;
235 auto tmp = strstr(enumConstantName,
"::");
237 auto enumConstantNameNoScope = tmp+2;
238 if (theEnum->GetConstant(enumConstantNameNoScope))
return true;
244 static pair<list<string>,
unsigned int> ctorArgs(
const char* classname,
UInt_t nMinArg) {
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 if (nargs==0 || nargs==
gInterpreter->MethodInfo_NDefaultArg(func)) {
276 MethodArgInfo_t* arg =
gInterpreter->MethodArgInfo_Factory(func);
279 const char* argTypeName =
gInterpreter->MethodArgInfo_TypeName(arg);
280 if (nreq<2 && ((
string(
"char*") != argTypeName
282 &&
string(
"const char*") != argTypeName)) {
285 ret.push_back(argTypeName) ;
286 if(!
gInterpreter->MethodArgInfo_DefaultValue(arg)) nreq++;
291 if (ret.size()<nMinArg) {
299 return pair<list<string>,
unsigned int>(ret,nreq);
314 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not found in factory alias table, nor in ROOT class table" << endl;
323 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" does not inherit from RooAbsArg" << endl;
330 size_t blevel = 0, end_tok, start_tok = 0;
331 bool litmode =
false;
332 for (end_tok = 0; end_tok < tmp.length(); end_tok++) {
334 if (tmp[end_tok]==
'{' || tmp[end_tok]==
'(' || tmp[end_tok]==
'[') blevel++;
335 if (tmp[end_tok]==
'}' || tmp[end_tok]==
')' || tmp[end_tok]==
']') blevel--;
338 if (tmp[end_tok]==
'"' || tmp[end_tok]==
'\'') litmode = !litmode;
343 if (litmode ==
false && blevel == 0 && tmp[end_tok] ==
',') {
344 _args.push_back(tmp.substr(start_tok, end_tok - start_tok));
345 start_tok = end_tok+1;
348 _args.push_back(tmp.substr(start_tok, end_tok));
351 pair<list<string>,
unsigned int> ca = ctorArgs(className,
_args.size()+2) ;
352 if (ca.first.size()==0) {
353 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR no suitable constructor found for class " << className << endl ;
360 if (
_args.size()+2<ca.second ||
_args.size()+2>ca.first.size()) {
361 if (ca.second==ca.first.size()) {
362 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid, " << className
363 <<
" expects " << ca.first.size()-2 << endl ;
366 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid " << className
367 <<
" expect number between " << ca.second-2 <<
" and " << ca.first.size()-2 << endl ;
374 string cintExpr(
Form(
"new %s(\"%s\",\"%s\"",className,objName,objName)) ;
382 list<string>::iterator ti = ca.first.begin() ; ++ti ; ++ti ;
383 for (vector<string>::iterator ai =
_args.begin() ; ai !=
_args.end() ; ++ai,++ti,++i) {
384 if ((*ti)==
"RooAbsReal&" || (*ti)==
"const RooAbsReal&") {
386 cintExpr +=
Form(
",RooFactoryWSTool::as_FUNC(%d)",i) ;
387 }
else if ((*ti)==
"RooAbsArg&" || (*ti)==
"const RooAbsArg&") {
389 cintExpr +=
Form(
",RooFactoryWSTool::as_ARG(%d)",i) ;
390 }
else if ((*ti)==
"RooRealVar&" || (*ti)==
"const RooRealVar&") {
392 cintExpr +=
Form(
",RooFactoryWSTool::as_VAR(%d)",i) ;
393 }
else if ((*ti)==
"RooAbsRealLValue&" || (*ti)==
"const RooAbsRealLValue&") {
395 cintExpr +=
Form(
",RooFactoryWSTool::as_VARLV(%d)",i) ;
396 }
else if ((*ti)==
"RooCategory&" || (*ti)==
"const RooCategory&") {
398 cintExpr +=
Form(
",RooFactoryWSTool::as_CAT(%d)",i) ;
399 }
else if ((*ti)==
"RooAbsCategory&" || (*ti)==
"const RooAbsCategory&") {
401 cintExpr +=
Form(
",RooFactoryWSTool::as_CATFUNC(%d)",i) ;
402 }
else if ((*ti)==
"RooAbsCategoryLValue&" || (*ti)==
"const RooAbsCategoryLValue&") {
404 cintExpr +=
Form(
",RooFactoryWSTool::as_CATLV(%d)",i) ;
405 }
else if ((*ti)==
"RooAbsPdf&" || (*ti)==
"const RooAbsPdf&") {
407 cintExpr +=
Form(
",RooFactoryWSTool::as_PDF(%d)",i) ;
408 }
else if ((*ti)==
"RooResolutionModel&" || (*ti)==
"const RooResolutionModel&") {
410 cintExpr +=
Form(
",RooFactoryWSTool::as_RMODEL(%d)",i) ;
411 }
else if ((*ti)==
"RooAbsData&" || (*ti)==
"const RooAbsData&") {
413 cintExpr +=
Form(
",RooFactoryWSTool::as_DATA(%d)",i) ;
414 }
else if ((*ti)==
"RooDataSet&" || (*ti)==
"const RooDataSet&") {
416 cintExpr +=
Form(
",RooFactoryWSTool::as_DSET(%d)",i) ;
417 }
else if ((*ti)==
"RooDataHist&" || (*ti)==
"const RooDataHist&") {
419 cintExpr +=
Form(
",RooFactoryWSTool::as_DHIST(%d)",i) ;
420 }
else if ((*ti)==
"const RooArgSet&") {
422 cintExpr +=
Form(
",RooFactoryWSTool::as_SET(%d)",i) ;
423 }
else if ((*ti)==
"const RooArgList&") {
425 cintExpr +=
Form(
",RooFactoryWSTool::as_LIST(%d)",i) ;
426 }
else if ((*ti)==
"const char*") {
428 cintExpr +=
Form(
",RooFactoryWSTool::as_STRING(%d)",i) ;
429 }
else if ((*ti)==
"Int_t" || (*ti)==
"int" || (*ti)==
"Bool_t" || (*ti)==
"bool") {
431 cintExpr +=
Form(
",RooFactoryWSTool::as_INT(%d)",i) ;
432 }
else if ((*ti)==
"Double_t") {
434 cintExpr +=
Form(
",RooFactoryWSTool::as_DOUBLE(%d)",i) ;
435 }
else if (isEnum(ti->c_str())) {
438 if (
_args[i].find(
Form(
"%s::",className)) != string::npos) {
439 qualvalue =
_args[i].c_str() ;
441 qualvalue =
Form(
"%s::%s",className,
_args[i].c_str()) ;
443 if (isValidEnumValue(ti->c_str(),qualvalue.c_str())) {
444 cintExpr +=
Form(
",(%s)%s",ti->c_str(),qualvalue.c_str()) ;
446 throw string(
Form(
"Supplied argument %s does not represent a valid state of enum %s",
_args[i].c_str(),ti->c_str())) ;
454 if (ti->find(
"const ")==0) {
455 btype = ti->c_str()+6 ;
459 if (btype.find(
"&")) {
460 btype.erase(btype.size()-1,btype.size()) ;
467 cintExpr +=
Form(
",(%s&)RooFactoryWSTool::as_OBJ(%d)",ti->c_str(),i) ;
469 throw string(
Form(
"Required argument with name %s of type '%s' is not in the workspace",
_args[i].c_str(),ti->c_str())) ;
474 }
catch (
const string &err) {
475 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR constructing " << className <<
"::" << objName <<
": " << err << endl ;
480 cxcoutD(
ObjectHandling) <<
"RooFactoryWSTool::createArg() Construct expression is " << cintExpr << endl ;
486 if (
string(className)==
"RooGenericPdf") {
488 }
else if (
string(className)==
"RooFormulaVar") {
498 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR in CINT constructor call to create object" << endl ;
519 char* tok = R__STRTOK_R(buf,
",",&save) ;
521 char* star=strchr(tok,
'*') ;
529 tok = R__STRTOK_R(0,
",",&save) ;
531 pdfList.
add(pdfList2) ;
533 }
catch (
const string &err) {
534 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
539 RooAddPdf pdf{objName,objName,pdfList,coefList,recursiveCoefs};
540 pdf.setStringAttribute(
"factory_tag",
Form(
"SUM::%s(%s)",objName,specList)) ;
561 char* tok = R__STRTOK_R(buf,
",",&save) ;
563 char* star=strchr(tok,
'*') ;
571 tok = R__STRTOK_R(0,
",",&save) ;
573 amplList.
add(amplList2) ;
575 }
catch (
const string &err) {
576 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooRealSumPdf: " << err << endl ;
596 string regPdfList=
"{" ;
600 char* tok = R__STRTOK_R(buf,
",",&save) ;
602 char *
sep = strchr(tok,
'|') ;
617 }
catch (
const string &err) {
618 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf Conditional argument: " << err << endl ;
625 if (regPdfList.size()>1) {
630 tok = R__STRTOK_R(0,
",",&save) ;
634 std::unique_ptr<RooProdPdf> pdf;
636 pdf = std::make_unique<RooProdPdf>(objName,objName,
asSET(regPdfList.c_str()),cmdList);
637 }
catch (
const string &err) {
638 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf input set of regular pdfs: " << err << endl ;
644 pdf->setStringAttribute(
"factory_tag",
Form(
"PROD::%s(%s)",objName,pdfList)) ;
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) ;
686 std::unique_ptr<RooSimultaneous> pdf;
688 pdf = std::make_unique<RooSimultaneous>(objName,objName,theMap,
asCATLV(indexCat)) ;
689 }
catch (
const string &err) {
690 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
696 pdf->setStringAttribute(
"factory_tag",
Form(
"SIMUL::%s(%s,%s)",objName,indexCat,pdfMap)) ;
716 char* tok = R__STRTOK_R(buf,
",",&save) ;
718 char* star=strchr(tok,
'*') ;
726 tok = R__STRTOK_R(0,
",",&save) ;
729 }
catch (
const string &err) {
730 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
736 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
742 auto sum = sumlist2.
empty() ? std::make_unique<RooAddition>(objName,objName,sumlist1)
743 : std::make_unique<RooAddition>(objName,objName,sumlist1,sumlist2);
745 sum->setStringAttribute(
"factory_tag",
Form(
"sum::%s(%s)",objName,specList)) ;
862 char* buf =
new char[strlen(expr)+1] ;
867 if (!isspace(*expr)) {
884 }
catch (
const string &error) {
885 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERROR in parsing: " << error << endl ;
891 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed" << endl ;
901 return out.size() ?
ws().
arg(out.c_str()) : 0 ;
920 if (
string(token).find(
"$Alias(")==0) {
946 const size_t bufBaseSize = strlen(token)+1;
947 char* buf_base =
new char[bufBaseSize] ;
948 char* buf = buf_base ;
949 strlcpy(buf,token,bufBaseSize) ;
952 list<string> singleExpr ;
959 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
960 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
963 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
967 if (!litmode && blevel==0 && ( (*
p)==
'=' || (*
p) ==
'|' || (*
p) ==
'*')) {
970 singleExpr.push_back(buf) ;
976 singleExpr.push_back(buf) ;
978 if (singleExpr.size()==1) {
985 list<char>::iterator ic =
separator.begin() ;
986 for (list<string>::iterator ii = singleExpr.begin() ; ii!=singleExpr.end() ; ++ii) {
1011 if (strlen(arg)==0) {
1016 if (arg[0]==
'\'' || arg[0]==
'"') {
1017 return string(arg) ;
1021 const size_t bufSize = strlen(arg)+1;
1022 char* buf =
new char[bufSize] ;
1023 strlcpy(buf,arg,bufSize) ;
1024 char* bufptr = buf ;
1026 string func,prefix ;
1027 vector<string> args ;
1031 char* tmpx = R__STRTOK_R(buf,
"([",&save) ;
1032 func = tmpx ? tmpx :
"" ;
1033 char*
p = R__STRTOK_R(0,
"",&save) ;
1048 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1049 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1052 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1058 if (!litmode && blevel==0 && ((*
p)==
',')) {
1060 args.push_back(tok) ;
1069 if (
p>bufptr && (*(
p-1)==
')'||*(
p-1)==
']')) {
1078 p = R__STRTOK_R(0,
"",&save) ;
1080 args.push_back(tmp) ;
1091 for(
const char* pp=arg ; *pp!=0 ; pp++) {
1092 if (*pp==
'(' || *pp==
'[' || *pp==
'{') {
1098 if (strstr(func.c_str(),
"::")) {
1103 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: Class::Instance must be followed by (...)" << endl ;
1106 }
else if (func[0]!=
'$'){
1110 }
else if (lb==
'(') {
1120 static Int_t globCounter = 0 ;
1122 autoname =
Form(
"gobj%d",globCounter) ;
1124 if (!
ws().arg(autoname.c_str())) {
1128 autoname =
Form(
"%s::%s",func.c_str(),autoname.c_str()) ;
1132 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: expect either Class(...) or Instance[...]" << endl ;
1140 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: $MetaClass must be followed by (...)" << endl ;
1160 const size_t bufSize = strlen(arg)+1;
1161 char* buf =
new char[bufSize] ;
1162 strlcpy(buf,arg,bufSize) ;
1164 vector<string> args ;
1175 if (*
p==
'{' || *
p==
'(' || *
p==
'[') level++ ;
1176 if (*
p==
'}' || *
p==
')' || *
p==
']') level-- ;
1182 if (level==0 && ((*
p)==
',')) {
1184 args.push_back(tok) ;
1192 if (
p>buf && *(
p-1)==
'}') {
1195 args.push_back(tok) ;
1203 vector<string>::iterator iter = args.begin() ;
1205 while(iter!= args.end()) {
1206 if (strlen(ret.c_str())>1) ret +=
"," ;
1230 if (args.size()!=2) {
1231 coutE(
ObjectHandling) <<
"RooFactorWSTool::processAliasExpression() ERROR $Alias() takes exactly two arguments, " << args.size() <<
" args found" << endl ;
1251 map<string,string>::iterator item =
_typeAliases.find(className) ;
1255 className = item->second.c_str() ;
1268 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not defined in ROOT class table" << endl ;
1285 for (vector<string>::iterator iter = args.begin() ; iter!=args.end() ; ++iter) {
1286 if (iter!=args.begin()) {
1313 string first = *(args.begin()) ;
1317 vector<string>::iterator ai = args.begin() ;
1318 if (args.size()==1) {
1321 Double_t xinit = atof((ai)->c_str()) ;
1323 RooRealVar tmp(func.c_str(),func.c_str(),xinit) ;
1329 }
else if (args.size()==2) {
1332 Double_t xlo = atof((ai++)->c_str()) ;
1334 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1335 RooRealVar tmp(func.c_str(),func.c_str(),xlo,xhi) ;
1341 }
else if (args.size()==3) {
1344 Double_t xinit = atof((ai++)->c_str()) ;
1345 Double_t xlo = atof((ai++)->c_str()) ;
1347 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xinit = " << xinit <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1348 RooRealVar tmp(func.c_str(),func.c_str(),xinit,xlo,xhi) ;
1358 for (vector<string>::iterator ai = args.begin() ; ai!=args.end() ; ++ai) {
1359 if (allStates.size()>0) {
1387 const char *className = R__STRTOK_R(buf,
":",&save) ;
1388 const char *instName = R__STRTOK_R(0,
":",&save) ;
1389 if (!className) className =
"";
1390 if (!instName) instName =
"" ;
1395 vector<string>::iterator iter = args.begin() ;
1396 vector<string> pargv ;
1398 while(iter!=args.end()) {
1399 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1404 pargv.push_back(tmp) ;
1410 for (map<string,IFace*>::iterator ii=
hooks().begin() ; ii!=
hooks().end() ; ++ii) {
1412 if (
hooks().find(className) !=
hooks().end()) {
1414 return iface->
create(*
this, className,instName,pargv) ;
1419 return string(instName) ;
1431 vector<string>::iterator iter = args.begin() ;
1432 vector<string> pargv ;
1433 while(iter!=args.end()) {
1434 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1437 pargv.push_back(tmp) ;
1441 string ret = func+
"("+pargs+
")" ;
1453 const size_t bufSize = strlen(funcExpr)+1;
1454 char* buf =
new char[bufSize] ;
1455 strlcpy(buf,funcExpr,bufSize) ;
1456 char* bufptr = buf ;
1459 vector<string> args ;
1463 char* tmpx = R__STRTOK_R(buf,
"(",&save) ;
1464 func = tmpx ? tmpx :
"" ;
1465 char*
p = R__STRTOK_R(0,
"",&save) ;
1479 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1480 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1483 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1489 if (!litmode && blevel==0 && ((*
p)==
',')) {
1491 args.push_back(tok) ;
1500 if (
p>bufptr && *(
p-1)==
')') {
1509 p = R__STRTOK_R(0,
"",&save) ;
1511 args.push_back(tmp) ;
1530 Int_t nParentheses(0), nBracket(0), nAccolade(0) ;
1531 const char* ptr = arg ;
1533 if (*ptr==
'(') nParentheses++ ;
1534 if (*ptr==
')') nParentheses-- ;
1535 if (*ptr==
'[') nBracket++ ;
1536 if (*ptr==
']') nBracket-- ;
1537 if (*ptr==
'{') nAccolade++ ;
1538 if (*ptr==
'}') nAccolade-- ;
1541 if (nParentheses!=0) {
1542 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nParentheses>0?
"(":
")") <<
"' in expression" << endl ;
1546 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nBracket>0?
"[":
"]") <<
"' in expression" << endl ;
1550 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nAccolade>0?
"{":
"}") <<
"' in expression" << endl ;
1563 throw string(
Form(
"Need argument number %d, but only %d args are provided",idx,(
Int_t)
_of->
_args.size())) ;
1575 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1582 throw string(
Form(
"RooAbsArg named %s not found",arg)) ;
1595 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1601 throw string(
Form(
"RooAbsReal named %s not found",arg)) ;
1605 throw string(
Form(
"Object named %s is not of type RooAbsReal",arg)) ;
1618 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1619 throw string(
Form(
"Numeric literal provided for argument (%s), but lvalue is required",arg)) ;
1624 throw string(
Form(
"RooAbsRealLValue named %s not found",arg)) ;
1628 throw string(
Form(
"Object named %s is not of type RooAbsRealLValue",arg)) ;
1642 throw string(
Form(
"RooRealVar named %s not found",arg)) ;
1657 throw string(
Form(
"RooAbsPdf named %s not found",arg)) ;
1672 throw string(
Form(
"RooResolutionModel named %s not found",arg)) ;
1676 throw string(
Form(
"Object named %s is not of type RooResolutionModel",arg)) ;
1691 throw string(
Form(
"RooAbsCategory named %s not found",arg)) ;
1695 throw string(
Form(
"Object named %s is not of type RooAbsCategory",arg)) ;
1709 throw string(
Form(
"RooAbsCategoryLValue named %s not found",arg)) ;
1714 throw string(
Form(
"Object named %s is not of type RooAbsCategoryLValue",arg)) ;
1728 throw string(
Form(
"RooCategory named %s not found",arg)) ;
1759 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1764 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1766 }
else if (tok[0] ==
'\'') {
1767 tok[strlen(tok) - 1] = 0;
1775 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1778 tok = R__STRTOK_R(0,
",{}",&save) ;
1796 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1800 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1802 }
else if (tok[0] ==
'\'') {
1803 tok[strlen(tok) - 1] = 0;
1811 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1814 tok = R__STRTOK_R(0,
",{}",&save) ;
1829 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1843 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1847 throw string(
Form(
"Dataset named %s is not of type RooDataHist",arg)) ;
1860 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1864 throw string(
Form(
"Dataset named %s is not of type RooDataSet",arg)) ;
1877 throw string(
Form(
"Object named %s not found",arg)) ;
1889 static vector<string> cbuf(10) ;
1890 static unsigned int cbuf_idx = 0 ;
1893 if (arg==0 || strlen(arg)==0) {
1899 cbuf[cbuf_idx].clear() ;
1900 const char*
p = arg+1 ;
1901 while(*
p && (*
p) !=
'"' && (*
p) !=
'\'' ) {
1902 cbuf[cbuf_idx] += *(
p++) ;
1904 const char* ret = cbuf[cbuf_idx].c_str() ;
1908 if (cbuf_idx==cbuf.size()) cbuf_idx=0 ;
1937 hooks()[typeName] = iface ;
1947 _hooks =
new map<string,IFace*> ;
1960 vector<string>::iterator iter = args.begin() ;
1961 vector<string> pargv ;
1962 while(iter!=args.end()) {
1963 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1966 pargv.push_back(tmp) ;
1971 string cl(typeName) ;
1977 }
else if (cl==
"RSUM") {
1982 }
else if (cl==
"ASUM") {
1987 }
else if (cl==
"PROD") {
1990 ft.
prod(instName,pargs) ;
1992 }
else if (cl==
"SIMUL") {
1995 if (pargv.size()>1) {
1996 ft.
simul(instName,pargv[0].c_str(),strchr(pargs,
',')+1) ;
1998 throw string(
Form(
"Need at least two arguments in call to SIMUL::%s, have %d: %s",instName,(
Int_t)pargv.size(),pargs)) ;
2001 }
else if (cl==
"EXPR") {
2004 if (args.size()<=2) {
2005 ft.
createArg(
"RooGenericPdf",instName,pargs) ;
2010 for (
UInt_t i=1 ; i<args.size() ; i++) {
2015 ft.
createArg(
"RooGenericPdf",instName,genargs) ;
2018 }
else if (cl==
"FCONV") {
2021 ft.
createArg(
"RooFFTConvPdf",instName,pargs) ;
2023 }
else if (cl==
"NCONV") {
2026 ft.
createArg(
"RooNumConvPdf",instName,pargs) ;
2028 }
else if (cl==
"sum") {
2033 }
else if (cl==
"prod") {
2038 }
else if (cl ==
"lagrangianmorph") {
2040 const std::array<std::string,4> funcArgs{{
"fileName",
"observableName",
"couplings",
"folders"}};
2041 map<string,string> mapped_inputs;
2043 for (
unsigned int i=1 ; i<pargv.size() ; i++) {
2044 if (pargv[i].find(
"$fileName(")!=0 &&
2045 pargv[i].find(
"$observableName(")!=0 &&
2046 pargv[i].find(
"$couplings(")!=0 &&
2047 pargv[i].find(
"$folders(")!=0 &&
2048 pargv[i].find(
"$NewPhysics(")!=0) {
2049 throw string(
Form(
"%s::create() ERROR: unknown token %s encountered",instName, pargv[i].c_str())) ;
2056 for (
unsigned int i=0 ; i<pargv.size() ; i++) {
2057 if (pargv[i].find(
"$NewPhysics(")==0) {
2059 for(
const auto& subarg: subargs) {
2063 char *tok = R__STRTOK_R(buf,
"=", &save);
2064 vector<string> parts;
2066 parts.push_back(
string(tok));
2067 tok = R__STRTOK_R(0,
"=", &save);
2069 if (parts.size() == 2){
2070 ft.
ws().
arg(parts[0].c_str())->
setAttribute(
"NewPhysics",atoi(parts[1].c_str()));
2072 else throw string(
Form(
"%s::create() ERROR: unknown token %s encountered, check input provided for %s",instName,subarg.c_str(), pargv[i].c_str()));
2077 if (subargs.size()==1){
2079 for(
auto const& param : funcArgs){
2080 if(pargv[i].find(param)!=string::npos) mapped_inputs[param]=subargs[0];
2083 else throw string(
Form(
"Incorrect number of arguments in %s, have %d, expect 1",pargv[i].c_str(),(
Int_t)subargs.size())) ;
2086 for(
auto const& param : funcArgs){
2087 if(strlen(pargsmorph) > 0) strlcat(pargsmorph,
",",
BUFFER_SIZE);
2088 strlcat(pargsmorph, mapped_inputs[param].c_str(),
BUFFER_SIZE);
2090 ft.
createArg(
"RooLagrangianMorphFunc",instName, pargsmorph);
2092 }
else if (cl==
"expr") {
2095 if (args.size()<=2) {
2096 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2101 for (
UInt_t i=1 ; i<args.size() ; i++) {
2106 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2109 }
else if (cl ==
"taylorexpand") {
2113 double eps1(1
e-6), eps2(1
e-3), observablesValue(0.0);
2115 if (pargv.size() < 2)
2116 throw string(
Form(
"taylorexpand::%s, requires atleast 2 arguments (function, observables) atleast, has %d arguments", instName, (
Int_t)pargv.size()));
2121 if (pargv.size() > 3)
2122 order = atoi(pargv[3].c_str());
2123 if (pargv.size() > 2) {
2124 if (pargv[2].find(
",") != string::npos)
2125 throw string(
Form(
"taylorexpand::%s, factory syntax supports expansion only around same value for all observables", instName));
2126 else observablesValue = atof(pargv[2].c_str());
2129 if (pargv.size() > 3)
2130 order = atoi(pargv[3].c_str());
2131 if (pargv.size() > 4)
2132 eps1 = atof(pargv[4].c_str());
2133 if (pargv.size() > 5)
2134 eps2 = atof(pargv[5].c_str());
2136 if (pargv.size() > 6)
2138 Form(
"taylorexpand::%s, requires max. 6 arguments, has %d arguments", instName, (
Int_t)pargv.size()));
2143 }
else if (cl==
"nconv") {
2146 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2148 }
else if (cl==
"nll") {
2154 }
else if (cl==
"chi2") {
2160 }
else if (cl==
"profile") {
2163 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2165 }
else if (cl==
"dataobs") {
2175 }
else if (cl==
"int") {
2182 if (pargv.size()<2 || pargv.size()>3) {
2183 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2189 strlcpy(buf,pargv[1].c_str(),256) ;
2191 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2192 if (!intobs) intobs=
"" ;
2194 const char* range = R__STRTOK_R(0,
"",&save) ;
2195 if (!range) range=
"" ;
2197 std::unique_ptr<RooAbsReal> integral;
2198 if (pargv.size()==2) {
2199 if (range && strlen(range)) {
2205 if (range && strlen(range)) {
2212 integral->SetName(instName) ;
2215 }
else if (cl==
"deriv") {
2219 if (pargv.size()<2 || pargv.size()>3) {
2220 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2225 std::unique_ptr<RooAbsReal> derivative;
2226 if (pargv.size()==2) {
2232 derivative->
SetName(instName) ;
2235 }
else if (cl==
"cdf") {
2239 if (pargv.size()<2 || pargv.size()>3) {
2240 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2245 std::unique_ptr<RooAbsReal> cdf;
2246 if (pargv.size()==2) {
2256 }
else if (cl==
"PROJ") {
2259 if (pargv.size()!=2) {
2260 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2265 projection->
SetName(instName) ;
2269 }
else if (cl==
"set") {
2274 return string(instName) ;
2279 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2282 return string(instName) ;
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
void SetName(const char *name) override
Set the name of the TNamed.
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
virtual TObject * clone(const char *newname=0) const =0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
A space to attach TBranches.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Int_t getSize() const
Return the number of elements in the collection.
RooAbsData is the common abstract base class for binned and unbinned datasets.
RooAbsReal * createCdf(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Create a cumulative distribution function of this p.d.f in terms of the observables listed in iset.
virtual RooAbsPdf * createProjection(const RooArgSet &iset)
Return a p.d.f that represent a projection of this p.d.f integrated over given observables.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, Double_t eps=0.001)
Return function representing first, second or third order derivative of this function.
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCategory is an object to represent discrete states.
bool defineType(const std::string &label)
Define a state with given name.
RooChi2Var implements a simple calculation from a binned dataset and a PDF.
The RooDataHist is a container class to hold N-dimensional binned data.
RooDataSet is a container class to hold unbinned data.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
void Delete(Option_t *o=0) override
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
static std::unique_ptr< RooAbsReal > taylorExpand(const char *name, const char *title, RooAbsReal &func, const RooAbsCollection &observables, std::vector< double > const &observableValues, int order=1, double eps1=1e-6, double eps2=1e-3)
RooProdPdf is an efficient implementation of a product of PDFs of the form.
A RooProduct represents the product of a given set of RooAbsReal objects.
The class RooRealSumPdf implements a PDF constructed from a sum of functions:
RooRealVar represents a variable that can be changed from the outside.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooStringVar is a RooAbsArg implementing string values.
The RooWorkspace is a persistable container for RooFit projects.
TObject * obj(RooStringView name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooCategory * cat(RooStringView name) const
Retrieve discrete variable (RooCategory) with given name. A null pointer is returned if not found.
Bool_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.
RooAbsArg * fundArg(RooStringView name) const
Return fundamental (i.e.
Bool_t commitTransaction()
Bool_t 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_t defineSet(const char *name, const RooArgSet &aset, Bool_t importMissing=kFALSE)
Define a named RooArgSet with given constituents.
Bool_t cancelTransaction()
Cancel an ongoing import transaction.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
RooAbsData * data(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
const RooArgSet * set(const char *name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
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 Silence(Bool_t flag=kTRUE)
RooConstVar & RooConst(Double_t val)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, Bool_t depsAreCond=kFALSE)
RooCmdArg NormSet(Args_t &&... argsOrArgSet)
void(off) SmallVectorTemplateBase< T
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static constexpr double s
static uint64_t sum(uint64_t i)