Consider the following unnamed macro:
TTree* tree=new TTree(“test”,“test”);
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: root.cern.ch/phpBB2/viewtopic.php?t=559
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  TFile f("test.root")
root  .ls
KEY: TTree test;1001 test
KEY: TTree test;1000 test
root  TTree *T1000 = (TTree*)f.Get("test;1000")
root  T1000.GetEntries()
root  TTree *T1001 = (TTree*)f.Get("test;1001")
root  T1001.GetEntries()
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
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