12 #if __cplusplus >= 201103L 13 #define ROOT_CPLUSPLUS11 1 30 #include <unordered_map> 44 #pragma optimize("",off) 158 static std::unordered_map<std::string, void *>
gClingFunctions = std::unordered_map<std::string, void * >();
164 char ops[] = {
'+',
'^',
'-',
'/',
'*',
'<',
'>',
'|',
'&',
'!',
'=',
'?'};
165 Int_t opsLen =
sizeof(ops)/
sizeof(
char);
166 for(
Int_t i = 0; i < opsLen; ++i)
176 char brackets[] = {
')',
'(',
'{',
'}'};
177 Int_t bracketsLen =
sizeof(brackets)/
sizeof(
char);
178 for(
Int_t i = 0; i < bracketsLen; ++i)
187 return !IsBracket(c) && !IsOperator(c) && c !=
',' && c !=
' ';
200 if ( (formula[i] ==
'e' || formula[i] ==
'E') && (i > 0 && i < formula.Length()-1) ) {
202 if ( (isdigit(formula[i-1]) || formula[i-1] ==
'.') && ( isdigit(formula[i+1]) || formula[i+1] ==
'+' || formula[i+1] ==
'-' ) )
212 if ( (formula[i] ==
'x' || formula[i] ==
'X') && (i > 0 && i < formula.Length()-1) && formula[i-1] ==
'0') {
213 if (isdigit(formula[i+1]) )
215 static char hex_values[12] = {
'a',
'A',
'b',
'B',
'c',
'C',
'd',
'D',
'e',
'E',
'f',
'F'};
216 for (
int jjj = 0; jjj < 12; ++jjj) {
217 if (formula[i+1] == hex_values[jjj])
234 Bool_t foundOpenParenthesis =
false;
235 if (pos == 0 || pos == formula.Length()-1)
return false;
236 for (
int i = pos-1; i >=0; i--) {
237 if (formula[i] ==
']' )
return false;
238 if (formula[i] ==
'[' ) {
239 foundOpenParenthesis =
true;
243 if (!foundOpenParenthesis )
return false;
246 for (
int i = pos+1; i < formula.Length(); i++) {
247 if (formula[i] ==
']' )
return true;
260 TRegexp numericPattern(
"p?[0-9]+");
263 int patternStart = numericPattern.
Index(
a, len);
264 bool aNumeric = (patternStart == 0 && *len ==
a.Length());
266 patternStart = numericPattern.
Index(
b, len);
267 bool bNumeric = (patternStart == 0 && *len ==
b.Length());
271 if (aNumeric && !bNumeric)
273 else if (!aNumeric && bNumeric)
275 else if (!aNumeric && !bNumeric)
278 int aInt = (
a[0] ==
'p') ? TString(
a(1,
a.Length())).Atoi() :
a.Atoi();
279 int bInt = (
b[0] ==
'p') ? TString(
b(1,
b.Length())).Atoi() :
b.Atoi();
290 for (
int i = 0; i < formula.Length(); i++) {
293 if (isalpha(formula[i]) || formula[i] ==
'{' || formula[i] ==
'[') {
296 j < formula.Length() && (IsFunctionNameChar(formula[j])
297 || (formula[i] ==
'{' && formula[j] ==
'}'));
300 TString
name = (TString)formula(i, j - i);
305 if (substitutions.find(
name) != substitutions.end()) {
306 formula.Replace(i,
name.Length(),
"(" + substitutions[
name] +
")");
307 i += substitutions[
name].Length() + 2 - 1;
309 }
else if (isalpha(formula[i])) {
312 i +=
name.Length() - 1;
324 fReadyToExecute =
false;
325 fClingInitialized =
false;
326 fAllParametersSetted =
false;
333 fLambdaPtr =
nullptr;
338 if (strlen(
name)!=1)
return false;
339 for (
auto const & specialName : {
"x",
"y",
"z",
"t"}){
340 if (strcmp(
name,specialName)==0)
return true;
353 gROOT->GetListOfFunctions()->Remove(
this);
359 int nLinParts = fLinearParts.size();
361 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
368 fClingInput(formula),fFormula(formula)
379 #ifndef R__HAS_VECCORE 386 if (addToGlobList &&
gROOT) {
391 gROOT->GetListOfFunctions()->Remove(old);
393 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",
name);
395 gROOT->GetListOfFunctions()->Add(
this);
415 fClingInput(formula),fFormula(formula)
427 for (
int i = 0; i < npar; ++i) {
431 assert (
fNpar == npar);
441 if (addToGlobList &&
gROOT) {
446 gROOT->GetListOfFunctions()->Remove(old);
448 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",
name);
450 gROOT->GetListOfFunctions()->Add(
this);
455 Error(
"TFormula",
"Syntax error in building the lambda expression %s", formula );
460 TNamed(formula.
GetName(),formula.GetTitle()), fMethod(nullptr)
468 gROOT->GetListOfFunctions()->Remove(old);
471 Error(
"TFormula",
"The name %s is reserved as a TFormula variable name.\n",formula.
GetName());
473 gROOT->GetListOfFunctions()->Add(
this);
493 std::string lambdaExpression = formula;
509 TString lambdaName =
TString::Format(
"lambda__id%zu", hasher(lambdaExpression) );
513 TString lineExpr =
TString::Format(
"std::function<double(double*,double*)> %s = %s ;",lambdaName.Data(), lambdaExpression.c_str() );
534 TString formula = expression;
535 if (formula.IsNull() ) {
537 if (formula.IsNull() ) formula =
GetTitle();
540 if (formula.IsNull() )
return -1;
552 return (ret) ? 0 : 1;
562 return (ret) ? 0 : 1;
591 for (
int i = 0; i < nLinParts; ++i)
delete fnew.
fLinearParts[i];
598 for (
int i = 0; i < nLinParts; ++i) {
602 linearOld->
Copy(*linearNew);
625 Error(
"TFormula",
"Syntax error in building the lambda expression %s",
fFormula.Data() );
670 for (
int i = 0; i < nLinParts; ++i)
delete fLinearParts[i];
688 TString prototypeArguments =
"";
689 if (hasVariables || hasParameters) {
691 prototypeArguments.Append(
"ROOT::Double_v*");
693 prototypeArguments.Append(
"Double_t*");
696 prototypeArguments.Append(
",");
699 prototypeArguments.Append(
"Double_t*");
704 Error(
"Eval",
"Can't find %s function prototype with arguments %s",
fClingName.Data(),
705 prototypeArguments.Data());
752 const TString defvars[] = {
"x",
"y",
"z",
"t"};
753 const pair<TString, Double_t> defconsts[] = {{
"pi",
TMath::Pi()},
771 const pair<TString,TString> funShortcuts[] =
772 { {
"sin",
"TMath::Sin" },
773 {
"cos",
"TMath::Cos" }, {
"exp",
"TMath::Exp"}, {
"log",
"TMath::Log"}, {
"log10",
"TMath::Log10"},
774 {
"tan",
"TMath::Tan"}, {
"sinh",
"TMath::SinH"}, {
"cosh",
"TMath::CosH"},
775 {
"tanh",
"TMath::TanH"}, {
"asin",
"TMath::ASin"}, {
"acos",
"TMath::ACos"},
776 {
"atan",
"TMath::ATan"}, {
"atan2",
"TMath::ATan2"}, {
"sqrt",
"TMath::Sqrt"},
777 {
"ceil",
"TMath::Ceil"}, {
"floor",
"TMath::Floor"}, {
"pow",
"TMath::Power"},
778 {
"binomial",
"TMath::Binomial"},{
"abs",
"TMath::Abs"},
779 {
"min",
"TMath::Min"},{
"max",
"TMath::Max"},{
"sign",
"TMath::Sign" },
783 std::vector<TString> defvars2(10);
784 for (
int i = 0; i < 9; ++i)
787 for (
auto var : defvars) {
788 int pos =
fVars.size();
801 for (
auto con : defconsts) {
802 fConsts[con.first] = con.second;
807 for (
auto fun : funShortcuts) {
819 #ifdef R__HAS_VECCORE 820 const pair<TString,TString> vecFunShortcuts[] =
821 { {
"sin",
"vecCore::math::Sin" },
822 {
"cos",
"vecCore::math::Cos" }, {
"exp",
"vecCore::math::Exp"}, {
"log",
"vecCore::math::Log"}, {
"log10",
"vecCore::math::Log10"},
823 {
"tan",
"vecCore::math::Tan"},
825 {
"asin",
"vecCore::math::ASin"},
826 {
"acos",
"TMath::Pi()/2-vecCore::math::ASin"},
827 {
"atan",
"vecCore::math::ATan"},
828 {
"atan2",
"vecCore::math::ATan2"}, {
"sqrt",
"vecCore::math::Sqrt"},
829 {
"ceil",
"vecCore::math::Ceil"}, {
"floor",
"vecCore::math::Floor"}, {
"pow",
"vecCore::math::Pow"},
830 {
"cbrt",
"vecCore::math::Cbrt"},{
"abs",
"vecCore::math::Abs"},
831 {
"min",
"vecCore::math::Min"},{
"max",
"vecCore::math::Max"},{
"sign",
"vecCore::math::Sign" }
835 for (
auto fun : vecFunShortcuts) {
852 Int_t polPos = formula.Index(
"pol");
855 Bool_t defaultVariable =
false;
857 Int_t openingBracketPos = formula.Index(
'(', polPos);
858 Bool_t defaultCounter = openingBracketPos ==
kNPOS;
859 Bool_t defaultDegree =
true;
862 if (!defaultCounter) {
865 sdegree = formula(polPos + 3, openingBracketPos - polPos - 3);
866 if (!sdegree.IsDigit())
867 defaultCounter =
true;
869 if (!defaultCounter) {
871 counter = TString(formula(openingBracketPos + 1, formula.Index(
')', polPos) - openingBracketPos)).Atoi();
873 Int_t temp = polPos + 3;
874 while (temp < formula.Length() && isdigit(formula[temp])) {
875 defaultDegree =
false;
878 degree = TString(formula(polPos + 3, temp - polPos - 3)).Atoi();
883 if (polPos - 1 < 0 || !
IsFunctionNameChar(formula[polPos - 1]) || formula[polPos - 1] ==
':') {
885 defaultVariable =
true;
887 Int_t tmp = polPos - 1;
891 variable = formula(tmp + 1, polPos - (tmp + 1));
893 Int_t param = counter + 1;
897 replacement.Append(
TString::Format(
"+[%d]*%s^%d", param, variable.Data(), tmp));
899 replacement.Append(
TString::Format(
"+[%d]*%s", param, variable.Data()));
905 replacement.Insert(0,
'(');
906 replacement.Append(
')');
909 if (defaultCounter && !defaultDegree) {
911 }
else if (defaultCounter && defaultDegree) {
912 pattern =
TString::Format(
"%spol", (defaultVariable ?
"" : variable.Data()));
917 if (!formula.Contains(pattern)) {
918 Error(
"HandlePolN",
"Error handling polynomial function - expression is %s - trying to replace %s with %s ",
919 formula.Data(), pattern.Data(), replacement.Data());
922 if (formula == pattern) {
927 formula.ReplaceAll(pattern, replacement);
928 polPos = formula.Index(
"pol");
954 map< pair<TString,Int_t> ,pair<TString,TString> > functions;
957 map<TString,Int_t> functionsNumbers;
958 functionsNumbers[
"gaus"] = 100;
959 functionsNumbers[
"bigaus"] = 102;
960 functionsNumbers[
"landau"] = 400;
961 functionsNumbers[
"expo"] = 200;
962 functionsNumbers[
"crystalball"] = 500;
965 formula.ReplaceAll(
"xygaus",
"gaus[x,y]");
966 formula.ReplaceAll(
"xgaus",
"gaus[x]");
967 formula.ReplaceAll(
"ygaus",
"gaus[y]");
968 formula.ReplaceAll(
"zgaus",
"gaus[z]");
969 formula.ReplaceAll(
"xexpo",
"expo[x]");
970 formula.ReplaceAll(
"yexpo",
"expo[y]");
971 formula.ReplaceAll(
"zexpo",
"expo[z]");
972 formula.ReplaceAll(
"xylandau",
"landau[x,y]");
973 formula.ReplaceAll(
"xyexpo",
"expo[x,y]");
975 const char * defaultVariableNames[] = {
"x",
"y",
"z"};
977 for (map<pair<TString, Int_t>, pair<TString, TString>>::iterator it = functions.begin(); it != functions.end();
980 TString funName = it->first.first;
981 Int_t funDim = it->first.second;
982 Int_t funPos = formula.Index(funName);
988 Int_t lastFunPos = funPos + funName.Length();
991 Int_t iposBefore = funPos - 1;
994 if (iposBefore >= 0) {
995 assert(iposBefore < formula.Length());
996 if (isalpha(formula[iposBefore])) {
999 funPos = formula.Index(funName, lastFunPos);
1004 Bool_t isNormalized =
false;
1005 if (lastFunPos < formula.Length()) {
1007 isNormalized = (formula[lastFunPos] ==
'n');
1010 if (lastFunPos < formula.Length()) {
1011 char c = formula[lastFunPos];
1014 if (isalnum(c) || (!
IsOperator(c) && c !=
'(' && c !=
')' && c !=
'[' && c !=
']')) {
1016 funPos = formula.Index(funName, lastFunPos);
1027 TString varList =
"";
1028 Bool_t defaultVariables =
false;
1031 Int_t openingBracketPos = funPos + funName.Length() + (isNormalized ? 1 : 0);
1033 if (openingBracketPos > formula.Length() || formula[openingBracketPos] !=
'[') {
1036 for (
Int_t idim = 0; idim < dim; ++idim)
1037 variables[idim] = defaultVariableNames[idim];
1038 defaultVariables =
true;
1041 closingBracketPos = formula.Index(
']', openingBracketPos);
1042 varList = formula(openingBracketPos + 1, closingBracketPos - openingBracketPos - 1);
1043 dim = varList.CountChar(
',') + 1;
1046 TString varName =
"";
1047 for (
Int_t i = 0; i < varList.Length(); ++i) {
1049 varName.Append(varList[i]);
1051 if (varList[i] ==
',') {
1064 if (dim != funDim) {
1065 pair<TString, Int_t> key = make_pair(funName, dim);
1066 if (functions.find(key) == functions.end()) {
1067 Error(
"PreProcessFormula",
"Dimension of function %s is detected to be of dimension %d and is not " 1068 "compatible with existing pre-defined function which has dim %d",
1069 funName.Data(), dim, funDim);
1073 funPos = formula.Index(funName, lastFunPos);
1078 Int_t openingParenthesisPos = (closingBracketPos ==
kNPOS) ? openingBracketPos : closingBracketPos + 1;
1079 bool defaultCounter = (openingParenthesisPos > formula.Length() || formula[openingParenthesisPos] !=
'(');
1084 if (defaultCounter) {
1090 TRegexp counterPattern(
"([0-9]+)");
1092 if (counterPattern.
Index(formula, len, openingParenthesisPos) == -1) {
1093 funPos = formula.Index(funName, funPos + 1);
1097 TString(formula(openingParenthesisPos + 1, formula.Index(
')', funPos) - openingParenthesisPos - 1))
1103 TString body = (isNormalized ? it->second.second : it->second.first);
1104 if (isNormalized && body ==
"") {
1105 Error(
"PreprocessFormula",
"%d dimension function %s has no normalized form.", it->first.second,
1109 for (
int i = 0; i < body.Length(); ++i) {
1110 if (body[i] ==
'{') {
1113 Int_t num = TString(body(i, body.Index(
'}', i) - i)).Atoi();
1117 body.Replace(i, pattern.Length(), variable, variable.Length());
1118 i += variable.Length() - 1;
1119 }
else if (body[i] ==
'[') {
1122 while (tmp < body.Length() && body[tmp] !=
']') {
1125 Int_t num = TString(body(i + 1, tmp - 1 - i)).Atoi();
1129 body.Replace(i + 1, tmp - 1 - i, replacement, replacement.Length());
1130 i += replacement.Length() + 1;
1134 if (defaultCounter && defaultVariables) {
1135 pattern =
TString::Format(
"%s%s", funName.Data(), (isNormalized ?
"n" :
""));
1137 if (!defaultCounter && defaultVariables) {
1138 pattern =
TString::Format(
"%s%s(%d)", funName.Data(), (isNormalized ?
"n" :
""), counter);
1140 if (defaultCounter && !defaultVariables) {
1141 pattern =
TString::Format(
"%s%s[%s]", funName.Data(), (isNormalized ?
"n" :
""), varList.Data());
1143 if (!defaultCounter && !defaultVariables) {
1145 TString::Format(
"%s%s[%s](%d)", funName.Data(), (isNormalized ?
"n" :
""), varList.Data(), counter);
1147 TString replacement = body;
1150 if (
fNumber == 0 && formula.Length() <= (pattern.Length() - funPos) + 1) {
1151 fNumber = functionsNumbers[funName] + 10 * (dim - 1);
1156 formula.Replace(funPos, pattern.Length(), replacement, replacement.Length());
1158 funPos = formula.Index(funName);
1168 TRegexp rangePattern(
"\\[[0-9]+\\.\\.[0-9]+\\]");
1171 while ((matchIdx = rangePattern.
Index(formula, len, matchIdx)) != -1) {
1172 int startIdx = matchIdx + 1;
1173 int endIdx = formula.Index(
"..", startIdx) + 2;
1174 int startCnt = TString(formula(startIdx, formula.Length())).Atoi();
1175 int endCnt = TString(formula(endIdx, formula.Length())).Atoi();
1177 if (endCnt <= startCnt)
1178 Error(
"HandleParamRanges",
"End parameter (%d) <= start parameter (%d) in parameter range", endCnt, startCnt);
1180 TString newString =
"[";
1181 for (
int cnt = startCnt;
cnt < endCnt;
cnt++)
1186 formula.Replace(matchIdx, formula.Index(
"]", matchIdx) + 1 - matchIdx, newString);
1188 matchIdx += newString.Length();
1202 std::map<std::pair<TString, Int_t>, std::pair<TString, TString>> parFunctions;
1206 for (
Int_t i = 0; i < formula.Length(); ++i) {
1210 if (formula[i] ==
'[') {
1211 while (formula[i] !=
']')
1216 if (formula[i] ==
'\"') {
1219 while (formula[i] !=
'\"');
1227 while (!
IsOperator(formula[i]) && i < formula.Length())
1233 if (isalpha(formula[i]) && !
IsOperator(formula[i])) {
1239 TString
name = (TString)formula(i, j - i);
1246 std::vector<int> argSeparators;
1247 argSeparators.push_back(j);
1249 for (k = j + 1; depth >= 1 && k < formula.Length(); k++) {
1250 if (formula[k] ==
',' && depth == 1) {
1252 argSeparators.push_back(k);
1253 }
else if (formula[k] ==
'(')
1255 else if (formula[k] ==
')')
1258 argSeparators.push_back(k - 1);
1264 obj =
gROOT->GetListOfFunctions()->FindObject(
name);
1269 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1277 bool nameRecognized = (f != NULL);
1282 TString replacementFormula;
1290 for (
auto keyval : parFunctions) {
1292 pair<TString, Int_t> name_ndim = keyval.first;
1294 pair<TString, TString> formulaPair = keyval.second;
1297 if (
name == name_ndim.first)
1298 replacementFormula = formulaPair.first;
1299 else if (
name == name_ndim.first +
"n" && formulaPair.second !=
"")
1300 replacementFormula = formulaPair.second;
1305 ndim = name_ndim.second;
1310 while ((idx = replacementFormula.Index(
'[', idx)) !=
kNPOS) {
1311 npar = max(npar, 1 + TString(replacementFormula(idx + 1, replacementFormula.Length())).Atoi());
1312 idx = replacementFormula.Index(
']', idx);
1314 Error(
"HandleFunctionArguments",
"Square brackets not matching in formula %s",
1315 (
const char *)replacementFormula);
1322 if (nArguments == ndim + npar || nArguments == npar || nArguments == ndim) {
1323 nameRecognized =
true;
1328 if (nameRecognized && ndim > 4)
1329 Error(
"HandleFunctionArguments",
"Number of dimensions %d greater than 4. Cannot parse formula.", ndim);
1332 if (nameRecognized && j < formula.Length() && formula[j] ==
'(') {
1337 map<TString, TString> argSubstitutions;
1339 const char *defaultVariableNames[] = {
"x",
"y",
"z",
"t"};
1342 bool canReplace =
false;
1343 if (nArguments == ndim + npar) {
1345 for (
int argNr = 0; argNr < nArguments; argNr++) {
1349 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1356 argSubstitutions[oldName] = newName;
1359 argSubstitutions[defaultVariableNames[argNr]] = newName;
1362 int parNr = argNr - ndim;
1365 argSubstitutions[oldName] = newName;
1368 if (f && oldName == newName)
1374 }
else if (nArguments == npar) {
1379 bool varsImplicit =
true;
1380 for (
int argNr = 0; argNr < nArguments && varsImplicit; argNr++) {
1381 int openIdx = argSeparators[argNr] + 1;
1382 int closeIdx = argSeparators[argNr + 1] - 1;
1385 if (formula[openIdx] !=
'[' || formula[closeIdx] !=
']' || closeIdx <= openIdx + 1)
1386 varsImplicit =
false;
1389 for (
int idx = openIdx + 1; idx < closeIdx && varsImplicit; idx++)
1391 varsImplicit =
false;
1394 Warning(
"HandleFunctionArguments",
1395 "Argument %d is not a parameter. Cannot assume variables are implicit.", argNr);
1402 for (
int dim = 0; dim < ndim; dim++) {
1403 argSubstitutions[
TString::Format(
"{V%d}", dim)] = defaultVariableNames[dim];
1407 for (
int argNr = 0; argNr < nArguments; argNr++) {
1411 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1415 argSubstitutions[oldName] = newName;
1418 if (f && oldName == newName)
1425 if (!canReplace && nArguments == ndim) {
1429 for (
int argNr = 0; argNr < nArguments; argNr++) {
1432 TString(formula(argSeparators[argNr] + 1, argSeparators[argNr + 1] - argSeparators[argNr] - 1));
1436 argSubstitutions[oldName] = newName;
1439 argSubstitutions[defaultVariableNames[argNr]] = newName;
1444 for (
int parNr = 0; parNr < npar; parNr++)
1458 formula.Replace(i, k - i, replacementFormula);
1459 i += replacementFormula.Length() - 1;
1462 Warning(
"HandleFunctionArguments",
"Unable to make replacement. Number of parameters doesn't work : " 1463 "%d arguments, %d dimensions, %d parameters",
1464 nArguments, ndim, npar);
1483 Int_t caretPos = formula.Last(
'^');
1486 TString right, left;
1487 Int_t temp = caretPos;
1490 if (formula[temp] ==
')') {
1493 while (depth != 0 && temp > 0) {
1494 if (formula[temp] ==
')')
1496 if (formula[temp] ==
'(')
1511 assert(temp + 1 >= 0);
1512 Int_t leftPos = temp + 1;
1513 left = formula(leftPos, caretPos - leftPos);
1519 if (temp >= formula.Length()) {
1520 Error(
"HandleExponentiation",
"Invalid position of operator ^");
1523 if (formula[temp] ==
'(') {
1526 while (depth != 0 && temp < formula.Length()) {
1527 if (formula[temp] ==
')')
1529 if (formula[temp] ==
'(')
1536 if (formula[temp] ==
'-' || formula[temp] ==
'+')
1542 while (temp < formula.Length() && ((depth > 0) || !
IsOperator(formula[temp]))) {
1548 if (temp < formula.Length() && formula[temp] ==
'(')
1550 if (temp < formula.Length() && formula[temp] ==
')') {
1558 right = formula(caretPos + 1, (temp - 1) - caretPos);
1561 TString pattern =
TString::Format(
"%s^%s", left.Data(), right.Data());
1562 TString replacement =
TString::Format(
"pow(%s,%s)", left.Data(), right.Data());
1566 formula.Replace(leftPos, pattern.Length(), replacement, replacement.Length());
1568 caretPos = formula.Last(
'^');
1578 Int_t linPos = formula.Index(
"@");
1579 if (linPos ==
kNPOS )
return;
1580 Int_t nofLinParts = formula.CountChar((
int)
'@');
1581 assert(nofLinParts > 0);
1592 while (temp >= 0 && formula[temp] !=
'@') {
1595 left = formula(temp + 1, linPos - (temp + 1));
1598 while (temp < formula.Length() && formula[temp] !=
'@') {
1601 TString right = formula(linPos + 1, temp - (linPos + 1));
1605 TString replacement =
1606 (
first) ?
TString::Format(
"([%d]*(%s))+([%d]*(%s))", Nlinear, left.Data(), Nlinear + 1, right.Data())
1608 Nlinear += (
first) ? 2 : 1;
1610 formula.ReplaceAll(pattern, replacement);
1618 linPos = formula.Index(
"@");
1632 formula.ReplaceAll(
"**",
"^");
1633 formula.ReplaceAll(
"++",
"@");
1634 formula.ReplaceAll(
" ",
"");
1644 formula.ReplaceAll(
"--",
"- -");
1645 formula.ReplaceAll(
"++",
"+ +");
1698 for (
Int_t i = 0; i < formula.Length(); ++i) {
1702 if (formula[i] ==
'[') {
1706 while (i < formula.Length() && formula[i] !=
']') {
1707 param.Append(formula[i++]);
1712 int paramIndex = -1;
1713 if (param.IsDigit()) {
1714 paramIndex = param.Atoi();
1715 param.Insert(0,
'p');
1718 for (
int idx = 0; idx <= paramIndex; ++idx) {
1726 Int_t oldParamLength = param.Length();
1727 param.ReplaceAll(
"\\s",
" ");
1729 i -= param.Length() - oldParamLength;
1741 formula.Replace(tmp, i - tmp, replacement, replacement.Length());
1747 if (formula[i] ==
'\"') {
1751 }
while (formula[i] !=
'\"');
1760 while (!
IsOperator(formula[i]) && i < formula.Length()) {
1769 if (isalpha(formula[i]) &&
1777 if (formula[i] ==
':' && ((i + 1) < formula.Length())) {
1778 if (formula[i + 1] ==
':') {
1787 name.Append(formula[i++]);
1790 if (formula[i] ==
'(') {
1792 if (formula[i] ==
')') {
1799 while (depth != 0 && i < formula.Length()) {
1800 switch (formula[i]) {
1801 case '(': depth++;
break;
1802 case ')': depth--;
break;
1810 body.Append(formula[i++]);
1813 Int_t originalBodyLen = body.Length();
1815 formula.Replace(i - originalBodyLen, originalBodyLen, body, body.Length());
1816 i += body.Length() - originalBodyLen;
1827 obj =
gROOT->GetListOfFunctions()->FindObject(
name);
1832 TF1 *
f1 =
dynamic_cast<TF1 *
>(obj);
1855 std::vector<TString> newNames;
1858 newNames.resize(f->
GetNpar());
1860 for (
int jpar = f->
GetNpar() - 1; jpar >= 0; --jpar) {
1863 if (pj[0] ==
'p' && TString(pj(1, pj.Length())).IsDigit()) {
1868 replacementFormula.ReplaceAll(oldName, newName);
1869 newNames[jpar] = newName;
1879 for (
int jpar = 0; jpar < f->
GetNpar(); ++jpar) {
1880 if (nparOffset > 0) {
1882 assert((
int)newNames.size() == f->
GetNpar());
1889 replacementFormula.Insert(0,
'(');
1890 replacementFormula.Insert(replacementFormula.Length(),
')');
1891 formula.Replace(i -
name.Length(),
name.Length(), replacementFormula, replacementFormula.Length());
1893 i += replacementFormula.Length() -
name.Length();
1905 formula.Replace(i -
name.Length(),
name.Length(), replacement, replacement.Length());
1937 for (list<TFormulaFunction>::iterator funcsIt =
fFuncs.begin(); funcsIt !=
fFuncs.end(); ++funcsIt) {
1947 TString shortcut = it->first;
1948 TString full = it->second;
1952 Ssiz_t index = formula.Index(shortcut, 0);
1953 while (index !=
kNPOS) {
1956 Ssiz_t i2 = index + shortcut.Length();
1957 if ((index > 0) && (isalpha(formula[index - 1]) || formula[index - 1] ==
':')) {
1958 index = formula.Index(shortcut, i2);
1961 if (i2 < formula.Length() && formula[i2] !=
'(') {
1962 index = formula.Index(shortcut, i2);
1966 formula.Replace(index, shortcut.Length(), full);
1967 Ssiz_t inext = index + full.Length();
1968 index = formula.Index(shortcut, inext);
1972 if (fun.
fName.Contains(
"::"))
1976 size_t index =
name.rfind(
"::");
1977 assert(index != std::string::npos);
1978 TString className = fun.
fName(0, fun.
fName(0, index).Length());
1979 TString functionName = fun.
fName(index + 2, fun.
fName.Length());
1985 TIter next(methodList);
1987 while ((p = (
TMethod *)next())) {
1988 if (strcmp(p->
GetName(), functionName.Data()) == 0 &&
2011 Info(
"TFormula",
"Could not find %s function with %d argument(s)", fun.
GetName(), fun.
GetNargs());
2028 formula.ReplaceAll(pattern, replacement);
2033 map<TString, TFormulaVariable>::iterator varsIt =
fVars.find(fun.
GetName());
2034 if (varsIt !=
fVars.end()) {
2036 TString
name = (*varsIt).second.GetName();
2037 Double_t value = (*varsIt).second.fValue;
2043 int varDim = (*varsIt).second.fArrayPos;
2044 if (varDim >=
fNdim) {
2049 if (
v.second.fArrayPos < varDim && !
v.second.fFound) {
2051 v.second.fFound =
true;
2058 TString replacement =
TString::Format(
"x[%d]", (*varsIt).second.fArrayPos);
2059 formula.ReplaceAll(pattern, replacement);
2069 TString funname = fun.
GetName();
2070 if (funname.Contains(
"x[") && funname.Contains(
"]")) {
2071 TString sdigit = funname(2, funname.Index(
"]"));
2072 int digit = sdigit.Atoi();
2073 if (digit >=
fNdim) {
2076 for (
int j = 0; j <
fNdim; ++j) {
2080 fVars[vname].fFound =
true;
2089 formula.ReplaceAll(pattern, funname);
2095 if (paramsIt !=
fParams.end()) {
2099 if (formula.Index(pattern) !=
kNPOS) {
2103 formula.ReplaceAll(pattern, replacement);
2112 map<TString, Double_t>::iterator constIt =
fConsts.find(fun.
GetName());
2113 if (constIt !=
fConsts.end()) {
2116 formula.ReplaceAll(pattern, value);
2132 if (!hasParameters) {
2145 Bool_t inputIntoCling = (formula.Length() > 0);
2146 if (inputIntoCling) {
2149 std::string inputFormula(formula.Data());
2153 std::string inputFormulaVecFlag = inputFormula;
2155 inputFormulaVecFlag +=
" (vectorized)";
2157 TString argType =
fVectorized ?
"ROOT::Double_v" :
"Double_t";
2160 TString argumentsPrototype =
TString::Format(
"%s%s%s", ( (hasVariables || hasParameters) ? (argType +
" *x").Data() :
""),
2161 (hasParameters ?
"," :
""), (hasParameters ?
"Double_t *p" :
""));
2178 inputIntoCling =
false;
2188 argumentsPrototype.Data(), inputFormula.c_str());
2207 if (inputIntoCling) {
2226 Bool_t allFunctorsMatched =
true;
2227 for (list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
2229 allFunctorsMatched =
false;
2230 if (it->GetNargs() == 0)
2231 Error(
"ProcessFormula",
"\"%s\" has not been matched in the formula expression", it->GetName());
2233 Error(
"ProcessFormula",
"Could not find %s function with %d argument(s)", it->GetName(), it->GetNargs());
2236 if (!allFunctorsMatched) {
2244 auto itvar =
fVars.begin();
2247 if (!itvar->second.fFound) {
2249 itvar =
fVars.erase(itvar);
2252 }
while (itvar !=
fVars.end());
2263 make_pair(make_pair(
"gaus", 1), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))",
2264 "[0]*exp(-0.5*(({V0}-[1])/[2])*(({V0}-[1])/[2]))/(sqrt(2*pi)*[2])")));
2265 functions.insert(make_pair(make_pair(
"landau", 1), make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)",
2266 "[0]*TMath::Landau({V0},[1],[2],true)")));
2267 functions.insert(make_pair(make_pair(
"expo", 1), make_pair(
"exp([0]+[1]*{V0})",
"")));
2269 make_pair(make_pair(
"crystalball", 1), make_pair(
"[0]*ROOT::Math::crystalball_function({V0},[3],[4],[2],[1])",
2270 "[0]*ROOT::Math::crystalball_pdf({V0},[3],[4],[2],[1])")));
2272 make_pair(make_pair(
"breitwigner", 1), make_pair(
"[0]*ROOT::Math::breitwigner_pdf({V0},[2],[1])",
2273 "[0]*ROOT::Math::breitwigner_pdf({V0},[2],[4],[1])")));
2275 functions.insert(make_pair(make_pair(
"cheb0", 1), make_pair(
"ROOT::Math::Chebyshev0({V0},[0])",
"")));
2276 functions.insert(make_pair(make_pair(
"cheb1", 1), make_pair(
"ROOT::Math::Chebyshev1({V0},[0],[1])",
"")));
2277 functions.insert(make_pair(make_pair(
"cheb2", 1), make_pair(
"ROOT::Math::Chebyshev2({V0},[0],[1],[2])",
"")));
2278 functions.insert(make_pair(make_pair(
"cheb3", 1), make_pair(
"ROOT::Math::Chebyshev3({V0},[0],[1],[2],[3])",
"")));
2280 make_pair(make_pair(
"cheb4", 1), make_pair(
"ROOT::Math::Chebyshev4({V0},[0],[1],[2],[3],[4])",
"")));
2282 make_pair(make_pair(
"cheb5", 1), make_pair(
"ROOT::Math::Chebyshev5({V0},[0],[1],[2],[3],[4],[5])",
"")));
2284 make_pair(make_pair(
"cheb6", 1), make_pair(
"ROOT::Math::Chebyshev6({V0},[0],[1],[2],[3],[4],[5],[6])",
"")));
2286 make_pair(make_pair(
"cheb7", 1), make_pair(
"ROOT::Math::Chebyshev7({V0},[0],[1],[2],[3],[4],[5],[6],[7])",
"")));
2287 functions.insert(make_pair(make_pair(
"cheb8", 1),
2288 make_pair(
"ROOT::Math::Chebyshev8({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8])",
"")));
2289 functions.insert(make_pair(make_pair(
"cheb9", 1),
2290 make_pair(
"ROOT::Math::Chebyshev9({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9])",
"")));
2292 make_pair(make_pair(
"cheb10", 1),
2293 make_pair(
"ROOT::Math::Chebyshev10({V0},[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10])",
"")));
2296 make_pair(make_pair(
"gaus", 2), make_pair(
"[0]*exp(-0.5*(({V0}-[1])/[2])^2 - 0.5*(({V1}-[3])/[4])^2)",
"")));
2298 make_pair(make_pair(
"landau", 2),
2299 make_pair(
"[0]*TMath::Landau({V0},[1],[2],false)*TMath::Landau({V1},[3],[4],false)",
"")));
2300 functions.insert(make_pair(make_pair(
"expo", 2), make_pair(
"exp([0]+[1]*{V0})",
"exp([0]+[1]*{V0}+[2]*{V1})")));
2303 make_pair(make_pair(
"bigaus", 2), make_pair(
"[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])",
2304 "[0]*ROOT::Math::bigaussian_pdf({V0},{V1},[2],[4],[5],[1],[3])")));
2386 if (i < 0 || i >=
n ) {
2387 Error(
"GetLinearPart",
"Formula %s has only %d linear parts - requested %d",
GetName(),
n,i);
2433 Bool_t anyNewVar =
false;
2434 for (
Int_t i = 0; i < size; ++i) {
2436 const TString &vname = vars[i];
2446 Int_t multiplier = 2;
2447 if (
fFuncs.size() > 100) {
2460 if (anyNewVar && !
fFormula.IsNull()) {
2472 Error(
"SetName",
"The name \'%s\' is reserved as a TFormula variable name.\n" 2473 "\tThis function will not be renamed.",
2478 auto listOfFunctions =
gROOT->GetListOfFunctions();
2479 TObject* thisAsFunctionInList =
nullptr;
2481 if (listOfFunctions){
2482 thisAsFunctionInList = listOfFunctions->
FindObject(
this);
2483 if (thisAsFunctionInList) listOfFunctions->Remove(thisAsFunctionInList);
2486 if (thisAsFunctionInList) listOfFunctions->Add(thisAsFunctionInList);
2500 for(
Int_t i = 0; i < size; ++i)
2502 pair<TString, Double_t>
v = vars[i];
2504 fVars[
v.first].fValue =
v.second;
2507 Error(
"SetVariables",
"Variable %s is not defined.",
v.first.Data());
2517 TString sname(
name);
2519 Error(
"GetVariable",
"Variable %s is not defined.", sname.Data());
2522 return fVars.find(sname)->second.fValue;
2530 TString sname(
name);
2532 Error(
"GetVarNumber",
"Variable %s is not defined.", sname.Data());
2535 return fVars.find(sname)->second.fArrayPos;
2543 if (ivar < 0 || ivar >=
fNdim)
return "";
2546 for (
auto &
v :
fVars) {
2547 if (
v.second.fArrayPos == ivar)
return v.first;
2549 Error(
"GetVarName",
"Variable with index %d not found !!",ivar);
2560 Error(
"SetVariable",
"Variable %s is not defined.",
name.Data());
2599 auto ret =
fParams.insert(std::make_pair(
name, pos));
2605 if (ret.first ==
fParams.begin())
2608 auto previous = (ret.first);
2610 pos = previous->second + 1;
2618 Warning(
"inserting parameter %s at pos %d when vector size is %d \n",
name.Data(), pos,
2628 for (
auto it = ret.first; it !=
fParams.end(); ++it) {
2638 if (processFormula) {
2666 Error(
"GetParameter",
"Parameter %s is not defined.",
name);
2681 Error(
"GetParameter",
"wrong index used - use GetParameter(name)");
2690 if (ipar < 0 || ipar >=
fNpar)
return "";
2694 if (p.second == ipar)
return p.first.Data();
2696 Error(
"GetParName",
"Parameter with index %d not found !!",ipar);
2729 Error(
"SetParameter",
"Parameter %s is not defined.",
name.Data());
2736 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2737 if (!it->second.fFound) {
2756 for(
Int_t i = 0 ; i < size ; ++i)
2758 pair<TString, Double_t> p = params[i];
2760 Error(
"SetParameters",
"Parameter %s is not defined", p.first.Data());
2763 fParams[p.first].fValue = p.second;
2764 fParams[p.first].fFound =
true;
2768 for (map<TString, TFormulaVariable>::iterator it =
fParams.begin(); it !=
fParams.end(); ++it) {
2769 if (!it->second.fFound) {
2780 if(!params || size < 0 || size >
fNpar)
return;
2783 Warning(
"SetParameters",
"size is not same of cling parameter size %d - %d",size,
int(
fClingParameters.size()) );
2784 for (
Int_t i = 0; i < size; ++i) {
2832 if (param < 0 || param >=
fNpar)
return;
2840 void TFormula::SetParNames(
const char *name0,
const char *name1,
const char *name2,
const char *name3,
2841 const char *name4,
const char *name5,
const char *name6,
const char *name7,
2842 const char *name8,
const char *name9,
const char *name10)
2872 if (ipar < 0 || ipar >
fNpar) {
2873 Error(
"SetParName",
"Wrong Parameter index %d ",ipar);
2879 if (it.second == ipar) {
2886 if (oldName.IsNull() ) {
2887 Error(
"SetParName",
"Parameter %d is not existing.",ipar);
2900 if (!formula.IsNull() ) {
2902 for(list<TFormulaFunction>::iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it)
2904 if (oldName == it->GetName()) {
2911 Error(
"SetParName",
"Parameter %s is not defined.", oldName.Data());
2915 TString newName =
name;
2916 newName.ReplaceAll(
" ",
"\\s");
2919 formula.ReplaceAll(pattern, replacement);
2927 #ifdef R__HAS_VECCORE 2929 Info(
"SetVectorized",
"Cannot vectorized a function of zero dimension");
2934 Error(
"SetVectorized",
"Cannot set vectorized to %d -- Formula is missing", vectorized);
2954 Warning(
"SetVectorized",
"Cannot set vectorized -- try building with option -Dbuiltin_veccore=On");
2964 #ifdef R__HAS_VECCORE 2968 return vecCore::Get( ret, 0 );
2975 Info(
"EvalPar",
"Function is vectorized - converting Double_t into ROOT::Double_v and back");
2978 const int maxDim = 4;
2979 std::array<ROOT::Double_v, maxDim> xvec;
2980 for (
int i = 0; i <
fNdim; i++)
2984 return vecCore::Get(ans, 0);
2987 std::vector<ROOT::Double_v> xvec(
fNdim);
2988 for (
int i = 0; i <
fNdim; i++)
2992 return vecCore::Get(ans, 0);
2997 Error(
"EvalPar",
"Formula is vectorized (even though VECCORE is disabled!)");
3003 #ifdef R__HAS_VECCORE 3013 return DoEvalVec(
x, params);
3016 return DoEval(
nullptr, params);
3021 Info(
"EvalPar",
"Function is not vectorized - converting ROOT::Double_v into Double_t and back");
3023 const int vecSize = vecCore::VectorSize<ROOT::Double_v>();
3024 std::vector<Double_t> xscalars(vecSize*
fNdim);
3026 for (
int i = 0; i < vecSize; i++)
3027 for (
int j = 0; j <
fNdim; j++)
3028 xscalars[i*
fNdim+j] = vecCore::Get(
x[j],i);
3031 for (
int i = 0; i < vecSize; i++)
3032 vecCore::Set(answers, i,
DoEval(&xscalars[i*
fNdim], params));
3043 double xxx[4] = {
x,
y,
z,t};
3052 double xxx[3] = {
x,
y,
z};
3061 double xxx[2] = {
x,
y};
3084 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3085 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3088 printf(
"%s is unknown.\n", fun.
GetName());
3095 std::function<double(double *, double *)> & fptr = * ( (std::function<double(double *, double *)> *)
fLambdaPtr);
3098 double *
v =
const_cast<double*
>(
x);
3099 double * p = (params) ? const_cast<double*>(params) :
const_cast<double*
>(
fClingParameters.data());
3104 Error(
"DoEval",
"Formula is invalid or not properly initialized - try calling TFormula::Compile");
3106 #ifdef EVAL_IS_NOT_CONST 3117 double * vars = (
x) ? const_cast<double*>(
x) :
const_cast<double*
>(
fClingVariables.data());
3120 (*fFuncPtr)(0, 1, args, &result);
3122 double *pars = (params) ? const_cast<double *>(params) :
const_cast<double *
>(
fClingParameters.data());
3124 (*fFuncPtr)(0, 2, args, &result);
3131 #ifdef R__HAS_VECCORE 3135 Error(
"Eval",
"Formula is invalid and not ready to execute ");
3136 for (
auto it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3139 printf(
"%s is unknown.\n", fun.
GetName());
3147 Error(
"DoEvalVec",
"Formula is invalid or not properly initialized - try calling TFormula::Compile");
3150 #ifdef EVAL_IS_NOT_CONST 3165 (*fFuncPtr)(0, 1, args, &result);
3167 double *pars = (params) ? const_cast<double *>(params) :
const_cast<double *
>(
fClingParameters.data());
3169 (*fFuncPtr)(0, 2, args, &result);
3173 #endif // R__HAS_VECCORE 3184 TString opt(option);
3193 if (opt.Contains(
"CLING") ) {
3195 std::size_t found = clingFunc.find(
"return");
3196 std::size_t found2 = clingFunc.rfind(
";");
3197 if (found == std::string::npos || found2 == std::string::npos) {
3198 Error(
"GetExpFormula",
"Invalid Cling expression - return default formula expression");
3201 TString clingFormula =
fClingInput(found+7,found2-found-7);
3203 if (!opt.Contains(
"P"))
return clingFormula;
3206 while (i < clingFormula.Length()-2 ) {
3208 if (clingFormula[i] ==
'p' && clingFormula[i+1] ==
'[' && isdigit(clingFormula[i+2]) ) {
3210 while ( isdigit(clingFormula[j]) ) { j++;}
3211 if (clingFormula[j] !=
']') {
3212 Error(
"GetExpFormula",
"Parameters not found - invalid expression - return default cling formula");
3213 return clingFormula;
3215 TString parNumbName = clingFormula(i+2,j-i-2);
3216 int parNumber = parNumbName.Atoi();
3217 assert(parNumber <
fNpar);
3219 clingFormula.Replace(i,j-i+1, replacement );
3220 i += replacement.Length();
3224 return clingFormula;
3226 if (opt.Contains(
"P") ) {
3230 while (i < expFormula.Length()-2 ) {
3232 if (expFormula[i] ==
'[') {
3234 while ( expFormula[j] !=
']' ) { j++;}
3235 if (expFormula[j] !=
']') {
3236 Error(
"GetExpFormula",
"Parameter names not found - invalid expression - return default formula");
3239 TString parName = expFormula(i+1,j-i-1);
3241 expFormula.Replace(i,j-i+1, replacement );
3242 i += replacement.Length();
3248 Warning(
"GetExpFormula",
"Invalid option - return default formula expression");
3258 printf(
" Formula expression: \n");
3259 printf(
"\t%s \n",
fFormula.Data() );
3260 TString opt(option);
3265 if (opt.Contains(
"V") ) {
3267 printf(
"List of Variables: \n");
3269 for (
int ivar = 0; ivar <
fNdim ; ++ivar) {
3274 printf(
"List of Parameters: \n");
3279 for (
int ipar = 0; ipar <
fNpar ; ++ipar) {
3283 printf(
"Expression passed to Cling:\n");
3288 Warning(
"Print",
"Formula is not ready to execute. Missing parameters/variables");
3289 for (list<TFormulaFunction>::const_iterator it =
fFuncs.begin(); it !=
fFuncs.end(); ++it) {
3292 printf(
"%s is unknown.\n", fun.
GetName());
3313 void TFormula::Streamer(
TBuffer &
b)
3315 if (
b.IsReading() ) {
3319 if (v <= 8 && v > 3 &&
v != 6) {
3332 Error(
"Streamer",
"Old formula read from file is NOT valid");
3378 if (
fNpar != (
int) parValues.size() ) {
3379 Error(
"Streamer",
"number of parameters computed (%d) is not same as the stored parameters (%d)",
fNpar,
int(parValues.size()) );
3391 assert(
fNpar == (
int) parValues.size() );
3394 if (
fParams.size() != paramMap.size() ) {
3395 Warning(
"Streamer",
"number of parameters list found (%zu) is not same as the stored one (%zu) - use re-created list",
fParams.size(),paramMap.size()) ;
3411 gROOT->GetListOfFunctions()->Add(
this);
3414 Error(
"Streamer",
"Formula read from file is NOT ready to execute");
3422 Error(
"Streamer",
"Reading version %d is not supported",
v);
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
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()
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()
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.
virtual void Delete(Option_t *option="")
Delete this object.
Int_t GetNargs() const
Number of function arguments.
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.
void InitWithPrototype(TClass *cl, const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Initialize the method invocation environment.
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)
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()
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()
constexpr Double_t Sigma()
R__EXTERN TInterpreter * gCling
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 const char * GetTitle() const
Returns title of object.