Fitting Histograms and plotting the result

Description

Python program

Click to retrieve the Python script of the example.

After having setup correctly your environment, you can run the example typing :
python -i fitHisto.py

Program flow

  1. The Python module AidaProxy is imported. This module loads the dictionary for the PI classes, making them available in the Python environment in the global namespace.
  2. One histogram is filled with a random distribution composed by two gaussian, a narrow one representing a signal and a wide one, representing the background.
  3. The histogram is fitted, using the AIDA fit interface. First a single gaussian fit is performed. The sequence of fitting is the following:
  4. A double gaussian fit is performed, after having created a new function "G+G"
  5. A Maximum binned likelihood fit is performed using the same double gaussian function. The fit method is changed using the setFitMethod("PoissonML") of the Fitter interface.
  6. The histogram is viewed in a ROOT canvas together with the three fitted functions. In red the Gaussian resulting from the first Chi2 fit, in green the double gaussian resulting from the Chi2 fit and in blue the double Gaussian resulting from the Maximum Likelihood fit.

    To plot in ROOT the module rootPlotter2.py is used. There the histograms and functions of AIDA are converted in ROOT objects. The dictionary to the ROOT classes using PyLCGDict (SealRootDict) is used .

  7. The histogram and the fitted functions are also plotted in HippoDraw.