49 Long64_t GetTotalSize(TBranch * b,
bool ondisk,
bool inclusive);
50 Long64_t GetBasketSize(TBranch * b,
bool ondisk,
bool inclusive);
55 Long64_t GetBasketSize(TObjArray * branches,
bool ondisk,
bool inclusive) {
57 size_t n = branches->GetEntries();
58 for(
size_t i = 0; i < n; ++ i ) {
59 result += GetBasketSize( dynamic_cast<TBranch*>( branches->At( i ) ), ondisk, inclusive );
64 Long64_t GetBasketSize(TBranch * b,
bool ondisk,
bool inclusive) {
67 if (ondisk && b->GetZipBytes() > 0) {
68 result = b->GetZipBytes();
70 result = b->GetTotBytes();
73 result += GetBasketSize(b->GetListOfBranches(), ondisk,
true);
80 Long64_t GetTotalSize( TBranch * br,
bool ondisk,
bool inclusive ) {
81 TMemFile f(
"buffer",
"CREATE");
82 if (br->GetTree()->GetCurrentFile()) {
83 f.SetCompressionSettings(br->GetTree()->GetCurrentFile()->GetCompressionSettings());
85 f.WriteObject(br,
"thisbranch");
86 TKey* key = f.GetKey(
"thisbranch");
89 size = key->GetNbytes();
91 size = key->GetObjlen();
92 return GetBasketSize(br, ondisk, inclusive) + size;
95 Long64_t GetTotalSize( TObjArray * branches,
bool ondisk ) {
97 size_t n = branches->GetEntries();
98 for(
size_t i = 0; i < n; ++ i ) {
99 result += GetTotalSize( dynamic_cast<TBranch*>( branches->At( i ) ), ondisk,
true );
100 cerr <<
"After " << branches->At( i )->GetName() <<
" " << result << endl;
105 Long64_t GetTotalSize(TTree *t,
bool ondisk) {
107 if (t->GetDirectory()) {
108 key = t->GetDirectory()->GetKey(t->GetName());
110 Long64_t ondiskSize = 0;
111 Long64_t totalSize = 0;
113 ondiskSize = key->GetNbytes();
114 totalSize = key->GetObjlen();
116 TMemFile f(
"buffer",
"CREATE");
117 if (t->GetCurrentFile()) {
118 f.SetCompressionSettings(t->GetCurrentFile()->GetCompressionSettings());
121 key = f.GetKey(t->GetName());
122 ondiskSize = key->GetNbytes();
123 totalSize = key->GetObjlen();
125 if (t->GetBranchRef() ) {
127 ondiskSize += GetBasketSize(t->GetBranchRef(),
true,
true);
129 totalSize += GetBasketSize(t->GetBranchRef(),
false,
true);
133 return ondiskSize + GetBasketSize(t->GetListOfBranches(),
true,
true);
135 return totalSize + GetBasketSize(t->GetListOfBranches(),
false,
true);
139 Long64_t sizeOnDisk(TTree *t) {
142 return GetTotalSize(t,
true);
145 Long64_t sizeOnDisk(TBranch *branch,
bool inclusive)
151 return GetTotalSize(branch,
true, inclusive);
154 void printBranchSummary(TBranch *br)
156 cout <<
"The branch \"" << br->GetName() <<
"\" takes " << sizeOnDisk(br,
true) <<
" bytes on disk\n";
157 size_t n = br->GetListOfBranches()->GetEntries();
158 for(
size_t i = 0; i < n; ++ i ) {
159 TBranch *subbr =
dynamic_cast<TBranch*
>(br->GetListOfBranches()->At(i));
160 cout <<
" Its sub-branch \"" << subbr->GetName() <<
"\" takes " << sizeOnDisk(subbr,
true) <<
" bytes on disk\n";
164 void printTreeSummary(TTree *t)
166 cout <<
"The TTree \"" << t->GetName() <<
"\" takes " << sizeOnDisk(t) <<
" bytes on disk\n";
167 size_t n = t->GetListOfBranches()->GetEntries();
168 for(
size_t i = 0; i < n; ++ i ) {
169 TBranch *br =
dynamic_cast<TBranch*
>(t->GetListOfBranches()->At(i));
170 cout <<
" Its branch \"" << br->GetName() <<
"\" takes " << sizeOnDisk(br,
true) <<
" bytes on disk\n";