Re: TFormula

From: Gero Flucke <flucke_at_mail.desy.de>
Date: Tue, 25 Oct 2005 09:16:41 +0200 (CEST)


On Tue, 25 Oct 2005, zaldy wrote:

> I wanted to insert a numerical constant inside the TFormula class.
> If I change the value of the numerical constant I
> keep on changing the code to update the numerical value.
>
> How can we insert a numerical constant in TFormula?
>
>
> For example:
>
> TFormula * form1 = TFormula("form1","10*sin(x)");

Hi,
you could do

Double_y myConst = ...;
TFormula * form1 = TFormula("form1",Form("%f*sin(x)", myConst));

In this case you fix the constant to the value it has when creating the TFormula, changing myConst later on has no effect...

> Sometimes I want to change the constant 10 to 15 or other values so I have
> to update the code again.
>
> How do we make it like this:
>
> TFormula * form1 = TFormula("form1","FuncConst()*sin(x)");
>
> where FuncConst() is defined (Double_t FuncConst() ) elsewhere.
>
> ------
> I see one hint in the use of the TMath functions, for example:
>
> TFormula * form1 = TFormula("form1","TMath::C()*sin(x)");
>
> Can inheriting from TMath class be possible for this case?

TMath has become a namespace meanwhile...

Cheers

        Gero

--
-----------------------------------------------------------------------
Gero Flucke
1a / 603
DESY
Notkestr. 85
22607 Hamburg
+49-(0)40-8998-2454
Received on Tue Oct 25 2005 - 09:25:39 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET