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;
33 size_type getBasketSize(TBranch*);
35 size_type getBasketSize(TObjArray* branches) {
36 size_type
result(static_cast<Long64_t>(0), 2);
37 size_t n = branches->GetEntries();
38 for (
size_t i = 0;
i <
n; ++
i) {
39 TBranch*
b =
dynamic_cast<TBranch*
>(branches->At(
i));
41 result += getBasketSize(b);
46 size_type getBasketSize(TBranch*
b) {
47 size_type
result(static_cast<Long64_t>(0), 2);
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());
61 size_type getTotalSize(TBranch*
br) {
62 TBufferFile buf(TBuffer::kWrite, 10000);
64 size_type
size = getBasketSize(br);
65 if (br->GetZipBytes() > 0)
66 size[kUncompressed] += buf.Length();
83 TFile*
file = TFile::Open(fileName.c_str());
84 if (file ==
nullptr || (!(*file).IsOpen()))
85 throw Error(
"unable to open data file " + fileName, 7002);
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);
92 if (events ==
nullptr)
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>(),
142 e = br.
name.rfind(
'_');
143 if (e != std::string::npos)
144 br.
name.replace(e, 1,
":");
164 co <<
"Branch Name | Average Uncompressed Size (Bytes/Event) | Average Compressed Size (Bytes/Event) \n";
174 uncompressed(
"uncompressed",
"branch sizes", top, -0.5, -0.5 + top),
175 compressed(
"compressed",
"branch sizes", top, -0.5, -0.5 + top),
176 cxAxis(compressed.GetXaxis()),
177 uxAxis(uncompressed.GetXaxis()),
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) {
193 double cm = compressed.GetMinimum(
i), um = uncompressed.GetMinimum(
i);
194 if (cm > 0 && cm < mn)
196 if (um > 0 && um < mn)
200 double mx =
std::max(compressed.GetMaximum(), uncompressed.GetMaximum());
202 uncompressed.SetMinimum(mn);
203 uncompressed.SetMaximum(mx);
204 compressed.SetMinimum(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);
212 compressed.GetYaxis()->SetTitle(
"Bytes");
213 compressed.SetFillColor(kBlue);
214 compressed.SetLineWidth(2);
215 uncompressed.GetYaxis()->SetTitle(
"Bytes");
216 uncompressed.SetFillColor(kRed);
217 uncompressed.SetLineWidth(2);
238 gROOT->SetStyle(
"Plain");
239 gStyle->SetOptStat(kFALSE);
240 gStyle->SetOptLogy();
244 c.SaveAs(plot.c_str());
247 TFile
f(file.c_str(),
"RECREATE");
edm::ErrorSummaryEntry Error
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.