STAR   Computing  
Understanding Root Macros
Offline computing tutorial Maintained by G. Van Buren

A good way to learn how Root runs is to look at a macro and try to follow what's going on. Some macros which have already been written can be found on the BNL computers at:

$STAR/StRoot/macros
I advise some caution in rummaging through the various available macros as you may find many ways to do the same thing, which can become a source of confusion. My recommendation is to study the macro I present below, which was designed with intended instructiveness.

I'll present here an examples macro and discuss what is happening inside. What are important to understand are the basic steps of the chain approach* to data analysis:

  1. Load software libraries
  2. Define an input file
  3. Construct a chain which controls the flow of the analysis
  4. Construct the makers which contain the analysis modules
  5. Initialize the chain (which in turn intializes all the makers)
  6. Loop over events to process from the input. For each event:
    1. Call the Make() member function of the chain - this calls each maker to perform its analysis
    2. Output each event as wanted
    3. Clear the chain
  7. Call the Finish() member function of the chain to perform any post-run processing
Try to follow along in the example below to see where these steps take place. It may take a good bit of time to read and follow along in the macro file, but it will make what is going on in the macro much clearer.

* It is not necessary to use a chain, and some of the macros found in the directory indicated forego the chain approach. However, the chain is the STAR Computing-endorsed method for analysis macros.


strange.C: A dst analysis macro for one of the physics working groups.