The FORMULA class (ROOT version 5)
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
(here Pol3 stands for Polynomial of degree 3)
TMath functions can be part of the expression, eg:
TMath::Landau(x)*sin(x)
TMath::Erf(x)
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(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. old.SetName("old"). then, old can be reused in a new expression. TFormula new("x*old") is equivalent to: TFormula new("x*sin(x*(x<0.5 || x>1))")
Up to 4 dimensions are supported (indicated by x, y, z, t) An expression may have 0 parameters or a list of parameters indicated by the sequence [par_number]
A graph showing the logic to compile and analyze a formula is shown in TFormula::Compile and TFormula::Analyze. Once a formula has been compiled, it can be evaluated for a given set of parameters. see graph in TFormula::EvalPar.
This class is the base class for the function classes TF1,TF2 and TF3. It is also used by the ntuple selection mechanism TNtupleFormula.
In version 7 of TFormula, the usage of fOper has been changed to improve the performance of TFormula::EvalPar. Conceptually, fOper was changed from a simple array of Int_t to an array of composite values. For example a 'ylandau(5)' operation used to be encoded as 4105; it is now encoded as (klandau >> kTFOperShift) + 5 Any class inheriting from TFormula and using directly fOper (which is now a private data member), needs to be updated to take this in consideration. The member functions recommended to set and access fOper are: SetAction, GetAction, GetActionParam For more performant access to the information, see the implementation TFormula::EvalPar
When creating complex formula , it may be necessary to increase some default parameters. see static function TFormula::SetMaxima
This is a frequently asked question. C++ is a strongly typed language. There is no way for TFormula (without recompiling this class) to know about all possible user defined data types. This also apply to the case of a static class function. Because TMath is a special and frequent case, TFormula is aware of all TMath functions.
Definition at line 65 of file TFormula.h.
Public Types | |
enum | { kNotGlobal = BIT(10) , kNormalized = BIT(14) , kLinear = BIT(16) } |
Public Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 , kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) } |
enum | EDeprecatedStatusBits { kObjInCanvas = BIT(3) } |
enum | EStatusBits { kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) , kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13) } |
Public Member Functions | |
TFormula () | |
Formula default constructor. | |
TFormula (const char *name, const char *formula) | |
Normal Formula constructor. | |
TFormula (const TFormula &formula) | |
Default constructor. | |
virtual | ~TFormula () |
Formula default destructor. | |
virtual void | Analyze (const char *schain, Int_t &err, Int_t offset=0) |
Analyze a sub-expression in one formula. | |
virtual Bool_t | AnalyzeFunction (TString &chaine, Int_t &err, Int_t offset=0) |
Check if the chain as function call. | |
virtual void | Clear (Option_t *option="") |
Resets the objects. | |
virtual Int_t | Compile (const char *expression="") |
Compile expression already stored in fTitle. | |
virtual void | Copy (TObject &formula) const |
Copy this formula. | |
virtual char * | DefinedString (Int_t code) |
Return address of string corresponding to special code. | |
virtual Double_t | DefinedValue (Int_t code) |
Return value corresponding to special code. | |
virtual Int_t | DefinedVariable (TString &variable, Int_t &action) |
Check if expression is in the list of defined variables. | |
virtual Double_t | Eval (Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const |
Evaluate this formula. | |
virtual Double_t | EvalPar (const Double_t *x, const Double_t *params=0) |
virtual Double_t | EvalParOld (const Double_t *x, const Double_t *params=0) |
Evaluate this formula. | |
virtual TString | GetExpFormula (Option_t *option="") const |
Reconstruct the formula expression from the internal TFormula member variables. | |
virtual const TObject * | GetLinearPart (Int_t i) |
Return linear part. | |
virtual Int_t | GetNdim () const |
virtual Int_t | GetNpar () const |
virtual Int_t | GetNumber () const |
Double_t | GetParameter (const char *name) const |
Return value of parameter named parName. | |
Double_t | GetParameter (Int_t ipar) const |
Return value of parameter number ipar. | |
virtual Double_t * | GetParameters () const |
virtual void | GetParameters (Double_t *params) |
virtual const char * | GetParName (Int_t ipar) const |
Return name of one parameter. | |
virtual Int_t | GetParNumber (const char *name) const |
Return parameter number by name. | |
virtual Bool_t | IsLinear () const |
virtual Bool_t | IsNormalized () const |
TFormula & | operator= (const TFormula &rhs) |
Operator =. | |
void | Optimize () |
MI include. | |
virtual void | Print (Option_t *option="") const |
Dump this formula with its attributes. | |
virtual void | ProcessLinear (TString &replaceformula) |
If the formula is for linear fitting, change the title to normal and fill the LinearParts array. | |
virtual void | SetNumber (Int_t number) |
virtual void | SetParameter (const char *name, Double_t parvalue) |
Initialize parameter number ipar. | |
virtual void | SetParameter (Int_t ipar, Double_t parvalue) |
Initialize parameter number ipar. | |
virtual void | SetParameters (const Double_t *params) |
Initialize array of all parameters. | |
virtual void | SetParameters (Double_t p0, Double_t p1, Double_t p2=0, Double_t p3=0, Double_t p4=0, Double_t p5=0, Double_t p6=0, Double_t p7=0, Double_t p8=0, Double_t p9=0, Double_t p10=0) |
Initialize up to 11 parameters All arguments except THE FIRST TWO are optional In case of a function with only one parameter, call this function with p1=0. | |
virtual void | SetParName (Int_t ipar, const char *name) |
Set name of parameter number ipar. | |
virtual void | SetParNames (const char *name0="p0", const char *name1="p1", const char *name2="p2", const char *name3="p3", const char *name4="p4", const char *name5="p5", const char *name6="p6", const char *name7="p7", const char *name8="p8", const char *name9="p9", const char *name10="p10") |
Set up to 11 parameter names. | |
void | Streamer (TBuffer &b, const TClass *onfile_class) |
Stream a class object. | |
void | Streamer (TBuffer &b, Int_t version, UInt_t start, UInt_t count, const TClass *onfile_class=0) |
specialized streamer function being able to read old TF1 versions as TF1Old in memory | |
virtual void | Update () |
Public Member Functions inherited from TNamed | |
TNamed () | |
TNamed (const char *name, const char *title) | |
TNamed (const TNamed &named) | |
TNamed copy ctor. | |
TNamed (const TString &name, const TString &title) | |
virtual | ~TNamed () |
TNamed destructor. | |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. | |
virtual Int_t | Compare (const TObject *obj) const |
Compare two TNamed objects. | |
virtual void | FillBuffer (char *&buffer) |
Encode TNamed into output buffer. | |
virtual const char * | GetName () const |
Returns name of object. | |
virtual const char * | GetTitle () const |
Returns title of object. | |
virtual ULong_t | Hash () const |
Return hash value for this object. | |
virtual Bool_t | IsSortable () const |
virtual void | ls (Option_t *option="") const |
List TNamed name and title. | |
TNamed & | operator= (const TNamed &rhs) |
TNamed assignment operator. | |
virtual void | SetName (const char *name) |
Set the name of the TNamed. | |
virtual void | SetNameTitle (const char *name, const char *title) |
Set all the TNamed parameters (name and title). | |
virtual void | SetTitle (const char *title="") |
Set the title of the TNamed. | |
virtual Int_t | Sizeof () const |
Return size of the TNamed part of the TObject. | |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. | |
TObject (const TObject &object) | |
TObject copy ctor. | |
virtual | ~TObject () |
TObject destructor. | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. | |
ULong_t | CheckedHash () |
Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object. | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. | |
virtual void | Delete (Option_t *option="") |
Delete this object. | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad) . | |
virtual void | Dump () const |
Dump contents of object on stdout. | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. | |
virtual const char * | GetIconName () const |
Returns mime type name of object. | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). | |
virtual Option_t * | GetOption () const |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. | |
Bool_t | HasInconsistentHash () const |
Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e. | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. | |
void | InvertBit (UInt_t f) |
Bool_t | IsDestructed () const |
IsDestructed. | |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). | |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. | |
void | operator delete (void *ptr) |
Operator delete. | |
void | operator delete[] (void *ptr) |
Operator delete []. | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". | |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. | |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. | |
Static Public Member Functions | |
static void | GetMaxima (Int_t &maxop, Int_t &maxpar, Int_t &maxconst) |
static function to get the maximum value of 3 parameters -maxop : maximum number of operations -maxpar : maximum number of parameters -maxconst : maximum number of constants | |
static void | SetMaxima (Int_t maxop=1000, Int_t maxpar=1000, Int_t maxconst=1000) |
static function to set the maximum value of 3 parameters | |
Static Public Member Functions inherited from TObject | |
static Longptr_t | GetDtorOnly () |
Return destructor only flag. | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. | |
Protected Types | |
enum | { kEnd = 0 , kAdd = 1 , kSubstract = 2 , kMultiply = 3 , kDivide = 4 , kModulo = 5 , kcos = 10 , ksin = 11 , ktan = 12 , kacos = 13 , kasin = 14 , katan = 15 , katan2 = 16 , kfmod = 17 , kpow = 20 , ksq = 21 , ksqrt = 22 , kstrstr = 23 , kmin = 24 , kmax = 25 , klog = 30 , kexp = 31 , klog10 = 32 , kpi = 40 , kabs = 41 , ksign = 42 , kint = 43 , kSignInv = 44 , krndm = 50 , kAnd = 60 , kOr = 61 , kEqual = 62 , kNotEqual = 63 , kLess = 64 , kGreater = 65 , kLessThan = 66 , kGreaterThan = 67 , kNot = 68 , kcosh = 70 , ksinh = 71 , ktanh = 72 , kacosh = 73 , kasinh = 74 , katanh = 75 , kStringEqual = 76 , kStringNotEqual = 77 , kBitAnd = 78 , kBitOr = 79 , kLeftShift = 80 , kRightShift = 81 , kJumpIf = 82 , kJump = 83 , kexpo = 100 , kxexpo = 100 , kyexpo = 101 , kzexpo = 102 , kxyexpo = 105 , kgaus = 110 , kxgaus = 110 , kygaus = 111 , kzgaus = 112 , kxygaus = 115 , klandau = 120 , kxlandau = 120 , kylandau = 121 , kzlandau = 122 , kxylandau = 125 , kpol = 130 , kxpol = 130 , kypol = 131 , kzpol = 132 , kParameter = 140 , kConstant = 141 , kBoolOptimize = 142 , kStringConst = 143 , kVariable = 144 , kFunctionCall = 145 , kData = 146 , kUnary = 147 , kBinary = 148 , kThree = 149 , kDefinedVariable = 150 , kDefinedString = 151 , kPlusD = 152 , kPlusDD = 153 , kMultD = 154 , kMultDD = 155 , kBoolOptimizeOr = 156 , kBoolOptimizeAnd = 157 , kBoolSet = 158 , kFDM = 159 , kFD0 = 160 , kFD1 = 161 , kFD2 = 162 , kFD3 = 163 } |
typedef Double_t(TObject::* | TFuncG) (const Double_t *, const Double_t *) const |
Protected Types inherited from TObject | |
enum | { kOnlyPrepStep = BIT(3) } |
Protected Member Functions | |
virtual Bool_t | CheckOperands (Int_t leftoperand, Int_t rightoperartion, Int_t &err) |
Check whether the operands at 'leftoper' and 'oper-1' are compatible with the operation at 'oper'. | |
virtual Bool_t | CheckOperands (Int_t operation, Int_t &err) |
Check whether the operand at 'oper-1' is compatible with the operation at 'oper'. | |
void | ClearFormula (Option_t *option="") |
Resets the objects. | |
virtual void | Convert (UInt_t fromVersion) |
Double_t | EvalParFast (const Double_t *x, const Double_t *params) |
Evaluate this formula. | |
Double_t | EvalPrimitive (const Double_t *x, const Double_t *params) |
Evaluate primitive formula. | |
Double_t | EvalPrimitive0 (const Double_t *x, const Double_t *params) |
Evaluate primitive formula. | |
Double_t | EvalPrimitive1 (const Double_t *x, const Double_t *params) |
Evaluate primitive formula. | |
Double_t | EvalPrimitive2 (const Double_t *x, const Double_t *params) |
Evaluate primitive formula. | |
Double_t | EvalPrimitive3 (const Double_t *x, const Double_t *params) |
Evaluate primitive formula. | |
Double_t | EvalPrimitive4 (const Double_t *x, const Double_t *params) |
Evaluate primitive formula. | |
Short_t | GetAction (Int_t code) const |
Short_t | GetActionOptimized (Int_t code) const |
Int_t | GetActionParam (Int_t code) const |
Int_t | GetActionParamOptimized (Int_t code) const |
Int_t * | GetOper () const |
Int_t * | GetOperOptimized () const |
virtual Bool_t | IsString (Int_t oper) const |
Return true if the expression at the index 'oper' has to be treated as a string. | |
void | MakePrimitive (const char *expr, Int_t pos) |
MakePrimitive find TFormulaPrimitive replacement for some operands. | |
Int_t | PreCompile () |
pointer to optimal function | |
void | SetAction (Int_t code, Int_t value, Int_t param=0) |
void | SetActionOptimized (Int_t code, Int_t value, Int_t param=0) |
virtual Bool_t | StringToNumber (Int_t code) |
Try to 'demote' a string into an array bytes. | |
Protected Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). | |
void | MakeZombie () |
Protected Attributes | |
TBits | fAlreadyFound |
Double_t * | fConst |
TString * | fExpr |
TString * | fExprOptimized |
Number of operators after optimization. | |
TObjArray | fFunctions |
TObjArray | fLinearParts |
TString * | fNames |
Int_t | fNconst |
Int_t | fNdim |
Int_t | fNoper |
Int_t | fNOperOptimized |
cache for information | |
Int_t | fNpar |
Int_t | fNstring |
Int_t | fNumber |
Int_t | fNval |
TOperOffset * | fOperOffset |
[fNOperOptimized] List of operators. (See documentation for changes made at version 7) | |
Int_t * | fOperOptimized |
[fNOperOptimized] List of expressions | |
TFuncG | fOptimal |
[fNPar] predefined function | |
Double_t * | fParams |
TFormulaPrimitive ** | fPredefined |
[fNOperOptimized] Offsets of operrands | |
Protected Attributes inherited from TNamed | |
TString | fName |
TString | fTitle |
Private Attributes | |
Int_t * | fOper |
#include "inc/v5/TFormula.h"
|
protected |
Definition at line 69 of file TFormula.h.
|
protected |
Definition at line 135 of file TFormula.h.
anonymous enum |
Enumerator | |
---|---|
kNotGlobal | |
kNormalized | |
kLinear |
Definition at line 211 of file TFormula.h.
TFormula::TFormula | ( | ) |
Formula default constructor.
Definition at line 136 of file TFormula_v5.cxx.
TFormula::TFormula | ( | const char * | name, |
const char * | formula | ||
) |
Normal Formula constructor.
Definition at line 163 of file TFormula_v5.cxx.
TFormula::TFormula | ( | const TFormula & | formula | ) |
Default constructor.
Definition at line 276 of file TFormula_v5.cxx.
|
virtual |
Formula default destructor.
Definition at line 314 of file TFormula_v5.cxx.
Analyze a sub-expression in one formula.
Expressions in one formula are recursively analyzed. Result of analysis is stored in the object tables.
the expression "gaus" is a substitute for
[0]*exp(-0.5*((x-[1])/[2])**2)
to obtain a standard normalized gaussian, use "gausn" instead of "gaus" the expression "gausn" is a substitute for
[0]*exp(-0.5*((x-[1])/[2])**2)/(sqrt(2*pi)*[2]))
WARNING: gaus and gausn are mutually exclusive in the same expression.
In the same way the expression "landau" is a substitute for
[0]*TMath::Landau(x,[1],[2],kFALSE)
to obtain a standard normalized landau, use "landaun" instead of "landau" the expression "landaun" is a substitute for
[0]*TMath::Landau(x,[1],[2],kTRUE)
WARNING: landau and landaun are mutually exclusive in the same expression.
Those pseudo operation are used to implement lazy evaluation of && and ||. When the left hand of the expression if false (respectively true), the evaluation of the right is entirely skipped (since it would not change the value of the expression).
&& 142 11 (one operation on right) 142 21 (2 operations on right) || 142 12 (one operation on right) 142 22 (2 operations on right)
functions calls (kFunctionCall) :
f0 145 0 f1 145 1 etc..
1 : Division By Zero 2 : Invalid Floating Point Operation 4 : Empty String 5 : invalid syntax 6 : Too many operators 7 : Too many parameters 10 : z specified but not x and y 11 : z and y specified but not x 12 : y specified but not x 13 : z and x specified but not y 20 : non integer value for parameter number 21 : atan2 requires two arguments 22 : pow requires two arguments 23 : degree of polynomial not specified 24 : Degree of polynomial must be positive 25 : Degree of polynomial must be less than 20 26 : Unknown name 27 : Too many constants in expression 28 : strstr requires two arguments 29 : interpreted or compiled function have to return a numerical type 30 : Bad numerical expression 31 : Part of the variable exist but some of it is not accessible or useable 40 : '(' is expected 41 : ')' is expected 42 : '[' is expected 43 : ']' is expected
By default, the formula is assigned fNumber=0. However, the following formula built with simple functions are assigned fNumber:
"gaus" 100 (or gausn) "xygaus" 110 "expo" 200 "polN" 300+N "landau" 400 "xylandau" 410
Note that expressions like gaus(0), expo(1) will force fNumber=0
If you overload this member function, you also HAVE TO never call the constructor:
and write your own constructor
which has to call the TFormula default constructor and whose implementation should be similar to the implementation of the normal TFormula constructor
This is necessary because the normal TFormula constructor call indirectly the virtual member functions Analyze, DefaultString, DefaultValue and DefaultVariable.
Definition at line 713 of file TFormula_v5.cxx.
Check if the chain as function call.
If you overload this member function, you also HAVE TO never call the constructor:
and write your own constructor
which has to call the TFormula default constructor and whose implementation should be similar to the implementation of the normal TFormula constructor
This is necessary because the normal TFormula constructor call indirectly the virtual member functions Analyze, DefaultString, DefaultValue and DefaultVariable.
Definition at line 347 of file TFormula_v5.cxx.
|
protectedvirtual |
Check whether the operands at 'leftoper' and 'oper-1' are compatible with the operation at 'oper'.
Definition at line 2182 of file TFormula_v5.cxx.
Check whether the operand at 'oper-1' is compatible with the operation at 'oper'.
Definition at line 2168 of file TFormula_v5.cxx.
Resets the objects.
Resets the object to its state before compilation.
Reimplemented from TNamed.
Definition at line 2213 of file TFormula_v5.cxx.
Resets the objects.
Resets the object to its state before compilation.
Definition at line 2223 of file TFormula_v5.cxx.
|
virtual |
Compile expression already stored in fTitle.
Loop on all subexpressions of formula stored in fTitle
If you overload this member function, you also HAVE TO never call the constructor:
and write your own constructor
which has to call the TFormula default constructor and whose implementation should be similar to the implementation of the normal TFormula constructor
This is necessary because the normal TFormula constructor call indirectly the virtual member functions Analyze, DefaultString, DefaultValue and DefaultVariable.
Definition at line 2292 of file TFormula_v5.cxx.
Reimplemented in TTreeFormula.
Definition at line 3564 of file TFormula_v5.cxx.
|
virtual |
Return address of string corresponding to special code.
This member function is inactive in the TFormula class. It may be redefined in derived classes.
If you overload this member function, you also HAVE TO never call the constructor:
and write your own constructor
which has to call the TFormula default constructor and whose implementation should be similar to the implementation of the normal TFormula constructor
This is necessary because the normal TFormula constructor call indirectly the virtual member functions Analyze, DefaultString, DefaultValue and DefaultVariable.
Definition at line 2555 of file TFormula_v5.cxx.
Return value corresponding to special code.
This member function is inactive in the TFormula class. It may be redefined in derived classes.
If you overload this member function, you also HAVE TO never call the constructor:
and write your own constructor
which has to call the TFormula default constructor and whose implementation should be similar to the implementation of the normal TFormula constructor
This is necessary because the normal TFormula constructor call indirectly the virtual member functions Analyze, DefaultString, DefaultValue and DefaultVariable.
Definition at line 2586 of file TFormula_v5.cxx.
Check if expression is in the list of defined variables.
This member function can be overloaded in derived classes
If you overload this member function, you also HAVE TO never call the constructor:
and write your own constructor
which has to call the TFormula default constructor and whose implementation should be similar to the implementation of the normal TFormula constructor
This is necessary because the normal TFormula constructor call indirectly the virtual member functions Analyze, DefaultString, DefaultValue and DefaultVariable.
The expected returns values are
Reimplemented in TTreeFormula.
Definition at line 2621 of file TFormula_v5.cxx.
|
virtual |
Evaluate this formula.
The current value of variables x,y,z,t is passed through x, y, z and t. The parameters used will be the ones in the array params if params is given otherwise parameters will be taken from the stored data members fParams
Definition at line 2668 of file TFormula_v5.cxx.
|
inlinevirtual |
Definition at line 235 of file TFormula.h.
Evaluate this formula.
The current value of variables x,y,z,t is passed through the pointer x. The parameters used will be the ones in the array params if params is given otherwise parameters will be taken from the stored data members fParams
Definition at line 4189 of file TFormula_v5.cxx.
Evaluate this formula.
The current value of variables x,y,z,t is passed through the pointer x. The parameters used will be the ones in the array params if params is given otherwise parameters will be taken from the stored data members fParams
Definition at line 2687 of file TFormula_v5.cxx.
Evaluate primitive formula.
Definition at line 4114 of file TFormula_v5.cxx.
Evaluate primitive formula.
Definition at line 4135 of file TFormula_v5.cxx.
Evaluate primitive formula.
Definition at line 4144 of file TFormula_v5.cxx.
Evaluate primitive formula.
Definition at line 4153 of file TFormula_v5.cxx.
Evaluate primitive formula.
Definition at line 4163 of file TFormula_v5.cxx.
Evaluate primitive formula.
Definition at line 4173 of file TFormula_v5.cxx.
Definition at line 104 of file TFormula.h.
Definition at line 112 of file TFormula.h.
Definition at line 105 of file TFormula.h.
Definition at line 113 of file TFormula.h.
Reconstruct the formula expression from the internal TFormula member variables.
This function uses the internal member variables of TFormula to construct the mathematical expression associated with the TFormula instance. This function can be used to get an expanded version of the expression originally assigned to the TFormula instance, i.e. that the string returned by GetExpFormula() doesn't depend on other TFormula object names.
if option contains "p" the returned string will contain the formula expression with symbolic parameters, eg [0] replaced by the actual value of the parameter. Example: if expression in formula is: "[0]*(x>-[1])+[2]*exp(-[3]*x)" and parameters are 3.25,-4.01,4.44,-0.04, GetExpFormula("p") will return: "(3.25*(x>+4.01))+(4.44*exp(+0.04*x))"
Definition at line 3022 of file TFormula_v5.cxx.
Return linear part.
Definition at line 3212 of file TFormula_v5.cxx.
static function to get the maximum value of 3 parameters -maxop : maximum number of operations -maxpar : maximum number of parameters -maxconst : maximum number of constants
Definition at line 4540 of file TFormula_v5.cxx.
|
inlinevirtual |
Definition at line 237 of file TFormula.h.
|
inlinevirtual |
Definition at line 238 of file TFormula.h.
|
inlinevirtual |
Definition at line 239 of file TFormula.h.
|
inlineprotected |
Definition at line 103 of file TFormula.h.
|
inlineprotected |
Definition at line 111 of file TFormula.h.
Double_t TFormula::GetParameter | ( | const char * | name | ) | const |
Return value of parameter named parName.
Definition at line 3231 of file TFormula_v5.cxx.
Return value of parameter number ipar.
Definition at line 3222 of file TFormula_v5.cxx.
|
inlinevirtual |
Definition at line 243 of file TFormula.h.
Definition at line 244 of file TFormula.h.
|
virtual |
Return name of one parameter.
Definition at line 3245 of file TFormula_v5.cxx.
|
virtual |
Return parameter number by name.
Definition at line 3255 of file TFormula_v5.cxx.
|
inlinevirtual |
Definition at line 247 of file TFormula.h.
|
inlinevirtual |
Definition at line 248 of file TFormula.h.
Return true if the expression at the index 'oper' has to be treated as a string.
Reimplemented in TTreeFormula.
Definition at line 3269 of file TFormula_v5.cxx.
MakePrimitive find TFormulaPrimitive replacement for some operands.
Definition at line 3746 of file TFormula_v5.cxx.
Operator =.
Definition at line 303 of file TFormula_v5.cxx.
void TFormula::Optimize | ( | ) |
MI include.
Optimize formula
Definition at line 3818 of file TFormula_v5.cxx.
|
protected |
Dump this formula with its attributes.
Reimplemented from TNamed.
Definition at line 3277 of file TFormula_v5.cxx.
If the formula is for linear fitting, change the title to normal and fill the LinearParts array.
Definition at line 3306 of file TFormula_v5.cxx.
Definition at line 107 of file TFormula.h.
|
inlineprotected |
Definition at line 115 of file TFormula.h.
static function to set the maximum value of 3 parameters
None of these parameters cannot be less than 10 (default is 1000) call this function to increase one or all maxima when processing very complex formula, eg TFormula::SetMaxima(100000,1000,1000000); If you process many functions with a small number of operations/parameters you may gain some memory and performance by decreasing these values.
Definition at line 4527 of file TFormula_v5.cxx.
Definition at line 251 of file TFormula.h.
Initialize parameter number ipar.
Definition at line 3375 of file TFormula_v5.cxx.
Initialize parameter number ipar.
Definition at line 3386 of file TFormula_v5.cxx.
Initialize array of all parameters.
See also the next function with the same name.
Definition at line 3397 of file TFormula_v5.cxx.
|
virtual |
Initialize up to 11 parameters All arguments except THE FIRST TWO are optional In case of a function with only one parameter, call this function with p1=0.
Minimum two arguments are required to differentiate this function from the SetParameters(cont Double_t *params)
Definition at line 3412 of file TFormula_v5.cxx.
Set name of parameter number ipar.
Definition at line 3432 of file TFormula_v5.cxx.
|
virtual |
Set up to 11 parameter names.
Definition at line 3441 of file TFormula_v5.cxx.
Stream a class object.
Definition at line 3460 of file TFormula_v5.cxx.
void TFormula::Streamer | ( | TBuffer & | b, |
Int_t | version, | ||
UInt_t | start, | ||
UInt_t | count, | ||
const TClass * | onfile_class = 0 |
||
) |
specialized streamer function being able to read old TF1 versions as TF1Old in memory
Definition at line 3498 of file TFormula_v5.cxx.
Try to 'demote' a string into an array bytes.
If this is not possible, return false.
Reimplemented in TTreeFormula.
Definition at line 2202 of file TFormula_v5.cxx.
|
inlinevirtual |
Definition at line 263 of file TFormula.h.
|
protected |
Definition at line 88 of file TFormula.h.
|
protected |
Definition at line 82 of file TFormula.h.
|
protected |
Definition at line 78 of file TFormula.h.
|
protected |
Number of operators after optimization.
Definition at line 92 of file TFormula.h.
|
protected |
Definition at line 85 of file TFormula.h.
|
protected |
Definition at line 86 of file TFormula.h.
|
protected |
Definition at line 84 of file TFormula.h.
|
protected |
Definition at line 74 of file TFormula.h.
|
protected |
Definition at line 71 of file TFormula.h.
|
protected |
Definition at line 73 of file TFormula.h.
|
protected |
cache for information
Definition at line 91 of file TFormula.h.
|
protected |
Definition at line 72 of file TFormula.h.
|
protected |
Definition at line 77 of file TFormula.h.
|
protected |
Definition at line 75 of file TFormula.h.
|
protected |
Definition at line 76 of file TFormula.h.
|
private |
Definition at line 80 of file TFormula.h.
|
protected |
[fNOperOptimized] List of operators. (See documentation for changes made at version 7)
Definition at line 94 of file TFormula.h.
|
protected |
[fNOperOptimized] List of expressions
Definition at line 93 of file TFormula.h.
|
protected |
[fNPar] predefined function
Definition at line 96 of file TFormula.h.
|
protected |
Definition at line 83 of file TFormula.h.
|
protected |
[fNOperOptimized] Offsets of operrands
Definition at line 95 of file TFormula.h.