9 #include <boost/bind.hpp>
19 #include "TObjArray.h"
23 #include "Riostream.h"
26 #include "TBufferFile.h"
32 typedef std::valarray<Long64_t>
size_type;
34 size_type getBasketSize( TBranch *);
36 size_type getBasketSize( TObjArray * branches) {
37 size_type
result(static_cast<Long64_t>(0),2);
38 size_t n = branches->GetEntries();
39 for(
size_t i = 0;
i <
n; ++
i ) {
40 TBranch *
b =
dynamic_cast<TBranch*
>( branches->At(
i ) );
42 result += getBasketSize(b);
47 size_type getBasketSize( TBranch *
b) {
48 size_type
result(static_cast<Long64_t>(0),2);
50 if ( b->GetZipBytes() > 0 ) {
51 result[kUncompressed] = b->GetTotBytes();
result[kCompressed] = b->GetZipBytes();
53 result[kUncompressed] = b->GetTotalSize();
result[kCompressed] = b->GetTotalSize();
55 result += getBasketSize( b->GetListOfBranches() );
61 size_type getTotalSize( TBranch *
br) {
62 TBufferFile buf( TBuffer::kWrite, 10000 );
63 TBranch::Class()->WriteBuffer( buf, br );
64 size_type
size = getBasketSize(br);
65 if ( br->GetZipBytes() > 0 )
66 size[kUncompressed] += buf.Length();
85 TFile *
file = TFile::Open( fileName.c_str() );
86 if( file==0 || ( !(*file).IsOpen() ) )
87 throw Error(
"unable to open data file " + fileName, 7002);
89 TObject *
o = file->Get(treeName.c_str() );
91 throw Error(
"no object \"" + treeName +
"\" found in file: " + fileName, 7003);
93 TTree *
events =
dynamic_cast<TTree*
> (
o);
95 throw Error(
"object \"" + treeName +
"\" is not a TTree in file: " + fileName, 7004);
99 throw Error(
"tree \"" + treeName +
"\" in file " + fileName +
" contains no Events", 7005);
102 TObjArray * branches = events->GetListOfBranches();
104 throw Error(
"tree \"" + treeName+
"\" in file " + fileName +
" contains no branches", 7006);
106 const size_t n = branches->GetEntries();
108 for(
size_t i = 0;
i <
n; ++
i ) {
109 TBranch * b =
dynamic_cast<TBranch*
>( branches->At(
i ) );
111 std::string
const name( b->GetName() );
112 if (
name ==
"EventAux" )
continue;
113 size_type
s = getTotalSize(b);
117 boost::bind(std::greater<double>(),
126 boost::bind(std::less<std::string>(),
143 e = br.
name.rfind(
'_');
144 if (e!=std::string::npos) br.
name.replace(e,1,
":");
170 co <<
"Branch Name | Average Uncompressed Size (Bytes/Event) | Average Compressed Size (Bytes/Event) \n";
200 for(
int i = 1;
i <=
top; ++
i ) {
202 if ( cm > 0 && cm < mn ) mn = cm;
203 if ( um > 0 && um < mn ) mn = um;
212 cxAxis->SetLabelOffset( -0.32 );
213 cxAxis->LabelsOption(
"v" );
214 cxAxis->SetLabelSize( 0.03 );
215 uxAxis->SetLabelOffset( -0.32 );
216 uxAxis->LabelsOption(
"v" );
217 uxAxis->SetLabelSize( 0.03 );
244 if( !plot.empty() ) {
245 gROOT->SetStyle(
"Plain" );
246 gStyle->SetOptStat( kFALSE );
247 gStyle->SetOptLogy();
251 c.SaveAs( plot.c_str() );
253 if ( !file.empty() ) {
254 TFile
f( file.c_str(),
"RECREATE" );
const T & max(const T &a, const T &b)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
tuple size
Write out results.