Tutorial 2: Modular Macro Files
In this tutorial I will cover the reasoning and methods involved in creating and managing modular macro
files. These instructions assume that you have already worked through Tutorial 1. For this tutorial, you will once again need to be physically
logged in on the OUHEP cluster, for the same reasons described before.
First, download the files for this tutorial here: sample2.tar.gz
Save the file in your atlas directory, then unpack it as before:
$ cd ~/atlas
You will now have several new files in your atlas directory:
$ tar -xzvf sample2.tar.gz
You will need all of these files, along with the files remaining from Tutorial 1. For the most part, we will only be editing the macro files in
PURPOSE OF MODULAR MACRO FILES
In the perfect world, we could use a single method to solve a single problem, and get useful results every
time. Unfortunately, this can't happen in the real world, especially in High Energy Physics. Because of
this, there are two collision-simulation methods that we use, (isajet and pythia) each with configurable
In the event that you would like to compare plots using two different configuration options for each method,
using modular macros will allow you to do so without re-writing the same code in 4 separate macro
Additionally, paw++ has been found to produce spikes (rather than useful plots) for some unknown reason when
too many events are contained in a single ntuple chain. For both isajet and pythia, this was found to happen
around 700,000 events. Luckily, modular macros allow for a workaround to this problem by using several
short ntuple chains rather than one long ntuple chain, and running the same base code on each chain.
HOW MODULAR MACROS WORK
With a normal macro file, paw++ reads the file from beginning to end, and executes each command along the
way. The same is ultimately true for modular macros -- paw++ reads the macro you loaded starting at the
beginning, and executes the commands in order. When it encounters a command like this:
exec sample2-2 2 1.2e+4 isajet
then paw++ "takes a break" from the current macro and begins executing commands from the macro
The rest of the line gives paw++ parameters to insert into specified points when it runs the macro being
called. These points are labeled , , , etc, in sample2-2.kumac, and are filled by the parameters
in the exec command. Paw++ runs the macro as though these parameters had been typed directly into
This is what makes the macro modular, and allows you to run the same code under different conditions
several times in the same run.
nt/chain sample2 atlfast.00.ntup
exec sample2-2 2
nt/chain sample2 atlfast.00.ntup
hi/cre/1d 1100 "# of Muons 15. 0. 15. 0.
id100 = 2100
hi/copy 1100 2100
hi/cre/1d 1100 "# of Muons" 15 0. 15. 0.
id100 = *1000+100
hi/copy 1100 [id100]
PROS AND CONS OF MODULAR MACROS
PRO - Can run different configurations of the same basic code without changing more than a line or
CON - Large changes require editing two files instead of just one.
PRO - Can employ histogram addition without adding more than a few lines (extra ntuple
CON - Slower. Since two files must be loaded, and the fortran file will probably be run several times
before the end, modular macros can be considerably slower.
STUDYING THE MACRO FILES
Finally, it's time to open up these macros and see what they do! Open sample2-1.kumac and sample2-2,kumac
side-by-side using NEdit (see Tutorial 1), or your favorite text editor. The
important thing is to have both of them on your screen at once, preferably side-by-side with sample2-1.kumac
on the left and sample2-2,kumac on the right.
Read through sample2-1.kumac, paying special attention to the comments. When you come to the line that calls
sample2-2.kumac, switch over and begin reading that one. At the end of sample2-2.kumac, continue reading
sample2-1.kumac where you left off. This is the order that paw++ will read the files.
When you're confident that you understand how these files work together, move on to the next section.
RUNNING THE MACROS
Now it's time to run your first modular macro. Your terminal should still be in the atlas directory, so run
paw++ from there. If not:
$ cd ~/atlas
In the paw++ Main Browser window, select Macros, then double-click "sample2-1.kumac". When you are prompted,
$ paw++ &
You should recall from reading the comments and code in sample2-2.kumac that you're processing both isajet
and pythia ntuples, so you should expect two postscript files, aptly named "isajet.ps" and "pythia.ps".
Issue a directory listing to make sure they're there, and print them out:
$ ls -ao
Now just go to the printer and pick up your plots!
$ lpr isajet.ps pythia.ps
Now that you know how modular macros interact, do the following:
1. Edit sample2.for - Add the functions for calculating Muon pt and Jet pt to this Fortran file, and
fill the same histograms as before.
2. Edit sample2-1.kumac - Add the new histograms for Muon and Jet pt to this file
3. Edit sample2-2.kumac - Add id-numbers for your new histograms, and two "extra" id-numbers so you
can create cross-sections from them as well. You should end up with a total of 10 plots. Add the new id-s
to the code that creates cross-sections, then print out the 10 plots on two pages: 6 on the first page, and 4
on the second. Make sure each postscript file ends up with a unique name, so they aren't overwritten. [hint:
try isajet-1.ps isajet-2.ps and pythia-1.ps pythia-2.ps]
If you need any help with this tutorial, please visit the resources listed on the menu and links above, or