Hi,
I try to use polynomial and breit-wigner function to fit a curve where background follows polynomial and the peak follows breit-wigner. But when I try to fit I only get a horizontal line which is much higher than data’s curve. I don’t know what’s wrong with my code. Here’s the code about fitting and the attachment is the data I use.
Thanks,
Zhaozhou
RooRealVar mass_peak("m0","m0",60,120);
RooRealVar width("width","width",0,100);
RooRealVar a0("a0","",0,1000);
RooRealVar x("x","",40,140);
x.setBins(1000);
RooPolyVar pol5("pol5","",x,RooArgList(a0));//construct a polynomial
RooRealVar coe_bw("coe_bw","",1);
RooRealVar coe_pol("coe_pol","",1);
RooBreitWigner bw("bw","Breit-Wigner function fit",x,mass_peak,width);//construct a Breit-Wigner function
RooDataHist *mass_data=new RooDataHist("Zmass","Z boson's mass",x,invmass_mmp);//convert data to roodatahist
RooPlot *plot_frame=x.frame(RooFit::Title("signal invariant mass of muon+ muon- and photon"),RooFit::Bins(1000));
RooAddPdf bwandpol("bwandpol","",RooArgList(bw,pol5),RooArgList(coe_bw,coe_pol));//construct function include background and peak
bwandpol.fitTo(*mass_data);//fit the curve
MCinvmass2E7.root (4.77 KB)