ROOT Version: 6.41.01
Platform: Linux (Fedora 44)
Compiler: g++ (GCC) 16.1.1 20260515 (Red Hat 16.1.1-2)
Hi…
Could someone kindly teach me why the python script below
- works with
withHist = True, and - works with
withHist = Falseandngraphs = 1, but - SEGs with
withHist = Falseandngraphslarger than 1 (w/o doingROOT.SetOwnership()?
The last case works when uncommenting the ROOT.SetOwnership(g, False) line.
Thanks in advance.
Kazuyoshi
import ROOT
from ROOT import TFile, TObjArray, TGraphErrors, TH1F
withHist = True
print("withHist = ", withHist)
fout = TFile(“nge.root”, “recreate”)
histos = TObjArray()
npoints = 10
ngraphs = 5
xtitle = “the x title”
ytitle = “the y title”
for idx in range(ngraphs):
gname = “g%d” % (idx)
gtitle = “the title of %s” % (gname)
print("gtitle = ",gtitle)
if not withHist:
g = TGraphErrors(npoints)
# ROOT.SetOwnership(g, False)
g.SetNameTitle(gname, “%s;%s;%s” % (gtitle,xtitle,ytitle))
else:
g = TH1F(gname,gname,npoints,0.,npoints)
histos.Add(g)
print("#items: ", histos.GetEntries())
histos.Write()
fout.Close()