Hi, rooters,

I am fittting my samples(see attachment XePaix.txt) with polynomial 10.

Here is my code:

```
/// \file
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooDataHist.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "RooPlot.h"
#include "TTree.h"
#include "TH1D.h"
#include "TRandom.h"
using namespace RooFit;
void rf_mathematical_integral()
{
RooRealVar x("x", "x", 0,0.12);
RooRealVar weight("weight", "weight", 0, 4e-5);
RooDataSet *data = RooDataSet::read("XePaix.txt",RooArgList(x,weight));
// create a weighted data
RooDataSet wdata(data->GetName(),data->GetTitle(),data,*data->get(),0,weight.GetName());
//pdf is pol6
RooRealVar poly_c1("poly_c1", "coefficient of x^1 term", 3.52922e-06);
RooRealVar poly_c2("poly_c2", "coefficient of x^2 term", 0.0168763,-1,1);
RooRealVar poly_c3("poly_c3", "coefficient of x^3 term", 0.193026,0,1);
RooRealVar poly_c4("poly_c4", "coefficient of x^4 term", -15.7153,-18,-14);
RooRealVar poly_c5("poly_c5", "coefficient of x^5 term", 674.883);
RooRealVar poly_c6("poly_c6", "coefficient of x^6 term", -18735.3);
RooRealVar poly_c7("poly_c7", "coefficient of x^7 term", 280024);
RooRealVar poly_c8("poly_c8", "coefficient of x^8 term", -2.26168e+06);
RooRealVar poly_c9("poly_c9", "coefficient of x^9 term", 9.43141e+06);
RooRealVar poly_c10("poly_c10", "coefficient of x^10 term", -1.60257e+07);
RooPolynomial poly("poly", "poly", x, RooArgList(poly_c1,poly_c2,poly_c3,poly_c4,poly_c5,poly_c6,poly_c7,poly_c8,poly_c9,poly_c10),0);
poly.fitTo(wdata, Range(0, 0.12), Extended(kTRUE));
//poly.fitTo(wdata,SumW2Error(kTRUE));
TCanvas *c = new TCanvas("rf102", "rf102", 800, 400);
RooPlot* xframe = x.frame();
wdata.plotOn(xframe);
poly.plotOn(xframe);
poly.paramOn(xframe,Layout(0.67,0.95,0.98));
xframe->Draw();
}
```

The fit result is:

I guess the **[RooArgList::RooArgList](const RooArgSet & set )** is less than 8. But my set is 10.

But I don’t know how to write my code with **agrList.add().**

Looking forward to your reply.

Best regards,

hurricane

XePaix.txt (3.9 KB)