Hi,

It seems like there is some kind of memory corruption going on when I fit a user defined

function in python. I am using root 4.01/02, python 2.3.3, and Linux 2.4.21. I appended

an example which is admittedly very convoluted. Simpler fits crash

also, but not as easily so it is harder to find an example for demonstration purposes.

The problem seems to occur as soon as I fit a user defined python function. When I define

TF1 with a TFormula that does the same thing as the python function, it works.

By the way, the example fit below will work if I move the line s=TF1(“s”,gax,-10.,10.,3)

two lines up (outside the function definition). This does not solve the problem though, it

just makes it more subtle.

Thanks,

Martin

PS: How can I use TMath::Erfc directly in python?

from ROOT import TH1D,TF1

from math import sqrt,exp

# Just a Gaussian

def gax(y, q):

if q[1]!=0:

result= q[2]/sqrt(2.*3.1415*q[1]*q[1]) exp(-0.5(y[0]-q[0])*(y[0]-q[0])/(q[1]*q[1]))

else:

result=0

return result

# Function that integrates user defined Gaussian

def ga(x, p):

s=TF1(“s”,gax,-10.,10.,3)

s.SetParameters(p[0],p[1],p[2])

return s.Integral(x[0],10)

# fill a histogram and fit

a=TH1D("","",100,-10,10)

er=TF1(“er”,“TMath::Erfc(x)”,0,10)

a.FillRandom(“er”,10000)

b=TF1(“b”,ga,-10,10,3)

b.SetParameters(0.,1.,1000.)

a.Fit(b,"","",-2,2)