Naive question about SetCacheSize/AddBranchToCache

Hello,

I was using ROOT 5.22.00i and I am now moving to 5.26.00d. I am using MakeClass() on my TTree that contain thousand of “Branch” :

fChain->SetBranchStatus("*",0);
only for the branch that I need for my analysis (for ALL events)
fChain->SetBranchStatus(“EF_2e5_medium”,1);

There is a lot optimization in 5.26.00d (dixit searches on Google :smiley: )

Should I add them together like :

Int_t cachesize=10000000;
fChain->SetCacheSize(cachesize);
fChain->AddBranchToCache("",kTRUE);
fChain->SetBranchStatus("
",0);
only for the branch that I need for my analysis (for ALL events)
fChain->SetBranchStatus(“EF_2e5_medium”,1);

fChain->StopCacheLearningPhase();

Sorry for the naive question
Thanks a lot
Cheers
Fabien

NO, this is not correct. You should call AddBranchToCache only for the selected branches.

Rene

Hi Rene,

Sure. Thanks a a lot.

Other question :
// ROOT monitoring
TTreePerfStats *ps = new TTreePerfStats(“ioperf”,physics);

ps->SaveAs(“file.root”);

works fine, but as you know when running on the GRID we can have one output file. I tried to store this TTreePerfStats in my main tree :

std::string name_file_histo=“file.root”;
TFile *fout=new TFile(name_file_histo.c_str(),“update”);
ps->Write();
fout->Close();

but in this case when I draw “ioperf->Draw()”, the IO RAW (red line are missing) and "ioperf->Print() give me :
root [3] ioperf->Print()
TreeCache = 0 MBytes
N leaves = 2312
ReadTotal = 0 MBytes
ReadUnZip = nan MBytes
ReadCalls = 0
ReadSize = nan KBytes/read
Readahead = 0 KBytes
Readextra = nan per cent
Real Time = 0.000 seconds
CPU Time = 0.000 seconds
Disk Time = 0.606 seconds
Disk IO = 0.000 MBytes/s
ReadUZRT = nan MBytes/s
ReadUZCP = nan MBytes/s
ReadRT = nan MBytes/s
ReadCP = nan MBytes/s

This is probably not the right thing to do but ps->SaveAs(“file.root”); remove all the content of my previous file.root (it seems that there is no option ps->SaveAs(“file.root”,“update”);
I am using 5.26.00d
Thanks
Cheers
Fabien

Fabien,

Instead of SaveAs you can cd to the file where you want to write and simply do:

   ps->Finish();
   ps->Write();

Rene

Hi Rene,

It is what I did but the plot is different if I use ps->SaveAs(…) or if I do ps->Write() !
I attached the plot that I got with the following lines :

// ROOT monitoring
TTreePerfStats *ps = new TTreePerfStats(“ioperf”,physics);
std::string name_file_histo=“file.root”;
TFile *fout=new TFile(name_file_histo.c_str(),“update”);

TDirectoryFile* dir= new TDirectoryFile(“RootStat”,“RootStat”);
fout->cd(“RootStat”);
ps->Write();
fout->Write();
fout->close()


If I do ps->SaveAs(“file.root”);
I got this plot :


Thanks
Cheers
Fabien

Do

ps->Finish(); ps->Write();
Rene

Well, this give the right histo with some weird scale [probably some info about the RealTime range are lost]


while with ps->SaveAs give the better scale :



Cheers
Fabien

Looking at the time stamp at the bottom of the picture, it is clear that your 2 pictures correspond to 2 different runs.
There is something wrong with the results. It looks like your file has one or more branches with an infinite compression factor, explaining the wrong scale for the real time axis.

Rene

Hi Rene,

Sorry, both are produced by running on the same data sample but with one with the SaveAs method and in the other case with ps->Write()

I have now some interesting observations (the “file.root” was already created and filled previously in my code) :

std::string name_file_histo=“file.root”;
TFile *fout=new TFile(name_file_histo.c_str(),“update”);
ps->SaveAs(“file2.root”);

TDirectoryFile* dir= new TDirectoryFile(“RootStat”,“RootStat”);
fout->cd(“RootStat”);
ps->Finish();
ps->Write();
fout->Write();
fout->Close();

both root file contain the plot with the bad scale !!

now if I change “update” by “recreate”

std::string name_file_histo=“file.root”;
TFile *fout=new TFile(name_file_histo.c_str(),“recreate”);
ps->SaveAs(“file2.root”);

TDirectoryFile* dir= new TDirectoryFile(“RootStat”,“RootStat”);
fout->cd(“RootStat”);
ps->Finish();
ps->Write();
fout->Write();
fout->Close();

both root file contain the correct plot with the correct scale (but the content is overwritten) !!

Did I do something wrong when I closed my file.root previously in my code ? (in another method)

Any idea ?
Cheers
Fabien

It is hard to follow what you mean without having the concrete code that produced the bad result.

Rene

Hi Rene,
Here a simple piece of code with the results

Good.C (780 Bytes)


Bad.C (780 Bytes)


Just look at the strange scale in the second case. In the second case, I just reopen the TEST.root file that was created and closed by doing :

TFile *fout=new TFile(name_file_histo.c_str(),“update”);

and this change the scale of the plot !!
If you can access lxplus machine@cern, I put my file here :
on lxplus231 : /tmp/ForRene/user.FabienTarrade.005646.AANT._00479.root

Cheers
Fabien

Could you post the result file TEST.root where you store the TTreePerfStats object (bad case) ?
or make publicly available the file at “/tmp/tarrade/user.FabienTarrade.data10_7TeV.periodF.physics_Egamma.PhysCont.AOD.t0pro04_v01.D3PD_DILEP-09-2010_1_GRL.100908171907/user.FabienTarrade.005646.AANT._00479.root”);

Rene

Done :
ls /tmp/ForRene
TEST.root
user.FabienTarrade.005646.AANT._00479.root

TEST.root (16.5 KB)

Cheers
Fabien

OK Julien, I have found the problem that is visible when reading only a tiny fraction of the file.
The time axis scale was wrong in this case.
The problem is now fixed in the SVN trunk.
Thanks for reporting this case.

Rene

Thanks Rene,
Cheers
Fabien