Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9319

[TTreeReader] main tree branch instead of friend tree branch accessed when branches have the same name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: master
    • Fix Version/s: 6.14/00, 6.16/00
    • Component/s: None
    • Labels:
      None
    • Environment:

      any

      Description

      Given two TTrees "t1" and "t2", with t1.AddFriend(t2, "friend"), trying to read "friend.x" silently reads "x" instead.

      This mismatch is only present if main tree has a branch that is called like the friend branch we are trying to read.
      Reading "friend.y" where "y" is not present in the main tree does the correct thing.

      Reproducer:

      #include <TFile.h>
      #include <TTree.h>
      #include <TTreeReader.h>
      #include <TTreeReaderValue.h>
       
      int main()
      {
         int x;
         TTree t1("t1", "t1");
         t1.Branch("x", &x);
         x = -1;
         t1.Fill();
       
         TTree t2("t2", "t2");
         t2.Branch("x", &x);
         x = 42;
         t2.Fill();
       
         t1.AddFriend(&t2, "friend");
         
         TTreeReader r(&t1);
         TTreeReaderValue<int> ra(r, "friend.x");
         r.Next();
         assert(*ra == 42);
       
         return 0;
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              axel Axel Naumann
              Reporter:
              eguiraud Enrico Guiraud
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: