Convoluted Landau(-x) in RooFit

Hi all,

I’m trying to fit a histogram with a convoluted Landau+gaussian function in RooFit. This works well, as long as the landau has its tail on the right side, whereas it fails whenever the landau has the tail on the left had side.

I need this functionality, because i’m trying to fit the distribution of positive and negative electrical signals. One workaround is to just mirror the histogram around 0, but I’m quite sure that there’s a smarter way in RooFit.

I’d be very happy for any help or feedback.
Thanks,
-marc

Here’s my code:

import ROOT
from ROOT import RooFit, RooRealVar, RooGaussian, RooLandau, RooDataSet, RooArgList, RooTreeData, RooFFTConvPdf, RooDataHist, RooWorkspace



rand = ROOT.TRandom(42)

hist = ROOT.TH1F('foo', 'bar', 500, -250., 250.)

func = ROOT.TF1('my_landau','[0] * TMath::Landau(-x,[1],[2])', hist.GetXaxis().GetXmin(), hist.GetXaxis().GetXmax())
func.SetParameters(1, -120., 15. )

hist.FillRandom('my_landau', 15000)

x   = RooRealVar('x', 'x', hist.GetXaxis().GetXmin(), hist.GetXaxis().GetXmax())
ral = RooArgList(x)
dh  = RooDataHist('dh', 'dh', ral, RooFit.Import(hist))



ml     = RooRealVar('ml', 'mean landau' , hist.GetMean(), hist.GetXaxis().GetXmin(),  hist.GetXaxis().GetXmax())
sl     = RooRealVar('sl', 'sigma landau', 10., -30., 30.)
landau = RooLandau ('lx', 'lx', x, ml, sl)

mg     = RooRealVar ('mg', 'mean gaus' , hist.GetMean(), hist.GetXaxis().GetXmin(),  hist.GetXaxis().GetXmax())
sg     = RooRealVar ('sg', 'sigma gaus', 10., -30., 30.)
gaus   = RooGaussian('gx', 'gx', x, mg, sg)

x.setBins(hist.GetNbinsX(),'cache')

## Construct landau (x) gauss
lxg = RooFFTConvPdf('lxg','landau (x) gaus', x, landau, gaus)
a = lxg.fitTo(dh)

frame = x.frame(RooFit.Title('landau (x) gauss convolution'))
dh.plotOn(frame)
lxg.plotOn(frame)

c = ROOT.TCanvas('lg_convolution','landau (x) gaus', 600, 600)
ROOT.gPad.SetLeftMargin(0.15)
frame.GetYaxis().SetTitleOffset(1.4)
frame.Draw()

Any one an idea?