Warning in TF2::Integral

Usually I try to think a lot before posting but maybe this is a simple question
for one of us…

Making a lot of integrals of a TF2 object (I need to fill a TH2 object
with integral values of that function) I receive this message

Warning in <TF2::Integral>: failed code=1, minpts=17, maxpts=10000, epsilon=1e-06, nfnevl=9979, relerr=0.00160722

where could the problem be?

I know that infos are less and I apologize for that : ask me anything is needed

Germano

Send the shortest possible RUNNING script reproducing this problem.

Rene

Thanks for reply and sorry for delay.

I don’t think this is the shortest running script (surely this is not a script) but
this concerns a class written by my own (maybe with horrible code) so I give
you the implementation file and its header with 2 commands to reproduce
the warning.

root [0] .L TSmear.cxx
root [1] TSmear *smear = new TSmear(20,30,2)
root [2] smear->CreateHisto()

This happens also with the compiled version.
I don’t think is useful but I use root v4.04.02f

Tnx, Germano
TSmear.h (2.68 KB)
TSmear.cxx (7.8 KB)

Hi, Germano,

I think you problem is that your TF2 doesn’t take any values besides 0 in some regions, where you are trying to integrate it. To see that you can run the attached changement of your code, which now draws the TF2 in the first region where the integral doesn’t converge.
In that case Integral function returns 0, so your histogram should be correct anyway.

Anna
TSmear.cxx (8.18 KB)

Tnx for your reply Anna,

If I’ve understood correctly your correction is made to show me the regions where
I have problems.
I’ll check my func because it is contructed to have no negative values and being
an analitic functionit follows that cannot exists “regions” where it is 0.

Anyway I don’t understand the point, why I receive warnings?
Maybe I miss some info about the algorithm used to do the integral, is it ?

Hi,

I get the same warning when I want to fit a histogram (2D) by a function using option “I”(integral). My histogram has some (10-20%) empty bines and function also is defined to give zero in forbidden region. (One can think of a filled circle inside a square that has some empty bines around the circle)

I am not sure if this warning is belong to the border bines or also occurs in empty bines. I have tried both chi-square and Likelihood methods with option “I” and the results are the same.
If the problem is in empty bines; is there any way to exclude empty bines in fitting procedure?

Thank you for your kind help.

This is now fixed in the CVS version - shouldn’t be any more warnings when trying to integrate a function over a region where it doesn’t take any non-zero values

Hi anna,

I updeted my root using these commandes:

cvs -z3 update -d -p
./configure win32gcc --build=debug
make -j2
make map

also I have add a background to my histogram and function, then I don’t have empty bines in hist. and zero values in function. But still I see a lots of this warning when I use “I” option.

did I do some thing wrong or It is not over yet?
thank a lot for your kind help.

Sohani

Could you post a running script reproducing the problem? Without it I can only say, that there are functions for which the IntegralMultiple algorithm doesn’t converge, for example, when trying to integrate a function with a sharp peak over a very large region. Maybe, that’s your case. Or maybe it’s a bug and if you post a script I’ll try to find it.

Hi Anna,

Sorry for a late reply. I tried every thing that I could do. Still I have the same poblem. I will try to make my program simpler to send it to you.
Thanks a lot for your kind attention

Hi Anna,

I tried to simplify my program to a small version (see attachment). There are two equal functions defined. First one has no parameter and I use it to fill a 2-D histogram. Second one has two parameter to fit and I use it as my fitting function.
I use option “I” in Fit command and I get huge number of the warnings. It is clear that most of them coming from the empty bines but also I have a lot from bines at the border of the histogram.

Is there some thing wrong in the code or is there a way to avoid the warnings?

Thank you for your kind attention
Sohani
testrun.cxx (1.66 KB)

Hi Anna,

Did yo find the problem in this code or fitting procedure?
If you need more details let me know.

Thank you for your kind attention.
Sohani

Hi,

I think I found why it keeps giving you warnings, but I’m still thinking about how to fix it and not break anything else.
You have probably looked at the TF1::IntegralMultiple function and remember, that there are adjustable parameters epsilon and # of iterations. The problem is, when this function is used for fitting with option “I” or for random number generation according to a function, these parameters are not adjustable. So, when the function is hard to integrate (like in your case), the algorithm doesn’t converge to the default value of epsilon in the default number of iterations, and there is now no way to reset the default. I’ve checked that it converges and doesn’t give any warnings with a much bigger epsilon and a much bigger # of iterations. Why is this particular function so hard to integrate for this algorithm, I don’t know.
This problem is on my list and I’ll do something about it as soon as I’m back from vacation next week.

Hi Anna,

Did yo find the problem in this code or fitting procedure?
If you need more details let me know.

Thank you for your kind attention.
Sohani