Hi,
I stumbled across a ‘trivial’ problem which however is somewhat annoying. When creating a histogram with TTree::Draw via e.g. (with TTree named n)
n->Draw(“m01>>h1(100,2.8,3.3)”)
a histogram is shown and stored as a namend object in the current TDirectory (as far as I understand it). If I repeat this command with ROOT 5.xx.x there is always created a new TH1F* replacing the old one in the TDirectory, i.e.
root [1] n->Draw("m01>>h1(100,2.8,3.4","");
root [2] h1
(class TH1F*)0x3505520
root [3] n->Draw("m01>>h1(100,2.8,3.3","");
root [4] h1
(class TH1F*)0x34f2cc0 // <== different pointer
In ROOT 6, however, the pointer/object is not updated or replaced:
root [1] n->Draw("m01>>h1(100,2.8,3.4","");
root [2] h1
(TH1F *) 0x51f42f0
root [3] n->Draw("m01>>h1(100,2.8,3.3","");
root [4] h1
(TH1F *) 0x51f42f0// <== the same old pointer
This leads in particular to the problem that I get a segfault if trying to do a h1->Draw() after the second TTree::Draw(…).
root [1] n->Draw("m01>>h1(100,2.8,3.4","");
root [2] h1->Draw()
root [3] n->Draw("m01>>h1(100,2.8,3.3","");
root [4] h1->Draw()
*** Break *** segmentation violation
When executing .ls I get indeed the changed pointer
root [5] .ls
TFile** D4230_B703p02_all1100/mrg_1117.root
TFile* D4230_B703p02_all1100/mrg_1117.root
OBJ: TTree n title : 0 at: 0x4b643c0
OBJ: TH1F h1 m01 : 0 at: 0x529c970
root [6] h1
(TH1F *) 0x51f42f0 // <== different address than with .ls above
but this is obviously not propagated to the variable h1 in scope. I think that this it related to the behaviour in ROOT6 not to recreate objects in the root prompt which already exist by name.
Does somebody know whether there is a practical way around this problem?
Best regards and thanks,
Klaus
Please read tips for efficient and successful posting and posting code
_ROOT Version:6.06/02
Platform: linux
Compiler: Not Provided