Privacy and Security Notice

Primex ROOT Talk

Primex ROOT Analysis Talk




Introduction to ROOT

In any physics analysis, it helps to produce plots to visually see the relationship between physical variables (ie angles, energy, momentum, etc). The tool described in this talk is ROOT.

ROOT is a software package developed at CERN to produce histograms, make fits, draw functions, store data, perform mathematical calculations, ....

Advantages of ROOT:

Getting Started

Go to the ROOT homepage. Here you can read up on ROOT. It has a good help section for classes and methods. You can download a paper manual here. Also, there are binaries and libraries which the adventurous student can download to build on their personal computers.

To start, type the command root at the prompt. Once you are in the root shell, the prompt changes to "root[0]".

To see the command line flags, type root -h. It should produce the following output.

Useful commands in the ROOT session are

A sneaky trick to opening a ROOT file automatically is to type root myfile.root.

If one is used to PAW and HBOOK histograms, the h2root command to convert the HBOOK to a ROOT file. This command only works on histograms. It does not convert an ntuple to a tree or ROOT ntuple.

Histograms

The most used aspect of ROOT for an analysis is the histogram.

What is a histogram? A hitogram is a plots a variable in discrete bins (x-axis) vs the number of events per bin (y-axis). In ROOT , histograms come in 3 dimensions - 1D(TH1), 2D(TH2), and 3D(TH3).

Here is an example to create a 1D histogram

Here is an example to create histograms with whistles and bells.

Trees

A tree is type of storage format. Many physicists are familiar with the ntuple format from PAW. The ROOT software does have a TNtuple class, but trees are far better. In both trees and ntuples, variables are saved on an event by event basis. With the ntuple, the data is like a table with a value of each variable stored in each column of the table. Ntuples come in two types, row-wise where the number of columns are fixed and column-wise where number of entries in the columns is dynamic.

With a tree, more types of values can be stored beyond integer and float numbers. You can stored arrays and classes. You can write your own event class with a member function on each leaf. Furthermore, a leaf can spawn multiple branches for organizing the information.




Using ROOT with Primex

There are numerous methods to analyze data. Here are three options I like to employ:

  1. C++ program analyzes Primex data file and creates a ROOT file with histograms.
  2. C++ program analyzes Primex data file and creates a ROOT file with a tree.
  3. C++ program converts Primex data file into a ROOT DST file. Use a ROOT macro to analyze the DST file.

The students should analyze the data in the method with which they feel most comfortable maybe even creating their own. Here are some advantages and disadvantages of my three methods.

Method 1

Method 2

Method 3

Method 1 - Histogram example

Most of the Primex software falls into this category. In this section, I will supply one of my packages. Your Primex executable codes show have these formats. My example package analyzes the monte carlo banks. The files are

Check out this directory for an example ROOT file and some fun macros.

Method 2 - Tree example

I do not have a Primex example at this time. All of my CLAS analyis is based on this method. Anyone interested in this scheme can ask me during office hours.

Method 3 - ROOT DST example

For an example of creating ROOT DSTs, go to $PRIMEX_BUILD/src/programs/prim_DSTmaker package. It has an executable code called prim_DSTmaker.cc. This program creates a tree where each leaf is a Primex bank item. Typically a DST file is about 400MB in size down from a 2GB raw data file. The reason for this is because I chose to save 5 or 6 banks (HYCALCLUSTER, EVENTID, VETOHIT, TAGMHIT, TRIGGER, ...).

To analyze the DST file, you need a macro. There are examples in the package called fileDST.C which works on one DST file and chainDST.C which analyzes many DST files.