This can happen only if the number of passed events (the numerator of the efficiency ratio) is larger than the total number of events (the denominator). This cannot happen for histogram for which you need to compute efficiency. You need to check that this condition is verified for all the histograms that are added using hadd

I don’t have this problem when I run the script for the individual rootfiles (all of them), so this is always satisfied:

h2_pt.GetBinContent(i) < h1_pt.GetBinContent(i), for all i

But when I hadd them together, I got this error. To me, it doesn’t seem to be a ratio of events problem. As a matter of fact, I can plot the efficiency curve regardless the error and I can see that no bin is having a value exceeding 1.

The only possiblity to have that error is that the bin content of the numerator histogram is larger than the one at the denominator.
Maybe something gets wrong in the merge in hand. I would need in this case a macro reproducing the problem together with the histogram data files