I am using root 5.34/36.
I have defined a 2D function that I want to integrate, as in the attachment. This function is a sort of convolution, and I am using TF2. When I perform the integral with the given parameters it returns 0, but I can draw the function and see that it is zero or positive in the area of integration.
I run the macro compiled in root with:
root [0] .L fit.C+
root [1] fit();

I want to use this function in a minimization (changing the parameters), with the integral in the denominator. I am open to suggestions about how to calculate this integral faster.

It’s the “efficiency” / “efficiencyF” function which fools ROOT. It’s value “jumps” between 0 and 1 and the current “integrator” is known to misbehave in such cases.
See also, for example: Simple Integral

Sometimes you can try to “hide” this problem if you increase the number of points … for each of your functions try to add:
SomeTF2->SetNpx(1000); SomeTF2->SetNpy(1000);
But I wouldn’t really trust the result.

could it help to use another integrator?
the “efficiencyF” is a try to implement limits for the integration which are not “square”, that is, the integral should not really by from -1 to 1 in both variables but inside the area returning 1 in “efficiencyF”. Is there a better way to implement integration limits which does not have this problem?

I will try the number of points suggestion as well!

Using SomeTF2->SetNpx and SomeTF2->SetNpy solves the problem for these parameters, but the integral takes much longer. And I also find it hard to trust the result. So my other questions remain:

Is there another integrator which should work better? (or/and faster?)
Is there a better way of implementing non-square integration limits?

If you play with the ROOT::Math::IntegratorMultiDim, you should probably remember that the default “integrator” (which stumbles upon sharp edges / steps) is the “adaptive multi-dimensional integration method / algorithm” ROOT::Math::AdaptiveIntegratorMultiDim (so, you’d better try something else).