musr_config for MUSR experiment
musr_config is run by the MUSR experiments as a daemon.
It is a MIDAS client
running under linux that runs on a PRESTART transition.
The MUSR experiment requires a number of parameters be set up prior
to the start of a run. These parameters are stored in the Midas online
data base (odb) . The parameters are normally set up by the user using
a custom-built interface written in Tcl,
but they may also be set up using the Midas browser or with odbedit.
These parameters must be checked for validity, and various calculations
made, and the results written to various areas of the odb for communication
with the frontend and other clients. This is handled by musr_config,
The front-end program aborts the start-of-run if the parameters
have not been validated recently by musr_config , or if the supplied
parameters are invalid,
Musr_config is linked with experim.h
<back to the top>
musr_config is divided for convenience into a number
of subroutines which do the following calculations/checks:
NOTE: all unused values in histogram arrays are set to -1, and unused
values in histogram titles arrays are set blank
Accesses musr area of odb "/equipment/musr_td_acq/settings"
for rig and mode to find INPUT parameters:
list of defined counters, their TDC input no., their I/O reg output
list of selected counters for histogramming
number of defined and selected counters
status of Dual spectra mode (enabled / disabled)
status of VME IO reg (enabled/disabled)
number of selected counters is valid (i.e. greater than 0, less than total
number of defined counters)
tdc resolution code and bytes per bin are valid.
Checks that the number of bins requested is less than maximum midas
event buffer size. If the requested number is too large, the
maximum number of bins available is used. Note: presently the limit on
the number of bins is the midas event buffer size, rather than the free
space available for histogram storage in the power pc.
checks that selected counters appear in defined counter array, checking
for duplicates and blank names
checks number of characters in counter names - truncates if necessary
checks selected channels of IO register (1-8 are valid)
generates list of selected TDC Inputs and histogram titles
generates TDC input bit pattern and IO register bit pattern for frontend
checks for duplicate TDC Input numbers
sort selected tdc inputs into ascending order
generate an HM_index array so frontend can send data out in counter order
Check for dual spectra mode and generate histogram arrays from the
For DUAL SPECTRA mode:
2 histograms per counter
checks suffixes are valid (not duplicate or blank, 2
characters maximum, otherwise uses defaults)
generate histogram titles from counter names and suffixes
& truncates if needed
double up selected TDC input arrays, sorted and
double up bit pattern for TDC inputs
turn on bit 0 in IO register to indicate dual spectra
For NORMAL mode:
1 histogram per counter
checks title length only
Writes calculated data into odb area: "/Equipment/musr_td_acq/Settings/output/selected
number of selected counters
number of histograms
arrays of selected TDC inputs, sorted TDC inputs, and HM_index
TDC input and IO register bitpatterns etc.
Calculates the data shift from the tdc resolution code,
and writes parameters needed by the frontend to the odb
e.g. number of bins, bytes per bin, shift, bit pattern of selected TDC
inputs, IO register bit pattern, HM_index etc.
write data into mdarc area in odb
e.g. camp host name, save interval for mdarc, number of bins,
resolution code, number of histograms,
histogram bin limits, beamline etc.
<back to the top>
checks whether scaler is enabled
checks the number of scaler channels is valid (16 channels maximum) -
highest 4 may be assigned to IMUSR
checks scaler channels are in ascending order, are not duplicated, and
are between 1 and 16
calcultates scaler input bit pattern (required by frontend)
truncates scaler titles at 32 characters
checks enough titles are supplied, and titles are unique
writes scaler data into scaler area in odb: "/equipment/scalers/settings"
Note: the order of the saved histograms (i.e. counter order)
PROGRAMMING NOTE: Counter Order
In the saved file, the histograms must be in Counter order. All
bin parameters (first good, bin zero etc) are in Counter Order. Counter
Order is determined by the order of the counters given in the rig.
Internally, the frontend stores histograms in TDC input order
(with unused inputs suppressed so that maximum use is made of the available
memory), and uses one level of mapping to achieve this.
The histograms must be sent out from the frontend in counter order,
so a second level of mapping is needed. This is implemented by using an
index into the data array (HM_Index) to select correct histogram
data for a particular counter.
Also dual spectra mode DOUBLES the no. of histograms generated.
Normal mode : 1 counter -> 1 histogram
Dual spectra mode: 1 counter -> 2 histograms
The histograms are sent out as "sample" histograms in counter order
followed by "reference" histograms in counter order
<back to the top>