I tried fitting a histogram: A peak with an exponential background; using roofit.
I defined two sub-ranges (excluding the peak region) and fitted the histogram. Following is the code:
(h1 is the pointer to my histogram)
RooRealVar x("x","mass",18,500); x.setRange("Range1",20.,52.3) ; x.setRange("Range2",106.9,500.) ; RooRealVar lambda("lambda", "slope", 0.01, -1., 1.); RooExponential expo("expo", "expo", x, lambda); RooDataHist dh("dh","dh",x,Import(*h1)) ; RooFitResult* r = expo.fitTo(dh,Range("Range1,Range2")) ; RooPlot* frame = new RooPlot() ; dh.plotOn(frame); expo.plotOn(frame);
But the plot is not showing. I am unsure whether the fit is accurate or not.
I saved it in a file and can see it using TBrowser. But I want it to show up when I run the script.