Divide of 2D histograms created by RDataFrame

Hi all,

I am trying to divide two 2D histograms created by RDataFrame, but it returns an error.
Small reproducible:

import ROOT

rdf = ROOT.RDataFrame(10)
rdf = rdf.Define("x", "rdfentry_").Define("y", "rdfentry_")

h1 = rdf.Histo2D(("h1", "title;x;y", 10, 0, 10, 10, 0, 10), "x", "y")
h2 = rdf.Histo2D(("h2", "title;x;y", 10, 0, 10, 10, 0, 10), "x", "y")
h1.Divide(h2)

output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: none of the 3 overloaded methods succeeded. Full details:
  bool TH1::Divide(const TH1* h1) =>
    TypeError: could not convert argument 1
  bool TH1::Divide(TF1* f1, double c1 = 1) =>
    TypeError: could not convert argument 1
  bool TH1::Divide(const TH1* h1, const TH1* h2, double c1 = 1, double c2 = 1, const char* option = "") =>
    TypeError: takes at least 2 arguments (1 given)

While simply:

>>> h1 = ROOT.TH2F("h1", "title;x;y", 10, 0, 10, 10,0, 10)
>>> h2 = ROOT.TH2F("h2", "title;x;y", 10, 0, 10, 10,0, 10)
>>> h1.Divide(h2)
True

Any thoughts?

cheers,
Bohdan

I usually do this using .GetPtr() on the histos returned directly from a RDF RResultPtr

h1.Divide(h2.GetPtr()) should work I think.

1 Like

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