CHIL - A Comprehensive Histogramming Language

A high level language, CHIL, has been developed for use in processing event-by-event experimental data at the Holifield Heavy Ion Research Facility (HHIRF) using PERKIN-ELMER 3230 computers. CHIL has been fully integrated into all software which supports on-line and off-line histogramming and off-line preprocessing. CHIL supports simple gates, free-form-gates (2-D regions of arbitrary shape), condition test and branch statements, bit-tests, loops, calls to up to three user supplied subroutines and histogram generating statements. Any combination of 1, 2, 3 or 4-D histograms (32 megachannels max) may be recorded at 16 or 32 bits/channel. User routines may intercept the data being processed and modify it as desired. The CPU-intensive part of the processing utilizes microcoded routines which enhance performance by about a factor of two.


Introduction
All experimental data from nuclear and atomic physics experiments at HHIRF are acquired in 16-bit list-mode (i.e.event-by-event).Each event normally consists of several parameter identification words, one or more pattern words, about 10 to 100 data words, (experimental parameters from ADC's, TDC's etc.) and an end-of-event word.The HHIRF list-data structure is shown below (all numbers are in hexadecimal).In some cases, a preprocessing step is also carried out in which selected events (of a given type for example) are retrieved from an input data tape, possibly modified, and saved on an output tape for subsequent processing.
A general purpose high-level language, CHIL, has been devised and implemented on the HHIRF PERKIN-ELMER 3230 computer system which supports both pre-processing and histogram generation.CHIL allows the user to specify test conditions and histogramming specifications in a way which is much more simple and compact than an equivalent FORTRAN program.A special set of microcoded routines (which execute in Writable Control Store and define new machine instructions) are used for most of the basic CPU-intensive operations.This results in a program which is often more efficient than an equivalent assembly language program tailored to the specific task.
•Operated by Martii Marietta Energy Systems, Inc. under contract DE-AC05-840R21400 with the U.S. Department of Energy.
Although CHIL supports many of the basic data processing requirements, it does not attempt to cover everything that all users may wish to do.For this reason, a provision is made for calling user supplied subroutines from the CHIL program on an event-by-event basis.These routines receive the event in expanded form, modify the event data as desired and pass it back to the CHIL program for additional processing.This type of user customization has proved to be a very effective means of meeting special requirements while maintaining a high degree of generality, standardization and associated reliability.

Chit Syntax
A summary of the CHIL syntax is given in Table 1.This table does not include all possible variations of th § language but is intended to illustrate the basics.Most of the statement types are described below in more detail.

$LPR -Parameter Lengths
The parameter length defines the maximum number of channels (always a power of 2) to be associated with a given parameter.Two syntax forms are supported: An implied loop and an explicit list.
Lengths may be re-defined as many times as convenient but all lengths must be given at least once before another statement type is encountered.

$DIP & $ASS -Parameter Names
Names (up to 8 characters in length) may be associated with some or all parameter numbers and be used to reference said parameters in the CHIL program.Two steps are required: Tirst, the name must appear in a $DIP statement (dimension parameter statement) which is much like the FORTRAN dimension statement.Next, values must be assigned via the $ASS statement which has both implied loop and explicit forms.For the implied loop case, JLO is the first value to assign and JNC is the value increment to be added for successive assignments.

$D1M & SPAT -Indexed Symbols
Indexed symbols are arrays of constants which are named and dimensioned via the $DIM statement and have values assigned by means of the $DAT statement or by an equate of the form: SYM(J) = EXPRESSION.
Values associated with such symbols may be re-defined any number of times within the CHIL program but the value at a given point in the program is fixed at compile time.All symbols -(indexed or simple) are variables at compile time but constants at run time.
$BAN 8 SBAF -Free-Form Gates Free-Form-Gates must be created outside of the CHIL program (usually via the HHIRF display program RIP* and stored on a special file (BAN file).
Incorporation of such 2-D gates into a CHIL program requires one or more $BAN statements which sr>ecifify the gate ID-numbers (IDA, I0B ...)'to be retrieved from the file and the X-length (LENGTH) to be allocated for storage of the gate tables in memory.The BAN-file to be processed may be specified in the CHIL program by the $BAF statement or may be deferred until run time.

SGLST & SHAPL -Gate Sets
Multiple gates which are to be imposed on a given parameter may be specified by the SGLST statement.Here LENGTH denotes the "parameter length" basis on which the gates are defined and ISN the set number by which the gate list is to be be referenced.Gates specified in a given $GLST statement may not overlap.If a large number (5 or more) gates are to be imposed on a given parameter, processing will proceed faster if the gates are "mapped" 2 .To do this one specifies the gates by means of the $MAPL statement.Otherwise, the rules are exactly the same as for the $CLST statement.As many continuation Tines as required are allowed.

ExDressioni
The CHIL compiler supports simple expressions which arc evaluated left to right.Let V represent a single value (number or previously defined symbol) and S an algebraic sum of Vs.The left hand side (A) as well as V and terms in S may be indexed symbols.Parenthesis are not allowed except for indexed symbols and the (MOD) expression.Legal forms follow: ;C ] encloses a list of bit numbers

Gating conditions
Two types of gating conditions are supported: One parameter (1-D) gates of the lo-limit, hi-limit type and two parameter (2-D) gates which are defined by a clockwise set of X,Y coordinates in two parameter space.The latter type may also be referred to as a frea form gate or Dy the slang term Banana gate due to fact that such regions defined on E vs E*DE plots often exhibit this shape.Gates may be specified singly or by multiple gate sets (.OR.lists).See Table 1 for a list of legal forms.The IFC test may be applied to a multiple 1-D or 2-D gate set as indicated.The first condition in the set to be satisfied determines the branch to be taken.If no condition is satisfied, the program drops through to the next run time executable statement.

H-Statements -Histogram Generation
The histogram statement (H-statement) specifies which parameters are to be histogrammed, the length of each histogram din.nsion, the range of interest and gating conditions.The L-specification L(LI,LJ ..) tells CHIL how many bits to shift the raw parameters prior to histogramming.The R-specification R(LOI,HII LOJ.HIJ ..), which is optional, can be used to select a limited' portion of the histogram dimensions given by the L-specification.
In general, the CONDITION field may actually include several single and/or multiple condition specifications (gate lists or sets).Each specification is considered to be an OR-list which contains one or more members.For the case where more than one OR-list is specified, these are "ANDED" together to produce multiple histograms.In other words, you will get a count "somewhere" if and cnly if some member of each OR-list is satisfied.If you have N OR-lists and NG(I) represents the number of gates in the Ith list, then the number of histograms (NH) actually implied is given by: NH = NG(1)*NG(2)* NG{N-1)*NG(N).

OH-Statements -Histogram Overlays
The OH-statement has exactly the same meaning as the H-statement except that the histogram origin is not advanced.That is, histogramming takes place in the "space" defined by the most recent H-statement.

Loops
Loops are implemented so as to look like FORTRAN but are actually expanded by the compiler so that loop parameters are constants.In the following example we produce 72 1-D histograms of parameters 1,4,7...214 with a gate (500,1000) set on associated parameters 2,5,8...215.
DO 100 1=1,214,3 J=I+1 H(I) L(512) G(J,500,1000) 100 CONTINUE CALL REPACK -Pre-Processing Pre-processing (as interpreted here) involves the processing of an input data stream to produce one or more output data streams (usually from and to mag tape).The processing may include selection of certain events or parameters, the modification or creation of parameters or any combination thereof.A CHIL based preprocessing task involves the use of HHIRF program LEMO (or a customized version thereof) to control the process combined with a CHIL program which directs the processing and selection.Modification or creation of parameters will normally require one or more user supplied subroutines (USERSUBS).The CHIL program may include any legal statement except for the H-statement.The statement CALL REPACK-initiates the "saving of an event" into the output data stream.In the following simple example, all parameters of the event are saved only if parameter 1 exists.

SLSTL-.
= 8192 $NPR 18 $LPR 1 TO 18 = 2048 IFN(l)100 CALL REPACK1 1,18 100 CONTINUE ;Tape record length (bytes) ;Number of parameters ;Length of parameters 1-18 ;Test for existance of P-l ;Save event in stream-1 CALL USERSUBX -User-Supplied Subroutines • One is able (by means of from 1 to 3 user supplied subroutines named.USERSUB1, USERSUB2, USERSUB3) To intercept and modify the event-by-event data stream that is being processed by a CHIL based tape scan, prescan, or on-line monitor task.The interception occurrs after the event is unpacked (i.e.all parameters are properly positioned in the event array and any parameters not present in the raw event are initialized to hexadecimal FFFF).Created or modified parameters may be, subsequently, tested and histogammed in the same way as any others.Stock processing tasks include dummy usersubs while customized tasks are produced by linking the user's special routines, which may include a command processor and other support routines, .with the standard main package.A skeleton USERSUB which just sets P-50 = P-l is shown below:

CHIL Compiler Output
The CHIL compiler processes the source program and generates an instruction list which contains opcodes, gate values and/or addresses, test parameter and histogram parameter addresses, histogram base offsets etc. and stores this "object code" in the Instruction Region of an array (CHIL array).Gate lists, maps and 2-0 gate tables are stored in a Data Region of this array as indicated below.The CHIL array is written onto a disk file which the processing program, subsequently, reads and uses to direct the operation of the microcoded procedures which do most the actual processing (histogram generation or new data stream construction).The CHIL processor goes through the complete instruction list once per event -branching as dictated by the data.

Microcoded Procedures
The Instruction Region of the CHIL array is composed of combinations of the opcodes (and associated date elements) given in the following list (i.e.these are the procedures available to the compiler).In this list ACC denotes the one accumulator at our disposal.A block diagram of a customized CHIL based histogramming program is shown in Figure 1.Histogram addresses to be incremented are pushed into partial sort buffers and processed via two phase sorting2 to produce histograms on disk.On-line monitor tasks accumulate the first 512K channels in memory.

Conclusions
CHIL has been in general use at HHIRF for about six months and has provided major improvements in both performance and ease of use of our processing software.An important feature of CHIL is it's robustness.First, the microcode is hardened against unexpected (illegal) data.Secondly, the CHIL compiler was designed with thorough syntax and logic checking to insure that illegal instructions are never generated.User acceptance of the new system w^s so immediate and trouble-free that CHIL has completely superseded all our older histogramming software.
Processing of such data usually involves tests on the pattern word bits, simple (1-D) gating, freeform (2-D) gating, tests for the existance of parameters and the generation of a number of one-and two-parameter histograms.
S) ;Means: A=(S)*V+S ;Means: A=(S)/V+S ;Means: A=((S)/V)*V+S ;No additional terms are allowed ;(same argument definition as FORTRAN) A=S+[S,S,..] Test And Branch Legal forms are: IFS(G(P LO.HI)) LABEL IFU(G(P LO.HI)) LABEL IFS(B(PX,PY ID)) LABEL 1FU(B(PX,PY ID)) LABEL These two IF statements may be applied to a single 1-D gate: G(P LO.HI) (where P denotes the test parameter and LO.HI the test limits) or to a single 2-0 gate: B(PX,PY ID) (where PX and PY denote the test parameters and ID the ID number given in the $8AN specification).If the stated requirement is met, the program branches to LABEL, otherwise, it drops through to the next run time executable statement.IFX & IFN -Test And Branch On Parameter Existance These two IF statements test the specified parameter value for hexadecimal FFFF (non existant) and branch to the given label if the requirement is met.All legal forms are given in Table 1.IFP -Multiple Branch On Parameter Value IFP tests the specified parameter (P) and branches to LI if P=0, L2 if P=l, etc.This test provides a means by which a test parameter created in a USERSUB may be used to direct the flow of the CHIL program.IFC -Condition-Set Testing Legal forms are: IFC(GS{P,IS NA.NB)) L1.L2.L3,... IFC(B(PX,PY IDA.IDB)) L1.L2.L3,...

Table 1 .
Summary Of CHIL Syntax