Beamline Instrument Software Support
SPEC Macro documentation:
|[ source code | installed at | configured at ]|
|See other macros in category: Detection MCA|
These macros provide users with basic MCA commands, i.e. start, stop, init, read memory, etc..., as well as with more sophisticated features such as ROIs, channel calibration, peak search, data saving and recovering, etc...
MCA control is inserted in SPEC internal code, making it possible to automatically operate the MCA, from standard SPEC counting and scanning commands, e.g. acquire, plot out, save spectrum for each point of a scan. A Graphical User Interface is also available.
About the usage of the Graphical User Interface (GUI) : it is at the moment only capable of monitoring the data acquired, as there is no connection between SPEC and that GUI, appart from the spectrum data itself and its calibration parameters, both stored in shared memory. For instance, the ROIs defined from SPEC or from the GUI are not connected together. They are two seperate sets of ROI definitions. The GUI is not capable of sending control commands to the hardware. Be more particularly aware that the acquisition times are not known by the GUI, so if you save the spectrum from the GUI, they wont be included in the file. rather use SPEC for saving your data. The GUI is a display.
Hardware supported :
Some Particular settings:
MCA macro user hook:
Users can hook their own macro to those macros, using "cdef()".
Usage: mcasetup [adc] [tmode] [gsz] [g] [cal] [Xlbl] [Xun] [nclr] [sleep] [bgnd] [gui] [log] [dots] [lines] [ebars] [flag] [red] [synchr]
Sets the MCA hardware and software up. You can either give all the parameters on the command line or use the menu that shows up when typing "mcasetup" alone.
It is possible to have the last acquisition elapsed times values reported in counters by simply configuring the counters you need out of mcaLt, mcaRt and mcaDt mnemonics, respectively standing for Live, Real and Dead times.
Disables the MCA.
The MCA is no longer addressed during standard SPEC operation ("ct", scans ..), but still from "mcaacq".
Enables back the MCA.
Initialises the MCA macros and hardware. Can be called at startup to re-setup things without giving any parameter, nor calling any menu. The current or default parameters are then set. Default are mensionned together with mcasetup description.
Usage: mcaacq [preset_seconds] [roi | first] [last]
Acquires data with the MCA only. The rest of counters configured in SPEC are not addressed by this command. If you need it, use standard ct command. (don't forgot, mcasetup set AUTO-RUN mode <ON>, or mcaon).
mcaacqconsists in the following sequence:
The MCA memory is read within the range specified, or if none, the active ROI .
If the requested preset time is 0 or un-specified, the acquisition is started "for ever"; press "control-C" or "s" or "q" to stop it.
Pressing "c" would clear the memory on the fly. If the GUI is not active, you can also change the plot update intervals (press "u"), change the plot x or y ranges (press "x" or "y"), integrate counts on region (press "i"), toggles plot attributes such as lines (press "l"), large dots ("d") and log y("g"). Meanwhile, the acquisition goes on.
Clears the active MCA memory group.
Usage: mcastart [preset_seconds]
Presets and starts an acquisition.
Stops acquisition if running.
Send "stop acquisition" signal whatever is the status of the device. It might happen that the device server gives a meaningless error message, if the status is already "IDLE".
Usage: mcaread [roi|first] [last]
Reads the MCA memory within the range specified.
Reports the MCA elapsed live , real and dead times.
Prints out a detailed status of the SPEC MCA registers.
Usage: mcaroi [no|name] [<first> <last>] [name]
Usage: mcanewfile [file_name]
Sets a new file prefix and initialises the spectrum run number, which appears in the file name as e.g. PREFIX_001.mca. But when spectrum was taken during a scan, the file name changes for PREFIX_001_000.mca, where first number is the scan number (SCAN_N) and second one the point number in the scan.
Usage: mcasave [roi|min] [max] [-silent]
Saves acquired data to disk file.
If a range is specified, the data are saved within that range, otherwise the whole spectrum is dumped to the file. The file is either the standard scanfile or a private MCA file, depending on "mcasetup" entries.
If standard scanfile is used, each spectrum originated from out of a scan (ct or mcaacq) is nevertheless referenced to a "scan number". (SCAN_N is incremented).
If a private file is used, it must have been set a prefix using "mcanewfile" command. Then each spectrum is saved to a different file. The file name extensions gives the information on its origin. see mcanewfile.
The file syntax is standard and MCA mixed. MCA syntax is described below:
Each MCA related line holds the character "@".
It consists of:
Usage: mcaload <file> <scan_no> [scanpt_no] [0|1]
Loads spectrum from a file.
The loaded spectrum is stored into WS memory as if it would have just been acquired. If file is a standard scan file, spectra are referrenced to by their "scan" number, and eventually their "scan_point" number. Both numbers must be 0 when loading data from private MCA files. 4th argument to 1 means that the calibration parameters are to be loaded from the file as well. In that case any other current calibration is overwritten. To avoid it, "mcasave" it with the current spectrum, before "mcaload"ing.
Reduced data channel numbering starts from the first channel value (prior to reduction) added integer part of half the "factor", every next point incremented by "factor" .....
Shows calibration fit parameters or inputs new parameters.
Toggles between channel (uncalib) and calibrated mode.
Computer aided energy calibration of the MCA.
Manual calibration of the MCA.
Peak search on the current spectrum.
Shows peaks found.
Usage: mcacplot [first|roi] [last]
A screen plot of the current MCA data in cplot format. Part of the plot parameters are taken from "mcasetup", rest from "cpsetup" settings.
Usage: mcapplot [first|roi] [last]
A printer plot of the current MCA data in cplot format. That follows the same rules as "mcacplot" macro.
Turns MCA Graphical Interface on.
Turns MCA Graphical Interface off.
Usage: mcasplot [xmin] [xmax] [ymin] [ymax]
Plots the current MCA data spectrum. Does nothing when using GUI.
Setup file service.
Usage: mca_defaults [mask]
Sets default values to some global variables.
Usage: mca_max_channels (size)
Returns installed device full memory size. If the device is disconneted, the size specified as input is returned, so that simulation mode or loaded data analysis are possible.
Checks wether a MCA is configured and reads in its device server name or its device type. If it appears that no device is configured, it makes that the mca macros detach themselves from the SPEC standard ones.
Usage: mca_state ()
Checks MCA State. (acquiring, idle, disconnected or not configured)
Usage: mca_setup (adc,tm,sz,g,cal,lbl,un,nclr,slp,bgd,lg,dt,ln,eb,flag,red,syn)
Reads in setup parameters and do the setup. see "mcasetup" for details
Usage: mca_dosetup ()
Does the actual setup, i.e. hardware setup, general operation setup and subsequent software setup.
hardware setup, i.e. Adc selection, Memory initialisation, and operation setup, i.e. time mode and soft preset.
Usage: mca_wait ()
loops printing a message till the acquisition is finished.
Does things that must or need only to be done once at startup.
Loads roi from file, Reset|Declare shared memory ...
software setup, i.e. inits memory and assign newly set up parameters to the relevant globals.
Un-hooks MCA operation from the standard macros.
Usage: mca_roideldef ()
Un-hooks ROI operation from the standard macros.
Hooks MCA operation to the standard macros.
Saves to DATAFILE MCA ROIS description.
Usage: mca_roicdef ()
Hooks ROI operation to the standard macros.
"config" / "reconfig" service. Hooked to "config_mac".
Display MCA General menu. (page 1)
Prepares MCA memory group setting.
Display MCA CPLOT menu. (page 2)
Checks availability of some menu options.
Usage: mca_io (command,argument,flag)
Management of input/output to the MCA.
flag 0: returns what mca_par() returns or argument if error occured (cheat a bit)
flag 1: returns really what mca_par() returns.
Plots and prints out times while waiting for the acquisition to complete. This is used by "mcaacq" macro.
Usage: mca_key <key>
Manages a menu which is callable using input keys. see "mcaacq".
Usage: mca_preset (seconds)
Sets the preset time value for the next acquisition.
Usage: mca_read [first_ch] [last_ch]
Read the MCA memory within the channel range specified. Default reads the whole memory.
Usage: mca_times ()
Reads in times elapsed. (Live, Real and Dead time).
Reads in MCA spectrum and plots it. That macro is hooked to "user_getcounts".
Usage: mca_getcounts <ROI_counter_mnemonic> <channel_min> <channel_max>
Integrates counts on ROIs and updates SPEC counters register. This is hooked to "user_getcounts", one hook per counter-assigned ROI.
Usage: mca_integrate (channel_min,channel_max)
Integrates counts on channels region. This is called by "mca_getcounts". Does a backgroung substraction if that option is turned on in "mcasetup".
re-loads ROI definition from disk.
saves ROI definition to disk.
Usage: mca_roinum (roi_id)
Returns ROI number, or -1 if not found. "roi_id" is a ROI name or a ROI number.
Usage: mca_roidisp ()
Prints out ROI definition table.
Usage: mca_roisetname (no,name)
Assigns ROI number <no> with name <name>.
Usage: mca_roisetrange (no,min,max)
Assigns ROI number <no> with specified range.
ROI edition menu.
New ROI input.
ROI name input.
ROI range input.
Opens next MCA private file, and writes header on it.
Usage: mca_filename (prefix, number, suffix)
Returns MCA private file name.
Returns true when the saveload package macros are loaded.
Usage: mca_sl_test [string]
Checks if saveload macro package is loaded.
Applies data reduction on data in SPEC memory.
The reduction consists of:
Usage: mca_savescanhead (ch_min,ch_max)
Save file header during scans. Hooked to "measure2".
Usage: mca_savescandata (ch_min,ch_max)
Save MCA data during scans. Hooked to "user_scan_loop".
Usage: mca_savectdata (ch_min,ch_max)
Save header and data to file after a "ct". Hooked to "user_handlecounts".
Usage: mca_saveacqdata (ch_min, ch_max, headline)
Save header and data to file after a "mcaacq". Called from "mcaacq".
Usage: mca_chtoE <array1> <col1> <array2> <col2>
Same as ps_chtoE from psearch.mac package. i.e., converts all the channels in array1[col1] to energies and puts these values into destination array2[col2]. The calibration function E=a+b ch + c ch^2 is used.
Reads in parameters from shared memory (GUI).
calibration parameter A.(Shared memory)
calibration parameter B.(Shared memory)
calibration parameter C.(Shared memory)
Usage: mca_Ech <mode> <energy> <channel>
Converts calibrated value into channels (mode 1) or reverse (mode 0) and returns the result.
Calculated the channel from the given Energy
Calculated the channel from the given Energy
Writes out parameters to shared memory (GUI).
Returns non 0 value if psearch macro package is loaded.
Usage: mca_ps_test [string]
Check if psearch macro package is loaded.
Decides between data in memory or in files for cplot.
Arranges cplot parameters for MCA private needs and calls cplot program. Recover previous cpsetup settings when finished.
not implemented yet. foreseen for c-plotting MCA data from a file.
Checks wether the GUI is running, otherwise starts it.
Usage: mca_guistart ()
Starts the Graphical Interface and returns its PID number.
Just an indirection for mca_plot1 for the sake of the GUI.
Usage: mca_plot1 (group,xelem,yelem,xmin,xmax,ymin,ymax)
MCA running plot.
Usage: mca_resize_to_roi <roi> <channel_min> <channel_max>
Resises specified range to the specified roi. (in channels)
Usage: mca_resize_to_last_read <channel_min> <channel_max>
Resises specified range to the last read spectrum range. (in channels)
Transfers data spectrum held in the shared memory into SPEC data group.
Usage: mca_msgw (seconds)
loops printing dots for the specified time (sec.).
Usage: mca_getoffset (name,column,xmin)
Returns array row number of first "xmin" value occurence in the specified array column.
Usage: mca_getnpts (name,column,xmin,xmax)
Returns number of points between first occurences of "xmin" and "xmax" in the specified array column.
Macro which is run once at mca.mac file loading to prepare things up.
Usage: mca_getroi <roi_number|roi_name> <mode> <first> <last>
Converts ROI into <first> and <last> range limit.
Converts channels into calibrated value all over the defined ROI.