ForceStyle vs. TH1::SetStat

Dear ROOT experts,

I stumbled over something funny using gROOT->ForceStyle() and the kNoStats bit in TH1. If you set gStyle->SetOptStat(0) and then ForceStyle(), this will set TH1::SetStat(false) for all histograms read after that. While this is true according to the comments in the code (‘Force setting of current style when reading objects’), would it not be much easier to just set gStyle->SetOptStat(0) again? Or did I miss the philosophy behind the code? (It may be that I see things like colors etc. as properties of a histogram, while I consider the decision to draw/not draw some parts of histograms, like stat boxes a setting of the program.)

Thanks,
Jeroen

It would be quite bad if gStyle->SetOptStat had an effect on existing objects. For example, you may have two canvases and wish to disable
the stats only in one canvas. For that we provide a menu item "Statistics"
in the canvas “Option” menu.

Rene

Hi Rene,

That indeed sounds about right. But for some reason I think of the gStyle things as global settings holding for all objects (so SetOptStat(false) would mean 'don’t draw any stats boxes). You could then override this with a per-object setting/draw option. That’s the way things work with line colours etc. isn’t it?

Thanks,
Jeroen

Correct. This is already the case. You can call myhist.SetStats(kTRUE/kFALSE)

Rene