BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
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
5R__ADD_INCLUDE_PATH($VMCWORKDIR)
6#include "macro/profiling/size/calculate_size.C"
7
8void 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 Double_t
long long Long64_t
#define R__ADD_INCLUDE_PATH(PATH)
R__EXTERN TSystem * gSystem
T * Get(const char *namecycle)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
const char * GetName() const override
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual Long64_t GetEntries() const
virtual TObjArray * GetListOfBranches()
void branch_sizes(TString fileName, TString treeName="bmndata")
Definition branch_sizes.C:8