Re: TF1 Syntax ...

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 24 Feb 2006 08:53:47 +0100 (MET)


Both answers are correct. You simply misunderstood what TMath::DegToRad() is doing, ie pi/180

Rene Brun

On Fri, 24 Feb 2006, zaldy wrote:

>
> Hi,
>
> Just want that I will be using with degree units in carrying a calculation
> but,
>
> What is wrong with (1) expression?
>
> ======================================================================
> NOTE: It seems the operation is OK because ROOT does not complain about
> the writing of parameter [0] in expression "cos([0]*x)".
> ======================================================================
>
> 1 ----WRONG
> root [0] TF1 * f = new TF1("f","pow(cos([0]*x),2)",0,90);
> root [1] f->SetParameter(0,TMath::DegToRad());
> root [2] cout<<"f Integral(0,90) = "<< f->Integral(0,90) << endl;
> f Integral(0,90) = 45 <----WRONG
>
>
> 2 -----CORRECT-----
> root [4] TF1 * f = new TF1("f","pow(cos(x),2)",0,90);
> root [5] cout<<"f Integral(0,90) = "<< f->Integral(0,0.5*TMath::Pi()) << endl;
> f Integral(0,90) = 0.785398 <----- CORRECT
>
>
> *******************************************
> * *
> * W E L C O M E to R O O T *
> * *
> * Version 4.04/02 6 June 2005 *
> * *
> * You are welcome to visit our Web site *
> * http://root.cern.ch *
> * *
> *******************************************
>
> gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
>
>
Received on Fri Feb 24 2006 - 08:53:56 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET