Load one special tree from TChain

Dear experts,

I have a question referring TChains. I have two different TChains (TChain1 and TChain2). I loop over the entries in the first chain (TChain1). What I want to do now is to load the same tree the second TChain (TChain2).

What I did so far is to load the entry in the first TChain:


Then I got the number of the tree in this TChain:

n = TChain1.GetTreeNumber()

What I want to do now, is to load the n-th TTree from TChain2. How can I do this if I only know the number of the Tree in the TChain1?

Thanks a lot in advance,


Did you try making the 2 chains friends?

Hi, thanks for your advice. I tried to make them friends but it still does not work as I want.
My problem is the following:
I have to match events with each other:
I have a chain containing files 1, 2, 3, … and a second chain containing the corresponding files 1, 2, 3,… as well. The files in the different chains have different number of entries.

Chain 1, file 1 includes a variable that tells at which position of Chain 2, file 1 the corresponding event is:
So I just do:
n = chain1.variable

My problem is that if the loop reaches the second file in chain 1 (file 2), chain.GetEntry(n) still gives the nth entry of file 1 in chain2, but I want to get something like chain2.GetEntry(n + number of entries in file1).

I hope, I could point out what I want to do. It would be great, if someone has an idea how I can solve this.

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