Physics 564 - Introductory Particle Physics


Using the Minuit minimization class

A very common problem encountered in the analysis of particle physics data is the need to find the minimum of a function of several variables. This has broad applications but is primarily used to determine the values for parameters in a model that provide an optimal description of a set of measurements. The TMinuit class in ROOT provides a way to do this numerically, using an algorithm that has been developed over the past 40 years.

Getting the examples

First, if you have not already done so, create a directory in which to store your work:
jones105@amdahl:~$ mkdir phys564
jones105@amdahl:~$ cd phys564
Next, copy the examples from my directory into yours:
jones105@amdahl:~/phys564$ cp -r ~jones105/phys564/examples .
jones105@amdahl:~/phys564$ cd examples
jones105@amdahl:~/phys564/examples$ ls -l
total 613
-rw-r--r--  1 jones105 phys   1018 Sep  1 10:20 DrawHistograms.C
-rw-r--r--  1 jones105 phys    699 Sep  1 09:54 DrawRandom.C
-rw-r--r--  1 jones105 phys    464 Oct 11 22:26 Makefile
-rwxr-xr-x  1 jones105 phys 137150 Oct 11 22:05 baryons
-rw-r--r--  1 jones105 phys   1997 Oct 11 16:15 baryons.cc
-rwxr-xr-x  1 jones105 phys 138751 Sep  1 10:08 histograms
-rw-r--r--  1 jones105 phys   2375 Sep  1 09:48 histograms.cc
-rwxr-xr-x  1 jones105 phys 133897 Oct 11 22:27 minuit
-rw-r--r--  1 jones105 phys    459 Oct 11 22:27 minuit.cc
-rwxr-xr-x  1 jones105 phys 136635 Sep  1 10:08 random
-rw-r--r--  1 jones105 phys   1452 Sep  1 09:47 random.cc
-rw-r--r--  1 jones105 phys   4871 Sep  1 10:25 random.gif
-rw-r--r--  1 jones105 phys  20802 Sep  1 10:25 random.ps
jones105@amdahl:~/phys564/examples$

Compiling the examples

The file called Makefile contains the instructions for compiling minuit.cc. To compile it, just do this:
jones105@amdahl:~/phys564/examples$ rm minuit
jones105@amdahl:~/phys564/examples$ make minuit
g++ -g -o minuit minuit.cc `root-config --cflags` `root-config --libs` -lMinuit

Minuit in more detail


#include "TMinuit.h"       //  Needed to declare the TMinuit class
...

//
//  The fcn function is called by Minuit with parameters passed in the
//  array par[].  fcn must store the calculated value of the function to
//  be minimized in f.  npar, gin and iflag can be ignored for now.  More
//  details can be found on the TMinuit class description.
//
void fcn(int &npar,double *gin,double &f,double *par,int iflag) {
  double a = par[0];
  double b = par[1];
  f = (a-4)*(a-4) + (b-2)*(b-2);    // This function has a minimum at a=4,b=2
}
...

TMinuit *min = new TMinuit(4);   //  New minimization class for up to 4 variables
min->SetFCN(fcn);                //  Tell Minuit about the function (above)
int ierr;                        //  Needed if you want to check for errors
min->mnparm(0,"first",value,step,min,max,ierr);
min->mnparm(1,"second",value,step,min,max,ierr);
min->Migrad();                   //  This invokes the default minimization algorithm.
...

The mnparm methods define new parameters. The first argument numbers them starting from zero. The second argument gives the parameter a name that you can recognize in the printout that Minuit generates. The other parameters are: When you run this program it produces the following output:
jones105@amdahl:~/phys564/examples$ ./minuit
 PARAMETER DEFINITIONS:
    NO.   NAME         VALUE      STEP SIZE      LIMITS
     1 a            0.00000e+00  1.00000e+00     no limits
     2 b            0.00000e+00  1.00000e+00     no limits
 **********
 **    1 **MIGRAD
 **********
 FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.
 START MIGRAD MINIMIZATION.  STRATEGY  1.  CONVERGENCE WHEN EDM .LT. 1.00e-04
 FCN=20 FROM MIGRAD    STATUS=INITIATE        8 CALLS           9 TOTAL
                     EDM= unknown      STRATEGY= 1      NO ERROR MATRIX
  EXT PARAMETER               CURRENT GUESS       STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  a            0.00000e+00   1.00000e+00   1.00000e+00  -8.00000e+00
   2  b            0.00000e+00   1.00000e+00   1.00000e+00  -4.00000e+00
 MIGRAD MINIMIZATION HAS CONVERGED.
 MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
 COVARIANCE MATRIX CALCULATED SUCCESSFULLY
 FCN=3.82627e-21 FROM MIGRAD    STATUS=CONVERGED      23 CALLS          24 TOTAL
                     EDM=7.65254e-21    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                   STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  a            4.00000e+00   1.00000e-00   4.88281e-04  -1.23404e-10
   2  b            2.00000e+00   1.00000e+00   4.88281e-04   8.75544e-12
 EXTERNAL ERROR MATRIX.    NDIM=  25    NPAR=  2    ERR DEF=1
  1.000e-00  2.483e-17
  2.483e-17  1.000e+00
 PARAMETER  CORRELATION COEFFICIENTS
       NO.  GLOBAL      1      2
        1  0.00000   1.000  0.000
        2  0.00000   0.000  1.000
All of this output is meaningful, although you may not appreciate it yet.

Fitting Baryon Masses

The other example shows how the parameters in a model for the baryon masses can be determined by minimizing the sum of the squares of the deviations of the measured and predicted baryon masses. You should copy the baryons.cc program, compile and link it using the Makefile provided and modify it to include the additional baryons described in the assignment.