Merged file io question

Hello,
the following is not a serious issue. I am asking out of curiosity.
I have 2 ROOT files with a tree, and I merge them.
I’m interested how the merged file is read. Apparently a merged file with 200 entries
is read differently than a chain of 2 files with 100 entries each.
I would expect that each basket of the merged file is read exactly once.
But what I see is different. One of the baskets is always read twice.
I can reproduce this with different trees and files. Is it working as supposed?
Thanks, Misha.

Example.

I have 2 files with 100 events each created with Proofbench, which I merge into a 3rd file of 200 events.
My Selector code prints out the number of bytes read and read calls per entry in a tree.
In the case of a merged file baskets are read in a regular way for first 100 entries.
For the remaining entries one read call is issued per bunch of baskets physically adjacent on disk.
This is similar to TTreeCache with learning phase of 100 entries.

ROOT 523-04.
File 1: www-linux.gsi.de/~zynovyev/oneba … ost_0.root
File 2: www-linux.gsi.de/~zynovyev/oneba … ost_1.root
Merged file: www-linux.gsi.de/~zynovyev/onebasket/plain.root
The physical layout of contents of the merged tree are at
www-linux.gsi.de/~zynovyev/onebasket/plain.log
Selector:
www-linux.gsi.de/~zynovyev/onebasket/Check.C
www-linux.gsi.de/~zynovyev/onebasket/Check.h
libEvent library:
www-linux.gsi.de/~zynovyev/onebasket/libEvent.so

Your example does not use the TreeCache at all. I have modified your files (see attachment) and made a small pilot file shown below showing how to activate the cache in your case.
For example, when running on the plain.root file, you should get the following output

root [0] .x do.C Before event #0 bytes read: 11014, read calls: 4 After event #0 bytes read: 43708, read calls: 21 After event #33 bytes read: 36107, read calls: 4
file do.C

{ gSystem.Load("test/libEvent"); //TFile f("event_tree_localhost_1.root"); TFile f("plain.root"); TTree *T = (TTree*)f.Get("EventTree"); //set the read cache Int_t cachesize = 10000000; //this is the default value: 10 MBytes T->SetCacheSize(cachesize); TTreeCache::SetLearnEntries(1); //one entry is sufficient to learn TTreeCache *tc = (TTreeCache*)f.GetCacheRead(); tc->SetEntryRange(0,T->GetEntries()); //process events T->Process("Check.C+"); }
Check.h (4.54 KB)
Check.C (3.5 KB)

Excuse me, perhaps I didn’t put it clearly enough.
I do not state that I use TTreeCache. And it is not my intention.
I’m interested how merged files are read without TTreeCache enabled.

I mentioned TTreeCache in the following context.
I notice that baskets of the merged file are accessed as if
TTreeCache is enabled with a learning phase of 100 entries.

I do not understand your question. There is no difference between a merged file and a normal file.

Rene

[quote]But what I see is different. One of the baskets is always read twice. [/quote]Which basket? How do you establish that it is read twice?

Cheers,
Philippe.

Thank you very much for your time. Indeed there is no difference between
a merged and a normal file.
I have now two issues which I would like to understand.
www-linux.gsi.de/~zynovyev/onebasket/stat.log
1)
Here is what happens when the aforementioned merged file is read.

event #99 - bytes read: 2313, read calls: 1
event #132 - bytes read: 12659, read calls: 4

Whereas I would expect at least

event #99 - bytes read: 2313, read calls: 1
event #132 - bytes read: 10346, read calls: 4

Why it is not

event #99 - bytes read: 2313, read calls: 1  
event #132 - bytes read: 2669, read calls: 1  
event #165 - bytes read: 2971, read calls: 1  
event #177 - bytes read: 4242, read calls: 1  
event #198 - bytes read: 464, read calls: 1 

I appreciate your help very very much.