BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
branch_sizes.C
Go to the documentation of this file.
1
// branch_sizes.C: size on disk of the branches of the event tree per event, used for the data volume tables of the
2
// format documents. The size of a branch is calculated with sizeOnDisk() of macro/profiling/size/calculate_size.C
3
// for the whole file (only the tree header is read, so even large files are processed fast)
4
// example: root -b -q -l 'branch_sizes.C("bmnsim.root")' | grep -E '^(#|SIZE)' > digi/branch_sizes_sim.txt
5
R__ADD_INCLUDE_PATH
($VMCWORKDIR)
6
#include "macro/profiling/size/calculate_size.C"
7
8
void
branch_sizes
(
TString
fileName,
TString
treeName =
"bmndata"
)
9
{
10
gSystem
->ExpandPathName(fileName);
11
TFile
* file =
TFile::Open
(fileName);
12
if
(!file || file->
IsZombie
()) {
13
cout <<
"ERROR: cannot open file "
<< fileName << endl;
14
return
;
15
}
16
TTree
* tree = (
TTree
*)file->
Get
(treeName);
17
if
(!tree || tree->
GetEntries
() == 0) {
18
cout <<
"ERROR: no tree "
<< treeName <<
" or no events in file "
<< fileName << endl;
19
return
;
20
}
21
22
Long64_t
nEvents = tree->
GetEntries
();
23
printf(
"# file %s, tree %s, %lld events\n"
,
gSystem
->BaseName(fileName), treeName.Data(), nEvents);
24
TIter
next(tree->
GetListOfBranches
());
25
TBranch
* branch;
26
while
((branch = (
TBranch
*)next())) {
27
// size of the branch together with its sub-branches
28
printf(
"SIZE %-28s zip/ev=%10.1f B\n"
, branch->
GetName
(), (
Double_t
)sizeOnDisk(branch,
true
) / nEvents);
29
}
30
}
Double_t
double Double_t
Long64_t
long long Long64_t
R__ADD_INCLUDE_PATH
#define R__ADD_INCLUDE_PATH(PATH)
gSystem
R__EXTERN TSystem * gSystem
TBranch
TDirectoryFile::Get
T * Get(const char *namecycle)
TFile
TFile::Open
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
TIter
TNamed::GetName
const char * GetName() const override
TObject::IsZombie
R__ALWAYS_INLINE Bool_t IsZombie() const
TString
TTree
TTree::GetEntries
virtual Long64_t GetEntries() const
TTree::GetListOfBranches
virtual TObjArray * GetListOfBranches()
branch_sizes
void branch_sizes(TString fileName, TString treeName="bmndata")
Definition
branch_sizes.C:8
services
format_docs
branch_sizes.C
Generated on
for BmnRoot by
1.17.0