Hi,
Another one for the experts: who decides whether or not a TH1 can be rebinned? (The TH1::kCanRebin bit.) When filling a TH1 with alphanumeric label entries, this bit is set when the first call to Fill() creates the bin labels. This makes sense. (I don’t think the docs spell it out too well though.) But why does a subsequent scaling reset this bit? It also means that this bit can never be relied on to keep it’s value. One always has to set it explicitly before calling any method that could lead to rebinning. Is that intentional?
This code
{
gROOT.Reset();
TH1D hist("hist", "hist", 1, 0., 1.);
std::cout << "0 hist can be rebinned ? " << hist.TestBit(TH1::kCanRebin) << std::endl;
hist.Fill("a", 1.);
std::cout << "1 hist can be rebinned ? " << hist.TestBit(TH1::kCanRebin) << std::endl;
hist.Scale(1.);
std::cout << "2 hist can be rebinned ? " << hist.TestBit(TH1::kCanRebin) << std::endl;
}
produces the following output (in both v5.12 and v5.16)
root [0] .x test_rebin.C
0 hist can be rebinned ? 0
1 hist can be rebinned ? 1
2 hist can be rebinned ? 0
Cheers,
Jeroen