Hello everyone,
I’m using RooFit in order to fit a distribution and find a parameter.
The data are from a TTree called “data” and it has a branch called “costheta”.
I wrote this code
using namespace std;
using namespace RooFit;
void fit()
{
TFile *input = new TFile("cosine.root");
TTree *cos = (TTree*)input->Get("data");
RooRealVar x("x","x",-1.,1.);
RooRealVar c("c","c",0.375);
RooRealVar na("na","na",1500,500,4000);
RooGenericPdf std("std","c*(1+x**2)",RooArgList(c,x));
RooRealVar a("a","a",0,-1.,1.);
RooRealVar nb("nb","nb",1500,500,4000);
RooGenericPdf asy("asy","a*x",RooArgList(a,x));
RooAddPdf p("p","p",RooArgList(std,asy),RooArgList(na,nb));
RooDataSet xdata("xdata","dataset in costheta", cos,x);
RooFitResult *result = p.fitTo(xdata);
RooPlot* xframe = x.frame();
xdata.plotOn(xframe) ;
p.plotOn(xframe);
xframe->Draw();
}
when i plot the RooDataSet xdata i get something completely wrong, i can’t understand why…obviously, the fit is not correct…i thought about a syntax error but it seems it is not the case…
Thanks in advance for help