ROOT » HIST » HIST » TFormulaParamOrder

class TFormulaParamOrder


The F O R M U L A class

This is a new version of the TFormula class based on Cling. This class is not 100% backward compatible with the old TFOrmula class, which is still available in ROOT as ROOT::v5::TFormula. Some of the TFormula member funtions available in version 5, such as Analyze and AnalyzeFunction are not available in the new TFormula. On the other hand formula expressions which were valid in version 5 are still valid in TFormula version 6

This class has been implemented during Google Summer of Code 2013 by Maciej Zimnoch.

Example of valid expressions:

  • sin(x)/x
  • [0]*sin(x) + [1]*exp(-[2]*x)
  • x + y**2
  • x^2 + y^2
  • [0]*pow([1],4)
  • 2*pi*sqrt(x/y)
  • gaus(0)*expo(3) + ypol3(5)*x
  • gausn(0)*expo(3) + ypol3(5)*x

In the last example above:

  • gaus(0) is a substitute for [0]*exp(-0.5*((x-[1])/[2])**2) and (0) means start numbering parameters at 0
  • gausn(0) is a substitute for [0]*exp(-0.5*((x-[1])/[2])**2)/(sqrt(2*pi)*[2])) and (0) means start numbering parameters at 0
  • expo(3) is a substitute for exp([3]+[4]*x
  • pol3(5) is a substitute for par[5]+par[6]*x+par[7]*x**2+par[8]*x**3 (PolN stands for Polynomial of degree N)

TMath functions can be part of the expression, eg:

  • TMath::Landau(x)*sin(x)
  • TMath::Erf(x)

Formula may contain constans, eg:

  • sqrt2
  • e
  • pi
  • ln10
  • infinity

and more.

Comparisons operators are also supported (&&, ||, ==, <=, >=, !)

Examples:

    `sin(x*(x<0.5 || x>1))`
>

If the result of a comparison is TRUE, the result is 1, otherwise 0.

Already predefined names can be given. For example, if the formula

 `TFormula old("old",sin(x*(x<0.5 || x>1)))`
>

one can assign a name to the formula. By default the name of the object = title = formula itself.

 `TFormula new("new","x*old")`
>

is equivalent to:

 `TFormula new("new","x*sin(x*(x<0.5 || x>1))")`
>

The class supports unlimited numer of variables and parameters. By default the names which can be used for the variables are x,y,z,t or x[0],x[1],x[2],x[3],....x[N] for N-dimensionals formula.

This class is not anymore the base class for the function classes TF1, but it has now adata member of TF1 which can be access via TF1::GetFormula.


Function Members (Methods)

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

bool operator()(const TString& a, const TString& b) const
 implement comparison used to set parameter orders in TFormula
 want p2 to be before p10
TFormula& operator=(const TFormula &rhs)