6 #include "TBranchRef.h" 50 Long64_t
GetTotalSize(TBranch * b,
bool ondisk,
bool inclusive);
51 Long64_t
GetBasketSize(TBranch * b,
bool ondisk,
bool inclusive);
53 Long64_t
GetBasketSize(TObjArray * branches,
bool ondisk,
bool inclusive) {
55 size_t n = branches->GetEntries();
56 for(
size_t i = 0;
i < n; ++
i ) {
57 result +=
GetBasketSize( dynamic_cast<TBranch*>( branches->At(
i ) ), ondisk, inclusive );
65 if (ondisk && b->GetZipBytes() > 0) {
66 result = b->GetZipBytes();
68 result = b->GetTotBytes();
71 result +=
GetBasketSize(b->GetListOfBranches(), ondisk,
true);
78 Long64_t
GetTotalSize( TBranch * br,
bool ondisk,
bool inclusive ) {
79 TMemFile f(
"buffer",
"CREATE");
80 if (br->GetTree()->GetCurrentFile()) {
81 f.SetCompressionSettings(br->GetTree()->GetCurrentFile()->GetCompressionSettings());
83 f.WriteObject(br,
"thisbranch");
84 TKey* key = f.GetKey(
"thisbranch");
87 size = key->GetNbytes();
89 size = key->GetObjlen();
95 size_t n = branches->GetEntries();
96 for(
size_t i = 0;
i < n; ++
i ) {
97 result +=
GetTotalSize( dynamic_cast<TBranch*>( branches->At(
i ) ), ondisk,
true );
98 cerr <<
"After " << branches->At(
i )->GetName() <<
" " << result << endl;
105 if (
t->GetDirectory()) {
106 key =
t->GetDirectory()->GetKey(
t->GetName());
108 Long64_t ondiskSize = 0;
109 Long64_t totalSize = 0;
111 ondiskSize = key->GetNbytes();
112 totalSize = key->GetObjlen();
114 TMemFile f(
"buffer",
"CREATE");
115 if (
t->GetCurrentFile()) {
116 f.SetCompressionSettings(
t->GetCurrentFile()->GetCompressionSettings());
119 key = f.GetKey(
t->GetName());
120 ondiskSize = key->GetNbytes();
121 totalSize = key->GetObjlen();
123 if (
t->GetBranchRef() ) {
131 return ondiskSize +
GetBasketSize(
t->GetListOfBranches(),
true,
true);
133 return totalSize +
GetBasketSize(
t->GetListOfBranches(),
false,
true);
154 cout <<
"The branch \"" << br->GetName() <<
"\" takes " <<
sizeOnDisk(br,
true) <<
" bytes on disk\n";
155 size_t n = br->GetListOfBranches()->GetEntries();
156 for(
size_t i = 0;
i < n; ++
i ) {
157 TBranch *subbr =
dynamic_cast<TBranch*
>(br->GetListOfBranches()->At(
i));
158 cout <<
" Its sub-branch \"" << subbr->GetName() <<
"\" takes " <<
sizeOnDisk(subbr,
true) <<
" bytes on disk\n";
164 cout <<
"The TTree \"" <<
t->GetName() <<
"\" takes " <<
sizeOnDisk(
t) <<
" bytes on disk\n";
165 size_t n =
t->GetListOfBranches()->GetEntries();
166 for(
size_t i = 0;
i < n; ++
i ) {
167 TBranch *br =
dynamic_cast<TBranch*
>(
t->GetListOfBranches()->At(
i));
168 cout <<
" Its branch \"" << br->GetName() <<
"\" takes " <<
sizeOnDisk(br,
true) <<
" bytes on disk\n";
180 cout <<
"Error, could not open input file: " <<
filename << endl;
198 const char *filename2=
"../../WCSim_clean/verification-test-scripts/wcsimtest.root",
199 bool verbose =
false)
202 cout <<
"Your version of WCSim assumes file: " << filename1 << endl
203 <<
"Stable GitHub version of WCSim assumes file: " << filename2 << endl;
206 for(
int itree = 0; itree <
ntrees; itree++) {
210 cout <<
"Trees sizes are identical!" << endl;
212 double change = (s1 - s2) * 100. / (
double)s2;
213 cout <<
"Your WCSim version tree is " << change <<
"% " << (change > 0 ?
"larger" :
"smaller")
214 <<
" than the master GitHub version" << endl;
Long64_t sizeOnDisk(TTree *t)
Long64_t GetTotalSize(TBranch *b, bool ondisk, bool inclusive)
string wcsimtrees[ntrees]
TFile * OpenFile(const char *filename)
void printBranchSummary(TBranch *br)
double t[MAX_N_ACTIVE_TUBES]
string wcsimbranches[ntrees]
Long64_t GetWCSimTreeSize(TFile *f, int itree, bool verbose)
void printTreeSummary(TTree *t)
int printSizes(const char *filename1="wcsimtest.root", const char *filename2="../../WCSim_clean/verification-test-scripts/wcsimtest.root", bool verbose=false)
Long64_t GetBasketSize(TBranch *b, bool ondisk, bool inclusive)