Greetings,
I ran into a strange problem that caused me hours of grief. Given a TTree, I draw a branch into an un-initialized histogram htemp. Then, after I SetBinContent the overflow bin, the number of bins in htemp doubles! See the following CINT session to understand the effect:
pb-d-128-141-131-37:roottalk jribnik$ root -b gaus_TTree.root
******************************
* Welcome to ROOT v5.18/00 *
******************************
******************************
* Welcome to ROOT v5.18/00 *
******************************
root [0]
Attaching file gaus_TTree.root as _file0...
root [1] .ls
TFile** gaus_TTree.root
TFile* gaus_TTree.root
KEY: TTree tree;1 tree
root [2] tree->GetListOfBranches()->ls("*")
OBJ: TBranch gaus gaus/D : 0 at: 0x282a440
root [3] tree->Draw("gaus>>htemp")
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [4] htemp
(class TH1F*)0x20be200
root [5] htemp->GetNbinsX()
(const Int_t)(100)
root [6] htemp->SetBinContent(101, 1)
root [7] htemp->GetNbinsX()
(const Int_t)(200)
root [8] htemp->SetBinContent(201, 1)
root [9] htemp->GetNbinsX()
(const Int_t)(400)
root [10]
If I draw the branch into a histogram initialized with the number of bins, i.e. >>htemp(100), the same problem occurs. However, if I draw the branch into a histogram initialized with axis limits, i.e. >>htemp(100, 0, 10), the problem goes away, but then I loose the flexibility of not having to know my axis limits a priori.
I have attached a ROOT macro that creates a simple TTree and demonstrates the effect. From the resulting histogram you can see that it also adds an entry and drastically changes the axis limits. I discovered this in compiled code on a Mac in 5.18/00, and have seen it also on Linux in 5.14/00e.
Does anyone know what is going on here?
Thanks,
Jake
roottalk.cpp (610 Bytes)