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

[DF] Cannot analyze friend trees in subdirectories with MT

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 6.16/00
    • Fix Version/s: 6.24/00, 6.22/04
    • Component/s: RDataFrame
    • Labels:
      None
    • Environment:

      x86_64-centos7-gcc48

      Description

      As reported in the forum (https://root-forum.cern.ch/t/rdf-friend-tree-in-subdirectory-of-file-mt-not-working/34219) processing a tree with a friend tree in a subdirectory of a root file with the RDataFrame does not work with Implicit MT enabled (without everything is fine).

      This is a reproducer which results in a seg fault when the event loop is triggered:

       

      #include <TROOT.h>
      #include <ROOT/RDataFrame.hxx>
      #include <ROOT/RVec.hxx>
      #include <TNtuple.h>
      #include <TFile.h>
      void create_file()
      {
         // Setting up trees
         auto f = TFile::Open("myfile.root", "RECREATE");
         TNtuple* t = new TNtuple("main", "", "val");
         TNtuple* tf = new TNtuple("friend", "", "val2");
         const auto vals = {1, 2, 3, 4, 5}; 
         for (const auto& val : vals)
         {   
            t->Fill(val);
            tf->Fill(-val);
         }   
         auto dir = f->mkdir("main");
         dir->cd();
         t->Write();
         f->cd();
         auto dir2 = f->mkdir("friend");
         dir2->cd();
         tf->Write();
         f->Close();
      }
      void analyze()
      {
         // Read file
         auto f = TFile::Open("myfile.root", "READ");
         TTree* t = (TTree*) f->Get("main/main");
         TTree* tf = (TTree*) f->Get("friend/friend");   // Add friend
         t->AddFriend(tf, "friend");
         auto df = ROOT::RDataFrame(*t);   // Trigger event loop
         std::cout << *df.Count() << std::endl;
      }
      int main()
      {
         ROOT::EnableImplicitMT();
         create_file();
         analyze();
      }
      

       

        Attachments

          Activity

            People

            Assignee:
            eguiraud Enrico Guiraud
            Reporter:
            joroemer Jonas Till Roemer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: