ROOT Beginners' FAQ
At this point of the guide, some basic questions could have already come to your mind. We will try to clarify some of them with further explanations in the following.
ROOT type declarations for basic data types[edit | edit source]
In the official ROOT documentation, you find special data types replacing the normal ones, e.g.
Int_t replacing the standard
int types. Using the ROOT types makes it easier to port code between platforms (64/32 bit) or operating systems (windows/Linux), as these types are mapped to suitable ones in the ROOT header files. If you want adaptive code of this type, use the ROOT type declarations. However, usually you do not need such adaptive code, and you can safely use the standard C type declarations for your private code, as we did and will do throughout this guide. If you intend to become a ROOT developer, however, you better stick to the official coding rules!
Configure ROOT at start-up[edit | edit source]
The behaviour of a ROOT session can be tailored with the options in the
.rootrc file. Examples of the tunable parameters are the ones related to the operating and window system, to the fonts to be used, to the location of start-up files. At start-up, ROOT looks for a
.rootrc file in the following order:
./.rootrc //local directory
$HOME/.rootrc //user directory
$ROOTSYS/etc/system.rootrc //global ROOT directory
If more than one
.rootrc files are found in the search paths above, the options are merged, with precedence local, user, global. The parsing and interpretation of this file is handled by the ROOT class
TEnv. Have a look to its documentation if you need such rather advanced features. The file
.rootrc defines the location of two rather important files inspected at start-up:
rootlogon.C. They can contain code that needs to be loaded and executed at ROOT startup.
rootalias.C is only loaded and best used to define some often used functions.
rootlogon.C contains code that will be executed at startup: this file is extremely useful for example to pre-load a custom style for the plots created with ROOT. This is done most easily by creating a new
TStyle object with your preferred settings, as described in the class reference guide, and then use the command
gROOT->SetStyle("MyStyleName"); to make this new style definition the default one. As an example, have a look in the file
rootlogon.C coming with this tutorial. Another relevant file is
rootlogoff.C that it called when the session is finished.
ROOT command history[edit | edit source]
Every command typed at the ROOT prompt is stored in a file
.root_hist in your home directory. ROOT uses this file to allow for navigation in the command history with the up-arrow and down-arrow keys. It is also convenient to extract successful ROOT commands with the help of a text editor for use in your own macros.
ROOT Global Pointers[edit | edit source]
All global pointers in ROOT begin with a small "g". Some of them were already implicitly introduced (for example in the section Configure ROOT at start-up). The most important among them are presented in the following:
- gROOT: the
gROOTvariable is the entry point to the ROOT system. Technically it is an instance of the
TROOTclass. Using the
gROOTpointer one has access to basically every object created in a ROOT based program. The
TROOTobject is essentially a container of several lists pointing to the main
- gStyle: By default ROOT creates a default style that can be accessed via the
gStylepointer. This class includes functions to set some of the following object attributes.
- Histogram axis
- Fill areas
- Histogram Statistics and Titles
- etc ...
- gSystem: An instance of a base class defining a generic interface to the underlying Operating System, in our case
- gInterpreter: The entry point for the ROOT interpreter. Technically an abstraction level over a singleton instance of
At this point you have already learnt quite a bit about some basic features of ROOT.
Please move on to become an expert!