EventAnalysis
1.3.0
|
A tree that reads only branches which have an address. More...
#include <SparseTree.h>
Public Member Functions | |
template<typename T > | |
Int_t | SetBranchAddress (const char *bname, T **add, TBranch **ptr=0) |
Set branch address and enable the branch. More... | |
A tree that reads only branches which have an address.
The standard TTree class reads by default all the branches; not just the ones for which an address has been set; this can impair the I/O performance severely when not every branch is of interest. The TTree::SetBranchStatus member function can be used to disable all the branches and then selectively re-enable only the interesting ones.
This procedure sometimes just doesn't work as expected, since branches are enabled by name, so if a class A has a member named m, and two objects a1 and a2 of class A are written on the file then two split branches named "m" will be present; enabling "m" will then enable both, also if only one among a1.m and a2.m is of interest. The solution of using a trailing dot in the name of the main branches (e.g. "a1." instead of "a1") will result in split branches named "a1.m" and "a2.m", with no name degeneration. This has a couple of minor side effects, like the necessity to also append the trailing dot to the branch name when setting the branch address for readout, and the fact that for branches containing a class like std::vector<int> the trailing dot will be removed from the branch name; in the end, some branches will have a trailing dot and some others not.
The SparseTree class is meant to simplify the readout of just a subset of branches (i.e. a "sparse" readout) from a tree written in a Root file. It disables all the branches and enables only those for which an address is set. Its usage is identical to that of the usual TTree:
In the example above, only the branch mc and its split sub-branches are enabled and effectively read from disk, improving the I/O performance.
Int_t EA::SparseTree::SetBranchAddress | ( | const char * | bname, |
T ** | add, | ||
TBranch ** | ptr = 0 |
||
) |
Set branch address and enable the branch.
This method disables all the branches on first call, and then enables the given branch and all of its sub-branches, recursively. Finally it sets the branch address.
bname | the name of the branch. |
add | the address of the pointer to the buffer object. |
ptr |