TEfficiency x-axis range issue

If I type the following commands in ROOT:

TEfficiency h(“h”,“h”,10,0.,10)

then although the plot is drawn, my x-axis range specification of 0-10 is ignored, and instead only the range 2-7 where points are present is drawn. Is this a bug?

I have found a work-around, which is to do:

// Draws entire 0-10 range, but with unwanted error bars on empty bins.
// Following previous command, this now draws entire 0-10 range.

Ian Tomalin

ROOT Version: 6.12/07
_Platform: GNU/Linux
Compiler: Not Provided

Hello Ian,

The problem is due to the default range computed by the underlying TGraph object used to paint the TEfficiency object. The empty points are skipped and therefore a different range is computed.
Maybe we should add an option to not do this inside TEfficiency.
However another possible workaround is to do:

   gPad->Update();  // this is needed otherwise GetPaintedGraph() will return a nullptr
   h.GetPaintedGraph()->GetHistogram()->SetBins(100,0.,10.);  // the number of bins,100, is arbitrary (must be only larger than the number of painted points)

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