Knowing which object(s) eat space in a given root file

Is there a way to know the size of the various keys in a root file ? (the idea being to find out where the space is going within a file)

I’ve tried something like :

TFile* f1 = …;
TIter nextKey(f1->GetListOfKeys());
TKey* key;

while ( (key=static_cast<TKey*>(nextKey())) )
{
cout<< Form("%20s size %10d bytes (objlen %10d) (%5.2f %% of file size)",
key->GetName(),
key->GetNbytes(),
key->GetObjlen(),
100.0*key->GetNbytes()/fileSize)<< endl;
}

but, at least for trees, this does not seem to give the answer I was hoping for (i.e. the key nbytes is way below the actual tree size)

Thanks,

Hi,

For a TTree, the key object only contains information about the TTree object itself (i.e. the meta data) and not about the data. To get information about the data (size), you will need to load the TTree object (and for example see the output of tree->Print()).

Cheers,
Philippe.