TEfficiency x-axis range issue

If I type the following commands in ROOT:

TEfficiency h(“h”,“h”,10,0.,10)
h.Fill(true,2)
h.Fill(true,2)
h.Fill(false,2)
h.Fill(false,7)
h.Draw(“AP”)

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.
h.Draw(“APE0”)
// Following previous command, this now draws entire 0-10 range.
h.Draw(“AP”)

Regards,
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:

   h.Draw("AP");
   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.