PyROOT Exercise 2: Graphs and Fits

Exercise

Write a python macro ExerciseGraph.py.

  1. Create a graph with symmetric errors and 5 points.
  2. Set the following points: (1.0, 2.1), (2.0, 2.9), (3.0, 4.05), (4.0, 5.2), (5.0, 5.95)
  3. Set the errors on x to 0.0 and the errors on y to 0.1 (all at once).
  4. Draw the graph including the axes and error bars.
  5. Create a one dimensional function f(x) = ax + b and fit it to the graph.

Bonus questions:

  1. Programatically obtain the two parameters a and b and their estimated uncertainties.

Solution