9 #include <boost/bind.hpp>
19 #include "TObjArray.h"
23 #include "Riostream.h"
25 #include "TBufferFile.h"
29 enum Indices { kUncompressed, kCompressed };
31 typedef std::valarray<Long64_t>
size_type;
35 size_type getBasketSize(TObjArray* branches) {
37 size_t n = branches->GetEntries();
38 for (
size_t i = 0;
i <
n; ++
i) {
39 TBranch*
b = dynamic_cast<TBranch*>(branches->At(
i));
49 if (
b->GetZipBytes() > 0) {
50 result[kUncompressed] =
b->GetTotBytes();
51 result[kCompressed] =
b->GetZipBytes();
53 result[kUncompressed] =
b->GetTotalSize();
54 result[kCompressed] =
b->GetTotalSize();
56 result += getBasketSize(
b->GetListOfBranches());
62 TBufferFile
buf(TBuffer::kWrite, 10000);
65 if (
br->GetZipBytes() > 0)
66 size[kUncompressed] +=
buf.Length();
84 if (
file ==
nullptr || (!(*file).IsOpen()))
87 TObject*
o =
file->Get(treeName.c_str());
89 throw Error(
"no object \"" + treeName +
"\" found in file: " +
fileName, 7003);
91 TTree*
events = dynamic_cast<TTree*>(
o);
93 throw Error(
"object \"" + treeName +
"\" is not a TTree in file: " +
fileName, 7004);
97 throw Error(
"tree \"" + treeName +
"\" in file " +
fileName +
" contains no Events", 7005);
99 TObjArray* branches =
events->GetListOfBranches();
100 if (branches ==
nullptr)
101 throw Error(
"tree \"" + treeName +
"\" in file " +
fileName +
" contains no branches", 7006);
103 const size_t n = branches->GetEntries();
105 for (
size_t i = 0;
i <
n; ++
i) {
106 TBranch*
b = dynamic_cast<TBranch*>(branches->At(
i));
110 if (
name ==
"EventAux")
118 boost::bind(std::greater<double>(),
134 size_t b =
br.fullName.find(
'_');
135 size_t e =
br.fullName.rfind(
'_');
137 br.name =
br.fullName;
140 br.name =
br.fullName.substr(
b + 1,
e -
b - 1);
142 e =
br.name.rfind(
'_');
143 if (
e != std::string::npos)
144 br.name.replace(
e, 1,
":");
146 br.name.append(
" (" +
br.fullName.substr(0,
b) +
")");
157 co <<
br.name <<
" " <<
br.uncompr_size <<
" " <<
br.compr_size <<
"\n";
164 co <<
"Branch Name | Average Uncompressed Size (Bytes/Event) | Average Compressed Size (Bytes/Event) \n";
182 cxAxis->SetBinLabel(
x + 1,
br.name.c_str());
183 uxAxis->SetBinLabel(
x + 1,
br.name.c_str());
192 for (
int i = 1;
i <=
top; ++
i) {
194 if (cm > 0 && cm < mn)
196 if (um > 0 && um < mn)
206 cxAxis->SetLabelOffset(-0.32);
207 cxAxis->LabelsOption(
"v");
208 cxAxis->SetLabelSize(0.03);
209 uxAxis->SetLabelOffset(-0.32);
210 uxAxis->LabelsOption(
"v");
211 uxAxis->SetLabelSize(0.03);
238 gROOT->SetStyle(
"Plain");
239 gStyle->SetOptStat(kFALSE);
240 gStyle->SetOptLogy();
242 h.uncompressed.Draw();
243 h.compressed.Draw(
"same");
244 c.SaveAs(
plot.c_str());
247 TFile
f(
file.c_str(),
"RECREATE");
248 h.compressed.Write();
249 h.uncompressed.Write();