next up previous contents
Next: STAF - Sorting Out Up: STAR Software Infrastructure Tools Previous: STAF - Data Structures

STAF - Physics Analysis Modules

  The term ``Physics Analysis Module'' is used in STAF to refer to the user written frunctions in C, C++ or Fortran 77 which do detector response simulation, event reconstruction, calibration, Monte Carlo evaluation, trigger simulation and post-DST physics analysis. Each software package in the STAR Library may contain 0, 1, 2 or more PAMs.

The PAMs must conform to an interface standard which will be explained and illustrated by example in the following tutorials. The PAM interface includes the list of tables which are used (input, output or update) by the module. In addition the module, which is defined as an integer function, returns a STAF condition value indicating to STAF the success or failure of the module's execution.

The information which the user provides in order to interface a module to STAF is contained in an Interface Definition Language (IDL) file. Remember there are two IDL file types (i.e. for modules and tables). The module idl file type defines which table types are input and output from a given module. The tool used for interfacing analysis modules in STAF is the STAR IDL Compiler (Stic). Stic produces glue code. Stic also generates template files in both C and Fortran for the analysis modules in the package, making it quite easy for the user to get started, even if he or she is totally unfamiliar with the STAF programming interface.

PAMs are linked to STAF package-by-package rather than individually. In other words, when building a SL97b STAF executable, the user selects package libraries to link, not the individual PAMs. The PAMs may require tables which belong to other packages. Likewise, a given table might be defined in one package but used by a module in a different package. At run time, however, PAMs are called individually using the AMI ASP via the ami/module/call STAF command. Some PAMs might be linked in the STAF executable but do not have to be called at run time.

Example Physics Analysis Modules and IDL files are available in Fortran, C and C++.

PAMs are named according to the STAF callable function name in the module definition. For Fortran modules the function name is defined in the statement:


Integer Function PAM_function_name(table1_h, table1, ...)

and in C modules by,


long PAM_function_name_(
     TABLE_HEAD_ST     *table1_h, PKG_typename_ST *table1 , ...)

The source codes are saved as UNIX files in the PKG/src subdirectory and are named:


     PAM_function_name.F     for Fortran,
     PAM_function_name.c     for C, and
     PAM_function_name.cc    for C++.

The PAM idl files for SL97b are placed in the PKG/src subdirectory. They are named PAM_function_name.idl and contain an interface statement,


interface PAM_function_name : amiModule {...};

which refers to the STAF callable function name. At run time the STAF command


ami/module/call PAM_function_name table1 table2 ...

invokes the named PAM and provides the list of current table instance names as arguments, where the table order is critical. In SL97b all the preceding reference names for a PAM and the associated files have the same root name.

Referring to the example PAM idl file tpt.idl note that the structure and syntax of the idl file is independent of the programming language. The essential elements of the PAM idl file are:

Table header and variable definitions are passed to the PAMs via the argument list in the function declaration statement. References to the table header and variables inside the PAM are to the local table names as defined in the function declaration statement. In Fortran modules the table variables are referred to as (exactly like Fortran STRUCTURES):


local_table_name(i).variable_name

where i = 1,2,... is the table row number, and in C/C++ codes as


local_table_name[i].variable_name

where i = 0,1,... is the table row number. From the KUIP command line table variables are referred to as


table_instance_name[i].variable_name

where i = 0,1,... For all cases tables with only 1 row must be referred to as


table(1).variable_name in Fortran modules
table[0].variable_name in C/C++ codes and KUIP commands.

Table attributes (i.e. maximum number of rows and number of rows used) are referred to in PAMs as:


local_table_name_h.maxlen in Fortran and C (read only)
local_table_name_h.nok in Fortran and C
local_table_name_h->nok in C++

Several useful STAF PAM programming guides are available:



next up previous contents
Next: STAF - Sorting Out Up: STAR Software Infrastructure Tools Previous: STAF - Data Structures
Lanny Ray
2/20/1998