Exercise 10: Write histograms to a file
In all the analysis macros we’ve worked with, we’ve drawn any plots in
Terminate method. Pick one of your analysis macros that creates
histograms, and revise it so that it does not draw the histograms on the
screen, but writes them to a file instead. Make sure that you don’t try
to write the histograms to
experiment.root; write them to a different
analysis.root. When you’re done, open
ROOT and check that your plots are what you expect.
In Saving your work, part 2, I described all the commands you’re likely to need.
Don’t forget to use the ROOT web site as a reference. Here’s a question that’s also a bit of a hint: What would be the difference between opening your new file with “UPDATE” access, “RECREATE” access, and “NEW” access? Why might it be a bad idea to open a file with “NEW” access? (A hint within a hint: what would happen if you ran your macro twice?)