Add a new column to TChain

Hello experts,

I am trying to adding a new columns to TChain instances that I want to analyse.
New columns will have a new value from existing value in the instance with specific formula.
I followed introduction to add a new column to existing TTree as explained in the page of TTree class descripttion, but ROOT says: Warning in TChain Fill may not use this method
I don’t want to a temporary measure for the solution such as merging input files so on, but I want to strict solution how to solve such problem in such case that I must add a new column when I am working with TChain.


A TChain is a “readonly” object. You cannot add branches to it.

Hi @Nikel ,
something you can do is reading the TChain and writing out a separate TTree with the new branch. You can then add the new TTree as a friend of the TChain in order to “paste” them together horizontally (see e.g. the documentation of AddFriend).


1 Like

That’s exactly what I want!! Very thanks for your answer and solution!!!

That is precisely what I am looking for!! Thank you so much for responding and providing a solution.

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