Adding a TBranch to a TChain

Hello,

I want to add a TBranch to a TChain. I am trying to use the Branch routine that I use flawlessly on TTrees, filling the branch with Fill(). Everything seems to work, but when trying to access this branch, I get a segmentation fault.

I was not able to find such an example with a TChain. Is it possible to do it? Using which routines?

Many thanks,
Best,
Alex

Hi Alex,

For all intent and purposes TChain is designed for reading TTree (and what you are trying is not implemented). To add a branch, you will need to add it explicitly to each underlying TTree (which you can reached from chain->GetTree() … you can monitor the change over to a new TTree by checking the value of chain->GetTreeNumber()).

Cheers,
Philippe

Thanks Philippe,

I have had a try without success. I don’t understand how to change the ttree separately first, and access the new branch in the tchain afterwards. Do you have examples?

Thanks again,
Alex