You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Now that we have learned how to create functions and to configure the fitter we are ready to start fitting. The following code shows how to perform a simple chi squared fit to a one dimensional histogram:

// The AIDA Factories
IAnalysisFactory af = IAnalysisFactory.create();
ITree = af.createTreeFactory().create();
IFunctionFactory ff = af.createFunctionFactory(tree);
IFitter fitter = af.createFitFactory().createFitter("chi2");

// Fit a gaussian to a given histogram h1
IFitResult result = fitter.fit(h1,"g");

Cloning When Fitting

When a function is provided to the fitter the user has to be aware that the AIDA prescription is to leave the input function unchanged, create a clone, perfom the fit on the clone and return the clone in the fit result. There are two advantages to this approach,

Fit Result

The outcome of a fit is an IFitResult. It contains the fitted function (see Cloning When Fitting), the error on the parameters, the covariance matrix etc.

  • No labels