Walkthrough: Saving and printing your work (15 minutes)

By now you’ve probably noticed the Save sub-menu under the File menu on the canvas. There are many file formats listed here, but we’re only going to use three of them for this tutorial.

Select Save->canvas-name.C from one of the canvases in your ROOT session. Let’s assume for the moment that you’re working with canvas c1, so the file “c1.C” is created. In your UNIX window, type

> less c1.C


(If you get complaints about a file not found, the name of the canvas is “see-one,” not “see-ell.”) As you can see, this can be an interesting way to learn more ROOT commands. However, it doesn’t record the procedure you went through to create your plots, only the minimal commands necessary to display them.

Next, select Save->c1.pdf from the same canvas.


Not only is the PDF format useful if you want to print something, but it’s usually simple to embed a PDF file in a paper or a presentation. You can’t embed a ROOT macro in a Powerpoint document and expect to see its graph!

Finally, select Save->c1.root from the same canvas to create the file c1.root. Quit ROOT with the .q command, and start it again.

To re-create your canvas from the “.C” file, use the command

[] .x c1.C


This is your first experience with a ROOT “macro,” a stored sequence of ROOT commands that you can execute at a later time. One advantage of the “.C method” is that you can edit the macro file, or cut-and-paste useful command sequences into macro files of your own.1

You can also start ROOT and have it execute the macro all in a single line:

> root c1.C

Printing at Nevis

If you are physically in the Nevis research building, you can print out your PDF file with the command

> lpr -Pbw-research c1.pdf

If you want to print directly from the ROOT canvas, click on File->Print, type lpr -Pbw-research in the first text box and leave the second one empty. Again, the printer name “bw-research” only has meaning at Nevis.


This is still useful if you’re working in pyroot, though you’ll have to do some translation from C++ to Python. This discussion may help with that conversion.