TF1 (TFormula) cannot use TMath::Landau

From: Christian Vogel <vogel_at_pi2.physik.uni-erlangen.de>
Date: Tue, 12 Jul 2005 17:48:28 +0200


Hi,

I am trying to fit some more complicated function to my data but have problems combining even simple formulae in my TF1s. As a simple example, I try a landau centered at 0, constant 1, sigma 0.5, TF1 *f = new TF1("f","landau",-10,10); f->Draw() works as expected.

Now I want to do more complicated stuff, so I try to use some of the TMath::-Functions to reproduce the landau above.

Quote from http://root.cern.ch/root/html/src/TFormula.cxx.html :
> In the same way the expression "landau" is a substitute for
> [0]*TMath::Landau(x,[1],[2],kFALSE).

So I try (kFALSE gives me an error, I substitute with 0):

 root [30] TF1 *g=new TF1("g","[0]*TMath::Landau(x,[1],[2],0)",-10,10)
 root [31] g->SetParameters(1,0,0.5)
 root [32] g->Draw()

!!! This only gives a flat line y=1 for all x in -10 .. 10. !!!

root [34] g->Print()
g : [0]*TMath::Landau(x,[1],[2],0) Ndim= 1, Npar= 3, Noper= 7

 fExpr[0] = [0]  action = 140 action param = 0 
 fExpr[1] = x  action = 144 action param = 0 
 fExpr[2] = [1]  action = 140 action param = 1 
 fExpr[3] = [2]  action = 140 action param = 2 
 fExpr[4] = 0  action = 141 action param = 0 
 fExpr[5] = Double_t TMath::Landau(Double_t x,Double_t mpv=0,Double_t sigma=1,Bool_t norm=kFALSE)  action = 145 action param = 4 
 fExpr[6] = *  action = 3 action param = 0 
Optimized expresion
 fExpr[0] = [0]           action = 146 action param = 0 
 fExpr[1] = x             action = 146 action param = 0 
 fExpr[2] = [1],[2],0,Double_t TMath::Landau(Double_t x,Double_t mpv=0,Double_t sigma=1,Bool_t norm=kFALSE)               action = 149 action param = 0 
 fExpr[3] = *             action = 3 action param = 0 
 Par  0                    p0 = 1
 Par  1                    p1 = 0
 Par  2                    p2 = 0.5

TH1.Print Name = Func, Entries= 100, Total sum= 100

What's the preferred way of fitting more complicated formulae? Always writing a compiled c-function?

root [38] gROOT->GetVersion()
(const char* 0x84d566c)"5.02/00"

        Chris

-- 
Message passing as the fundamental operation of the OS is just an
excercise in computer science masturbation.  It may feel good, but you
don't actually get anything DONE. -- Linus Torvalds
Received on Tue Jul 12 2005 - 17:53:02 MEST

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