Go to Notes and Further References, Exercises, top,
Analysing Data with Root
- The Classes you need to get started
  • TBrowser
    • A graphical interface used to manipulate objects.
  • TFile
    • Represents a data file.
    • Typically holds one or more TTree objects
  • TTree
    • Represents a set of events.
    • Each event consists of a set of objects.
    • I/O is synchronised so that all objects are read or written together.
    • TTrees can display event data graphically (histograms and plots).
  • TCanvas
    • A rectangular graphical display window
  • TPad
    • A rectangular area on a TCanvas.

Notes and Further References

See also the
videos that accompany this tutorial and the Standard N-tuples

Fermilab have developed a set of ROOT Educational Resources which includes:-

The Companion has:-


Before running any exercises see
tutorial preparation.

Mouse Driven ROOT

The first exercise shows how much you can do with almost no typing.
  1. Run ROOT:- root and you should get the ROOT prompt (root [0] - the number increments each time you type in a new command).

  2. Type:- TFile* f = new TFile("$MINOS_TUTORIAL_DATA/F00018143_0000.sntp.root"); which creates a new TFile from the specified file and returns a pointer to it in the variable f. Don't worry about all the warnings of the type:-
      Warning in : no dictionary for class ... is available
    they just mean that although ROOT knows about the data for the classes it doesn't have the code for them. We could fix this with commands like:-
    to add our code to ROOT but we won't do this now just to show how much we can do simply with ROOT.

  3. Now create a TBrowser by typing:- TBrowser b; A ROOT Object Browser window should open.

  4. In the left hand pane click on the ROOT Files icon, and this should show a right hand pane with a single object - the TFile we have just created. If it's not obvious that it is a TFile right click and context menu opens, the top line of which will tell you the type of any object.

  5. Double click on this TFile and now you should see an NtpSR TTree and that can be double clicked to get to a single TBranchElelement called NtpSRrecord. Keep double clicking until you get to a TBranchElement that is shown as a leaf. You have reached the data.

  6. If you double click on any leaf a histogram of it gets displayed.

    On either axis you can

  7. For more sophisticated manipulation of n-tuples right click on the TTree NtpSR icon and the context menu TTree appears. Select StartViewer and a TreeViewer window opens.

  8. You can embellish histograms by going to their window, clicking on the Edit menu and then selecting Editor. This produces a separate window that has a menu of objects that you can click on to select and then left click on the histogram window to insert.

  9. To exit from ROOT type:- .q

Macro Driven ROOT

The above demonstration gives a taste for the type of thing you can do just with the mouse, but there is a limit to what you can do, and then its time to write a ROOT macro. In fact there is one already written. Take a look at analysing_data_with_root.C

Run ROOT and the type:-

.x $MINOS_TUTORIAL_MACROS/analysing_data_with_root.C and then look at the macro and try to understand how it works.
Note to Maintainers: When making changes please follow the maintenance rules

Contact: Nick West <n.west1@physics.ox.ac.uk>
Security, Privacy, Legal Fermi National Accelerator Laboratory