# Fit range and chiSquare

I’m fitting to a sub-range of a histogram. Do I need to tell chiSquare what sub-range I’m using?

This is what I’m doing now:`Double_t chi2 = framex->chiSquare("curvetot","Hist",floatpars);`The PDF is “curvetot” and the data is “Hist”, with a number of non-constant parameters = “floatpars”.

More detail, for reference:

```RooRealVar *mass = new RooRealVar("mass","m(#Lambda_{b})",5619.51,"MeV"); RooDataHist *data = new RooDataHist("data","1D",RooArgList(*mass),h100); ... RooAbsReal * nll = totalPdf.createNLL(*data,Extended(kTRUE),Range(4300,5950)); ... RooPlot *framex = mass->frame(); data->plotOn(framex,Name("Hist"),MarkerColor(kBlack),LineColor(kBlack),DataError(RooAbsData::SumW2)); totalPdf.plotOn(framex,Name("curvetot"),LineColor(kBlue)); ... RooArgSet *floatpar = totalPdf.getParameters(data); int floatpars = (floatpar->selectByAttrib("Constant",kFALSE))->getSize(); Double_t chi2 = framex->chiSquare("curvetot","Hist",floatpars);```

Hi,

You don’t need to specify the range in the RooPlot::chisquare function. The range of the plotted curve is used when computing the chi square.
You can look also on how it is implemented in the code :
root.cern.ch/doc/master/RooCurv … tml#l00546

Lorenzo