Note on the RHIC pC CNI online monitor program and scripts Dec.2004-Jan.2005 From Run-05 RHIC pp run, online monitor of the RHIC CNI polarimeter will be regularly carried out by the new RHIC polarimter application. This brand new tool will be enough for monitoring the pC CNI once the system works in normal operation. However at te debugging stage (beginning of run), the tool which had been used for years might be usuful for turning the polarimeter system. Following writeup explains how this tentatively made tool is constructed, which subroutines, variables are called in each section, etc. The monitoring tool package consists of several parts (several languages). (1) main script part (GUI : using the perl/tk package) | | | |--> (2) Binary executable program (binary data -> hbook format: C,C++) | |----> (3) Display script (monitoring: Paw Kumac) Section (1) This script is written in "perl" script language using the "Tk" module for the GUI display. This "Tk.pm" package is not in standard perl library and need to be installed mandatory. The site http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html explains the detail of installation procedure and the answers for the many FAQs. If you are familier with the perl language, you can get basic idea of the perl/Tk grammaer from, http://www.perl.com/pub/a/1999/10/perltk/ Note that despite of the light weight, easy implimentation feature, and good performance, this package is getting obsolete. The Tk module is installed in "pc2pc.rhic.bnl.gov". The source script is located at, /home/e950/pol2004-offl/rhicana.pl The scripts consists of many blocks (subroutines), and the list is summarized at the begining of the script, and you can easily track which block works for what from the summary. I believe the code is well commented and well segmented into the small sections for each purpose. Basically the code consists of three parts, o define the variables o define the geometry of GUI (canvas, buttons, pads, ...) o define the subroutines (called from the actions i.e. pushing button etc) It is easy to start this GUI. Just go to the directory and issue the command. > cd /home/e950/pol2004-offl > ./rhicana.pl & A new window will pop-up. The idea of using GUI is WYSIWYG (What you see is what you get), and this little gui is also designed with this concept. But at the first use, you can try with the graphical users guide from, http://www4.rcf.bnl.gov/~cnipol/Analysis/OsamuDocs/files/[file name] file name = How_to_look_at_RHIC_CNI_data_recipe.ppt or How_to_look_at_RHIC_CNI_data_recipe.pdf Main purpose of this GUI is to just display the online result and online information. For the event data (which will be the default format in Run-05), each raw data must be converted into the readable format (hbook in this case) before display. [Conversion program] The conversion program is called at the subroutine "sub startana" (Read (2) for detail descriptions). The options (arguments) values which will be handed over to the conversion program are set from the GUI buttons and dialog boxes. [Display commands] There are two kinds. One is for showing the quick results from scaler part of the data (any data contains this part). This does not require the data conversion (scaler part is automatically converted into readable format right after the measurements). These are, - scaler banana cut plot -- cutq.kumac (called from "sub scaler_banana") - scaler L-R asym plot -- lr_bunch.kumac (called from "sub scaler_lt") - polarization vector plot -- pvector.kumac (called from "sub pvector") The other type, displaying the results of event mode data, a kumac file "asymplot.kumac" is called from "sub show_result" (details in section (3)). According to the display mode option, the GUI either scans the reuslts all the way down to the end (all mode), or displays only specified section. Section (2) The conversion program is compiled from the source codes in the directory, /home/e950/pol2004-offl/bin of the linux box for DAQ: pc2pc.rhic.bnl.gov and only the binary code is copied to /home/e950/pol2004-offl for use. (./bin_2003_version was used for the old data format, and ./bin_dev was used for the developement use.) The banary executable "asymrhic" is made of several source files (see Makefile in the same directory). Their main purposes and subroutines inside are, asym_main.C main code. Dealing with the command options, decoding the data stream, call for the subroutines, booking the histgrams (the list of histgrams are found in the middle of this code), read configuration files, main() readloop() hist_book() hist_close() read_ramptiming() reConfig() printConfig() sqass() ... square root formula asym_process.C process one event, chose or descard it according to the cut criteria. fill histgrams. definition of dlayer function. event_process() ekin() ... dead layer function asym_calc.C calculate numbers of asymmetries at the end of one data. the results are stored in the form of histograms end_process() hb_lib.f translation routine from C++ --> fortran. by defining the function in this file, the cern library functions can be used in C++ code with the format of fortran. asymrhic.h defining the constants, global variables and functions The histograms are defined in asym_main.C (see the list in the middle). The options (> command -option1 -option2 ... ) are defined in the asym_main.C and they are used to specify the data filename, number of events to take, output file name, other configuration files, event cut threshold, and toggling the mode swithes with which the booked and filled histograms are determined. The explanations of each option is in the code, or it can be confirmed by command line, i.e. > asymrhic -h . Section (3) The display scripts are based on the PawX11 application. As mentioned in section (1), they are called from the GUI application. All the kumac (script) files are located in /home/e950/pol2004-offl/Kumac Useful links for PAW beginners: http://wwwasd.web.cern.ch/wwwasd/paw/index.html --- official page http://wwwasd.web.cern.ch/wwwasd/cgi-bin/listpawfaqs.pl --- FAQ (very usuful) Followings are the scrips to display the scaler part of the data (they will work for all the runs). These are usuful when quick check is needed for the quick feedback. The arguments (mostly "run id") can be handed to the script by means of options when it invoked from PAW interactive mode, but from the GUI application it is done through using "environment variables". - cutq.kumac Arguments: run id, 2nd argument is not used Display the strip by strip (scaler 2D) bananas for one detector, i.e show 12 plots per page. In addition to the 2D histogram, the look up table cut boundaries (upper, lower, and average) are also showed. - lr_bunch.kumac Argument: run id Display three kinds of plot 1) bunch distribution -- Detected carbon distribution for 6 silicons 2) strip and detector distributions -- Detected carbon distributions 3) show bunch by bunch asymmetries for X90, X45 and Y45 they are corrected for luminosity asymmetry and acceptance asymmetry - pvector.kumac Argument: run id Display two plots in one page Top: the fitting of 6 data points (left-right asymmetry luminosity normalized) with sine function. Bottom left : polarization vector plot Bottom right: the summary of the values Next one is the main script which shows the results of event mode data. - asymplot.kumac Arguments: run id, plot id These arguments are also handed to the script through the environment variables. The script is segmented in numbers of blocks (called 'macro') and according to the plot id (default id is 'all', meaning to display all the plot one by one), the processes are casted to a selected macros. With any choice, the basic macros, - macro main - macro setting (setting up the basic variables) - macro file (read the file according to the run id) - macro polarization (recalculate the online pol value) are executed at the begining. Other macros (listed in 'macro main') are defined with their macro named after their 'plot id', - macro plot_banana plotting the carbon lucus for each strip. The plot is based on the event mode data (not from FPGA memory). The bananas are shown together with the event cut criteria lines. - macro strip plotting the strip distributions for each detector showing three event categries i.e. total, tof cut only, and additionally energy cut - macro mass display the invariant mass plot for each strip (6pages), and in the last page, summarize the centroids and width of strips extracted from the gaussian fit. - macro splumi show bunch distribution related plots. (1st page) bunch distributions of event numbers, wall current monitor values, and specific luminisity (event/beam intensity) (2nd page) spin pattern - macro energy show the energy spectrums before and after the carbon (banana) event cut for each detector separately. show the energy spectrum which is based on pulse height for each detector, overlapping one to the other. The slope is compared to the elastic expectation. show the similar plots which is based on integral. - macro physasym in the top plot, show the physics asymmetry as a function of bunch id, accumulate the statistics as the bunch id number increases. In the bottom plot, the averaged asymmetries out of every 4 bunches are shown - macro asymother the luminosity and acceptance asymmetry as a function of bunch crossing id are shown - macro pol_each just text outputs. the strip by strip asymmetries i.e. asym = (u - R*d)/(u + R*d) are calculated and displayed. - macro RL the left-right asymmetry or the up-down are shown as a function of bunch id without accumulation. different spin signs are shown with different colors. Also the projections to Y-axises are shown. - macro ratio show some ratio for the bad bunch monitor. 1. ratio of carbon (time + energy cut) to total events 2. ratio of background (events under bananas) to carbon events these are plotted as a function of bunch id 3. ratio of carbon (time + energy cut) to just energy cut Also the projections of these - macro timing bunch timing stability is assessed by picking up the region (600-650keV kinetic energy events) and be compared the center and the width of each bunch. - macro diff_t show the physics asymmetries (x90, x45, y45) for different -t ranges. - macro t_dep show the -t dependence of physics asymmetries, and compared with the theory curve. - macro chisq left-right asymmetries are calculated for each detector and each strip, taking into account the acceptance asymmetry. The 6 data points are fit with sine function for each bunch and extract the chi square of the fit. Each fit and the summary of the chi square distribution is plotted.