ROOT Version: 6.13/02 Platform: Not Provided Compiler: Not Provided
I have 4 files file0.root, file1.root ,file2.root and friendfile.root. They all have a single TTree inside. file0, file1 and file2 has identical tree structure and each of them have 200 entries. The tree in friendfile.root has different branches and is supposed to be added as friend, which has 400 entries. I found that TTreeReader won’t read pass entry 200 of friendfile.root. Here’s a demonstration:
TChain chain("maintree");
chain.Add("file*.root");
TChain friend_chain("maintree");
friend_chain.Add("friendfile.root");
chain.AddFriend(&friend_chain);
TTreeReader reader(&chain);
// The branch "EventID" comes from the tree in friendfile.root
// It contains the index of each event and should be identical to what you supplied with SetEntry(i)
TTreeReaderValue<int> idx(reader, "EventID");
reader.GetEntry(10);
cout << *idx << endl; // this show 10 correctly
reader.GetEntry(201);
cout << *idx << endl; // but this shows 1 instead of 201??
This seems to be a problem unique to TTreeReader. I tried SetBranchAddress and it reads my friendfile correctly.
Please see if anything is wrong with my code and possible ways to solve it. Thanks for all your help.
Yes it’s supposed to be SetEntry(201); Thanks for looking into it. Meanwhile if there’s any workaround that allows me to keep using TTreeReader please let me know. I can rewrite my script to use SetBranchAddress instead but it will not be as simple.
Sorry - I cannot reproduce this (my initial test was broken). Would you have a reproducer for me? E.g. by sending the input files to me?
Maybe you could check the attached non-reproducing reproducer at https://sft.its.cern.ch/jira/browse/ROOT-9886 to see how it differs from your case, i.e. if I misunderstood something?