12 #if __cplusplus >= 201103L 13 #define ROOT_CPLUSPLUS11 1 30 #include <unordered_map> 36 #pragma optimize("",off) 215 static std::unordered_map<std::string, void *>
gClingFunctions = std::unordered_map<std::string, void * >();
221 const static std::set<char> ops {
'+',
'^',
'-',
'/',
'*',
'<',
'>',
'|',
'&',
'!',
'=',
'?',
'%'};
222 return ops.end() != ops.find(c);
229 char brackets[] = {
')',
'(',
'{',
'}'};
230 Int_t bracketsLen =
sizeof(brackets)/
sizeof(
char);
231 for(
Int_t i = 0; i < bracketsLen; ++i)
240 return !IsBracket(c) && !IsOperator(c) && c !=
',' && c !=
' ';
246 return name ==
"x" || name ==
"z" || name ==
"y" || name ==
"t";
253 if ( (formula[i] ==
'e' || formula[i] ==
'E') && (i > 0 && i < formula.Length()-1) ) {
255 if ( (isdigit(formula[i-1]) || formula[i-1] ==
'.') && ( isdigit(formula[i+1]) || formula[i+1] ==
'+' || formula[i+1] ==
'-' ) )
265 if ( (formula[i] ==
'x' || formula[i] ==
'X') && (i > 0 && i < formula.Length()-1) && formula[i-1] ==
'0') {
266 if (isdigit(formula[i+1]) )
268 static char hex_values[12] = {
'a',
'A',
'b',
'B',
'c',
'C',
'd',
'D',
'e',
'E',
'f',
'F'};
269 for (
int jjj = 0; jjj < 12; ++jjj) {
270 if (formula[i+1] == hex_values[jjj])
287 Bool_t foundOpenParenthesis =
false;
288 if (pos == 0 || pos == formula.Length()-1)
return false;
289 for (
int i = pos-1; i >=0; i--) {
290 if (formula[i] ==
']' )
return false;
291 if (formula[i] ==
'[' ) {
292 foundOpenParenthesis =
true;
296 if (!foundOpenParenthesis )
return false;
299 for (
int i = pos+1; i < formula.Length(); i++) {
300 if (formula[i] ==
']' )
return true;
313 TRegexp numericPattern(
"p?[0-9]+");
316 int patternStart = numericPattern.
Index(a, len);
317 bool aNumeric = (patternStart == 0 && *len == a.Length());
319 patternStart = numericPattern.
Index(b, len);
320 bool bNumeric = (patternStart == 0 && *len == b.Length());
324 if (aNumeric && !bNumeric)
326 else if (!aNumeric && bNumeric)
328 else if (!aNumeric && !bNumeric)
331 int aInt = (a[0] ==
'p') ? TString(
a(1, a.Length())).Atoi() : a.Atoi();
332 int bInt = (b[0] ==
'p') ? TString(
b(1, b.Length())).Atoi() : b.Atoi();
343 for (
int i = 0; i < formula.Length(); i++) {
346 if (isalpha(formula[i]) || formula[i] ==
'{' || formula[i] ==
'[') {
349 j < formula.Length() && (IsFunctionNameChar(formula[j])
350 || (formula[i] ==
'{' && formula[j] ==
'}'));
353 TString
name = (TString)formula(i, j - i);
358 if (substitutions.find(name) != substitutions.end()) {
359 formula.Replace(i, name.Length(),
"(" + substitutions[
name] +
")");
360 i += substitutions[
name].Length() + 2 - 1;
362 }
else if (isalpha(formula[i])) {
365 i += name.Length() - 1;
377 fReadyToExecute =
false;
378 fClingInitialized =
false;
379 fAllParametersSetted =
false;
386 fLambdaPtr =
nullptr;
391 if (strlen(name)!=1)
return false;
392 for (
auto const & specialName : {
"x",
"y",
"z",
"t"}){
393 if (strcmp(name,specialName)==0)
return true;
406 gROOT->GetListOfFunctions()->Remove(
this);
412 int nLinParts = fLinearParts.size();
414 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
421 fClingInput(formula),fFormula(formula)
432 #ifndef R__HAS_VECCORE 439 if (addToGlobList &&
gROOT) {
442 old =
dynamic_cast<TFormula*
> (
gROOT->GetListOfFunctions()->FindObject(name) );
444 gROOT->GetListOfFunctions()->Remove(old);
446 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",name);
448 gROOT->GetListOfFunctions()->Add(
this);
480 for (
int i = 0; i < npar; ++i) {
484 assert (
fNpar == npar);
494 if (addToGlobList &&
gROOT) {
497 old =
dynamic_cast<TFormula*
> (
gROOT->GetListOfFunctions()->FindObject(name) );
499 gROOT->GetListOfFunctions()->Remove(old);
501 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",name);
503 gROOT->GetListOfFunctions()->Add(
this);
508 Error(
"TFormula",
"Syntax error in building the lambda expression %s", formula );
521 gROOT->GetListOfFunctions()->Remove(old);
524 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",formula.
GetName());
526 gROOT->GetListOfFunctions()->Add(
this);
546 std::string lambdaExpression = formula;
552 auto funcit = gClingFunctions.find(lambdaExpression);
553 if (funcit != gClingFunctions.end() ) {
565 auto hasher = gClingFunctions.hash_function();
566 TString lambdaName =
TString::Format(
"lambda__id%zu", hasher(lambdaExpression) );
570 TString lineExpr =
TString::Format(
"std::function<double(double*,double*)> %s = %s ;",lambdaName.Data(), lambdaExpression.c_str() );
575 gClingFunctions.insert ( std::make_pair ( lambdaExpression,
fLambdaPtr) );
591 TString formula = expression;
592 if (formula.IsNull() ) {
594 if (formula.IsNull() ) formula =
GetTitle();
597 if (formula.IsNull() )
return -1;
609 return (ret) ? 0 : 1;
619 return (ret) ? 0 : 1;
648 for (
int i = 0; i < nLinParts; ++i)
delete fnew.
fLinearParts[i];
655 for (
int i = 0; i < nLinParts; ++i) {
659 linearOld->
Copy(*linearNew);
682 Error(
"TFormula",
"Syntax error in building the lambda expression %s",
fFormula.Data() );
727 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
745 TString prototypeArguments =
"";
746 if (hasVariables || hasParameters) {
748 prototypeArguments.Append(
"ROOT::Double_v*");
750 prototypeArguments.Append(
"Double_t*");
753 prototypeArguments.Append(
",");
756 prototypeArguments.Append(
"Double_t*");
761 Error(
"PrepareEvalMethod",
"Can't compile function %s prototype with arguments %s",
fClingName.Data(),
762 prototypeArguments.Data());
785 Error(
"PrepareEvalMethod",
"Callfunc retuned from Cling is not valid");
791 Error(
"PrepareEvalMethod",
"Compiled function pointer is null");
823 const TString defvars[] = {
"x",
"y",
"z",
"t"};
824 const pair<TString, Double_t> defconsts[] = {{
"pi",
TMath::Pi()},
842 const pair<TString,TString> funShortcuts[] =
843 { {
"sin",
"TMath::Sin" },
844 {
"cos",
"TMath::Cos" }, {
"exp",
"TMath::Exp"}, {
"log",
"TMath::Log"}, {
"log10",
"TMath::Log10"},
845 {
"tan",
"TMath::Tan"}, {
"sinh",
"TMath::SinH"}, {
"cosh",
"TMath::CosH"},
846 {
"tanh",
"TMath::TanH"}, {
"asin",
"TMath::ASin"}, {
"acos",
"TMath::ACos"},
847 {
"atan",
"TMath::ATan"}, {
"atan2",
"TMath::ATan2"}, {
"sqrt",
"TMath::Sqrt"},
848 {
"ceil",
"TMath::Ceil"}, {
"floor",
"TMath::Floor"}, {
"pow",
"TMath::Power"},
849 {
"binomial",
"TMath::Binomial"},{
"abs",
"TMath::Abs"},
850 {
"min",
"TMath::Min"},{
"max",
"TMath::Max"},{
"sign",
"TMath::Sign" },
854 std::vector<TString> defvars2(10);
855 for (
int i = 0; i < 9; ++i)
858 for (
const auto &var : defvars) {
859 int pos =
fVars.size();
872 for (
auto con : defconsts) {
873 fConsts[con.first] = con.second;
878 for (
auto fun : funShortcuts) {
890 #ifdef R__HAS_VECCORE 891 const pair<TString,TString> vecFunShortcuts[] =
892 { {
"sin",
"vecCore::math::Sin" },
893 {
"cos",
"vecCore::math::Cos" }, {
"exp",
"vecCore::math::Exp"}, {
"log",
"vecCore::math::Log"}, {
"log10",
"vecCore::math::Log10"},
894 {
"tan",
"vecCore::math::Tan"},
896 {
"asin",
"vecCore::math::ASin"},
897 {
"acos",
"TMath::Pi()/2-vecCore::math::ASin"},
898 {
"atan",
"vecCore::math::ATan"},
899 {
"atan2",
"vecCore::math::ATan2"}, {
"sqrt",
"vecCore::math::Sqrt"},
900 {
"ceil",
"vecCore::math::Ceil"}, {
"floor",
"vecCore::math::Floor"}, {
"pow",
"vecCore::math::Pow"},
901 {
"cbrt",
"vecCore::math::Cbrt"},{
"abs",
"vecCore::math::Abs"},
902 {
"min",
"vecCore::math::Min"},{
"max",
"vecCore::math::Max"},{
"sign",
"vecCore::math::Sign" }
906 for (
auto fun : vecFunShortcuts) {
923 Int_t polPos = formula.Index(
"pol");
926 Bool_t defaultVariable =
false;
928 Int_t openingBracketPos = formula.Index(
'(', polPos);
929 Bool_t defaultCounter = openingBracketPos ==
kNPOS;
930 Bool_t defaultDegree =
true;
933 if (!defaultCounter) {
936 sdegree = formula(polPos + 3, openingBracketPos - polPos - 3);
937 if (!sdegree.IsDigit())
938 defaultCounter =
true;
940 if (!defaultCounter) {
941 degree = sdegree.Atoi();
942 counter = TString(formula(openingBracketPos + 1, formula.Index(
')', polPos) - openingBracketPos)).Atoi();
944 Int_t temp = polPos + 3;
945 while (temp < formula.Length() && isdigit(formula[temp])) {
946 defaultDegree =
false;
949 degree = TString(formula(polPos + 3, temp - polPos - 3)).Atoi();
954 if (polPos - 1 < 0 || !
IsFunctionNameChar(formula[polPos - 1]) || formula[polPos - 1] ==
':') {
956 defaultVariable =
true;
958 Int_t tmp = polPos - 1;
962 variable = formula(tmp + 1, polPos - (tmp + 1));
964 Int_t param = counter + 1;
966 while (tmp <= degree) {
968 replacement.Append(
TString::Format(
"+[%d]*%s^%d", param, variable.Data(), tmp));
970 replacement.Append(
TString::Format(
"+[%d]*%s", param, variable.Data()));
976 replacement.Insert(0,
'(');
977 replacement.Append(
')');
980 if (defaultCounter && !defaultDegree) {
981 pattern =
TString::Format(
"%spol%d", (defaultVariable ?
"" : variable.Data()), degree);
982 }
else if (defaultCounter && defaultDegree) {
983 pattern =
TString::Format(
"%spol", (defaultVariable ?
"" : variable.Data()));
985 pattern =
TString::Format(
"%spol%d(%d)", (defaultVariable ?
"" : variable.Data()), degree, counter);
988 if (!formula.Contains(pattern)) {
989 Error(
"HandlePolN",
"Error handling polynomial function - expression is %s - trying to replace %s with %s ",
990 formula.Data(), pattern.Data(), replacement.Data());
993 if (formula == pattern) {
998 formula.ReplaceAll(pattern, replacement);
999 polPos = formula.Index(
"pol");
1025 map< pair<TString,Int_t> ,pair<TString,TString> > functions;
1028 map<TString,Int_t> functionsNumbers;
1029 functionsNumbers[
"gaus"] = 100;
1030 functionsNumbers[
"bigaus"] = 102;
1031 functionsNumbers[
"landau"] = 400;
1032 functionsNumbers[
"expo"] = 200;
1033 functionsNumbers[
"crystalball"] = 500;
1036 formula.ReplaceAll(
"xyzgaus",
"gaus[x,y,z]");
1037 formula.ReplaceAll(
"xygaus",
"gaus[x,y]");
1038 formula.ReplaceAll(
"xgaus",
"gaus[x]");
1039 formula.ReplaceAll(
"ygaus",
"gaus[y]");
1040 formula.ReplaceAll(
"zgaus",
"gaus[z]");
1041 formula.ReplaceAll(
"xexpo",
"expo[x]");
1042 formula.ReplaceAll(
"yexpo",
"expo[y]");
1043 formula.ReplaceAll(
"zexpo",
"expo[z]");
1044 formula.ReplaceAll(
"xylandau",
"landau[x,y]");
1045 formula.ReplaceAll(
"xyexpo",
"expo[x,y]");
1047 const char * defaultVariableNames[] = {
"x",
"y",
"z"};
1049 for (map<pair<TString, Int_t>, pair<TString, TString>>::iterator it = functions.begin(); it != functions.end();
1052 TString funName = it->first.first;
1053 Int_t funDim = it->first.second;
1054 Int_t funPos = formula.Index(funName);
1060 Int_t lastFunPos = funPos + funName.Length();
1063 Int_t iposBefore = funPos - 1;
1066 if (iposBefore >= 0) {
1067 assert(iposBefore < formula.Length());
1068 if (isalpha(formula[iposBefore])) {
1071 funPos = formula.Index(funName, lastFunPos);
1076 Bool_t isNormalized =
false;
1077 if (lastFunPos < formula.Length()) {
1079 isNormalized = (formula[lastFunPos] ==
'n');
1082 if (lastFunPos < formula.Length()) {
1083 char c = formula[lastFunPos];
1086 if (isalnum(c) || (!
IsOperator(c) && c !=
'(' && c !=
')' && c !=
'[' && c !=
']')) {
1088 funPos = formula.Index(funName, lastFunPos);
1099 TString varList =
"";
1100 Bool_t defaultVariables =
false;
1103 Int_t openingBracketPos = funPos + funName.Length() + (isNormalized ? 1 : 0);
1105 if (openingBracketPos > formula.Length() || formula[openingBracketPos] !=
'[') {
1107 variables.resize(dim);
1108 for (
Int_t idim = 0; idim < dim; ++idim)
1109 variables[idim] = defaultVariableNames[idim];
1110 defaultVariables =
true;
1113 closingBracketPos = formula.Index(
']', openingBracketPos);
1114 varList = formula(openingBracketPos + 1, closingBracketPos - openingBracketPos - 1);
1115 dim = varList.CountChar(
',') + 1;
1116 variables.resize(dim);
1118 TString varName =
"";
1119 for (
Int_t i = 0; i < varList.Length(); ++i) {
1121 varName.Append(varList[i]);
1123 if (varList[i] ==
',') {
1124 variables[Nvar] = varName;
1131 variables[Nvar] = varName;
1136 if (dim != funDim) {
1137 pair<TString, Int_t> key = make_pair(funName, dim);
1138 if (functions.find(key) == functions.end()) {
1139 Error(
"PreProcessFormula",
"Dimension of function %s is detected to be of dimension %d and is not " 1140 "compatible with existing pre-defined function which has dim %d",
1141 funName.Data(), dim, funDim);
1145 funPos = formula.Index(funName, lastFunPos);
1150 Int_t openingParenthesisPos = (closingBracketPos ==
kNPOS) ? openingBracketPos : closingBracketPos + 1;
1151 bool defaultCounter = (openingParenthesisPos > formula.Length() || formula[openingParenthesisPos] !=
'(');
1156 if (defaultCounter) {
1162 TRegexp counterPattern(
"([0-9]+)");
1164 if (counterPattern.
Index(formula, len, openingParenthesisPos) == -1) {
1165 funPos = formula.Index(funName, funPos + 1);
1169 TString(formula(openingParenthesisPos + 1, formula.Index(
')', funPos) - openingParenthesisPos - 1))
1175 TString body = (isNormalized ? it->second.second : it->second.first);
1176 if (isNormalized && body ==
"") {
1177 Error(
"PreprocessFormula",
"%d dimension function %s has no normalized form.", it->first.second,
1181 for (
int i = 0; i < body.Length(); ++i) {
1182 if (body[i] ==
'{') {
1185 Int_t num = TString(body(i, body.Index(
'}', i) - i)).Atoi();
1186 TString variable = variables[num];
1189 body.Replace(i, pattern.Length(), variable, variable.Length());
1190 i += variable.Length() - 1;
1191 }
else if (body[i] ==
'[') {
1194 while (tmp < body.Length() && body[tmp] !=
']') {
1197 Int_t num = TString(body(i + 1, tmp - 1 - i)).Atoi();
1201 body.Replace(i + 1, tmp - 1 - i, replacement, replacement.Length());
1202 i += replacement.Length() + 1;
1206 if (defaultCounter && defaultVariables) {
1207 pattern =
TString::Format(
"%s%s", funName.Data(), (isNormalized ?
"n" :
""));
1209 if (!defaultCounter && defaultVariables) {
1210 pattern =
TString::Format(
"%s%s(%d)", funName.Data(), (isNormalized ?
"n" :
""), counter);
1212 if (defaultCounter && !defaultVariables) {
1213 pattern =
TString::Format(
"%s%s[%s]", funName.Data(), (isNormalized ?
"n" :
""), varList.Data());
1215 if (!defaultCounter && !defaultVariables) {
1217 TString::Format(
"%s%s[%s](%d)", funName.Data(), (isNormalized ?
"n" :
""), varList.Data(), counter);
1219 TString replacement = body;
1222 if (
fNumber == 0 && formula.Length() <= (pattern.Length() - funPos) + 1) {
1223 fNumber = functionsNumbers[funName] + 10 * (dim - 1);
1228 formula.Replace(funPos, pattern.Length(), replacement, replacement.Length());
1230 funPos = formula.Index(funName);
1240 TRegexp rangePattern(
"\\[[0-9]+\\.\\.[0-9]+\\]");
1243 while ((matchIdx = rangePattern.
Index(formula, len, matchIdx)) != -1) {
1244 int startIdx = matchIdx + 1;
1245 int endIdx = formula.Index(
"..", startIdx) + 2;
1246 int startCnt = TString(formula(startIdx, formula.Length())).Atoi();
1247 int endCnt = TString(formula(endIdx, formula.Length())).Atoi();
1249 if (endCnt <= startCnt)
1250 Error(
"HandleParamRanges",
"End parameter (%d) <= start parameter (%d) in parameter range", endCnt, startCnt);
1252 TString newString =
"[";
1253 for (
int cnt = startCnt;
cnt < endCnt;
cnt++)
1258 formula.Replace(matchIdx, formula.Index(
"]", matchIdx) + 1 - matchIdx, newString);
1260 matchIdx += newString.Length();
1274 std::map<std::pair<TString, Int_t>, std::pair<TString, TString>> parFunctions;
1278 for (
Int_t i = 0; i < formula.Length(); ++i) {
1282 if (formula[i] ==
'[') {
1283 while (formula[i] !=
']')
1288 if (formula[i] ==
'\"') {
1291 while (formula[i] !=
'\"');
1299 while (!
IsOperator(formula[i]) && i < formula.Length())
1305 if (isalpha(formula[i]) && !
IsOperator(formula[i])) {
1311 TString
name = (TString)formula(i, j - i);
1318 std::vector<int> argSeparators;
1319 argSeparators.push_back(j);
1321 for (k = j + 1; depth >= 1 && k < formula.Length(); k++) {
1322 if (formula[k] ==
',' && depth == 1) {
1324 argSeparators.push_back(k);
1325 }
else if (formula[k] ==
'(')
1327 else if (formula[k] ==
')')
1330 argSeparators.push_back(k - 1);
1336 obj =
gROOT->GetListOfFunctions()->FindObject(name);
1341 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1349 bool nameRecognized = (f != NULL);
1354 TString replacementFormula;
1362 for (
auto keyval : parFunctions) {
1364 pair<TString, Int_t> name_ndim = keyval.first;
1366 pair<TString, TString> formulaPair = keyval.second;
1369 if (name == name_ndim.first)
1370 replacementFormula = formulaPair.first;
1371 else if (name == name_ndim.first +
"n" && formulaPair.second !=
"")
1372 replacementFormula = formulaPair.second;
1377 ndim = name_ndim.second;
1382 while ((idx = replacementFormula.Index(
'[', idx)) !=
kNPOS) {
1383 npar = max(npar, 1 + TString(replacementFormula(idx + 1, replacementFormula.Length())).Atoi());
1384 idx = replacementFormula.Index(
']', idx);
1386 Error(
"HandleFunctionArguments",
"Square brackets not matching in formula %s",
1387 (
const char *)replacementFormula);
1394 if (nArguments == ndim + npar || nArguments == npar || nArguments == ndim) {
1395 nameRecognized =
true;
1400 if (nameRecognized && ndim > 4)
1401 Error(
"HandleFunctionArguments",
"Number of dimensions %d greater than 4. Cannot parse formula.", ndim);
1404 if (nameRecognized && j < formula.Length() && formula[j] ==
'(') {
1409 map<TString, TString> argSubstitutions;
1411 const char *defaultVariableNames[] = {
"x",
"y",
"z",
"t"};
1414 bool canReplace =
false;
1415 if (nArguments == ndim + npar) {
1417 for (
int argNr = 0; argNr < nArguments; argNr++) {
1421 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1428 argSubstitutions[oldName] = newName;
1431 argSubstitutions[defaultVariableNames[argNr]] = newName;
1434 int parNr = argNr - ndim;
1437 argSubstitutions[oldName] = newName;
1440 if (f && oldName == newName)
1446 }
else if (nArguments == npar) {
1451 bool varsImplicit =
true;
1452 for (
int argNr = 0; argNr < nArguments && varsImplicit; argNr++) {
1453 int openIdx = argSeparators[argNr] + 1;
1454 int closeIdx = argSeparators[argNr + 1] - 1;
1457 if (formula[openIdx] !=
'[' || formula[closeIdx] !=
']' || closeIdx <= openIdx + 1)
1458 varsImplicit =
false;
1461 for (
int idx = openIdx + 1; idx < closeIdx && varsImplicit; idx++)
1463 varsImplicit =
false;
1466 Warning(
"HandleFunctionArguments",
1467 "Argument %d is not a parameter. Cannot assume variables are implicit.", argNr);
1474 for (
int dim = 0; dim < ndim; dim++) {
1475 argSubstitutions[
TString::Format(
"{V%d}", dim)] = defaultVariableNames[dim];
1479 for (
int argNr = 0; argNr < nArguments; argNr++) {
1483 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1487 argSubstitutions[oldName] = newName;
1490 if (f && oldName == newName)
1497 if (!canReplace && nArguments == ndim) {
1501 for (
int argNr = 0; argNr < nArguments; argNr++) {
1504 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1508 argSubstitutions[oldName] = newName;
1511 argSubstitutions[defaultVariableNames[argNr]] = newName;
1516 for (
int parNr = 0; parNr < npar; parNr++)
1530 formula.Replace(i, k - i, replacementFormula);
1531 i += replacementFormula.Length() - 1;
1534 Warning(
"HandleFunctionArguments",
"Unable to make replacement. Number of parameters doesn't work : " 1535 "%d arguments, %d dimensions, %d parameters",
1536 nArguments, ndim, npar);
1555 Int_t caretPos = formula.Last(
'^');
1558 TString right, left;
1559 Int_t temp = caretPos;
1562 if (formula[temp] ==
')') {
1565 while (depth != 0 && temp > 0) {
1566 if (formula[temp] ==
')')
1568 if (formula[temp] ==
'(')
1583 assert(temp + 1 >= 0);
1584 Int_t leftPos = temp + 1;
1585 left = formula(leftPos, caretPos - leftPos);
1591 if (temp >= formula.Length()) {
1592 Error(
"HandleExponentiation",
"Invalid position of operator ^");
1595 if (formula[temp] ==
'(') {
1598 while (depth != 0 && temp < formula.Length()) {
1599 if (formula[temp] ==
')')
1601 if (formula[temp] ==
'(')
1608 if (formula[temp] ==
'-' || formula[temp] ==
'+')
1614 while (temp < formula.Length() && ((depth > 0) || !
IsOperator(formula[temp]))) {
1620 if (temp < formula.Length() && formula[temp] ==
'(')
1622 if (temp < formula.Length() && formula[temp] ==
')') {
1630 right = formula(caretPos + 1, (temp - 1) - caretPos);
1633 TString pattern =
TString::Format(
"%s^%s", left.Data(), right.Data());
1634 TString replacement =
TString::Format(
"pow(%s,%s)", left.Data(), right.Data());
1638 formula.Replace(leftPos, pattern.Length(), replacement, replacement.Length());
1640 caretPos = formula.Last(
'^');
1650 Int_t linPos = formula.Index(
"@");
1651 if (linPos ==
kNPOS )
return;
1652 Int_t nofLinParts = formula.CountChar((
int)
'@');
1653 assert(nofLinParts > 0);
1664 while (temp >= 0 && formula[temp] !=
'@') {
1667 left = formula(temp + 1, linPos - (temp + 1));
1670 while (temp < formula.Length() && formula[temp] !=
'@') {
1673 TString right = formula(linPos + 1, temp - (linPos + 1));
1677 TString replacement =
1678 (first) ?
TString::Format(
"([%d]*(%s))+([%d]*(%s))", Nlinear, left.Data(), Nlinear + 1, right.Data())
1680 Nlinear += (first) ? 2 : 1;
1682 formula.ReplaceAll(pattern, replacement);
1690 linPos = formula.Index(
"@");
1704 formula.ReplaceAll(
"**",
"^");
1705 formula.ReplaceAll(
"++",
"@");
1706 formula.ReplaceAll(
" ",
"");
1716 formula.ReplaceAll(
"--",
"- -");
1717 formula.ReplaceAll(
"++",
"+ +");
1770 for (
Int_t i = 0; i < formula.Length(); ++i) {
1774 if (formula[i] ==
'[') {
1778 while (i < formula.Length() && formula[i] !=
']') {
1779 param.Append(formula[i++]);
1784 int paramIndex = -1;
1785 if (param.IsDigit()) {
1786 paramIndex = param.Atoi();
1787 param.Insert(0,
'p');
1790 for (
int idx = 0; idx <= paramIndex; ++idx) {
1798 param.ReplaceAll(
"\\s",
" ");
1810 formula.Replace(tmp, i - tmp, replacement, replacement.Length());
1814 int deltai = replacement.Length() - (i-tmp);
1820 if (formula[i] ==
'\"') {
1824 }
while (formula[i] !=
'\"');
1833 while (!
IsOperator(formula[i]) && i < formula.Length()) {
1842 if (isalpha(formula[i]) &&
1850 if (formula[i] ==
':' && ((i + 1) < formula.Length())) {
1851 if (formula[i + 1] ==
':') {
1860 name.Append(formula[i++]);
1863 if (formula[i] ==
'(') {
1865 if (formula[i] ==
')') {
1872 while (depth != 0 && i < formula.Length()) {
1873 switch (formula[i]) {
1874 case '(': depth++;
break;
1875 case ')': depth--;
break;
1883 body.Append(formula[i++]);
1886 Int_t originalBodyLen = body.Length();
1888 formula.Replace(i - originalBodyLen, originalBodyLen, body, body.Length());
1889 i += body.Length() - originalBodyLen;
1902 obj =
gROOT->GetListOfFunctions()->FindObject(name);
1907 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1930 std::vector<TString> newNames;
1933 newNames.resize(f->
GetNpar());
1935 for (
int jpar = f->
GetNpar() - 1; jpar >= 0; --jpar) {
1938 if (pj[0] ==
'p' && TString(pj(1, pj.Length())).IsDigit()) {
1943 replacementFormula.ReplaceAll(oldName, newName);
1944 newNames[jpar] = newName;
1954 for (
int jpar = 0; jpar < f->
GetNpar(); ++jpar) {
1955 if (nparOffset > 0) {
1957 assert((
int)newNames.size() == f->
GetNpar());
1964 replacementFormula.Insert(0,
'(');
1965 replacementFormula.Insert(replacementFormula.Length(),
')');
1966 formula.Replace(i - name.Length(), name.Length(), replacementFormula, replacementFormula.Length());
1968 i += replacementFormula.Length() - name.Length();
1980 formula.Replace(i - name.Length(), name.Length(), replacement, replacement.Length());
2012 for (list<TFormulaFunction>::iterator funcsIt =
fFuncs.begin(); funcsIt !=
fFuncs.end(); ++funcsIt) {
2023 TString shortcut = it->first;
2024 TString full = it->second;
2028 Ssiz_t index = formula.Index(shortcut, 0);
2029 while (index !=
kNPOS) {
2032 Ssiz_t i2 = index + shortcut.Length();
2033 if ((index > 0) && (isalpha(formula[index - 1]) || formula[index - 1] ==
':')) {
2034 index = formula.Index(shortcut, i2);
2037 if (i2 < formula.Length() && formula[i2] !=
'(') {
2038 index = formula.Index(shortcut, i2);
2042 formula.Replace(index, shortcut.Length(), full);
2043 Ssiz_t inext = index + full.Length();
2044 index = formula.Index(shortcut, inext);
2051 #ifdef TFORMULA_CHECK_FUNCTIONS 2053 if (fun.
fName.Contains(
"::"))
2057 size_t index =
name.rfind(
"::");
2058 assert(index != std::string::npos);
2059 TString className = fun.
fName(0, fun.
fName(0, index).Length());
2060 TString functionName = fun.
fName(index + 2, fun.
fName.Length());
2066 TIter next(methodList);
2068 while ((p = (
TMethod *)next())) {
2069 if (strcmp(p->
GetName(), functionName.Data()) == 0 &&
2092 Info(
"TFormula",
"Could not find %s function with %d argument(s)", fun.
GetName(), fun.
GetNargs());
2110 formula.ReplaceAll(pattern, replacement);
2115 map<TString, TFormulaVariable>::iterator varsIt =
fVars.find(fun.
GetName());
2116 if (varsIt !=
fVars.end()) {
2118 TString
name = (*varsIt).second.GetName();
2119 Double_t value = (*varsIt).second.fValue;
2122 if (!
fVars[name].fFound) {
2125 int varDim = (*varsIt).second.fArrayPos;
2126 if (varDim >=
fNdim) {
2131 if (
v.second.fArrayPos < varDim && !
v.second.fFound) {
2133 v.second.fFound =
true;
2140 TString replacement =
TString::Format(
"x[%d]", (*varsIt).second.fArrayPos);
2141 formula.ReplaceAll(pattern, replacement);
2151 TString funname = fun.
GetName();
2152 if (funname.Contains(
"x[") && funname.Contains(
"]")) {
2153 TString sdigit = funname(2, funname.Index(
"]"));
2154 int digit = sdigit.Atoi();
2155 if (digit >=
fNdim) {
2158 for (
int j = 0; j <
fNdim; ++j) {
2162 fVars[vname].fFound =
true;
2171 formula.ReplaceAll(pattern, funname);
2177 if (paramsIt !=
fParams.end()) {
2181 if (formula.Index(pattern) !=
kNPOS) {
2185 formula.ReplaceAll(pattern, replacement);
2194 map<TString, Double_t>::iterator constIt =
fConsts.find(fun.
GetName());
2195 if (constIt !=
fConsts.end()) {
2198 formula.ReplaceAll(pattern, value);
2214 if (!hasParameters) {
2227 Bool_t inputIntoCling = (formula.Length() > 0);
2228 if (inputIntoCling) {
2231 std::string inputFormula(formula.Data());
2235 std::string inputFormulaVecFlag = inputFormula;
2237 inputFormulaVecFlag +=
" (vectorized)";
2239 TString argType =
fVectorized ?
"ROOT::Double_v" :
"Double_t";
2242 TString argumentsPrototype =
TString::Format(
"%s%s%s", ( (hasVariables || hasParameters) ? (argType +
" *x").Data() :
""),
2243 (hasParameters ?
"," :
""), (hasParameters ?
"Double_t *p" :
""));
2255 auto funcit = gClingFunctions.find(inputFormulaVecFlag);
2257 if (funcit != gClingFunctions.end()) {
2260 inputIntoCling =
false;
2266 auto hasher = gClingFunctions.hash_function();
2270 argumentsPrototype.Data(), inputFormula.c_str());
2289 if (inputIntoCling) {
2296 gClingFunctions.insert(std::make_pair(inputFormulaVecFlag, (
void *)
fFuncPtr));
2315 for (list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
2317 if (!it->fFound && !it->IsFuncCall()) {
2319 if (it->GetNargs() == 0)
2320 Error(
"ProcessFormula",
"\"%s\" has not been matched in the formula expression", it->GetName());
2322 Error(
"ProcessFormula",
"Could not find %s function with %d argument(s)", it->GetName(), it->GetNargs());
2333 auto itvar =
fVars.begin();
2336 if (!itvar->second.fFound) {
2338 itvar =
fVars.erase(itvar);
2341 }
while (itvar !=
fVars.end());
2352 make_pair(make_pair(
"gaus", 1), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))",
2353 "[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))/(sqrt(2*pi)*[2])")));
2354 functions.insert(make_pair(make_pair(
"landau", 1), make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)",
2355 "[0]*TMath::Landau({V0},[1],[2],true)")));
2356 functions.insert(make_pair(make_pair(
"expo", 1), make_pair(
"exp([0]+[1]*{V0})",
"")));
2358 make_pair(make_pair(
"crystalball", 1), make_pair(
"[0]*ROOT::Math::crystalball_function({V0},[3],[4],[2],[1])",
2359 "[0]*ROOT::Math::crystalball_pdf({V0},[3],[4],[2],[1])")));
2361 make_pair(make_pair(
"breitwigner", 1), make_pair(
"[0]*ROOT::Math::breitwigner_pdf({V0},[2],[1])",
2362 "[0]*ROOT::Math::breitwigner_pdf({V0},[2],[4],[1])")));
2364 functions.insert(make_pair(make_pair(
"cheb0", 1), make_pair(
"ROOT::Math::Chebyshev0({V0},[0])",
"")));
2365 functions.insert(make_pair(make_pair(
"cheb1", 1), make_pair(
"ROOT::Math::Chebyshev1({V0},[0],[1])",
"")));
2366 functions.insert(make_pair(make_pair(
"cheb2", 1), make_pair(
"ROOT::Math::Chebyshev2({V0},[0],[1],[2])",
"")));
2367 functions.insert(make_pair(make_pair(
"cheb3", 1), make_pair(
"ROOT::Math::Chebyshev3({V0},[0],[1],[2],[3])",
"")));
2369 make_pair(make_pair(
"cheb4", 1), make_pair(
"ROOT::Math::Chebyshev4({V0},[0],[1],[2],[3],[4])",
"")));
2371 make_pair(make_pair(
"cheb5", 1), make_pair(
"ROOT::Math::Chebyshev5({V0},[0],[1],[2],[3],[4],[5])",
"")));
2373 make_pair(make_pair(
"cheb6", 1), make_pair(
"ROOT::Math::Chebyshev6({V0},[0],[1],[2],[3],[4],[5],[6])",
"")));
2375 make_pair(make_pair(
"cheb7", 1), make_pair(
"ROOT::Math::Chebyshev7({V0},[0],[1],[2],[3],[4],[5],[6],[7])",
"")));
2376 functions.insert(make_pair(make_pair(
"cheb8", 1),
2377 make_pair(
"ROOT::Math::Chebyshev8({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8])",
"")));
2378 functions.insert(make_pair(make_pair(
"cheb9", 1),
2379 make_pair(
"ROOT::Math::Chebyshev9({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9])",
"")));
2381 make_pair(make_pair(
"cheb10", 1),
2382 make_pair(
"ROOT::Math::Chebyshev10({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10])",
"")));
2385 make_pair(make_pair(
"gaus", 2), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])^2 - 0.5*(({V1}-[3])/[4])^2)",
"")));
2387 make_pair(make_pair(
"landau", 2),
2388 make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)*TMath::Landau({V1},[3],[4],false)",
"")));
2389 functions.insert(make_pair(make_pair(
"expo", 2), make_pair(
"exp([0]+[1]*{V0})",
"exp([0]+[1]*{V0}+[2]*{V1})")));
2392 make_pair(make_pair(
"gaus", 3), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])^2 - 0.5*(({V1}-[3])/[4])^2 - 0.5*(({V2}-[5])/[6])^2)",
"")));
2395 make_pair(make_pair(
"bigaus", 2), make_pair(
"[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])",
2396 "[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])")));
2488 if (i < 0 || i >= n ) {
2489 Error(
"GetLinearPart",
"Formula %s has only %d linear parts - requested %d",
GetName(),n,i);
2535 Bool_t anyNewVar =
false;
2536 for (
Int_t i = 0; i < size; ++i) {
2538 const TString &vname = vars[i];
2548 Int_t multiplier = 2;
2549 if (
fFuncs.size() > 100) {
2562 if (anyNewVar && !
fFormula.IsNull()) {
2574 Error(
"SetName",
"The name \'%s\' is reserved as a TFormula variable name.\n" 2575 "\tThis function will not be renamed.",
2580 auto listOfFunctions =
gROOT->GetListOfFunctions();
2581 TObject* thisAsFunctionInList =
nullptr;
2583 if (listOfFunctions){
2584 thisAsFunctionInList = listOfFunctions->
FindObject(
this);
2585 if (thisAsFunctionInList) listOfFunctions->Remove(thisAsFunctionInList);
2588 if (thisAsFunctionInList) listOfFunctions->Add(thisAsFunctionInList);
2602 for(
Int_t i = 0; i < size; ++i)
2606 fVars[
v.first].fValue =
v.second;
2609 Error(
"SetVariables",
"Variable %s is not defined.",
v.first.Data());
2619 const auto nameIt =
fVars.find(name);
2620 if (
fVars.end() == nameIt) {
2621 Error(
"GetVariable",
"Variable %s is not defined.", name);
2624 return nameIt->second.fValue;
2632 const auto nameIt =
fVars.find(name);
2633 if (
fVars.end() == nameIt) {
2634 Error(
"GetVarNumber",
"Variable %s is not defined.", name);
2637 return nameIt->second.fArrayPos;
2645 if (ivar < 0 || ivar >=
fNdim)
return "";
2648 for (
auto &
v :
fVars) {
2649 if (
v.second.fArrayPos == ivar)
return v.first;
2651 Error(
"GetVarName",
"Variable with index %d not found !!",ivar);
2662 Error(
"SetVariable",
"Variable %s is not defined.", name.Data());
2701 auto ret =
fParams.insert(std::make_pair(name, pos));
2707 if (ret.first ==
fParams.begin())
2710 auto previous = (ret.first);
2712 pos = previous->second + 1;
2720 Warning(
"inserting parameter %s at pos %d when vector size is %d \n", name.Data(), pos,
2730 for (
auto it = ret.first; it !=
fParams.end(); ++it) {
2740 if (processFormula) {
2768 Error(
"GetParameter",
"Parameter %s is not defined.",name);
2783 Error(
"GetParameter",
"wrong index used - use GetParameter(name)");
2792 if (ipar < 0 || ipar >=
fNpar)
return "";
2796 if (p.second == ipar)
return p.first.Data();
2798 Error(
"GetParName",
"Parameter with index %d not found !!",ipar);
2831 Error(
"SetParameter",
"Parameter %s is not defined.", name.Data());
2838 for (map<TString, TFormulaVariable>::iterator it = fParams.begin(); it != fParams.end(); ++it) {
2839 if (!it->second.fFound) {
2858 for(
Int_t i = 0 ; i < size ; ++i)
2860 pair<TString, Double_t> p = params[i];
2862 Error(
"SetParameters",
"Parameter %s is not defined", p.first.Data());
2865 fParams[p.first].fValue = p.second;
2866 fParams[p.first].fFound =
true;
2870 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2871 if (!it->second.fFound) {
2882 if(!params || size < 0 || size >
fNpar)
return;
2885 Warning(
"SetParameters",
"size is not same of cling parameter size %d - %d",size,
int(
fClingParameters.size()) );
2886 for (
Int_t i = 0; i < size; ++i) {
2934 if (param < 0 || param >=
fNpar)
return;
2943 const char *name4,
const char *name5,
const char *name6,
const char *name7,
2944 const char *name8,
const char *name9,
const char *name10)
2974 if (ipar < 0 || ipar >
fNpar) {
2975 Error(
"SetParName",
"Wrong Parameter index %d ",ipar);
2981 if (it.second == ipar) {
2983 fParams.erase(oldName);
2984 fParams.insert(std::make_pair(name, ipar) );
2988 if (oldName.IsNull() ) {
2989 Error(
"SetParName",
"Parameter %d is not existing.",ipar);
3002 if (!formula.IsNull() ) {
3004 for(list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it)
3006 if (oldName == it->GetName()) {
3013 Error(
"SetParName",
"Parameter %s is not defined.", oldName.Data());
3017 TString newName =
name;
3018 newName.ReplaceAll(
" ",
"\\s");
3021 formula.ReplaceAll(pattern, replacement);
3029 #ifdef R__HAS_VECCORE 3031 Info(
"SetVectorized",
"Cannot vectorized a function of zero dimension");
3036 Error(
"SetVectorized",
"Cannot set vectorized to %d -- Formula is missing", vectorized);
3056 Warning(
"SetVectorized",
"Cannot set vectorized -- try building with option -Dbuiltin_veccore=On");
3064 return DoEval(x, params);
3066 #ifdef R__HAS_VECCORE 3068 if (
fNdim == 0 || !x) {
3070 return vecCore::Get( ret, 0 );
3077 Info(
"EvalPar",
"Function is vectorized - converting Double_t into ROOT::Double_v and back");
3080 const int maxDim = 4;
3081 std::array<ROOT::Double_v, maxDim> xvec;
3082 for (
int i = 0; i <
fNdim; i++)
3086 return vecCore::Get(ans, 0);
3089 std::vector<ROOT::Double_v> xvec(
fNdim);
3090 for (
int i = 0; i <
fNdim; i++)
3094 return vecCore::Get(ans, 0);
3099 Error(
"EvalPar",
"Formula is vectorized (even though VECCORE is disabled!)");
3105 #ifdef R__HAS_VECCORE 3115 return DoEvalVec(
x, params);
3118 return DoEval(
nullptr, params);
3123 Info(
"EvalPar",
"Function is not vectorized - converting ROOT::Double_v into Double_t and back");
3125 const int vecSize = vecCore::VectorSize<ROOT::Double_v>();
3126 std::vector<Double_t> xscalars(vecSize*
fNdim);
3128 for (
int i = 0; i < vecSize; i++)
3129 for (
int j = 0; j <
fNdim; j++)
3130 xscalars[i*fNdim+j] = vecCore::Get(
x[j],i);
3133 for (
int i = 0; i < vecSize; i++)
3134 vecCore::Set(answers, i,
DoEval(&xscalars[i*fNdim], params));
3145 double xxx[4] = {
x,
y,
z,t};
3154 double xxx[3] = {
x,
y,z};
3163 double xxx[2] = {
x,y};
3186 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3187 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3190 printf(
"%s is unknown.\n", fun.
GetName());
3200 auto thisFormula =
const_cast<TFormula*
>(
this);
3204 Error(
"DoEval",
"Formula has error and it is not properly initialized ");
3209 std::function<double(double *, double *)> & fptr = * ( (std::function<double(double *, double *)> *)
fLambdaPtr);
3212 double *
v =
const_cast<double*
>(
x);
3213 double * p = (params) ? const_cast<double*>(params) :
const_cast<double*
>(
fClingParameters.data());
3220 double * vars = (
x) ? const_cast<double*>(x) :
const_cast<double*
>(
fClingVariables.data());
3223 (*fFuncPtr)(0, 1, args, &result);
3225 double *pars = (params) ? const_cast<double *>(params) :
const_cast<double *
>(
fClingParameters.data());
3227 (*fFuncPtr)(0, 2, args, &result);
3234 #ifdef R__HAS_VECCORE 3238 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3239 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3242 printf(
"%s is unknown.\n", fun.
GetName());
3252 auto thisFormula =
const_cast<TFormula*
>(
this);
3262 (*fFuncPtr)(0, 1, args, &result);
3264 double *pars = (params) ? const_cast<double *>(params) :
const_cast<double *
>(
fClingParameters.data());
3266 (*fFuncPtr)(0, 2, args, &result);
3270 #endif // R__HAS_VECCORE 3283 Info(
"ReInitializeEvalMethod",
"compile now lambda expression function using Cling");
3292 if (!
fLazyInitialization)
Warning(
"ReInitializeEvalMethod",
"Formula is NOT properly initialized - try calling again TFormula::PrepareEvalMethod");
3306 if (funcit != gClingFunctions.end()) {
3340 TString opt(option);
3349 if (opt.Contains(
"CLING") ) {
3351 std::size_t found = clingFunc.find(
"return");
3352 std::size_t found2 = clingFunc.rfind(
";");
3353 if (found == std::string::npos || found2 == std::string::npos) {
3354 Error(
"GetExpFormula",
"Invalid Cling expression - return default formula expression");
3357 TString clingFormula =
fClingInput(found+7,found2-found-7);
3359 if (!opt.Contains(
"P"))
return clingFormula;
3362 while (i < clingFormula.Length()-2 ) {
3364 if (clingFormula[i] ==
'p' && clingFormula[i+1] ==
'[' && isdigit(clingFormula[i+2]) ) {
3366 while ( isdigit(clingFormula[j]) ) { j++;}
3367 if (clingFormula[j] !=
']') {
3368 Error(
"GetExpFormula",
"Parameters not found - invalid expression - return default cling formula");
3369 return clingFormula;
3371 TString parNumbName = clingFormula(i+2,j-i-2);
3372 int parNumber = parNumbName.Atoi();
3373 assert(parNumber <
fNpar);
3375 clingFormula.Replace(i,j-i+1, replacement );
3376 i += replacement.Length();
3380 return clingFormula;
3382 if (opt.Contains(
"P") ) {
3386 while (i < expFormula.Length()-2 ) {
3388 if (expFormula[i] ==
'[') {
3390 while ( expFormula[j] !=
']' ) { j++;}
3391 if (expFormula[j] !=
']') {
3392 Error(
"GetExpFormula",
"Parameter names not found - invalid expression - return default formula");
3395 TString parName = expFormula(i+1,j-i-1);
3397 expFormula.Replace(i,j-i+1, replacement );
3398 i += replacement.Length();
3404 Warning(
"GetExpFormula",
"Invalid option - return default formula expression");
3414 printf(
" Formula expression: \n");
3415 printf(
"\t%s \n",
fFormula.Data() );
3416 TString opt(option);
3421 if (opt.Contains(
"V") ) {
3423 printf(
"List of Variables: \n");
3425 for (
int ivar = 0; ivar <
fNdim ; ++ivar) {
3430 printf(
"List of Parameters: \n");
3435 for (
int ipar = 0; ipar <
fNpar ; ++ipar) {
3439 printf(
"Expression passed to Cling:\n");
3444 Warning(
"Print",
"Formula is not ready to execute. Missing parameters/variables");
3445 for (list<TFormulaFunction>::const_iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3448 printf(
"%s is unknown.\n", fun.
GetName());
3469 void TFormula::Streamer(
TBuffer &
b)
3475 if (v <= 8 && v > 3 && v != 6) {
3488 Error(
"Streamer",
"Old formula read from file is NOT valid");
3541 if (
fNpar != (
int) parValues.size() ) {
3542 Error(
"Streamer",
"number of parameters computed (%d) is not same as the stored parameters (%d)",
fNpar,
int(parValues.size()) );
3545 if (v > 11 &&
fNdim != ndim) {
3546 Error(
"Streamer",
"number of dimension computed (%d) is not same as the stored value (%d)",
fNdim, ndim );
3561 assert(
fNpar == (
int) parValues.size() );
3564 if (
fParams.size() != paramMap.size() ) {
3565 Warning(
"Streamer",
"number of parameters list found (%zu) is not same as the stored one (%zu) - use re-created list",
fParams.size(),paramMap.size()) ;
3581 gROOT->GetListOfFunctions()->Add(
this);
3584 Error(
"Streamer",
"Formula read from file is NOT ready to execute");
3592 Error(
"Streamer",
"Reading version %d is not supported",v);
constexpr Double_t H()
Planck's constant in .
virtual const char * GetName() const
Returns name of object.
constexpr Double_t K()
Boltzmann's constant in .
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Double_t Floor(Double_t x)
virtual TFormula * GetFormula()
static double p3(double t, double a, double b, double c, double d)
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *) const
constexpr Double_t Sqrt2()
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
CallFunc_t * GetCallFunc() const
virtual void SetName(const char *name)
Set the name of the TNamed.
Buffer base class used for serializing objects.
Regular expression class.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
R__EXTERN TVirtualMutex * gROOTMutex
const TList * GetListOfAllPublicMethods(Bool_t load=kTRUE)
Returns a list of all public methods of this class and its base classes.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
constexpr Double_t Ln10()
Natural log of 10 (to convert log to ln)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
The TNamed class is the base class for all named ROOT classes.
Double_t Log10(Double_t x)
virtual Bool_t Declare(const char *code)=0
static double p2(double t, double a, double b, double c)
void(* Generic_t)(void *, int, void **, void *)
Method or function calling interface.
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
virtual void Delete(Option_t *option="")
Delete this object.
Int_t GetNargs() const
Number of function arguments.
constexpr Double_t G()
Gravitational constant in: .
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
The ROOT global object gROOT contains a list of all defined classes.
static double p1(double t, double a, double b)
Bool_t IsValid() const
Return true if the method call has been properly initialized and is usable.
constexpr Double_t E()
Base of natural log: .
void InitWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Initialize the method invocation environment.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
static constexpr double degree
Ssiz_t Index(const TString &str, Ssiz_t *len, Ssiz_t start=0) const
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match...
#define R__LOCKGUARD(mutex)
constexpr Double_t C()
Velocity of light in .
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.
Mother of all ROOT objects.
constexpr Double_t EulerGamma()
Euler-Mascheroni Constant.
you should not use this method at all Int_t Int_t z
Global functions class (global functions are obtained from CINT).
virtual void Copy(TObject &named) const
Copy this to obj.
Short_t Max(Short_t a, Short_t b)
Each ROOT class (see TClass) has a linked list of methods.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
constexpr Double_t LogE()
Base-10 log of e (to convert ln to log)
constexpr Double_t Sigma()
Stefan-Boltzmann constant in .
virtual Bool_t CallFunc_IsValid(CallFunc_t *) const
R__EXTERN TInterpreter * gCling
constexpr Double_t R()
Universal gas constant ( ) in
Int_t GetNargsOpt() const
Number of function optional (default) arguments.
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual const char * GetTitle() const
Returns title of object.