Walkthrough: The ROOT browser (5 minutes)

Note

The ROOT browser is a useful tool, and you may find yourself creating one at every ROOT session.

One way to retrieve the contents of file “c1.root” is to use the ROOT browser. Start up ROOT and create a browser with the command:1$$^,$$2

[] TBrowser tb


In the left-hand pane, scroll to the folder with the same name as your home directory.3 Scroll through the list of files. You’ll notice special icons for any files that end in “.C” or “.root”. If you double-click on a file that ends in “.C”:

• if the Editor tab is in front ROOT will display its contents in the editor window;

• if the Canvas tab is in front, ROOT will execute its contents.

Click on the Canvas tab, then double-click on c1.C to see what happens.

Now double-click on c1.root, then double-click on c1;1.

Note

Don’t see anything? Click on the Canvas 1 tab in the browser window.

What does “c1;1” mean? You’re allowed to write more than one object with the same name to a ROOT file (this topic is part of a lesson later in this tutorial). The first object has “;1” put after its name, the second “;2”, and so on. You can use this facility to keep many versions of a histogram in a file, and be able to refer back to any previous version.

At this point, saving a canvas as a “.C” file or as a “.root” file may look the same to you. But these files can do more than save and re-create canvases. In general, a “.C” file will contain ROOT commands and functions that you’ll write yourself; “.root” files will contain structured objects such as n-tuples.

As nifty as the ROOT browser is, for the work that you’ll do this summer you’ll probably reach the limits of what it can do for you, especially if you have to work with large numbers of files, histograms, n-tuples, or plots.

Still, it’s nice to know that it’s there, in case (as the name suggests) you want to browse quickly through a couple of ROOT files.

1

It may take a long time for the TBrowser to start up. I’ve reported this issue to the ROOT Developers. Until then, I must ask you to be patient.

2

You may see someone using this command instead:

[] new TBrowser


The difference is slight, and only matters if you’re experienced with C++. (If you are experienced with C++: what is that difference? Here’s a hint.)

3

If you have a Nevis temporary account, the folder hierarchy may be puzzling to you; your home directory will be in /nevis/milne/files/<account>. For now, don’t worry about this. If you’d like to know more, there’s the Nevis wiki automount page.