TGraphAsymmErrors::Divide skips bins

As described in TGraphAsymmErrors::Divide method:

If the denominator becomes 0 or pass > total, the corresponding bin is skipped.

While an efficiency does not indeed make sense when the denominator is zero, silently skipping those bins is extremely error-prone. Why not raising an exception (thinking about PyROOT) or at least returning a flag?

ROOT Version: 6.22/09
Platform: CentOS 7 (Core)
Compiler: GCC 9.3.0

Hi @bfontana,

These changes, if performed, must be carefully documented as it might break user code that was previously “working”. That said, @moneta or @couet might provide more useful information on this.


The help says:

If the denominator becomes 0 or pass > total, the corresponding bin is skipped.

It is true that, in the code, the protections against dividing by 0 are done without printing a waning. My guess is that too many warnings might be generated if a such message is printed. Documenting a bit more precisely might help. We can also have a logic which print the warning only once. I let @moneta decide what is the best.

I agree with could have the logic to print such a warning the first time the denominator histogram has a bin with zero content. Having an exception as said before will likely break too much existing code. It can be quite common to have empty bins in the histograms.



Another possibility: one could add an enumerator with the following options:

  1. (default) whenever the denominator is zero or pass > total a warning is printed (no backward-compatibility issues)
  2. an exception is raised
  3. the bins that satisfy the above conditions are set to zero and no exception is raised

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.