69#define BUFFER_SIZE 64000
158 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createFactory() ERROR: variable with name '" <<
name <<
"' already exists" << endl ;
185 const size_t tmpSize = strlen(stateNameList)+1;
186 std::vector<char> tmp(tmpSize);
187 strlcpy(tmp.data(),stateNameList,tmpSize) ;
189 char* tok = R__STRTOK_R(tmp.data(),
",",&save) ;
191 char*
sep = strchr(tok,
'=') ;
200 tok = R__STRTOK_R(0,
",",&save) ;
213 static bool isEnum(
const char* classname) {
215 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
222 static bool isValidEnumValue(
const char* enumName,
const char* enumConstantName) {
225 if (!enumName)
return false;
228 if (!enumName)
return false;
231 if (theEnum->GetConstant(enumConstantName))
return true;
233 auto tmp = strstr(enumConstantName,
"::");
235 auto enumConstantNameNoScope = tmp+2;
236 if (theEnum->GetConstant(enumConstantNameNoScope))
return true;
242 static pair<list<string>,
unsigned int> ctorArgs(
const char* classname, std::size_t nPassedArgs) {
250 ClassInfo_t* cls =
gInterpreter->ClassInfo_Factory(classname);
251 MethodInfo_t* func =
gInterpreter->MethodInfo_Factory(cls);
264 if (
string(classname) !=
gInterpreter->MethodInfo_TypeName(func)) {
270 int nDefaultArgs =
gInterpreter->MethodInfo_NDefaultArg(func);
271 if (nargs == nDefaultArgs) {
275 MethodArgInfo_t* arg =
gInterpreter->MethodArgInfo_Factory(func);
278 const char* argTypeName =
gInterpreter->MethodArgInfo_TypeName(arg);
279 if (nreq<2 && ((
string(
"char*") != argTypeName
281 &&
string(
"const char*") != argTypeName)) {
284 ret.push_back(argTypeName) ;
285 if(!
gInterpreter->MethodArgInfo_DefaultValue(arg)) nreq++;
292 if(
static_cast<int>(nPassedArgs) >= nargs - nDefaultArgs &&
static_cast<int>(nPassedArgs) <= nargs) {
298 return pair<list<string>,
unsigned int>(ret,nreq);
313 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not found in factory alias table, nor in ROOT class table" << endl;
322 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" does not inherit from RooAbsArg" << endl;
329 size_t blevel = 0, end_tok, start_tok = 0;
330 bool litmode =
false;
331 for (end_tok = 0; end_tok < tmp.length(); end_tok++) {
333 if (tmp[end_tok]==
'{' || tmp[end_tok]==
'(' || tmp[end_tok]==
'[') blevel++;
334 if (tmp[end_tok]==
'}' || tmp[end_tok]==
')' || tmp[end_tok]==
']') blevel--;
337 if (tmp[end_tok]==
'"' || tmp[end_tok]==
'\'') litmode = !litmode;
342 if (litmode ==
false && blevel == 0 && tmp[end_tok] ==
',') {
343 _args.push_back(tmp.substr(start_tok, end_tok - start_tok));
344 start_tok = end_tok+1;
347 _args.push_back(tmp.substr(start_tok, end_tok));
350 pair<list<string>,
unsigned int> ca = ctorArgs(className,
_args.size()+2) ;
351 if (ca.first.empty()) {
352 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR no suitable constructor found for class " << className << endl ;
359 if (
_args.size()+2<ca.second ||
_args.size()+2>ca.first.size()) {
360 if (ca.second==ca.first.size()) {
361 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid, " << className
362 <<
" expects " << ca.first.size()-2 << endl ;
365 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR number of arguments provided (" <<
_args.size() <<
") for class is invalid " << className
366 <<
" expect number between " << ca.second-2 <<
" and " << ca.first.size()-2 << endl ;
373 string cintExpr(
Form(
"new %s(\"%s\",\"%s\"",className,objName,objName)) ;
381 list<string>::iterator ti = ca.first.begin() ; ++ti ; ++ti ;
382 for (vector<string>::iterator ai =
_args.begin() ; ai !=
_args.end() ; ++ai,++ti,++i) {
383 if ((*ti)==
"RooAbsReal&" || (*ti)==
"const RooAbsReal&" || (*ti)==
"RooAbsReal::Ref") {
385 cintExpr +=
Form(
",RooFactoryWSTool::as_FUNC(%d)",i) ;
386 }
else if ((*ti)==
"RooAbsArg&" || (*ti)==
"const RooAbsArg&") {
388 cintExpr +=
Form(
",RooFactoryWSTool::as_ARG(%d)",i) ;
389 }
else if ((*ti)==
"RooRealVar&" || (*ti)==
"const RooRealVar&") {
391 cintExpr +=
Form(
",RooFactoryWSTool::as_VAR(%d)",i) ;
392 }
else if ((*ti)==
"RooAbsRealLValue&" || (*ti)==
"const RooAbsRealLValue&") {
394 cintExpr +=
Form(
",RooFactoryWSTool::as_VARLV(%d)",i) ;
395 }
else if ((*ti)==
"RooCategory&" || (*ti)==
"const RooCategory&") {
397 cintExpr +=
Form(
",RooFactoryWSTool::as_CAT(%d)",i) ;
398 }
else if ((*ti)==
"RooAbsCategory&" || (*ti)==
"const RooAbsCategory&") {
400 cintExpr +=
Form(
",RooFactoryWSTool::as_CATFUNC(%d)",i) ;
401 }
else if ((*ti)==
"RooAbsCategoryLValue&" || (*ti)==
"const RooAbsCategoryLValue&") {
403 cintExpr +=
Form(
",RooFactoryWSTool::as_CATLV(%d)",i) ;
404 }
else if ((*ti)==
"RooAbsPdf&" || (*ti)==
"const RooAbsPdf&") {
406 cintExpr +=
Form(
",RooFactoryWSTool::as_PDF(%d)",i) ;
407 }
else if ((*ti)==
"RooResolutionModel&" || (*ti)==
"const RooResolutionModel&") {
409 cintExpr +=
Form(
",RooFactoryWSTool::as_RMODEL(%d)",i) ;
410 }
else if ((*ti)==
"RooAbsData&" || (*ti)==
"const RooAbsData&") {
412 cintExpr +=
Form(
",RooFactoryWSTool::as_DATA(%d)",i) ;
413 }
else if ((*ti)==
"RooDataSet&" || (*ti)==
"const RooDataSet&") {
415 cintExpr +=
Form(
",RooFactoryWSTool::as_DSET(%d)",i) ;
416 }
else if ((*ti)==
"RooDataHist&" || (*ti)==
"const RooDataHist&") {
418 cintExpr +=
Form(
",RooFactoryWSTool::as_DHIST(%d)",i) ;
419 }
else if ((*ti)==
"const RooArgSet&") {
421 cintExpr +=
Form(
",RooFactoryWSTool::as_SET(%d)",i) ;
422 }
else if ((*ti)==
"const RooArgList&") {
424 cintExpr +=
Form(
",RooFactoryWSTool::as_LIST(%d)",i) ;
425 }
else if ((*ti)==
"const char*") {
427 cintExpr +=
Form(
",RooFactoryWSTool::as_STRING(%d)",i) ;
428 }
else if ((*ti)==
"Int_t" || (*ti)==
"int" || (*ti)==
"bool" || (*ti)==
"bool") {
430 cintExpr +=
Form(
",RooFactoryWSTool::as_INT(%d)",i) ;
431 }
else if ((*ti)==
"double") {
433 cintExpr +=
Form(
",RooFactoryWSTool::as_DOUBLE(%d)",i) ;
434 }
else if (isEnum(ti->c_str())) {
437 if (
_args[i].find(
Form(
"%s::",className)) != string::npos) {
438 qualvalue =
_args[i].c_str() ;
440 qualvalue =
Form(
"%s::%s",className,
_args[i].c_str()) ;
442 if (isValidEnumValue(ti->c_str(),qualvalue.c_str())) {
443 cintExpr +=
Form(
",(%s)%s",ti->c_str(),qualvalue.c_str()) ;
445 throw string(
Form(
"Supplied argument %s does not represent a valid state of enum %s",
_args[i].c_str(),ti->c_str())) ;
453 if (ti->find(
"const ")==0) {
454 btype = ti->c_str()+6 ;
458 if (btype.find(
"&")) {
459 btype.erase(btype.size()-1,btype.size()) ;
466 cintExpr +=
Form(
",(%s&)RooFactoryWSTool::as_OBJ(%d)",ti->c_str(),i) ;
468 throw string(
Form(
"Required argument with name %s of type '%s' is not in the workspace",
_args[i].c_str(),ti->c_str())) ;
473 }
catch (
const string &err) {
474 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR constructing " << className <<
"::" << objName <<
": " << err << endl ;
479 cxcoutD(
ObjectHandling) <<
"RooFactoryWSTool::createArg() Construct expression is " << cintExpr << endl ;
482 if (std::unique_ptr<RooAbsArg> arg{
reinterpret_cast<RooAbsArg*
>(
gROOT->ProcessLineFast(cintExpr.c_str()))}) {
483 if (
string(className)==
"RooGenericPdf") {
484 arg->setStringAttribute(
"factory_tag",
Form(
"EXPR::%s(%s)",objName,varList)) ;
485 }
else if (
string(className)==
"RooFormulaVar") {
486 arg->setStringAttribute(
"factory_tag",
Form(
"expr::%s(%s)",objName,varList)) ;
488 arg->setStringAttribute(
"factory_tag",
Form(
"%s::%s(%s)",className,objName,varList)) ;
494 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR in CINT constructor call to create object" << endl ;
515 char* tok = R__STRTOK_R(buf,
",",&save) ;
517 char* star=strchr(tok,
'*') ;
525 tok = R__STRTOK_R(0,
",",&save) ;
527 pdfList.
add(pdfList2) ;
529 }
catch (
const string &err) {
530 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooAddPdf: " << err << endl ;
535 RooAddPdf pdf{objName,objName,pdfList,coefList,recursiveCoefs};
536 pdf.setStringAttribute(
"factory_tag",
Form(
"SUM::%s(%s)",objName,specList)) ;
557 char* tok = R__STRTOK_R(buf,
",",&save) ;
559 char* star=strchr(tok,
'*') ;
567 tok = R__STRTOK_R(0,
",",&save) ;
569 amplList.
add(amplList2) ;
571 }
catch (
const string &err) {
572 coutE(
ObjectHandling) <<
"RooFactoryWSTool::add(" << objName <<
") ERROR creating RooRealSumPdf: " << err << endl ;
592 string regPdfList=
"{" ;
596 char* tok = R__STRTOK_R(buf,
",",&save) ;
598 char *
sep = strchr(tok,
'|') ;
605 bool invCond(
false) ;
613 }
catch (
const string &err) {
614 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf Conditional argument: " << err << endl ;
621 if (regPdfList.size()>1) {
626 tok = R__STRTOK_R(0,
",",&save) ;
630 std::unique_ptr<RooProdPdf> pdf;
632 pdf = std::make_unique<RooProdPdf>(objName,objName,
asSET(regPdfList.c_str()),cmdList);
633 }
catch (
const string &err) {
634 coutE(
ObjectHandling) <<
"RooFactoryWSTool::prod(" << objName <<
") ERROR creating RooProdPdf input set of regular pdfs: " << err << endl ;
640 pdf->setStringAttribute(
"factory_tag",
Form(
"PROD::%s(%s)",objName,pdfList)) ;
654 map<string,RooAbsPdf*> theMap ;
659 char* tok = R__STRTOK_R(buf,
",",&save) ;
661 char* eq = strchr(tok,
'=') ;
663 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName
664 <<
" expect mapping token of form 'state=pdfName', but found '" << tok <<
"'" << endl ;
671 theMap[tok] = &
asPDF(eq+1) ;
672 }
catch (
const string &err ) {
673 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous: " << err << endl ;
677 tok = R__STRTOK_R(0,
",",&save) ;
682 std::unique_ptr<RooSimultaneous> pdf;
684 pdf = std::make_unique<RooSimultaneous>(objName,objName,theMap,
asCATLV(indexCat)) ;
685 }
catch (
const string &err) {
686 coutE(
ObjectHandling) <<
"RooFactoryWSTool::simul(" << objName <<
") ERROR creating RooSimultaneous::" << objName <<
" " << err << endl ;
692 pdf->setStringAttribute(
"factory_tag",
Form(
"SIMUL::%s(%s,%s)",objName,indexCat,pdfMap)) ;
712 char* tok = R__STRTOK_R(buf,
",",&save) ;
714 char* star=strchr(tok,
'*') ;
722 tok = R__STRTOK_R(0,
",",&save) ;
725 }
catch (
const string &err) {
726 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: " << err << endl ;
732 coutE(
ObjectHandling) <<
"RooFactoryWSTool::addfunc(" << objName <<
") ERROR creating RooAddition: syntax error: either all sum terms must be products or none" << endl ;
738 auto sum = sumlist2.
empty() ? std::make_unique<RooAddition>(objName,objName,sumlist1)
739 : std::make_unique<RooAddition>(objName,objName,sumlist1,sumlist2);
741 sum->setStringAttribute(
"factory_tag",
Form(
"sum::%s(%s)",objName,specList)) ;
858 std::vector<char> buf(strlen(expr)+1);
861 char* buftmp = buf.data();
863 if (!isspace(*expr)) {
880 }
catch (
const string &error) {
881 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERROR in parsing: " << error << endl ;
887 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed" << endl ;
893 return out.size() ?
ws().
arg(out.c_str()) : 0 ;
912 if (
string(token).find(
"$Alias(")==0) {
938 const size_t bufBaseSize = strlen(token)+1;
939 std::vector<char> buf_base(bufBaseSize);
940 char* buf = buf_base.data();
941 strlcpy(buf,token,bufBaseSize) ;
944 list<string> singleExpr ;
947 bool litmode(
false) ;
951 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
952 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
955 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
959 if (!litmode && blevel==0 && ( (*
p)==
'=' || (*
p) ==
'|' || (*
p) ==
'*')) {
962 singleExpr.push_back(buf) ;
968 singleExpr.push_back(buf) ;
970 if (singleExpr.size()==1) {
976 list<char>::iterator ic =
separator.begin() ;
977 for (list<string>::iterator ii = singleExpr.begin() ; ii!=singleExpr.end() ; ++ii) {
1001 if (strlen(arg)==0) {
1006 if (arg[0]==
'\'' || arg[0]==
'"') {
1007 return string(arg) ;
1011 const size_t bufSize = strlen(arg)+1;
1012 std::vector<char> buf(bufSize);
1013 strlcpy(buf.data(),arg,bufSize) ;
1014 char* bufptr = buf.data();
1016 string func,prefix ;
1017 vector<string> args ;
1021 char* tmpx = R__STRTOK_R(buf.data(),
"([",&save) ;
1022 func = tmpx ? tmpx :
"" ;
1023 char*
p = R__STRTOK_R(0,
"",&save) ;
1033 bool litmode(
false) ;
1037 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1038 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1041 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1047 if (!litmode && blevel==0 && ((*
p)==
',')) {
1049 args.push_back(tok) ;
1058 if (
p>bufptr && (*(
p-1)==
')'||*(
p-1)==
']')) {
1067 p = R__STRTOK_R(0,
"",&save) ;
1069 args.push_back(tmp) ;
1077 for(
const char* pp=arg ; *pp!=0 ; pp++) {
1078 if (*pp==
'(' || *pp==
'[' || *pp==
'{') {
1084 if (strstr(func.c_str(),
"::")) {
1089 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: Class::Instance must be followed by (...)" << endl ;
1092 }
else if (func[0]!=
'$'){
1096 }
else if (lb==
'(') {
1106 static Int_t globCounter = 0 ;
1108 autoname =
Form(
"gobj%d",globCounter) ;
1110 if (!
ws().arg(autoname.c_str())) {
1114 autoname =
Form(
"%s::%s",func.c_str(),autoname.c_str()) ;
1118 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: expect either Class(...) or Instance[...]" << endl ;
1126 coutE(
ObjectHandling) <<
"RooFactoryWSTool::processSingleExpression(" << arg <<
"): ERROR: Syntax error: $MetaClass must be followed by (...)" << endl ;
1146 const size_t bufSize = strlen(arg)+1;
1147 std::vector<char> buf(bufSize);
1148 strlcpy(buf.data(),arg,bufSize) ;
1150 std::vector<string> args ;
1153 char* tok = buf.data()+1 ;
1154 char*
p = buf.data()+1 ;
1161 if (*
p==
'{' || *
p==
'(' || *
p==
'[') level++ ;
1162 if (*
p==
'}' || *
p==
')' || *
p==
']') level-- ;
1168 if (level==0 && ((*
p)==
',')) {
1170 args.push_back(tok) ;
1178 if (
p>buf.data() && *(
p-1)==
'}') {
1181 args.push_back(tok) ;
1186 vector<string>::iterator iter = args.begin() ;
1188 while(iter!= args.end()) {
1189 if (strlen(ret.c_str())>1) ret +=
"," ;
1213 if (args.size()!=2) {
1214 coutE(
ObjectHandling) <<
"RooFactorWSTool::processAliasExpression() ERROR $Alias() takes exactly two arguments, " << args.size() <<
" args found" << endl ;
1234 map<string,string>::iterator item =
_typeAliases.find(className) ;
1238 className = item->second.c_str() ;
1251 coutE(
ObjectHandling) <<
"RooFactoryWSTool::createArg() ERROR class " << className <<
" not defined in ROOT class table" << endl ;
1268 for (vector<string>::iterator iter = args.begin() ; iter!=args.end() ; ++iter) {
1269 if (iter!=args.begin()) {
1296 string first = *(args.begin()) ;
1300 vector<string>::iterator ai = args.begin() ;
1301 if (args.size()==1) {
1304 double xinit = atof((ai)->c_str()) ;
1306 RooRealVar tmp(func.c_str(),func.c_str(),xinit) ;
1312 }
else if (args.size()==2) {
1315 double xlo = atof((ai++)->c_str()) ;
1316 double xhi = atof(ai->c_str()) ;
1317 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1318 RooRealVar tmp(func.c_str(),func.c_str(),xlo,xhi) ;
1324 }
else if (args.size()==3) {
1327 double xinit = atof((ai++)->c_str()) ;
1328 double xlo = atof((ai++)->c_str()) ;
1329 double xhi = atof(ai->c_str()) ;
1330 cxcoutD(
ObjectHandling) <<
"CREATE variable " << func <<
" xinit = " << xinit <<
" xlo = " << xlo <<
" xhi = " << xhi << endl ;
1331 RooRealVar tmp(func.c_str(),func.c_str(),xinit,xlo,xhi) ;
1341 for (vector<string>::iterator ai = args.begin() ; ai!=args.end() ; ++ai) {
1342 if (allStates.size()>0) {
1370 const char *className = R__STRTOK_R(buf,
":",&save) ;
1371 const char *instName = R__STRTOK_R(0,
":",&save) ;
1372 if (!className) className =
"";
1373 if (!instName) instName =
"" ;
1378 vector<string>::iterator iter = args.begin() ;
1379 vector<string> pargv ;
1381 while(iter!=args.end()) {
1382 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1387 pargv.push_back(tmp) ;
1393 for (map<string,IFace*>::iterator ii=
hooks().begin() ; ii!=
hooks().end() ; ++ii) {
1395 if (
hooks().find(className) !=
hooks().end()) {
1397 return iface->
create(*
this, className,instName,pargv) ;
1402 return string(instName) ;
1414 vector<string>::iterator iter = args.begin() ;
1415 vector<string> pargv ;
1416 while(iter!=args.end()) {
1417 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1420 pargv.push_back(tmp) ;
1424 string ret = func+
"("+pargs+
")" ;
1436 const size_t bufSize = strlen(funcExpr)+1;
1437 std::vector<char> buf(bufSize);
1438 strlcpy(buf.data(),funcExpr,bufSize) ;
1439 char* bufptr = buf.data();
1442 vector<string> args ;
1446 char* tmpx = R__STRTOK_R(buf.data(),
"(",&save) ;
1447 func = tmpx ? tmpx :
"" ;
1448 char*
p = R__STRTOK_R(0,
"",&save) ;
1457 bool litmode(
false) ;
1461 if (*
p==
'{' || *
p==
'(' || *
p==
'[') blevel++ ;
1462 if (*
p==
'}' || *
p==
')' || *
p==
']') blevel-- ;
1465 if (*
p==
'"' || *
p==
'\'') litmode = !litmode ;
1471 if (!litmode && blevel==0 && ((*
p)==
',')) {
1473 args.push_back(tok) ;
1482 if (
p>bufptr && *(
p-1)==
')') {
1491 p = R__STRTOK_R(0,
"",&save) ;
1493 args.push_back(tmp) ;
1509 Int_t nParentheses(0), nBracket(0), nAccolade(0) ;
1510 const char* ptr = arg ;
1512 if (*ptr==
'(') nParentheses++ ;
1513 if (*ptr==
')') nParentheses-- ;
1514 if (*ptr==
'[') nBracket++ ;
1515 if (*ptr==
']') nBracket-- ;
1516 if (*ptr==
'{') nAccolade++ ;
1517 if (*ptr==
'}') nAccolade-- ;
1520 if (nParentheses!=0) {
1521 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nParentheses>0?
"(":
")") <<
"' in expression" << endl ;
1525 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nBracket>0?
"[":
"]") <<
"' in expression" << endl ;
1529 coutE(
ObjectHandling) <<
"RooFactoryWSTool::checkSyntax ERROR non-matching '" << (nAccolade>0?
"{":
"}") <<
"' in expression" << endl ;
1542 throw string(
Form(
"Need argument number %d, but only %d args are provided",idx,(
Int_t)
_of->
_args.size())) ;
1554 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1561 throw string(
Form(
"RooAbsArg named %s not found",arg)) ;
1574 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1580 throw string(
Form(
"RooAbsReal named %s not found",arg)) ;
1584 throw string(
Form(
"Object named %s is not of type RooAbsReal",arg)) ;
1597 if (arg[0]==
'.' || arg[0]==
'+' || arg[0] ==
'-' || isdigit(arg[0])) {
1598 throw string(
Form(
"Numeric literal provided for argument (%s), but lvalue is required",arg)) ;
1603 throw string(
Form(
"RooAbsRealLValue named %s not found",arg)) ;
1607 throw string(
Form(
"Object named %s is not of type RooAbsRealLValue",arg)) ;
1621 throw string(
Form(
"RooRealVar named %s not found",arg)) ;
1636 throw string(
Form(
"RooAbsPdf named %s not found",arg)) ;
1651 throw string(
Form(
"RooResolutionModel named %s not found",arg)) ;
1655 throw string(
Form(
"Object named %s is not of type RooResolutionModel",arg)) ;
1670 throw string(
Form(
"RooAbsCategory named %s not found",arg)) ;
1674 throw string(
Form(
"Object named %s is not of type RooAbsCategory",arg)) ;
1688 throw string(
Form(
"RooAbsCategoryLValue named %s not found",arg)) ;
1693 throw string(
Form(
"Object named %s is not of type RooAbsCategoryLValue",arg)) ;
1707 throw string(
Form(
"RooCategory named %s not found",arg)) ;
1738 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1743 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1745 }
else if (tok[0] ==
'\'') {
1746 tok[strlen(tok) - 1] = 0;
1754 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1757 tok = R__STRTOK_R(0,
",{}",&save) ;
1775 char* tok = R__STRTOK_R(tmp,
",{}",&save) ;
1779 if (tok[0]==
'.' || tok[0]==
'+' || tok[0] ==
'-' || isdigit(tok[0])) {
1781 }
else if (tok[0] ==
'\'') {
1782 tok[strlen(tok) - 1] = 0;
1790 throw string(
Form(
"RooAbsArg named %s not found",tok)) ;
1793 tok = R__STRTOK_R(0,
",{}",&save) ;
1808 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1822 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1826 throw string(
Form(
"Dataset named %s is not of type RooDataHist",arg)) ;
1839 throw string(
Form(
"RooAbsData named %s not found",arg)) ;
1843 throw string(
Form(
"Dataset named %s is not of type RooDataSet",arg)) ;
1856 throw string(
Form(
"Object named %s not found",arg)) ;
1868 static vector<string> cbuf(10) ;
1869 static unsigned int cbuf_idx = 0 ;
1872 if (arg==0 || strlen(arg)==0) {
1878 cbuf[cbuf_idx].clear() ;
1879 const char*
p = arg+1 ;
1880 while(*
p && (*
p) !=
'"' && (*
p) !=
'\'' ) {
1881 cbuf[cbuf_idx] += *(
p++) ;
1883 const char* ret = cbuf[cbuf_idx].c_str() ;
1887 if (cbuf_idx==cbuf.size()) cbuf_idx=0 ;
1916 hooks()[typeName] = iface ;
1926 _hooks =
new map<string,IFace*> ;
1939 vector<string>::iterator iter = args.begin() ;
1940 vector<string> pargv ;
1941 while(iter!=args.end()) {
1942 if (strlen(pargs)>0) strlcat(pargs,
",",
BUFFER_SIZE) ;
1945 pargv.push_back(tmp) ;
1950 string cl(typeName) ;
1954 ft.
add(instName,pargs,
false) ;
1956 }
else if (cl==
"RSUM") {
1959 ft.
add(instName,pargs,
true) ;
1961 }
else if (cl==
"ASUM") {
1966 }
else if (cl==
"PROD") {
1969 ft.
prod(instName,pargs) ;
1971 }
else if (cl==
"SIMUL") {
1974 if (pargv.size()>1) {
1975 ft.
simul(instName,pargv[0].c_str(),strchr(pargs,
',')+1) ;
1977 throw string(
Form(
"Need at least two arguments in call to SIMUL::%s, have %d: %s",instName,(
Int_t)pargv.size(),pargs)) ;
1980 }
else if (cl==
"EXPR") {
1983 if (args.size()<=2) {
1984 ft.
createArg(
"RooGenericPdf",instName,pargs) ;
1989 for (
UInt_t i=1 ; i<args.size() ; i++) {
1994 ft.
createArg(
"RooGenericPdf",instName,genargs) ;
1997 }
else if (cl==
"FCONV") {
2000 ft.
createArg(
"RooFFTConvPdf",instName,pargs) ;
2002 }
else if (cl==
"NCONV") {
2005 ft.
createArg(
"RooNumConvPdf",instName,pargs) ;
2007 }
else if (cl==
"sum") {
2012 }
else if (cl==
"prod") {
2017 }
else if (cl==
"expr") {
2020 if (args.size()<=2) {
2021 ft.
createArg(
"RooFormulaVar",instName,pargs) ;
2026 for (
UInt_t i=1 ; i<args.size() ; i++) {
2031 ft.
createArg(
"RooFormulaVar",instName,genargs) ;
2034 }
else if (cl ==
"taylorexpand") {
2038 double eps1(1
e-6), eps2(1
e-3), observablesValue(0.0);
2040 if (pargv.size() < 2)
2041 throw string(
Form(
"taylorexpand::%s, requires atleast 2 arguments (function, observables) atleast, has %d arguments", instName, (
Int_t)pargv.size()));
2046 if (pargv.size() > 3)
2047 order = atoi(pargv[3].c_str());
2048 if (pargv.size() > 2) {
2049 if (pargv[2].find(
",") != string::npos)
2050 throw string(
Form(
"taylorexpand::%s, factory syntax supports expansion only around same value for all observables", instName));
2051 else observablesValue = atof(pargv[2].c_str());
2054 if (pargv.size() > 3)
2055 order = atoi(pargv[3].c_str());
2056 if (pargv.size() > 4)
2057 eps1 = atof(pargv[4].c_str());
2058 if (pargv.size() > 5)
2059 eps2 = atof(pargv[5].c_str());
2061 if (pargv.size() > 6)
2063 Form(
"taylorexpand::%s, requires max. 6 arguments, has %d arguments", instName, (
Int_t)pargv.size()));
2068 }
else if (cl==
"nconv") {
2071 ft.
createArg(
"RooNumConvolution",instName,pargs) ;
2073 }
else if (cl==
"nll") {
2079 }
else if (cl==
"chi2") {
2085 }
else if (cl==
"profile") {
2088 ft.
createArg(
"RooProfileLL",instName,pargs) ;
2090 }
else if (cl==
"dataobs") {
2093 std::unique_ptr<RooAbsArg> funcClone{
static_cast<RooAbsArg*
>(ft.
asARG(pargv[1].c_str()).
clone(instName))};
2099 }
else if (cl==
"int") {
2106 if (pargv.size()<2 || pargv.size()>3) {
2107 throw string(
Form(
"int::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2113 strlcpy(buf,pargv[1].c_str(),256) ;
2115 const char* intobs = R__STRTOK_R(buf,
"|",&save) ;
2116 if (!intobs) intobs=
"" ;
2118 const char* range = R__STRTOK_R(0,
"",&save) ;
2119 if (!range) range=
"" ;
2121 std::unique_ptr<RooAbsReal> integral;
2122 if (pargv.size()==2) {
2123 if (range && strlen(range)) {
2129 if (range && strlen(range)) {
2136 integral->SetName(instName) ;
2139 }
else if (cl==
"deriv") {
2143 if (pargv.size()<2 || pargv.size()>3) {
2144 throw string(
Form(
"deriv::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2149 std::unique_ptr<RooAbsReal> derivative;
2150 if (pargv.size()==2) {
2156 derivative->
SetName(instName) ;
2159 }
else if (cl==
"cdf") {
2163 if (pargv.size()<2 || pargv.size()>3) {
2164 throw string(
Form(
"cdf::%s, requires 2 or 3 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2169 std::unique_ptr<RooAbsReal> cdf;
2170 if (pargv.size()==2) {
2180 }
else if (cl==
"PROJ") {
2183 if (pargv.size()!=2) {
2184 throw string(
Form(
"PROJ::%s, requires 2 arguments, have %d arguments",instName,(
Int_t)pargv.size())) ;
2189 projection->
SetName(instName) ;
2193 }
else if (cl==
"set") {
2198 return string(instName) ;
2203 throw string(
Form(
"RooFactoryWSTool::SpecialsIFace::create() ERROR: Unknown meta-type %s",typeName)) ;
2206 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'.
virtual TObject * clone(const char *newname=nullptr) const =0
void SetName(const char *name) override
Set the name of the TNamed.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
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.
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 std::liste...
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, double 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=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.
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 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 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.
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...
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)
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)