Hi,
I just found that I TTreeCache does not work for TBranch::GetEntry().
TTreeCache works for TTree::GetEntry,
TFile *f = TFile::Open("NTUP_TOPMU.3.root");
TTree *physics = (TTree*)f->Get("physics");
physics->SetCacheSize(10*1024*1024);
physics->SetCacheLearnEntries(1);
Int_t nevt=physics->GetEntries();
physics->SetBranchStatus("*",0);
physics->SetBranchStatus("RunNumber",1);
physics->SetBranchStatus("EventNumber",1);
for (Int_t i=0; i<nevt; i++) {
physics->GetEntry(i);
}
physics->PrintCacheStats();
And I got the result:
But if I switched from TTree::GetEntry to TBranch::GetEntry, TTreeCache does not work:
TFile *f = TFile::Open("NTUP_TOPMU.3.root");
TTree *physics = (TTree*)f->Get("physics");
physics->SetCacheSize(10*1024*1024);
physics->SetCacheLearnEntries(1);
Int_t nevt=physics->GetEntries();
physics->SetBranchStatus("*",0);
physics->SetBranchStatus("RunNumber",1);
physics->SetBranchStatus("EventNumber",1);
for (Int_t i=0; i<nevt; i++) {
physics->GetBranch("RunNumber")->GetEntry(i);
physics->GetBranch("EventNumber")->GetEntry(i);
}
physics->PrintCacheStats();
and got the result:
Obviously TTreeCache was not used at all.
According to the source code of TTree, TTree::GetEntry just reads in a list of branches via TBranch::GetEntry, plus reads in list of friends.
I tried ROOT 5.28.00g, 5.30.03 and 5.32.oo-rc2, and got the same result.
I can not understand why TTreeCache works for TTree::GetEntry but not for TBranch::GetEntry.
–Shuwei