TChain with friends and GetListOfBranches

So I have a TChain, to which I have friended another TChain. Something like this;

TChain *primary = new TChain("Primary");
primary->AddFile("/Path/To/Primary.root", -1, "CollectionTree");
TChain *friend = new TChain("Friend"); 
friend->AddFile("/Path/To/Friend.root", -1, "FriendCollectionTree"); // This here contains a branch called "FriendOnly"

I can confirm that the primary chain now has access to that “FriendOnly” branch;

UInt_t friendOnlyData;
primary->SetBranchAddress("FriendOnly", &friendOnlyData);
for ( int i =0; i < 3; i++){
  cout << friendOnlyData << "\n";

and I’m seeing the expected data. But the list returned by GetListOfBranches doesn’t reflect that;

ofstream out("list_of_branches.txt");
for (auto branch : *primary->GetListOfBranches()){
  std::string name = branch->GetName();
  out << name << "\n";

I won’t find “FriendOnly” in “list_of_branches.txt”.

I’m hunting for a complete list of branches available from the chain, including those supplied by friend trees. Ultimately I will need their names and contained data types to create a custom RDataSource, but I think know how to get data types once I have names.

Currently, I’m thinking that the only option is to loop over the friend trees, and for each friend tree loop over their branches. Is that accurate, or is there a way to get all the branches available to a TChain without directly looping over the friends?

ROOT Version: 6.24/06
Platform: NAME=“CentOS Linux” VERSION=“7 (Core)” ID_LIKE=“rhel fedora” CLUSTER=“sunrise”
Compiler: using macros at the root prompt.

I guess @pcanal can help you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.