#include "TFile.h"
#include "TTree.h"
#include "TBranch.h"
#include "TString.h"
#include "TKey.h"
#include <iostream>
Go to the source code of this file.
Definition at line 9 of file sizetree.C.
References cnt, f, i, n, name, next, obj, printf(), s, t, and TString.
18 TFile *
f=
new TFile(fname,
"READ");
22 TIter
next(f->GetListOfKeys());
23 while ( (key = (TKey*)
next()) )
25 TObject *
obj = key->ReadObj();
27 if (!obj->InheritsFrom(
"TTree"))
continue;
29 name[
cnt] = obj->GetName();
30 TTree*
t = (TTree*) obj;
32 n[
cnt] = t->GetEntries();
33 br[
cnt] = t->GetNbranches();
36 TObjArray* branches = t->GetListOfBranches();
37 for(
int i=0;
i<=branches->GetLast(); ++
i)
39 TBranch* branch = (TBranch*)branches->UncheckedAt(
i);
40 s += branch->GetZipBytes();
54 for (
int i=cnt;
i>1;--
i)
56 for (
int j=0;j<
i-1;++j)
58 if (size[ar[j]]<size[ar[j+1]])
60 int tmp=ar[j];ar[j]=ar[j+1];ar[j+1]=tmp;
65 for (
int i=0;i<
cnt;++
i)
66 printf(
"%2d. %10s : N = %8d, BR = %5d, N*BR = %7dk, Size = %7dk\n",
67 ar[i],name[ar[i]].Data(), n[ar[i]], br[ar[i]], (n[ar[i]]*br[ar[i]])/1000, size[ar[i]]/1000);
69 cout <<
"total size: "<<totsize/1000<<
"k"<<endl;
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)