How to list the size (in Bytes) of TObjects saved in a TFile?

Hi,
I’d like to know the size of the TObjects saved in a TFile ?
How can I perform that ?
I have heavy files with a lot of TObjects saved inside, and wish to know which objects make the greatest part of the file’s overall size.

From the doc, I would do in python something like:
from ROOT import TFile
f = TFile(myfile.root)
for k in f.GetListOfKeys():
print “{:40s}{:3.1f}”.format(k.GetName(), k.GetNbytes())

But the numbers do not correspond to what I see in the output of TObject->Print()

Thanks


ROOT Version 6.12.04
Platform, compiler (SLC6.2, gcc4.9):


Hi,

can TFile::Map be of help here?

Cheers,
D

Hi,
I tried TFile::Map. It is interesting, but it prints out the size of every TBaskets, and without its name.
What I wish is the total size of the TTree including all TBaskets in the TFile.
I think it is the number comming after “File Size” in TTree::Print()

******************************************************************************
*Tree    :t_modules : physical modules packets                               *
*Entries :  8016038 : Total =      3414990933 bytes  File  Size = 1206857303 *
*        :          : Tree compression factor =   2.83                       *
******************************************************************************

How can I get that number directly ?

Thanks,

TTree::GetZipBytes will return the size of the baskets on file, to which you need to add the size of the TKey for the TTree itself.

Thanks. That’s what I need.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.