If one plots a pdf in specific ranges and then makes a pull histogram, only the upper range is included. Reproducer below.
import ROOT as r
ws = r.RooWorkspace("workspace")
x = ws.factory("x[-10, 10]")
x.setRange("lo", -10, -5)
x.setRange("hi", 5, 10)
pdf = ws.factory("Gaussian::pdf(x, m1[0], s1[3])")
ds = pdf.generate(r.RooArgSet(x), 1000)
fr = x.frame()
ds.plotOn(fr)
pdf.plotOn(fr, r.RooFit.Range("lo,hi"))
pull = fr.pullHist()
c = r.TCanvas()
fr2 = x.frame()
fr2.addPlotable(pull, "P")
fr2.Draw()
c.SaveAs("output.pdf")
output.pdf (14.9 KB)
moneta
January 28, 2022, 8:35am
2
Hi,
The problem is that when you have separate range two RooCurve objects represent the pdf in the two range. The RooCurve’s have the same name so you cannot retrieve both of them and only the last one is used for drawing.
I will open a GitHub issue on this
Thank you for reporting this problem.
Lorenzo
moneta
January 28, 2022, 8:40am
3
1 Like
system
Closed
February 11, 2022, 8:41am
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
jonas
September 22, 2022, 11:50pm
5
A PR was opened to fix this problem in ROOT 6.28:
root-project:master
← guitargeek:issue-9741
opened 11:37PM - 22 Sep 22 UTC
When plotting a pdf in 2 separate ranges, 2 RooCurve objects are created with th… e same name . When using pullHist or whatever function of RooPlot accessing the RooCurve by its name, only the last of the two curve can be retrieved. Since RooPlot has no way to access its list of containing objects, apart than given the name, only the RooCurve with the upper range will be used.
Code to reproduce the problem:
```Python
import ROOT as r
ws = r.RooWorkspace("workspace")
x = ws.factory("x[-10, 10]")
x.setRange("lo", -10, -5)
x.setRange("hi", 5, 10)
pdf = ws.factory("Gaussian::pdf(x, m1[0], s1[3])")
ds = pdf.generate(r.RooArgSet(x), 1000)
fr = x.frame()
ds.plotOn(fr)
pdf.plotOn(fr, r.RooFit.Range("lo,hi"))
pull = fr.pullHist()
c = r.TCanvas()
fr2 = x.frame()
fr2.addPlotable(pull, "P")
fr2.Draw()
```
This commit suggests to fix the issue by also considering the ranges of all the other curves that have the same name as the first curve that was found.
Closes #9741.