Divide histograms:Cannot divide histograms with different number of bins

Dear expert,

I want to divide 2 histograms defined as follow:

df=ROOT.DataFrame(ch)
p={"1":array('d',[740, 961, 1249, 1622, 2107, 2737, 3556, 4619, 6000,8000]))
nbins=len(p["1"])-1
h_frac=ROOT.TH1F("h","",bins,p["1"])
h_nom=df.Filter(sel_1).Histo1D(ROOT.ROOT.RDF.TH1DModel("h_nom","",nbins,p["1"]),branch)
h_denom=df.Filter(sel_2).Histo1D(ROOT.ROOT.RDF.TH1DModel("h_denom","",nbins,p["1"]),branch)
h_frac.Divide(h_nom.GetPtr(),h_denom.GetPtr(),1.,1.,"B")

when I do

print("h_nom bins=", h_nom.GetNbinsX())
print("h_denom bins=", h_denom.GetNbinsX())

I get 9 in both cases

but I am getting this error

Error in TH1F::Divide: Cannot divide histograms with different number of bins

is there anything I can do here ?

Sara

Maybe: h_frac = ROOT.TH1D("h", "", nbins, p["1"])

Thanks Wile for pointing that out I corrected it and I had a typo in my code as well.

I ll be more careful next time

Cheers

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