lukash
January 13, 2016, 1:29pm
1
How can I set the type of the histogram returned by the method
RooAbsReal->createHistogram() in pyroot?
root.cern.ch/doc/master/classRo … a97333fd38
I would like to create a histogram with double precision (TH1D or TH2D in other cases), but when I call the method, I always get a TH1F only:
from ROOT import RooWorkspace
w = RooWorkspace("w")
x = w.factory("x[0.,10.]")
pdf = w.factory("Gaussian::pdf(x,5.,1.)")
hist = pdf.createHistogram("hist", x)
print type(hist)
Danilo
January 13, 2016, 2:42pm
2
Hi,
can you post a reproducer?
In PyROOT everything seems fine:
import ROOT
code='''
TH1* getTH1F(){return new TH1F();}
TH1* getTH2F(){return new TH2F();}
'''
ROOT.gInterpreter.Declare(code)
h1 = ROOT.getTH1F()
h2 = ROOT.getTH2F()
print type(h1)
print type(h2)
outputs
<class '__main__.TH1F'>
<class '__main__.TH2F'>
as expected.
Cheers,
Danilo
Follow the lapin blanc, get here: https://root.cern.ch/doc/master/RooAbsRealLValue_8h_source.html so all histo is THF. Type is type. Can force cast, but is ask memory issue.
-Dom
Danilo
January 13, 2016, 8:52pm
4
Hi,
Sorry, I misread your post. The answer of dom is appropriate.
Cheers,
Danilo
lukash
January 14, 2016, 10:42am
5
Thanks a lot for the quick answer!
So the return type is a TH1F anyway and the precision will not increase by forcing it to be a double.