Bad fit at boundaries for convoluted RooHistPdf

Hi,

I thought I posted it in the beginning, but it seems it didn’t work :frowning: It should be attached to this post, and if not, here is the code anyway:

[code]#!/usr/bin/env python2
import ROOT
ROOT.gROOT.SetBatch()

get shape (used to fit), a simple landau

hShape = ROOT.TH1F(“landau”, “”, 120, 60, 120)
for i in range(10000):
hShape.Fill(ROOT.gRandom.Landau(91, 2.5))

get data, laundau convolutet with a gausian

hData = ROOT.TH1F(“landauGaus”, “”, 120, 60, 120)
for i in range(1000000):
hData.Fill(ROOT.gRandom.Landau(91, 2.5) + ROOT.gRandom.Gaus(0, 3))

x = ROOT.RooRealVar(“x”, “x”, 60, 120)

x.setBins(10000, “cache”)

taken from Problem with a Breit-Wigner convolved with a Crystal-Ball

x.setMin(“cache”, 50.5)
x.setMax(“cache”, 130.5)

data is breit-wigner convoluted with a gaussian, taken from histogram

dhData = ROOT.RooDataHist(“dhSig”, “”, ROOT.RooArgList(x), ROOT.RooFit.Import(hData))

take the background shape from a histogram (this time breit-wigner only)

dhShape = ROOT.RooDataHist(“dhShape”, “”, ROOT.RooArgList(x), ROOT.RooFit.Import(hShape))
pdfShape = ROOT.RooHistPdf(“pdfShape”, “”, ROOT.RooArgSet(x), dhShape, 0)

define gausian to smear background shape

mean = ROOT.RooRealVar(“mean”, “mean”, 0, -5, 5)
width = ROOT.RooRealVar(“width”, “width”, 2, 0, 10)
smearGaus = ROOT.RooGaussian(“smearGaus”, “”, x, mean, width)

smear our background histogram with an gaussian

smearedShape = ROOT.RooFFTConvPdf(“smearedShape”,"", x, pdfShape, smearGaus)

fit the result

smearedShape.fitTo(dhData)

and draw all

frame = x.frame(ROOT.RooFit.Title(" "))
dhData.plotOn(frame)
smearedShape.plotOn(frame)
c = ROOT.TCanvas()
frame.Draw()
ROOT.gPad.SaveAs(“fitExample.pdf”)
ROOT.gPad.SaveAs(“fitExample.png”)
[/code]
fitExample.py (1.54 KB)