Please read tips for efficient and successful posting and posting code
ROOT Version: 6.18/04
Platform: Centos7
Compiler: gcc 8.3.0
I have two different types of ROOT files, according to the data they contain - let’s call them A
and B
. Specifically, they both contain a TTree with the same name and the same branches, except for one special branch called var_A
or var_B
depending on the input file.
I am currently retrieving this branch in a way that is consistent for any input as:
type var_global;
...
tree->SetBranchStatus("var_*",1);
TBranch* brA = (TBranch*)tree->GetListOfBranches()->FindObject("var_A");
TBranch* brB = (TBranch*)tree->GetListOfBranches()->FindObject("var_B");
if (brA) tree->SetBranchAddress("var_A",&var_global);
else if (brB) tree->SetBranchAddress("var_B",&var_global);
What if var_A
in file A
is no longer one branch, but two branches var_A1
and var_A2
? With TTree::Draw
I can set up an alias
if (brA) tree->SetAlias("var_global", "(var_A1||var_A2)");
Is there a way to do something similar to an alias when looping over the tree and retrieving these branches with TTree::GetEntry
?