Loopif...loopfail... command (parameter-list environment)}

The LOOPIF command is a parameter-list form of the IF command, i.e. it executes an IF test for all words in an input parameter-list. Each time an item from the list (or item pair from the lists) is found that satisfies the test statements1 are executed.

If the input list is a word parameter list (See Createlist command) then for each test the current parameter value being tested is placed in the reserved variable WORDX (or WORDY for parameter-list-namey).

For the LOOPIF...MASKEDBY bitmask-set-name and LOOPIF...GATEDBY commands, the gate number passed each time is placed in the reserved variable GATE.

If the NEWLISTX and/or NEWLISTY (for the second list in 2D gate-map case) keywords are used to specify output parameter lists then for each parameter which satisifes the test all the other parameters in the input list are copied to the specified output lists.

If no parameter-list items satisfy the test and LOOPFAIL has been specified then statements2 are executed.

Example

Consider the case where 2 group parameter lists are being tested together against a 2D gate-map. Each valid word in the first list is tested with all valid words in the second list:

CREATELIST LIST1 GE30
CREATELIST LIST2 GE150
LOOPIF LIST1.E2 LIST2.E2 GATEDBY GATES1  NEWLISTX=LIST1A  NEWLISTY=LIST2A
   INC MAT6(LIST1A.E2,LIST2A.E2)

i.e. all the combinations of E2 words in lists LIST1 and LIST2 will be tested. For those combinations which pass any of the gates in the gate-map GATES1 then the INC command will cause all permutations of the remaining E2 words in the lists (LIST1A and LIST2A) to be incremented into the 2D spectrum MAT6.


Validation test operator (VALID)

For a word parameter list, statements1 are executed for each word in the list which is present in the event. For a group parameter list, statements1 are executed for each group in the list which is present in the event. If the optional " $-word=" is specified in the command then the group identifier is assigned to the $-word variable for each iteration of the loop.

Comparison operators (EQ,NE,GE,LE,GT,LT)

In this format of the LOOPIF command all words from parameter-list found in the event are compared with the value of sortword or expression according to the operator specified. For each case which gives the result true then statements1 are executed.

Example

CREATELIST  GELIST  FROM  GE
LOOPIF GELIST.E1 GT THRESHOLD {
    INC SPEC1(GAMA)
    INC SPEC2(TAC)
    }
LOOPFAIL  EVENTEND

In the above example, the spectrum increments are performed if the value of GELIST.E1 is greater than that of sortword THRESHOLD. Otherwise event processing is terminated for that event (EVENTEND command).


Filtering operators (PASSES,FAILS)

The first form of the command allows valid member of parameter-list to tested against the gate defined by the expressions lower-limit and upper-limit. In the second form of the command each valid member of parameter-list to tested against a gate in the array gate-array-name (See Gate-Array command) where the array element number used is given by the expression index.

Example

*DATA
GATEARRAY TACGATES
1 (100 4000)  2 (90 4000) ...
 ...
*COMMANDS
CREATELIST  GELIST  FROM  GE
LOOPIF $GROUPX=GELIST.TAC PASSES TACGATES($GROUPX) {
     ...
    }

LOOPIF...PASSES is true for each case where a member of parameter-list falls inside the gate defined by lower-limit and upper-limit inclusive. Conversely LOOPIF...FAILS is true for each case where a member of parameter-list is present in the event and falls outside the limits of the gate.

Masking operator (MASKEDBY)

LOOPIF...MASKEDBY is true for words in the list where all the bits set in the 16-bit mask or a gate in bitmask-set-name are present in the word being tested. For the latter case the gate number passed is placed in the reserved word GATE.

Gate-testing operator (GATEDBY)

LOOPIF...GATEDBY is true for each case where a member of parameter-list falls within the set of gates associated with gate-expr. Whenever a gate is passed the gate number will be placed in the reserved variable GATE. The data defining the gate limits within the gate-map is specified in the *DATA section.

In the above case each member of the parameter-list found in the event is tested against the gate-map specified,

Example

  ...
*DATA
GATEMAP 1D MASS130A[0:600]
(100 180) (160 270) (250 340) (330
 460) (440 560)
  ...
*COMMANDS
  ...
CREATELIST RLIST1 FROM GE
LOOPIF RLIST1.E2 GATEDBY MASS130A  NEWLISTX=RLIST2 {
       ...
    LOOPIF RLIST2.E2 GATEDBY ... {
           ...
         }
    }

For the 2D gate-map-test format one or both of the parameters to be tested must be a list-expression,

Example

  ...
*DATA
GATES 2D MAP1[64,64]
(12 20  20 22  23 26  19 31  17 27  16 23)   (19 24  25 21  30 27  31 38
29 40  26 38  23 26  21 24)   (35 28  38 32  40 33  42 41  40 45  38 41
37 39  36 32)
  ...
*COMMANDS
  ...
SUMEN = ...
CREATELIST GELIST FROM GE
LOOPIF GELIST.E2 SUMEN GATEDBY MAP1 NEWLISTX=OUTLIST1 {
    LOOPIF OUTLIST1.E2 GATEDBY ...
       ...