Exercise 4: Displaying fit parameters (10 minutes)

Fit the ebeam histogram to a gaussian distribution.

Note

OK, that part was easy. It was particularly easy because the “gaus” function is built into ROOT, so you don’t have to worry about a user-defined function.

Let’s make it a bit harder: the parameters from the fit are displayed in the ROOT text window; your task is to put them on the histogram as well. You want to see the parameter names, the values of the parameters, and the errors on the parameters as part of the plot.

Note

This is trickier, because you have to hunt for the answer on the ROOT web site… and when you see the answer, you may be tempted to change it instead of typing in exactly what’s on the web site.

Take a look at the description of the TH1::Draw() method. In that description, it says “See THistPainter::Paint for a description of all the drawing options.” Click on the word THistPainter. There’s lots of interesting stuff here, but for now focus on the section “Fit Statistics.” (This is a repeat of how I found the “surf1” option in Exercise 1.)

There was another way to figure this out, and maybe you tried it: Draw a histogram, select Options->Fit Parameters, fit a function to the histogram, save it as c1.C, and look at the file. OK, the command is there, mingled with the TPaveStats options… but would you have been able to guess which one it was if you hadn’t looked it up on the web site?