Histo1d returning PyROOT_NoneType in python

Although the other rdataframe functionality works fine for me with pyroot, histogramming with Histo1d is not. If I call Histo1d on the rdataframe it returns a RResultPtr that has a value of None. Here is an example code,

    rdf = ROOT.RDataFrame(m_tree_name, in_file)
    
    print "The rdf contains: "
    print rdf
    
    print "The histo is: "
    print rdf.Histo1D("hcand_boosted_n")
    
    print "The value is: "
    print rdf.Histo1D("hcand_boosted_n").GetValue()

that returns the following,

    The rdf contains: 
    <ROOT.ROOT::RDataFrame object at 0x520d4f0> 
    The histo is: 
    <ROOT.ROOT::RDF::RResultPtr<TH1D> object at 0x3df9580>
    The value is: 
    None

Note that I have been using the framework with filters, defines, etc without problem for a while. Also this branch “hcand_boosted_n” definitely exists, and is something like TTreeReaderValue<Int_t> hcand_boosted_n.


ROOT Version: 6.14
Python: 3.6
Platform: Manjaro
Compiler: Not Provided


Hi @dabbott

Actually you do not need to call GetValue on your histogram.
If you do:

rdf = ROOT.RDataFrame(m_tree_name, in_file)

h = rdf.Histo1D( "hcand_boosted_n")

c = ROOT.TCanvas()
h.Draw()

And now you run that script with python -i (notice the -i that will keep the interpreter alive and thus the canvas), it should draw correctly your histogram.
What you get back from rdf.Histo1D is some proxy that behaves like a histogram.

Enric

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.