WARNING:Plotting -- WARNING: Function evaluation error


I have a custom PDF class made with RooClassFactory::makePdf(…)
The PDF contains a 2D histogram that is generated on the fly that’s proportional to the PDF in XY, Z[x,y] ~ N*P(x,y). So in the evaluate(), I can just use bin content of Z(x,y) to evaluate the probabilities and return that value in the evaluate().

It works fine most of the time when Z[x,y] are well populated, when I went to a parameter region where Z[x,y] only has a few bins filled (~ 10 bins) I get these warnings for every bin in the PDF / Z.

[#0] WARNING:Plotting – WARNING: Function evaluation error(s) at coordinates [x]=1.09339 [y]=0.00143

~ 8000 of these for each x , y

[#0] WARNING:Plotting – WARNING: Function evaluation error(s) at coordinates [x]=9.95408 [y]=2.99375

And the PDF plotted by createHistogram(“x,y”,…) comes up completely empty. I check that some of the bins have non-zero values and the warning still comes up. I did this by adding a cout to the evaulate()

cout<<"x = “<<x<<” y = “<<y<<” binFound “<<binFound<<” Z = "<GetBinContent(binFound)<<endl;

This gives outputs like this in non-zero bins in Z(x,y)…
x = 1.53239 y = 2.40143 binFound = 3617 Z = 6.9320
[#0] WARNING:Plotting – WARNING: Function evaluation error(s) at coordinates [x]=1.53239 [y]=2.40143

It’s interesting that the code still complaints that it cannot evaluate the function at this coordinate even though Z(x,y) returns a reasonably value. There were many 0s returned by the evaluate() before, does this put the PDF into a mode where it just assume that the PDF is no valid?


A minor update: I found that if I reduce the range on x by a factor of 5, then do a pdf->createHistogram (just something to evoke the evaluate() ) then change it back to it’s normal range. The PDF will work fine afterward 99% of the time. Most of the population lies on the lower side of x so reducing the range allows the PDF to get to the non-zero points more quickly.

I think this allows to PDF to find the non-zero points more quickly so it won’t have the evaluation error anymore.


You should check your function better. The error occurs probably because the function value is negative and RooFIt is trying to do a log of a negative number

Best Regards


The evaluate() samples from a TH2 that is never negative. It’s zero in most of the bins but never negative. I made the weights positive definite just in case, the same symptom occurs.


Hi Lorenzo,

is there a way to suppress such warnings?