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");