12 #include "utilities.hh" 24 return (name>var.
name);
41 for(
size_t ivar=0; ivar<vars.size(); ivar++){
42 if(var.
name == vars[ivar].name){
55 int main(
int argc,
char *argv[]){
59 cout<<endl<<
"Format is: ./run/disk_usage.exe file <treename=tree>"<<endl<<endl;
63 TString nametree=
"tree",
filename = argv[1];
64 if(argc>=3) nametree = argv[2];
66 TChain chain(nametree);
67 if(!chain.Add(
filename) || !chain.GetListOfLeaves()) {
68 cout<<endl<<
"No tree found in "<<
filename<<endl<<endl;
72 long zip_sum(0), tot_sum(0);
74 double nentries = chain.GetEntries();
76 vector<Variable> vars, allvars;
77 set<Variable>::iterator it;
79 for(
int i = 0; i < chain.GetListOfLeaves()->GetSize(); ++i){
80 TBranch *b =
static_cast<TLeaf*
>(chain.GetListOfLeaves()->At(i))->GetBranch();
83 v.
name = b->GetName();
90 if(v.
name.Length() > max_length) max_length = v.
name.Length();
94 if(index == -1) vars.push_back(v);
101 int wbytes=10, wother=11;
104 sort(allvars.begin(), allvars.end(),
varCompare);
106 << endl <<
"Tree \""<< nametree <<
"\" occupies "<< zip_sum <<
" bytes and has "<<
addCommas(nentries)<<
" entries (" 107 <<
roundNumber(zip_sum,2,nentries*1024)<<
" kB/event):" << endl;
108 cout <<endl<< setw(max_length) <<
"Branch name" <<
' ' 109 << setw(wbytes) <<
"Byte/ev" <<
' ' 110 << setw(wother) <<
"Frac. [%]" <<
' ' 111 << setw(wother) <<
"Cumulative" << sep
112 << setw(max_length) <<
"Branch group name" <<
' ' 113 << setw(wbytes) <<
"Byte/ev" <<
' ' 114 << setw(wother) <<
"Frac. [%]" <<
' ' 115 << setw(wother) <<
"Cumulative" << endl;
116 for(
int ind=0;
ind<(max_length+wbytes+2*wother+3);
ind++) cout <<
"=";
118 for(
int ind=0;
ind<(max_length+wbytes+2*wother+3);
ind++) cout <<
"=";
120 << setw(max_length) <<
"Total" <<
' ' 121 << setw(wbytes) <<
roundNumber(zip_sum,1,nentries) <<
' ' 122 << setw(wother) <<
"100.00" <<
' ' 123 << setw(wother) <<
"-" << sep
124 << setw(max_length) <<
"Total" <<
' ' 125 << setw(wbytes) <<
roundNumber(zip_sum,1,nentries) <<
' ' 126 << setw(wother) <<
"100.00" <<
' ' 127 << setw(wother) <<
"-" << endl;
128 long running_total(0), tot2=0;
129 for(
size_t ivar=0; ivar<allvars.size(); ivar++){
130 running_total += allvars[ivar].zip_size;
131 double this_frac = (100.0*allvars[ivar].zip_size)/zip_sum;
132 double tot_frac = (100.0*running_total)/zip_sum;
133 cout << setw(max_length) << allvars[ivar].name <<
" " 134 << setw(wbytes) <<
roundNumber(allvars[ivar].zip_size,2,nentries) <<
" " 137 if(ivar<vars.size()){
138 tot2 += vars[ivar].zip_size;
139 this_frac = (100.0*vars[ivar].zip_size)/zip_sum;
140 tot_frac = (100.0*tot2)/zip_sum;
141 cout << setw(max_length) << vars[ivar].name <<
" " 142 << setw(wbytes) <<
roundNumber(vars[ivar].zip_size,2,nentries) <<
" "
virtual string do_grouping() const
virtual char do_thousands_sep() const
bool operator<(const Variable &var) const
bool varCompare(const Variable &var1, const Variable &var2)
TString addCommas(double num)
TString roundNumber(double num, int decimals, double denom=1.)
int main(int argc, char *argv[])
int findVar(const Variable &var, vector< Variable > &vars)