ROOT

From Electron Ion Collider

Jump to: navigation, search

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

Contents

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 (see Computing) this is done automatically. If not, you can select the currently used version of ROOT by adding /afs/rhic.bnl.gov/eic/env/pro/root/bin to your PATH. To add this to your path, in a c shell use the command:

setenv PATH /afs/rhic.bnl.gov/eic/env/pro/root/bin/:{$PATH}

or in bash:

export PATH=/afs/rhic.bnl.gov/eic/env/pro/root/bin:$PATH

After this, you can use the root executable from any directory.

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


Using ROOT to analyse Monte Carlo events

A macro has been written to create a ROOT TTree from the text files produced by the following Monte Carlo event generators: PEPSI, PYTHIA, RAPGAP and DJANGO. The TTree class is documented in detail in chapter 12 of the ROOT User's Guide.

Detector Smearing

A C++ namespace, Namespace Smear containing classes and functions to easily perform detector smearing on MC data formatted using BuildTree is available in the same binaries. See page for more information.

Arcane ROOT knowledge

Is ROOT causing you to tear your hair out in frustration? Maybe one of the following hints can help you. If not, you can always search or submit a question to the ROOTTALK mailing list. Or, ask your friendly neighbourhood ROOT wizard.


Moving and resizing the palette axis of a 2D histogram

When drawn with the option "colz" a 2D histogram is drawn using a colour scale, with a colour palette giving the key. For example:

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

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->SetX1NDC( 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.

Personal tools