ROOT

From Electron Ion Collider
Jump to: navigation, search

For analysing Monte Carlo data in ROOT, see Monte Carlo and Smearing.


ROOT is an object-oriented data analysis framework written in C++. It was developed at CERN to allow efficient large-scale data analysis.

Running ROOT

If you have an EIC account, then in order to run the ROOT analysis package you will have to add the location of the ROOT binary to your path. If you source the EIC logon script this is done automatically. If not, you can select the currently used version of ROOT by adding the location of ROOT to your PATH environment variable. To add this to your path, in a c shell use the command:

setenv PATH $ROOTSYS:{$PATH}

or in bash:

export PATH=$ROOTSYS:$PATH

where ROOTSYS is the path to the desired ROOT installation. Currently the standard EIC installation is /afs/rhic.bnl.gov/eic/PACKAGES/root-v5-34-18. After this, you can use the root executable from any directory.

You will also need to add the location of the ROOT libraries to your LD_LIBRARY_PATH environment variable using

setenv LD_LIBRARY_PATH $ROOTSYS/lib:{$LD_LIBRARY_PATH}

or

export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH

If you are just getting started in running the ROOT analysis framework, there is a tutorials directory at:

/afs/rhic.bnl.gov/eic/PACKAGES/root/tutorials

These tutorials are discussed in detail at the main ROOT webpage at CERN and are worth looking over, especially for anyone who is new to ROOT.

ROOT Utilities

There are a number of classes providing utilities to simplify making figures in ROOT, provided via the eicplot package.

Help with ROOT

If you have questions about ROOT, you can search or submit a question to the ROOTTALK mailing list. Or, you can ask on the EIC software mailing list.

Below are some random ROOT tips that you may find useful. Please feel free to add your own.

Moving and resizing the palette axis of a 2D histogram

A 2D histogram drawn with option "colz" is drawn using a colour scale, with a colour palette on the right giving the key.
When drawn with the option "colz" a 2D histogram is drawn using a colour scale, with a colour palette giving the key, as shown in the figure.

It may be that, as in this example, the right margin in which the colour palette is drawn is not large enough to fit the text labels. To increase the space for the colour palette, first increase the right margin of the image:

gPad->SetRightMargin(0.15); // The default right margin is 0.1 i.e. 10% of the image width

This provides more space for the colour palette, but does not actually reposition it. To do that, do the following, after drawing with colz:

TPaletteAxis* palette
      = dynamic_cast<TPaletteAxis*>(myHistogram.GetListOfFunctions()->FindObject("palette"));
if(palette) {
   palette->SetX1NDC(0.86); // Start the palette 86 % of the way across the image
   palette->SetX2NDC(0.91); // End the palette 91% of the way across the image
   gPad->Modified(); // Update with the new position
} // if
The histogram with the right margin increased.
The histogram with the colour palette repositioned.

Note that the vertical size of the palette can also be modified using SetY1NDC (0.1 by default) and SetY2NDC (0.9 by default).


Logarithmic axes

Setting an axis to be logarithmic is done via the graphical pad (TPad, TCanvas etc) on which a histogram is drawn, rather than via the histogram itself. For example:

myPad.SetLogx(1); // Or 0 for linear. Also SetLogy, SetLogz.
myHistogram.Draw(); // Histogram is draw with logarithmic x axis.

Note that when a pad is divided, its logarithmic axis settings are not propagated to its divisions - these must be set separately. For example:

myPad.SetLogx(1); // Sets logarithmic x.
myPad.Divide(2, 3); // 2 divisions in x and 3 divisions in y.
myPad.cd(1); // Select division 1.
myHistogram.Draw(); // Huh? Where is the logarithmic x axis?
myPad.cd(1)->SetLogx(1); // Select division 1 and set it to logarithmic x.
myHistogram.Draw(); // Histogram is now drawn with logarithmic x axis.

If you wish many of your histograms to have a logarithmic axis, it may be easier to set that as the default via the TStyle class:

gStyle->SetOptLogx(1); // Every x axis is logarithmic. Likewise SetOptLogy, SetOptLogz.

Note that this must be done before creating the pad to which you are drawing.