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

Ownership of TTree is shared between RooFit and file after writing a RooDataSet

    XMLWordPrintable

    Details

      Description

      import ROOT
       
      ws = ROOT.RooWorkspace('ws')  # workspace to store fit results, etc.
       
      x = ROOT.RooRealVar('x', 'x', 0)  # generate some data in this dimension later
       
      fs = ROOT.TFile('store.root', 'RECREATE')
      ROOT.RooAbsData.setDefaultStorageType(ROOT.RooAbsData.Tree)  # use Tree-backed data store
       
      data = ROOT.RooDataSet('data', 'data', ROOT.RooArgSet(x))
      for v in range(1000):  # fill dataset with very meaningful data
          x.setVal(v)
          data.add(ROOT.RooArgSet(x))
       
      getattr(ws, 'import')(data)  # add dataset to workspace
                                   # `import` is a python keyword, need to use `getattr`
       
      ws.Print('v')  # check that everything looks as expected
       
      wf = ROOT.TFile('ws.root', 'RECREATE')  # save workspace to this file
      ws.Write()
      wf.Close()  # this seems to be part of the problem
       
      # when leaving wf opened and deleting `ws` and `data`, there is no segfault
      # del ws, data 
       
      print('Done!')  # the segfault appears after this line
      

        Attachments

          Activity

            People

            • Assignee:
              shageboe Stephan Hageboeck
              Reporter:
              shageboe Stephan Hageboeck
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: