Latest update 21.07.97
This is a short description of the source code for the TPC padmonitor program. The program was originally written for the NA49 experiment at CERN. It was then modified to be used in STAR, and now new features and options have been added for the use of BRAHMS. The STAR code is still in the files, but is compiled only whith a certain compile option. A description of how to use the Padmonitor program can be found here.
The padmonitor package with source code, object files, executables and
documentation is organized the usual way in this directory structure:
padm---+---bin | +---doc | +---lib----+--irix | | +---src +-- ... | +---wrkThe makefile Makefile is situated in the ./lib/ directory. To compile and link go to this directory and simply type "gmake", the objectfiles will be generated in the underlying derectory (./bin/irix/) and the executable padm will be placed in the ./bin/ derectory.
The program links to Xlib and AthenaTools library files. The AthenaTools library can be found in /rhic_data/code/tpc/pdm/At/. If this is moved the makefile will have to be changed.
main.c widgets.c padplane.c configuration.c rawX.c callbacks.c usersupplied.c display_2d.c pedestal.c
main.c contains the main program which basically calls the initialization functions and then controls the X event loop. The default path to .ConfigurationFile is set in this file.
In widgets.c one finds the routines for setting up the Motif widgets (windows, menues, frames, buttons, labels, etc.). Any change in the user interface has to be made here. Each widget is often defined together with the name of the callback function, which handles the X event caused by an action on the respective widget. So one can, in this file, find the reference to the code, that takes care of any action on the user interface.
All functions concerning the padplane are found in padplane.c. Initialization of the padplane is done in function get_padinfo() where all padplane specific default values are set. Furthermore the memory for the padplane data is allocated in this function.
The padplane default values are overwritten by values from .ConfigurationFile (if specified). This is done in functions of file configuration.c. Note that some entries in the configuration file is required in order to make a correct initialization.
In file rawX.c one finds the function for selecting colors and pixels of the X-window display.
All callbacks from the X event loop is handled by functions in callbacks.c , these functions may call functions in other files. Any action on the userinterface creates an X event, which has a piece of code in this file.
usersupplied.c contains the functions for opening DAQ or datafile, and for reading events from DAQ or datafile into the padmonitor data structure. Here one finds a set of functions for STAR and a set of functions for BRAHMS. The program uses the set of functions which is specified in the configuration file by the Experiment entry.
The code for 2d_display (time vs. pad#) is found in 2d_display.c. The code for pedestal saving and subtraction is in pedestal.c
main() initialization define widgets get_padinfo() set default values configure() allocate memory set X display values Realize widgets (start X event loop) repeat callback (handle X event) until done exit
The datastructure for padplane is defined in file
./inc/padinfo.h.
The structure looks as follows:
pads--> enum _padStatus status--------background enum _padStatus color foreground short s_max not_equipped short s_min empty float cap_res underRange int sector, row, pad inRange union _data data-----+ overRange | overFlow | indicator | area1 | area2 | present | | +----short *s unsigned char *b
Note that the pad datastructure here is shown with the possible values of the pad status. These are not variables.
We see that the structure allows two types of ADC values. Either
the ADC value can be of type "unsigned char" (b) or of type "short"
(s). This way one can use 1 or 2 bytes datawords. Only one of the
types is allocated memory and used when the program is running. This
is done by having two versions of the functions that use the specific
datastructure. These functions have the extention _byte or
_short.
Whether to use 1 or 2 bytes datawords is determined in the
configuration file whith the Bits entry. Function
bits_Conv() of file configuration.c sets up variables
and pointers to the proper set of functions, related to the chosen
number of bits.
+----------------+ | event number | int | number of hits | int +----------------+ | pad number | int | number of bins | char | first bin | char +----------------+ | bin 0 ADC | char | bin 1 ADC | ... | ... | | bin n ADC | +----------------+
The first two bloks of the event are defined as structures
(event_header and pad_header).
Each datafile should start with a file ID of type int and then a
sequence of events. if the datastructure of the file is not correct
the program will probably crash at some point. Various check
statements should be added to avoid this.
The datastructure described here most likely will change. In the final
version the ADC values should probably be of type "short". Its fairly
simple to change this in the function getevt_file_brahms().
The function configure() has been expanded with the Experiment=brahms option in file configure.c
In file widgets.c menubuttons have been added to the "Right histogram" menu and frame9 with the "Time Cut" labels has been added.
The callback.c file has been expanded with a callback function for the "Right histogram" menu - rhistoCB(). Various modifications have been made in some of the existing functions in order to make this work. A new function ChangeLimitMode() has been added to take care of the new "Time Cut" labels. To avoid crashes when performing actions on an empty histogram a number of check statements has been added to callback.c .
Helvetica-Bold.afm Helvetica-BoldOblique.afm Helvetica-Oblique.afm Helvetica.afm
The path and names can be changed in the Makefile for the AthenaTools library by changing AFMPATH and/or the -DDFLT_FONTFAMILY option. Then of course the library will have to be recompiled .