Walkthrough: The ROOT browser

(5 minutes)


The ROOT browser is a useful tool, though it can be a bit clumsy at times. Let’s give it a try.

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
Example TBrowser image

Figure 11: When I start the TBrowser, this is what I see. Your window won’t be quite the same, if for no other reason that my home directory has more files and sub-directories than yours does… at least for now!

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.


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.


If you’re not at Nevis, depending on the details of your ROOT set-up, you may see something similar with a title that reads RBrowser. This is the next-generation ROOT Browser. It doesn’t have all the bells-and-whistles of the original TBrowser yet; for example, you can’t right-click on the name of an n-tuple to start the TreeViewer.

It won’t be hard to figure out how to use the RBrowser on your own. If you really want to see the TBrowser as used in this tutorial, quit ROOT, edit the file ~/.rootrc, and add the line:

Browser.Name: TRootBrowser

Save the file and start up ROOT again. You should see the TBrowser from now on.


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.)


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.