30#include <unordered_map>
38#pragma optimize("",off)
265static std::unordered_map<std::string, void *>
gClingFunctions = std::unordered_map<std::string, void * >();
272 for (
int i = 0; i < nobjects; ++i) {
273 if (fromv5[i] &&
target[i]) {
274 TFormula fnew(fromv5[i]->GetName(), fromv5[i]->GetExpFormula());
290 const static std::set<char> ops {
'+',
'^',
'-',
'/',
'*',
'<',
'>',
'|',
'&',
'!',
'=',
'?',
'%'};
291 return ops.end() != ops.find(
c);
298 char brackets[] = {
')',
'(',
'{',
'}'};
299 Int_t bracketsLen =
sizeof(brackets)/
sizeof(
char);
300 for(
Int_t i = 0; i < bracketsLen; ++i)
322 if ( (formula[i] ==
'e' || formula[i] ==
'E') && (i > 0 && i < formula.
Length()-1) ) {
324 if ( (isdigit(formula[i-1]) || formula[i-1] ==
'.') && ( isdigit(formula[i+1]) || formula[i+1] ==
'+' || formula[i+1] ==
'-' ) )
334 if ( (formula[i] ==
'x' || formula[i] ==
'X') && (i > 0 && i < formula.
Length()-1) && formula[i-1] ==
'0') {
335 if (isdigit(formula[i+1]) )
337 static char hex_values[12] = {
'a',
'A',
'b',
'B',
'c',
'C',
'd',
'D',
'e',
'E',
'f',
'F'};
338 for (
int jjj = 0; jjj < 12; ++jjj) {
339 if (formula[i+1] == hex_values[jjj])
356 Bool_t foundOpenParenthesis =
false;
357 if (pos == 0 || pos == formula.
Length()-1)
return false;
358 for (
int i = pos-1; i >=0; i--) {
359 if (formula[i] ==
']' )
return false;
360 if (formula[i] ==
'[' ) {
361 foundOpenParenthesis =
true;
365 if (!foundOpenParenthesis )
return false;
368 for (
int i = pos+1; i < formula.
Length(); i++) {
369 if (formula[i] ==
']' )
return true;
382 TRegexp numericPattern(
"p?[0-9]+");
385 int patternStart = numericPattern.
Index(
a, &
len);
386 bool aNumeric = (patternStart == 0 &&
len ==
a.Length());
388 patternStart = numericPattern.
Index(
b, &
len);
389 bool bNumeric = (patternStart == 0 &&
len ==
b.Length());
391 if (aNumeric && !bNumeric)
393 else if (!aNumeric && bNumeric)
395 else if (!aNumeric && !bNumeric)
398 int aInt = (
a[0] ==
'p') ?
TString(
a(1,
a.Length())).
Atoi() :
a.Atoi();
399 int bInt = (
b[0] ==
'p') ?
TString(
b(1,
b.Length())).
Atoi() :
b.Atoi();
410 for (
int i = 0; i < formula.
Length(); i++) {
413 if (isalpha(formula[i]) || formula[i] ==
'{' || formula[i] ==
'[') {
417 || (formula[i] ==
'{' && formula[j] ==
'}'));
425 if (substitutions.find(
name) != substitutions.end()) {
429 }
else if (isalpha(formula[i])) {
432 i +=
name.Length() - 1;
458 if (strlen(
name)!=1)
return false;
459 for (
auto const & specialName : {
"x",
"y",
"z",
"t"}){
460 if (strcmp(
name,specialName)==0)
return true;
473 gROOT->GetListOfFunctions()->Remove(
this);
478 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
485 fClingInput(formula),fFormula(formula)
494#ifndef R__HAS_VECCORE
510 if (addToGlobList &&
gROOT) {
515 gROOT->GetListOfFunctions()->Remove(old);
517 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",
name);
519 gROOT->GetListOfFunctions()->Add(
this);
531 fClingInput(formula),fFormula(formula)
544 for (
int i = 0; i < npar; ++i) {
548 assert (
fNpar == npar);
558 if (addToGlobList &&
gROOT) {
563 gROOT->GetListOfFunctions()->Remove(old);
565 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",
name);
567 gROOT->GetListOfFunctions()->Add(
this);
572 Error(
"TFormula",
"Syntax error in building the lambda expression %s", formula );
577 TNamed(formula.GetName(),formula.GetTitle())
579 formula.TFormula::Copy(*
this);
585 gROOT->GetListOfFunctions()->Remove(old);
588 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",formula.
GetName());
590 gROOT->GetListOfFunctions()->Add(
this);
601 rhs.TFormula::Copy(*
this);
608 std::string lambdaExpression = formula;
632 TString lineExpr =
TString::Format(
"std::function<double(double*,double*)> %s = %s ;",lambdaName.
Data(), lambdaExpression.c_str() );
659 if (formula.
IsNull() )
return -1;
671 return (ret) ? 0 : 1;
681 return (ret) ? 0 : 1;
710 for (
int i = 0; i < nLinParts; ++i)
delete fnew.
fLinearParts[i];
717 for (
int i = 0; i < nLinParts; ++i) {
721 linearOld->
Copy(*linearNew);
746 Error(
"TFormula",
"Syntax error in building the lambda expression %s",
fFormula.
Data() );
792 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
799static std::unique_ptr<TMethodCall>
801 bool IsVectorized,
bool AddCladArrayRef =
false) {
802 std::unique_ptr<TMethodCall>
803 Method = std::unique_ptr<TMethodCall>(
new TMethodCall());
805 TString prototypeArguments =
"";
806 if (HasVariables || HasParameters) {
808 prototypeArguments.
Append(
"ROOT::Double_v*");
810 prototypeArguments.
Append(
"Double_t*");
812 auto AddDoublePtrParam = [&prototypeArguments]() {
813 prototypeArguments.
Append(
",");
814 prototypeArguments.
Append(
"Double_t*");
820 if (AddCladArrayRef) {
821 prototypeArguments.
Append(
",");
822 prototypeArguments.
Append(
"clad::array_ref<Double_t>");
827 Method->InitWithPrototype(FuncName, prototypeArguments);
828 if (!Method->IsValid()) {
829 Error(
"prepareMethod",
830 "Can't compile function %s prototype with arguments %s", FuncName,
831 prototypeArguments.
Data());
839 if (!method)
return nullptr;
843 Error(
"prepareFuncPtr",
"Callfunc retuned from Cling is not valid");
850 Error(
"prepareFuncPtr",
"Compiled function pointer is null");
886 TString triggerAutoparsing =
"namespace ROOT_TFormula_triggerAutoParse {\n"; triggerAutoparsing +=
fClingInput +
"\n}";
905 const TString defvars[] = {
"x",
"y",
"z",
"t"};
906 const pair<TString, Double_t> defconsts[] = {{
"pi",
TMath::Pi()},
924 const pair<TString,TString> funShortcuts[] =
925 { {
"sin",
"TMath::Sin" },
926 {
"cos",
"TMath::Cos" }, {
"exp",
"TMath::Exp"}, {
"log",
"TMath::Log"}, {
"log10",
"TMath::Log10"},
927 {
"tan",
"TMath::Tan"}, {
"sinh",
"TMath::SinH"}, {
"cosh",
"TMath::CosH"},
928 {
"tanh",
"TMath::TanH"}, {
"asin",
"TMath::ASin"}, {
"acos",
"TMath::ACos"},
929 {
"atan",
"TMath::ATan"}, {
"atan2",
"TMath::ATan2"}, {
"sqrt",
"TMath::Sqrt"},
930 {
"ceil",
"TMath::Ceil"}, {
"floor",
"TMath::Floor"}, {
"pow",
"TMath::Power"},
931 {
"binomial",
"TMath::Binomial"},{
"abs",
"TMath::Abs"},
932 {
"min",
"TMath::Min"},{
"max",
"TMath::Max"},{
"sign",
"TMath::Sign" },
936 std::vector<TString> defvars2(10);
937 for (
int i = 0; i < 9; ++i)
940 for (
const auto &var : defvars) {
941 int pos =
fVars.size();
954 for (
auto con : defconsts) {
955 fConsts[con.first] = con.second;
960 for (
auto fun : funShortcuts) {
973 const pair<TString,TString> vecFunShortcuts[] =
974 { {
"sin",
"vecCore::math::Sin" },
975 {
"cos",
"vecCore::math::Cos" }, {
"exp",
"vecCore::math::Exp"}, {
"log",
"vecCore::math::Log"}, {
"log10",
"vecCore::math::Log10"},
976 {
"tan",
"vecCore::math::Tan"},
978 {
"asin",
"vecCore::math::ASin"},
979 {
"acos",
"TMath::Pi()/2-vecCore::math::ASin"},
980 {
"atan",
"vecCore::math::ATan"},
981 {
"atan2",
"vecCore::math::ATan2"}, {
"sqrt",
"vecCore::math::Sqrt"},
982 {
"ceil",
"vecCore::math::Ceil"}, {
"floor",
"vecCore::math::Floor"}, {
"pow",
"vecCore::math::Pow"},
983 {
"cbrt",
"vecCore::math::Cbrt"},{
"abs",
"vecCore::math::Abs"},
984 {
"min",
"vecCore::math::Min"},{
"max",
"vecCore::math::Max"},{
"sign",
"vecCore::math::Sign" }
988 for (
auto fun : vecFunShortcuts) {
1008 Bool_t defaultVariable =
false;
1010 Int_t openingBracketPos = formula.
Index(
'(', polPos);
1011 Bool_t defaultCounter = openingBracketPos ==
kNPOS;
1012 Bool_t defaultDegree =
true;
1013 Int_t degree, counter;
1015 if (!defaultCounter) {
1018 sdegree = formula(polPos + 3, openingBracketPos - polPos - 3);
1020 defaultCounter =
true;
1022 if (!defaultCounter) {
1023 degree = sdegree.
Atoi();
1024 counter =
TString(formula(openingBracketPos + 1, formula.
Index(
')', polPos) - openingBracketPos)).
Atoi();
1026 Int_t temp = polPos + 3;
1027 while (temp < formula.
Length() && isdigit(formula[temp])) {
1028 defaultDegree =
false;
1031 degree =
TString(formula(polPos + 3, temp - polPos - 3)).
Atoi();
1036 if (polPos - 1 < 0 || !
IsFunctionNameChar(formula[polPos - 1]) || formula[polPos - 1] ==
':') {
1038 defaultVariable =
true;
1040 Int_t tmp = polPos - 1;
1044 variable = formula(tmp + 1, polPos - (tmp + 1));
1046 Int_t param = counter + 1;
1048 while (tmp <= degree) {
1058 replacement.
Insert(0,
'(');
1062 if (defaultCounter && !defaultDegree) {
1064 }
else if (defaultCounter && defaultDegree) {
1067 pattern =
TString::Format(
"%spol%d(%d)", (defaultVariable ?
"" : variable.
Data()), degree, counter);
1071 Error(
"HandlePolN",
"Error handling polynomial function - expression is %s - trying to replace %s with %s ",
1075 if (formula == pattern) {
1081 polPos = formula.
Index(
"pol");
1107 map< pair<TString,Int_t> ,pair<TString,TString> > functions;
1110 map<TString,Int_t> functionsNumbers;
1111 functionsNumbers[
"gaus"] = 100;
1112 functionsNumbers[
"bigaus"] = 102;
1113 functionsNumbers[
"landau"] = 400;
1114 functionsNumbers[
"expo"] = 200;
1115 functionsNumbers[
"crystalball"] = 500;
1126 formula.
ReplaceAll(
"xylandau",
"landau[x,y]");
1129 const char * defaultVariableNames[] = {
"x",
"y",
"z"};
1131 for (map<pair<TString, Int_t>, pair<TString, TString>>::iterator it = functions.begin(); it != functions.end();
1134 TString funName = it->first.first;
1135 Int_t funDim = it->first.second;
1145 Int_t iposBefore = funPos - 1;
1148 if (iposBefore >= 0) {
1149 assert(iposBefore < formula.
Length());
1154 funPos = formula.
Index(funName, lastFunPos);
1159 Bool_t isNormalized =
false;
1160 if (lastFunPos < formula.
Length()) {
1162 isNormalized = (formula[lastFunPos] ==
'n');
1165 if (lastFunPos < formula.
Length()) {
1166 char c = formula[lastFunPos];
1169 if (isalnum(
c) || (!
IsOperator(
c) &&
c !=
'(' &&
c !=
')' &&
c !=
'[' &&
c !=
']')) {
1171 funPos = formula.
Index(funName, lastFunPos);
1180 std::vector<TString> variables;
1183 Bool_t defaultVariables =
false;
1186 Int_t openingBracketPos = funPos + funName.
Length() + (isNormalized ? 1 : 0);
1188 if (openingBracketPos > formula.
Length() || formula[openingBracketPos] !=
'[') {
1190 variables.resize(dim);
1191 for (
Int_t idim = 0; idim < dim; ++idim)
1192 variables[idim] = defaultVariableNames[idim];
1193 defaultVariables =
true;
1196 closingBracketPos = formula.
Index(
']', openingBracketPos);
1197 varList = formula(openingBracketPos + 1, closingBracketPos - openingBracketPos - 1);
1199 variables.resize(dim);
1204 varName.
Append(varList[i]);
1206 if (varList[i] ==
',') {
1207 variables[Nvar] = varName;
1214 variables[Nvar] = varName;
1219 if (dim != funDim) {
1220 pair<TString, Int_t> key = make_pair(funName, dim);
1221 if (functions.find(key) == functions.end()) {
1222 Error(
"PreProcessFormula",
"Dimension of function %s is detected to be of dimension %d and is not "
1223 "compatible with existing pre-defined function which has dim %d",
1224 funName.
Data(), dim, funDim);
1228 funPos = formula.
Index(funName, lastFunPos);
1233 Int_t openingParenthesisPos = (closingBracketPos ==
kNPOS) ? openingBracketPos : closingBracketPos + 1;
1234 bool defaultCounter = (openingParenthesisPos > formula.
Length() || formula[openingParenthesisPos] !=
'(');
1239 if (defaultCounter) {
1245 TRegexp counterPattern(
"([0-9]+)");
1247 if (counterPattern.
Index(formula, &
len, openingParenthesisPos) == -1) {
1248 funPos = formula.
Index(funName, funPos + 1);
1252 TString(formula(openingParenthesisPos + 1, formula.
Index(
')', funPos) - openingParenthesisPos - 1))
1258 TString body = (isNormalized ? it->second.second : it->second.first);
1259 if (isNormalized && body ==
"") {
1260 Error(
"PreprocessFormula",
"%d dimension function %s has no normalized form.", it->first.second,
1264 for (
int i = 0; i < body.
Length(); ++i) {
1265 if (body[i] ==
'{') {
1269 TString variable = variables[num];
1273 i += variable.
Length() - 1;
1274 }
else if (body[i] ==
'[') {
1277 while (tmp < body.
Length() && body[tmp] !=
']') {
1284 body.
Replace(i + 1, tmp - 1 - i, replacement, replacement.
Length());
1285 i += replacement.
Length() + 1;
1289 if (defaultCounter && defaultVariables) {
1292 if (!defaultCounter && defaultVariables) {
1293 pattern =
TString::Format(
"%s%s(%d)", funName.
Data(), (isNormalized ?
"n" :
""), counter);
1295 if (defaultCounter && !defaultVariables) {
1298 if (!defaultCounter && !defaultVariables) {
1306 fNumber = functionsNumbers[funName] + 10 * (dim - 1);
1313 funPos = formula.
Index(funName);
1323 TRegexp rangePattern(
"\\[[0-9]+\\.\\.[0-9]+\\]");
1326 while ((matchIdx = rangePattern.
Index(formula, &
len, matchIdx)) != -1) {
1327 int startIdx = matchIdx + 1;
1328 int endIdx = formula.
Index(
"..", startIdx) + 2;
1332 if (endCnt <= startCnt)
1333 Error(
"HandleParamRanges",
"End parameter (%d) <= start parameter (%d) in parameter range", endCnt, startCnt);
1336 for (
int cnt = startCnt; cnt < endCnt; cnt++)
1341 formula.
Replace(matchIdx, formula.
Index(
"]", matchIdx) + 1 - matchIdx, newString);
1343 matchIdx += newString.
Length();
1357 std::map<std::pair<TString, Int_t>, std::pair<TString, TString>> parFunctions;
1365 if (formula[i] ==
'[') {
1366 while (formula[i] !=
']')
1371 if (formula[i] ==
'\"') {
1374 while (formula[i] !=
'\"');
1388 if (isalpha(formula[i]) && !
IsOperator(formula[i])) {
1401 std::vector<int> argSeparators;
1402 argSeparators.push_back(j);
1404 for (k = j + 1; depth >= 1 && k < formula.
Length(); k++) {
1405 if (formula[k] ==
',' && depth == 1) {
1407 argSeparators.push_back(k);
1408 }
else if (formula[k] ==
'(')
1410 else if (formula[k] ==
')')
1413 argSeparators.push_back(k - 1);
1424 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1432 bool nameRecognized = (
f !=
nullptr);
1439 ndim =
f->GetNdim();
1440 npar =
f->GetNpar();
1441 replacementFormula =
f->GetExpFormula();
1445 for (
const auto &keyval : parFunctions) {
1447 const pair<TString, Int_t> &name_ndim = keyval.first;
1449 const pair<TString, TString> &formulaPair = keyval.second;
1452 if (
name == name_ndim.first)
1453 replacementFormula = formulaPair.first;
1454 else if (
name == name_ndim.first +
"n" && formulaPair.second !=
"")
1455 replacementFormula = formulaPair.second;
1460 ndim = name_ndim.second;
1465 while ((idx = replacementFormula.
Index(
'[', idx)) !=
kNPOS) {
1466 npar = max(npar, 1 +
TString(replacementFormula(idx + 1, replacementFormula.
Length())).
Atoi());
1467 idx = replacementFormula.
Index(
']', idx);
1469 Error(
"HandleFunctionArguments",
"Square brackets not matching in formula %s",
1470 (
const char *)replacementFormula);
1477 if (nArguments == ndim + npar || nArguments == npar || nArguments == ndim) {
1478 nameRecognized =
true;
1483 if (nameRecognized && ndim > 4)
1484 Error(
"HandleFunctionArguments",
"Number of dimensions %d greater than 4. Cannot parse formula.", ndim);
1487 if (nameRecognized && j < formula.
Length() && formula[j] ==
'(') {
1492 map<TString, TString> argSubstitutions;
1494 const char *defaultVariableNames[] = {
"x",
"y",
"z",
"t"};
1497 bool canReplace =
false;
1498 if (nArguments == ndim + npar) {
1500 for (
int argNr = 0; argNr < nArguments; argNr++) {
1504 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1511 argSubstitutions[oldName] = newName;
1514 argSubstitutions[defaultVariableNames[argNr]] = newName;
1517 int parNr = argNr - ndim;
1520 argSubstitutions[oldName] = newName;
1523 if (
f && oldName == newName)
1529 }
else if (nArguments == npar) {
1534 bool varsImplicit =
true;
1535 for (
int argNr = 0; argNr < nArguments && varsImplicit; argNr++) {
1536 int openIdx = argSeparators[argNr] + 1;
1537 int closeIdx = argSeparators[argNr + 1] - 1;
1540 if (formula[openIdx] !=
'[' || formula[closeIdx] !=
']' || closeIdx <= openIdx + 1)
1541 varsImplicit =
false;
1544 for (
int idx = openIdx + 1; idx < closeIdx && varsImplicit; idx++)
1546 varsImplicit =
false;
1549 Warning(
"HandleFunctionArguments",
1550 "Argument %d is not a parameter. Cannot assume variables are implicit.", argNr);
1557 for (
int dim = 0; dim < ndim; dim++) {
1558 argSubstitutions[
TString::Format(
"{V%d}", dim)] = defaultVariableNames[dim];
1562 for (
int argNr = 0; argNr < nArguments; argNr++) {
1566 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1570 argSubstitutions[oldName] = newName;
1573 if (
f && oldName == newName)
1580 if (!canReplace && nArguments == ndim) {
1584 for (
int argNr = 0; argNr < nArguments; argNr++) {
1587 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1591 argSubstitutions[oldName] = newName;
1594 argSubstitutions[defaultVariableNames[argNr]] = newName;
1599 for (
int parNr = 0; parNr < npar; parNr++)
1613 formula.
Replace(i, k - i, replacementFormula);
1614 i += replacementFormula.
Length() - 1;
1617 Warning(
"HandleFunctionArguments",
"Unable to make replacement. Number of parameters doesn't work : "
1618 "%d arguments, %d dimensions, %d parameters",
1619 nArguments, ndim, npar);
1642 Int_t temp = caretPos;
1645 if (formula[temp] ==
')') {
1648 while (depth != 0 && temp > 0) {
1649 if (formula[temp] ==
')')
1651 if (formula[temp] ==
'(')
1666 assert(temp + 1 >= 0);
1667 Int_t leftPos = temp + 1;
1668 left = formula(leftPos, caretPos - leftPos);
1674 if (temp >= formula.
Length()) {
1675 Error(
"HandleExponentiation",
"Invalid position of operator ^");
1678 if (formula[temp] ==
'(') {
1681 while (depth != 0 && temp < formula.
Length()) {
1682 if (formula[temp] ==
')')
1684 if (formula[temp] ==
'(')
1691 if (formula[temp] ==
'-' || formula[temp] ==
'+')
1697 while (temp < formula.
Length() && ((depth > 0) || !
IsOperator(formula[temp]))) {
1703 if (temp < formula.
Length() && formula[temp] ==
'(')
1705 if (temp < formula.
Length() && formula[temp] ==
')') {
1713 right = formula(caretPos + 1, (temp - 1) - caretPos);
1728 caretPos = formula.
Last(
'^');
1738 if(formula.
Length() == 0)
return;
1740 if(terms.size() <= 1)
return;
1744 int delimeterPos = 0;
1745 for(std::size_t iTerm = 0; iTerm < terms.size(); ++iTerm) {
1747 delimeterPos += terms[iTerm].size() + (iTerm == 0);
1750 expandedFormula += terms[iTerm];
1751 expandedFormula += formula(delimeterPos, formula.
Length() - (delimeterPos + 1));
1755 auto termName = std::string(
"__linear") + std::to_string(iTerm+1);
1757 std::stringstream ss;
1758 ss <<
"([" << iTerm <<
"]*(" << terms[iTerm] <<
"))";
1759 expandedFormula += ss.str();
1760 if(iTerm < terms.size() - 1) expandedFormula +=
"+";
1762 formula = expandedFormula;
1844 if (formula[i] ==
'[') {
1848 while (i < formula.
Length() && formula[i] !=
']') {
1849 param.
Append(formula[i++]);
1854 int paramIndex = -1;
1856 paramIndex = param.
Atoi();
1860 for (
int idx = 0; idx <= paramIndex; ++idx) {
1880 formula.
Replace(tmp, i - tmp, replacement, replacement.
Length());
1884 int deltai = replacement.
Length() - (i-tmp);
1890 if (formula[i] ==
'\"') {
1894 }
while (formula[i] !=
'\"');
1912 if (isalpha(formula[i]) &&
1920 if (formula[i] ==
':' && ((i + 1) < formula.
Length())) {
1921 if (formula[i + 1] ==
':') {
1930 name.Append(formula[i++]);
1933 if (formula[i] ==
'(') {
1935 if (formula[i] ==
')') {
1942 while (depth != 0 && i < formula.
Length()) {
1943 switch (formula[i]) {
1944 case '(': depth++;
break;
1945 case ')': depth--;
break;
1953 body.
Append(formula[i++]);
1958 formula.
Replace(i - originalBodyLen, originalBodyLen, body, body.
Length());
1959 i += body.
Length() - originalBodyLen;
1977 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1987 TString replacementFormula =
f->GetExpFormula();
2000 std::vector<TString> newNames;
2003 newNames.resize(
f->GetNpar());
2005 for (
int jpar =
f->GetNpar() - 1; jpar >= 0; --jpar) {
2013 replacementFormula.
ReplaceAll(oldName, newName);
2014 newNames[jpar] = newName;
2016 newNames[jpar] =
f->GetParName(jpar);
2024 for (
int jpar = 0; jpar <
f->GetNpar(); ++jpar) {
2025 if (nparOffset > 0) {
2027 assert((
int)newNames.size() ==
f->GetNpar());
2034 replacementFormula.
Insert(0,
'(');
2035 replacementFormula.
Insert(replacementFormula.
Length(),
')');
2038 i += replacementFormula.
Length() -
name.Length();
2082 for (list<TFormulaFunction>::iterator funcsIt =
fFuncs.begin(); funcsIt !=
fFuncs.end(); ++funcsIt) {
2103 if ((
index > 0) && (isalpha(formula[
index - 1]) || formula[
index - 1] ==
':')) {
2107 if (i2 < formula.
Length() && formula[i2] !=
'(') {
2121#ifdef TFORMULA_CHECK_FUNCTIONS
2128 assert(
index != std::string::npos);
2136 TIter next(methodList);
2140 (fun.
GetNargs() <=
p->GetNargs() && fun.
GetNargs() >=
p->GetNargs() -
p->GetNargsOpt())) {
2154 if (
f && fun.
GetNargs() <=
f->GetNargs() && fun.
GetNargs() >=
f->GetNargs() -
f->GetNargsOpt()) {
2162 Info(
"TFormula",
"Could not find %s function with %d argument(s)", fun.
GetName(), fun.
GetNargs());
2185 map<TString, TFormulaVariable>::iterator varsIt =
fVars.find(fun.
GetName());
2186 if (varsIt !=
fVars.end()) {
2195 int varDim = (*varsIt).second.fArrayPos;
2196 if (varDim >=
fNdim) {
2201 if (
v.second.fArrayPos < varDim && !
v.second.fFound) {
2203 v.second.fFound =
true;
2224 int digit = sdigit.
Atoi();
2225 if (digit >=
fNdim) {
2228 for (
int j = 0; j <
fNdim; ++j) {
2232 fVars[vname].fFound =
true;
2247 if (paramsIt !=
fParams.end()) {
2264 map<TString, Double_t>::iterator constIt =
fConsts.find(fun.
GetName());
2265 if (constIt !=
fConsts.end()) {
2284 if (!hasParameters) {
2298 if (inputIntoCling) {
2301 std::string inputFormula(formula.
Data());
2305 std::string inputFormulaVecFlag = inputFormula;
2307 inputFormulaVecFlag +=
" (vectorized)";
2312 TString argumentsPrototype =
TString::Format(
"%s%s%s", ( (hasVariables || hasParameters) ? (argType +
" *x").Data() :
""),
2313 (hasParameters ?
"," :
""), (hasParameters ?
"Double_t *p" :
""));
2330 inputIntoCling =
false;
2340 argumentsPrototype.
Data(), inputFormula.c_str());
2359 if (inputIntoCling) {
2385 for (list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
2387 if (!it->fFound && !it->IsFuncCall()) {
2389 if (it->GetNargs() == 0)
2390 Error(
"ProcessFormula",
"\"%s\" has not been matched in the formula expression", it->GetName());
2392 Error(
"ProcessFormula",
"Could not find %s function with %d argument(s)", it->GetName(), it->GetNargs());
2403 auto itvar =
fVars.begin();
2406 if (!itvar->second.fFound) {
2408 itvar =
fVars.erase(itvar);
2411 }
while (itvar !=
fVars.end());
2422 make_pair(make_pair(
"gaus", 1), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))",
2423 "[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))/(sqrt(2*pi)*[2])")));
2424 functions.insert(make_pair(make_pair(
"landau", 1), make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)",
2425 "[0]*TMath::Landau({V0},[1],[2],true)")));
2426 functions.insert(make_pair(make_pair(
"expo", 1), make_pair(
"exp([0]+[1]*{V0})",
"")));
2428 make_pair(make_pair(
"crystalball", 1), make_pair(
"[0]*ROOT::Math::crystalball_function({V0},[3],[4],[2],[1])",
2429 "[0]*ROOT::Math::crystalball_pdf({V0},[3],[4],[2],[1])")));
2431 make_pair(make_pair(
"breitwigner", 1), make_pair(
"[0]*ROOT::Math::breitwigner_pdf({V0},[2],[1])",
2432 "[0]*ROOT::Math::breitwigner_pdf({V0},[2],[4],[1])")));
2434 functions.insert(make_pair(make_pair(
"cheb0", 1), make_pair(
"ROOT::Math::Chebyshev0({V0},[0])",
"")));
2435 functions.insert(make_pair(make_pair(
"cheb1", 1), make_pair(
"ROOT::Math::Chebyshev1({V0},[0],[1])",
"")));
2436 functions.insert(make_pair(make_pair(
"cheb2", 1), make_pair(
"ROOT::Math::Chebyshev2({V0},[0],[1],[2])",
"")));
2437 functions.insert(make_pair(make_pair(
"cheb3", 1), make_pair(
"ROOT::Math::Chebyshev3({V0},[0],[1],[2],[3])",
"")));
2439 make_pair(make_pair(
"cheb4", 1), make_pair(
"ROOT::Math::Chebyshev4({V0},[0],[1],[2],[3],[4])",
"")));
2441 make_pair(make_pair(
"cheb5", 1), make_pair(
"ROOT::Math::Chebyshev5({V0},[0],[1],[2],[3],[4],[5])",
"")));
2443 make_pair(make_pair(
"cheb6", 1), make_pair(
"ROOT::Math::Chebyshev6({V0},[0],[1],[2],[3],[4],[5],[6])",
"")));
2445 make_pair(make_pair(
"cheb7", 1), make_pair(
"ROOT::Math::Chebyshev7({V0},[0],[1],[2],[3],[4],[5],[6],[7])",
"")));
2446 functions.insert(make_pair(make_pair(
"cheb8", 1),
2447 make_pair(
"ROOT::Math::Chebyshev8({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8])",
"")));
2448 functions.insert(make_pair(make_pair(
"cheb9", 1),
2449 make_pair(
"ROOT::Math::Chebyshev9({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9])",
"")));
2451 make_pair(make_pair(
"cheb10", 1),
2452 make_pair(
"ROOT::Math::Chebyshev10({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10])",
"")));
2455 make_pair(make_pair(
"gaus", 2), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])^2 - 0.5*(({V1}-[3])/[4])^2)",
"")));
2457 make_pair(make_pair(
"landau", 2),
2458 make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)*TMath::Landau({V1},[3],[4],false)",
"")));
2459 functions.insert(make_pair(make_pair(
"expo", 2), make_pair(
"exp([0]+[1]*{V0})",
"exp([0]+[1]*{V0}+[2]*{V1})")));
2462 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)",
"")));
2465 make_pair(make_pair(
"bigaus", 2), make_pair(
"[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])",
2466 "[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])")));
2558 if (i < 0 || i >=
n ) {
2559 Error(
"GetLinearPart",
"Formula %s has only %d linear parts - requested %d",
GetName(),
n,i);
2605 Bool_t anyNewVar =
false;
2608 const TString &vname = vars[i];
2618 Int_t multiplier = 2;
2619 if (
fFuncs.size() > 100) {
2644 Error(
"SetName",
"The name \'%s\' is reserved as a TFormula variable name.\n"
2645 "\tThis function will not be renamed.",
2650 auto listOfFunctions =
gROOT->GetListOfFunctions();
2651 TObject* thisAsFunctionInList =
nullptr;
2653 if (listOfFunctions){
2654 thisAsFunctionInList = listOfFunctions->
FindObject(
this);
2655 if (thisAsFunctionInList) listOfFunctions->Remove(thisAsFunctionInList);
2658 if (thisAsFunctionInList) listOfFunctions->Add(thisAsFunctionInList);
2676 fVars[
v.first].fValue =
v.second;
2679 Error(
"SetVariables",
"Variable %s is not defined.",
v.first.Data());
2690 if (
fVars.end() == nameIt) {
2691 Error(
"GetVariable",
"Variable %s is not defined.",
name);
2694 return nameIt->second.fValue;
2703 if (
fVars.end() == nameIt) {
2704 Error(
"GetVarNumber",
"Variable %s is not defined.",
name);
2707 return nameIt->second.fArrayPos;
2715 if (ivar < 0 || ivar >=
fNdim)
return "";
2718 for (
auto &
v :
fVars) {
2719 if (
v.second.fArrayPos == ivar)
return v.first;
2721 Error(
"GetVarName",
"Variable with index %d not found !!",ivar);
2732 Error(
"SetVariable",
"Variable %s is not defined.",
name.Data());
2771 auto ret =
fParams.insert(std::make_pair(
name, pos));
2777 if (ret.first ==
fParams.begin())
2780 auto previous = (ret.first);
2782 pos = previous->second + 1;
2790 Warning(
"inserting parameter %s at pos %d when vector size is %d \n",
name.Data(), pos,
2800 for (
auto it = ret.first; it !=
fParams.end(); ++it) {
2810 if (processFormula) {
2838 Error(
"GetParameter",
"Parameter %s is not defined.",
name);
2853 Error(
"GetParameter",
"wrong index used - use GetParameter(name)");
2862 if (ipar < 0 || ipar >=
fNpar)
return "";
2866 if (
p.second == ipar)
return p.first.Data();
2868 Error(
"GetParName",
"Parameter with index %d not found !!",ipar);
2901 Error(
"SetParameter",
"Parameter %s is not defined.",
name.Data());
2908 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2909 if (!it->second.fFound) {
2930 pair<TString, Double_t>
p = params[i];
2932 Error(
"SetParameters",
"Parameter %s is not defined",
p.first.Data());
2940 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2941 if (!it->second.fFound) {
2952 if(!params || size < 0 || size >
fNpar)
return;
3004 if (param < 0 || param >=
fNpar)
return;
3013 const char *name4,
const char *name5,
const char *name6,
const char *name7,
3014 const char *name8,
const char *name9,
const char *name10)
3044 if (ipar < 0 || ipar >
fNpar) {
3045 Error(
"SetParName",
"Wrong Parameter index %d ",ipar);
3051 if (it.second == ipar) {
3059 Error(
"SetParName",
"Parameter %d is not existing.",ipar);
3072 if (!formula.
IsNull() ) {
3074 for(list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it)
3076 if (oldName == it->GetName()) {
3083 Error(
"SetParName",
"Parameter %s is not defined.", oldName.
Data());
3099#ifdef R__HAS_VECCORE
3101 Info(
"SetVectorized",
"Cannot vectorized a function of zero dimension");
3106 Error(
"SetVectorized",
"Cannot set vectorized to %d -- Formula is missing", vectorized);
3124 Warning(
"SetVectorized",
"Cannot set vectorized -- try building with option -Dbuiltin_veccore=On");
3134#ifdef R__HAS_VECCORE
3138 return vecCore::Get( ret, 0 );
3145 Info(
"EvalPar",
"Function is vectorized - converting Double_t into ROOT::Double_v and back");
3148 const int maxDim = 4;
3149 std::array<ROOT::Double_v, maxDim> xvec;
3150 for (
int i = 0; i <
fNdim; i++)
3154 return vecCore::Get(ans, 0);
3157 std::vector<ROOT::Double_v> xvec(
fNdim);
3158 for (
int i = 0; i <
fNdim; i++)
3162 return vecCore::Get(ans, 0);
3167 Error(
"EvalPar",
"Formula is vectorized (even though VECCORE is disabled!)");
3179 if (!IsCladRuntimeIncluded) {
3180 IsCladRuntimeIncluded =
true;
3181 gInterpreter->Declare(
"#include <Math/CladDerivator.h>\n#pragma clad OFF");
3187 std::string &GenerationInput) {
3188 std::string ReqFuncName = FuncName +
"_req";
3190 GenerationInput = std::string(
"#pragma cling optimize(2)\n") +
3191 "#pragma clad ON\n" +
3192 "void " + ReqFuncName +
"() {\n" +
3193 CladStatement +
"\n " +
3202 Bool_t hasParameters = (Npar > 0);
3203 Bool_t hasVariables = (Ndim > 0);
3204 std::unique_ptr<TMethodCall>
3205 method =
prepareMethod(hasParameters, hasVariables, FuncName.c_str(),
3227 (*FuncPtr)(0, 2, args,
nullptr);
3242 struct array_ref_interface {
3247 array_ref_interface ari{
result,
static_cast<size_t>(result_size)};
3249 (*FuncPtr)(0, 3, args,
nullptr);
3269 std::string GradientCall
3270 (
"clad::gradient(" + std::string(
fClingName.
Data()) +
", \"p\");");
3290 Error(
"GradientPar",
"Could not initialize the formula!");
3295 Error(
"GradientPar",
"Could not generate a gradient for the formula %s!",
3302 "The size of gradient result is %zu but %d is required. Resizing.",
3334 std::string indexes = (
fNpar - 1 == 0) ?
"0" : std::string(
"0:")
3335 + std::to_string(
fNpar - 1);
3336 std::string HessianCall
3338 + indexes +
"]\" );");
3354 Error(
"HessianPar",
"Could not initialize the formula!");
3359 Error(
"HessianPar",
"Could not generate a hessian for the formula %s!",
3366 "The size of hessian result is %zu but %d is required. Resizing.",
3380#ifdef R__HAS_VECCORE
3390 return DoEvalVec(
x, params);
3393 return DoEval(
nullptr, params);
3398 Info(
"EvalPar",
"Function is not vectorized - converting ROOT::Double_v into Double_t and back");
3400 const int vecSize = vecCore::VectorSize<ROOT::Double_v>();
3401 std::vector<Double_t> xscalars(vecSize*
fNdim);
3403 for (
int i = 0; i < vecSize; i++)
3404 for (
int j = 0; j <
fNdim; j++)
3405 xscalars[i*
fNdim+j] = vecCore::Get(
x[j],i);
3408 for (
int i = 0; i < vecSize; i++)
3409 vecCore::Set(answers, i,
DoEval(&xscalars[i*
fNdim], params));
3420 double xxx[4] = {
x,
y,z,t};
3429 double xxx[3] = {
x,
y,z};
3438 double xxx[2] = {
x,
y};
3461 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3462 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3465 printf(
"%s is unknown.\n", fun.
GetName());
3477 auto thisFormula =
const_cast<TFormula*
>(
this);
3481 Error(
"DoEval",
"Formula has error and it is not properly initialized ");
3487 std::function<
double(
double *,
double *)> & fptr = * ( (std::function<
double(
double *,
double *)> *)
fLambdaPtr);
3490 double *
v =
const_cast<double*
>(
x);
3491 double *
p = (params) ?
const_cast<double*
>(params) :
const_cast<double*
>(
fClingParameters.data());
3498 double * vars = (
x) ?
const_cast<double*
>(
x) :
const_cast<double*
>(
fClingVariables.data());
3501 (*fFuncPtr)(0, 1, args, &
result);
3503 double *pars = (params) ?
const_cast<double *
>(params) :
const_cast<double *
>(
fClingParameters.data());
3505 (*fFuncPtr)(0, 2, args, &
result);
3512#ifdef R__HAS_VECCORE
3516 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3517 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3520 printf(
"%s is unknown.\n", fun.
GetName());
3532 auto thisFormula =
const_cast<TFormula*
>(
this);
3536 Error(
"DoEval",
"Formula has error and it is not properly initialized ");
3548 (*fFuncPtr)(0, 1, args, &
result);
3550 double *pars = (params) ?
const_cast<double *
>(params) :
const_cast<double *
>(
fClingParameters.data());
3552 (*fFuncPtr)(0, 2, args, &
result);
3569 Info(
"ReInitializeEvalMethod",
"compile now lambda expression function using Cling");
3576 if (!
fLazyInitialization)
Warning(
"ReInitializeEvalMethod",
"Formula is NOT properly initialized - try calling again TFormula::PrepareEvalMethod");
3635 std::size_t found = clingFunc.find(
"return");
3636 std::size_t found2 = clingFunc.rfind(
";");
3637 if (found == std::string::npos || found2 == std::string::npos) {
3638 Error(
"GetExpFormula",
"Invalid Cling expression - return default formula expression");
3643 if (!opt.
Contains(
"P"))
return clingFormula;
3646 while (i < clingFormula.
Length()-2 ) {
3648 if (clingFormula[i] ==
'p' && clingFormula[i+1] ==
'[' && isdigit(clingFormula[i+2]) ) {
3650 while ( isdigit(clingFormula[j]) ) { j++;}
3651 if (clingFormula[j] !=
']') {
3652 Error(
"GetExpFormula",
"Parameters not found - invalid expression - return default cling formula");
3653 return clingFormula;
3655 TString parNumbName = clingFormula(i+2,j-i-2);
3656 int parNumber = parNumbName.
Atoi();
3657 assert(parNumber <
fNpar);
3659 clingFormula.
Replace(i,j-i+1, replacement );
3660 i += replacement.
Length();
3664 return clingFormula;
3670 while (i < expFormula.
Length()-2 ) {
3672 if (expFormula[i] ==
'[') {
3674 while ( expFormula[j] !=
']' ) { j++;}
3675 if (expFormula[j] !=
']') {
3676 Error(
"GetExpFormula",
"Parameter names not found - invalid expression - return default formula");
3679 TString parName = expFormula(i+1,j-i-1);
3681 expFormula.
Replace(i,j-i+1, replacement );
3682 i += replacement.
Length();
3688 Warning(
"GetExpFormula",
"Invalid option - return default formula expression");
3693 std::unique_ptr<TInterpreterValue>
v =
gInterpreter->MakeInterpreterValue();
3694 std::string s(
"(void (&)(Double_t *, Double_t *, clad::array_ref<Double_t>)) ");
3697 return v->ToString();
3701 std::unique_ptr<TInterpreterValue>
v =
gInterpreter->MakeInterpreterValue();
3703 return v->ToString();
3712 printf(
" Formula expression: \n");
3721 printf(
"List of Variables: \n");
3723 for (
int ivar = 0; ivar <
fNdim ; ++ivar) {
3728 printf(
"List of Parameters: \n");
3733 for (
int ipar = 0; ipar <
fNpar ; ++ipar) {
3737 printf(
"Expression passed to Cling:\n");
3740 printf(
"Generated Gradient:\n");
3745 printf(
"Generated Hessian:\n");
3752 Warning(
"Print",
"Formula is not ready to execute. Missing parameters/variables");
3753 for (list<TFormulaFunction>::const_iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3756 printf(
"%s is unknown.\n", fun.
GetName());
3779 if (
b.IsReading() ) {
3783 if (v <= 8 && v > 3 &&
v != 6) {
3796 Error(
"Streamer",
"Old formula read from file is NOT valid");
3849 if (
fNpar != (
int) parValues.size() ) {
3850 Error(
"Streamer",
"number of parameters computed (%d) is not same as the stored parameters (%d)",
fNpar,
int(parValues.size()) );
3853 if (
v > 11 &&
fNdim != ndim) {
3854 Error(
"Streamer",
"number of dimension computed (%d) is not same as the stored value (%d)",
fNdim, ndim );
3869 assert(
fNpar == (
int) parValues.size() );
3872 if (
fParams.size() != paramMap.size() ) {
3873 Warning(
"Streamer",
"number of parameters list found (%zu) is not same as the stored one (%zu) - use re-created list",
fParams.size(),paramMap.size()) ;
3889 gROOT->GetListOfFunctions()->Add(
this);
3892 Error(
"Streamer",
"Formula read from file is NOT ready to execute");
3900 Error(
"Streamer",
"Reading version %d is not supported",
v);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void GetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Stores the parameters of the given function into pars.
winID h TVirtualViewer3D TVirtualGLPainter p
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 target
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 UChar_t len
R__EXTERN TInterpreter * gCling
R__EXTERN TVirtualMutex * gROOTMutex
#define R__LOCKGUARD(mutex)
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
const TList * GetListOfAllPublicMethods(Bool_t load=kTRUE)
Returns a list of all public methods of this class and its base classes.
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.
virtual TFormula * GetFormula()
Global functions class (global functions are obtained from CINT).
virtual Longptr_t ProcessLine(const char *line, EErrorCode *error=nullptr)=0
virtual Bool_t Declare(const char *code)=0
virtual Bool_t CallFunc_IsValid(CallFunc_t *) const
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *) const
Method or function calling interface.
CallFunc_t * GetCallFunc() const
Each ROOT class (see TClass) has a linked list of methods.
The TNamed class is the base class for all named ROOT classes.
void Copy(TObject &named) const override
Copy this to obj.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Regular expression class.
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...
TString & Insert(Ssiz_t pos, const char *s)
Int_t Atoi() const
Return integer value of string.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
void ToUpper()
Change string to upper case.
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
constexpr Double_t G()
Gravitational constant in: .
constexpr Double_t C()
Velocity of light in .
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
constexpr Double_t K()
Boltzmann's constant in : .
constexpr Double_t Sqrt2()
constexpr Double_t E()
Base of natural log: .
constexpr Double_t Sigma()
Stefan-Boltzmann constant in : .
constexpr Double_t H()
Planck's constant in : .
constexpr Double_t LogE()
Base-10 log of e (to convert ln to log)
constexpr Double_t Ln10()
Natural log of 10 (to convert log to ln)
constexpr Double_t EulerGamma()
Euler-Mascheroni Constant.
constexpr Double_t R()
Universal gas constant ( ) in
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
void(* Generic_t)(void *, int, void **, void *)