9 #include <boost/bind.hpp> 19 #include "TObjArray.h" 25 #include "TBufferFile.h" 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(); result[kCompressed] = b->GetZipBytes();
52 result[kUncompressed] = b->GetTotalSize(); result[kCompressed] = b->GetTotalSize();
54 result += getBasketSize( b->GetListOfBranches() );
60 size_type getTotalSize( TBranch *
br) {
61 TBufferFile buf( TBuffer::kWrite, 10000 );
63 size_type
size = getBasketSize(br);
64 if ( br->GetZipBytes() > 0 )
65 size[kUncompressed] += buf.Length();
84 TFile *
file = TFile::Open( fileName.c_str() );
85 if( file==0 || ( !(*file).IsOpen() ) )
86 throw Error(
"unable to open data file " + fileName, 7002);
88 TObject *
o = file->Get(treeName.c_str() );
90 throw Error(
"no object \"" + treeName +
"\" found in file: " + fileName, 7003);
92 TTree *
events =
dynamic_cast<TTree*
> (
o);
94 throw Error(
"object \"" + treeName +
"\" is not a TTree in file: " + fileName, 7004);
98 throw Error(
"tree \"" + treeName +
"\" in file " + fileName +
" contains no Events", 7005);
101 TObjArray * branches = events->GetListOfBranches();
103 throw Error(
"tree \"" + treeName+
"\" in file " + fileName +
" contains no branches", 7006);
105 const size_t n = branches->GetEntries();
107 for(
size_t i = 0;
i <
n; ++
i ) {
108 TBranch *
b =
dynamic_cast<TBranch*
>( branches->At(
i ) );
111 if (
name ==
"EventAux" )
continue;
116 boost::bind(std::greater<double>(),
125 boost::bind(std::less<std::string>(),
142 e = br.
name.rfind(
'_');
143 if (e!=std::string::npos) br.
name.replace(e,1,
":");
169 co <<
"Branch Name | Average Uncompressed Size (Bytes/Event) | Average Compressed Size (Bytes/Event) \n";
181 uncompressed(
"uncompressed",
"branch sizes", top, -0.5, - 0.5 + top ),
182 compressed(
"compressed",
"branch sizes", top, -0.5, - 0.5 + top ),
183 cxAxis(compressed.GetXaxis()),
184 uxAxis(uncompressed.GetXaxis()),
189 cxAxis->SetBinLabel(
x + 1, br.
name.c_str() );
190 uxAxis->SetBinLabel(
x + 1, br.
name.c_str() );
199 for(
int i = 1;
i <= top; ++
i ) {
200 double cm = compressed.GetMinimum(
i ), um = uncompressed.GetMinimum(
i );
201 if ( cm > 0 && cm < mn ) mn = cm;
202 if ( um > 0 && um < mn ) mn = um;
205 double mx =
std::max( compressed.GetMaximum(), uncompressed.GetMaximum() );
207 uncompressed.SetMinimum( mn );
208 uncompressed.SetMaximum( mx );
209 compressed.SetMinimum( mn );
211 cxAxis->SetLabelOffset( -0.32 );
212 cxAxis->LabelsOption(
"v" );
213 cxAxis->SetLabelSize( 0.03 );
214 uxAxis->SetLabelOffset( -0.32 );
215 uxAxis->LabelsOption(
"v" );
216 uxAxis->SetLabelSize( 0.03 );
217 compressed.GetYaxis()->SetTitle(
"Bytes" );
218 compressed.SetFillColor( kBlue );
219 compressed.SetLineWidth( 2 );
220 uncompressed.GetYaxis()->SetTitle(
"Bytes" );
221 uncompressed.SetFillColor( kRed );
222 uncompressed.SetLineWidth( 2 );
243 if( !plot.empty() ) {
244 gROOT->SetStyle(
"Plain" );
245 gStyle->SetOptStat( kFALSE );
246 gStyle->SetOptLogy();
250 c.SaveAs( plot.c_str() );
252 if ( !file.empty() ) {
253 TFile
f( file.c_str(),
"RECREATE" );
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
T x() const
Cartesian x coordinate.