TTree::AutoSave() question

Consider the following unnamed macro:

TFile f(“test.root”,“recreate”);
TTree* tree=new TTree(“test”,“test”);
Int_t a;
for ( int i = 0 ; i <1000000 ; i++)
if ( i % 1000 == 1) tree->AutoSave(“SaveSelf”);

The resulting TFile has two test TTrees with different cycles: 1000 and 1001.

From Phhilippe’s answer to post:

I understand that the tree with cycle 1000 is saved by the last AutoSave (happening at event 999001), and the cycle 1001 is created by f.Write() at event 999999.
I wonder why, then, the number of entries in the TTrees is, for both cases, 999999.

I cannot reproduce your problem. After having run your script, I do:

root [0] TFile f("test.root") root [1] .ls TFile** test.root TFile* test.root KEY: TTree test;1001 test KEY: TTree test;1000 test root [2] TTree *T1000 = (TTree*)f.Get("test;1000") root [3] T1000.GetEntries() (const Long64_t)999002 root [4] TTree *T1001 = (TTree*)f.Get("test;1001") root [5] T1001.GetEntries() (const Long64_t)1000000


Dear Rene,
thanks for the lines of code, I was wrong.
I was inspecting the trees using the TBrowser and starting a tree viewer.
I think that the tree viewer always attaches to the tree with the largest cycle number, I was starting the viewer for cycle 1000 and getting 999999 events (from cycle 1001).
Is this correct?



I cannot reproduce this problem. Could you clarify all your steps?


I start root with:

root -l test.root
root[0]new TBrowser

I then open the root file, I can see the two trees with cycle 1000 and 1001.
I select “test;1000” right clicking on it and then select start viewer (see screenshot.png).

TreeViewer reports: “First entry: 0 Last entry: 999999” (see screenshot1.png)

Drawing leaf a also reports 1M entries (screenshot2.png).

Hope this clarify,


Currently, the TBrowser always load the latest version (highest cycle) no matter which one you click on.



FYI, this should be fixed in svn rev 30090

Cheers, Bertrand.