How to Make Your Own Analysis Module


If you have run production on a Monte Carlo sample, or if you have data samples that you want to look at, you will typically want to run an analysis job. For example, you may want to look at the momentum distribution of COT tracks, or examine the impact parameter distribution of tracks from B-daughters in top Monte Carlo events. To do this you will almost certainly want to create your own module specific to your own analysis interests. A simplified procedure for doing this is described below.




Making the Library and making the Executable:

You can build the library and make the executable all in one step or in individual steps. From your offline release area (in this example the int5 area, not the int5/MyAna area), do the following to make the library and the executable

gmake MyAna.all (This will first compile the module code, put the compiled code into a library in your /int5/lib area. It will then make an executable called MyAnaExe which will appear in your /test/bin/$BFARCH/ area.)

If you would like to just make the library you can do the following:

gmake MyAna.lib This is very helpful if you have executed setenv USESHLIBS 1, since this will remake the shared library for your package, and you will normally be able to rerun without remaking your exe. See this for more details on shared libraries.

If you would like to just make the exe you can do the following:

gmake MyAna.bin

Note: The gmake is smart enough to tell when the library needs to be remade. Sometimes however, you might want to force it just to be sure. You can do that by changing the modification date on either the module header file or the module c++ code. One way to do this is by the following command:

1) touch MyAna/MyAnaModule.cc (This changes the modification date on the file.
2) gmake MyAna.all (This will now remake the library and the exe.)

Running the Exe:

After running gmake, look in the area bin/$BFARCH in your test release directory test. You should see the file MyAnaExe. You can now run this exe, but you will usually want to run with a .tcl file. This file contains a list of commands for the exe, and is like the .uic file of Run I. An example .tcl file is myana.tcl. These files run on a simulated t-tbar file which can be found on fcdfsgi2, but you can modify it to run on any (recent) Run II dataset by modifying the input file specified in the module talk DHInput section. To run this at the command line you type (from the int5 directory):

bin/$BFARCH/MyAnaExe myana.tcl

This will run the exe, and you will see various print statements from you code sent to the screen. You might prefer this job to run in the background, and send these results to a log file. To do this you type

bin/$BFARCH/MyAnaExe myana.tcl >&! myana.log &

The first ">" says send the output to the logfile myana.log. The first "&" says send all output including error messages to that log file. The "!" says overwrite the log file if it exists.
The second "&" says to run the job in the background.

To look at the log file while the job is running you can type:

tail -f myana.log

This will print out the last 10 lines of the log file, continuing until you type ctrl-c.

Examining the Output:

After you have successfully run the exe, the file results/myana.root should exist. This file contains an ntuple that you can now examine using root. To look at some of the information in this root file, we will start by using the ROOT browser:


To report a bug, or request more info, contact cdf-bugs@cdfsga.fnal.gov.
Last update 21-March-2001 by Richard Hughes