Examples: Fitting the muon lifetime

The muon lifetime example configuration file is MuonLifetime.txt. This file defines the fit variable to use, t, as well as the fit model: a 1D fit for a signal and a background component. The signal component type has been set to be an exponential, and the background is a polynomial of order 1. Note that the exponential PDF uses the reciprocal of the constant, so one fits for the lifetime, and the coefficient of the polynomial is fixed to zero (so the background is flat).

The macro used to fit the muon lifetime is MuonLifetime.cc, which in turn uses the data file MuonLifetime.dat. An AFitMaster object is used in order to construct the fit model:

   AFitMaster master("MuonLifetime.txt");
   RooAbsPdf * pdf = master.getPdf();
 

Once the pdf has been obtained, the data file is opened and a RooDataSet is read from this. The data file is a single column ascii file called MuonLifetime.dat. The data are fitted in the normal way using

   pdf->fitTo(data, "etm");
 

so that an extended unbinned maximum likelihood fit is performed. If the fit is successful you should obtain a plot that (see figure) looks like MuonLifetime.eps.

.
Fig 1: Example output of the MuonLifetime.cc macro, showing the exponential decay from muons, on top of a flat background.

This page is maintained by Adrian Bevan.