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

Error retrieving the size of an std::vector read from a TTree

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • High
    • Resolution: Fixed
    • 6.12/06, 6.16/00
    • 6.22/00
    • PyROOT
    • SLC6, x86_64, GCC 6.2, Python 3.6.3.

      Reported also on MacOs.

    Description

      The following code prints an invalid size for an std::vector that is read from a TTree, when doing it with TTree::SetBranchAddress and TTree::GetEntry. The same reading via the pythonic iterator of TTree does not have the issue.

      import ROOTmyFile = ROOT.TFile("testTreeForError.root")
      tree = myFile.Get("treeName")pt = ROOT.std.vector('float')()
      tree.SetBranchStatus('pt',1)
      tree.SetBranchAddress('pt',pt)
      tree.GetEntry(0)
      print("Using SetBranchAddress")
      print("Object:", pt)
      print("Size:", pt.size())
      print("First Pt:", pt.at(0))print("Using tree loop")
      for ev in tree:
        print("Object:", ev.pt)
        print("Size:", ev.pt.size())
        print("First Pt:", ev.pt.at(0))
      exit(1)
      

       Seems to be a Python3-related issue, since the same code with Python2 works fine.

      Attachments

        Activity

          People

            etejedor Enric Tejedor Saavedra
            etejedor Enric Tejedor Saavedra
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: