This example is similar to the previous one except that it contains a triple gate instead of a double one.
! compressed data sortfile
! triple gates updating 2D matrix
!
*FORMATS
gam[1:134] (tag:3, e4:13)
*DATA
!! gates for energy=e4/2
GATEMAP 1D gates1 [2050]
( 672 680) (1165 1175) (1346 1358)
(1474 1486) (1544 1556) (1686 1698)
(1566 1578) (2036 2048) (998 1006)
(1239 1249) (1433 1443)
*SPECTRA
!== sort spectra ======
triple2d 4096 2D
*COMMANDS
CREATELIST gamlist FROM gam
LOOPIF $c=gamlist.e4 VALID
$c.e4=$c.e4/2
if (NUMBER(gamlist)) LT 5
ENDEVENT
!! triple gated 2D update
!!
!! Use LOOPIF to decide whether the event satisfies 3, 4 or 5 gates
!! Then loop over the appropriate words in event to update matrix
!! and exit loop
!!
!! Update Algorithm:
!! For m-dim update and p gates, words which satisfy gates are g parameters,
!! all others are x parameters. Have 3 possible cases:
!! 1. satisfy exactly p gates -- update m-tuples from x params
!! 2. satisfy at least p+m gates -- update m-tuples from g+x params
!! 3. satisfy p+k gates, k<= m -- update m-tuples which involve <= k g params
}
!!
!! for this case:
!! 1. satisfy exactly 3 gates -- update doubles from listp3
!! 2. satisfy at least 5 gates -- update doubles from gamlist
!! 3. satisfy exactly 4 gates -- update g params with singles from listp4
!!
LOOPIF gamlist.e4 GATEDBY gates1 NEWLISTX=listp1
{
!! >=1 gate
LOOPIF listp1.e4 GATEDBY gates1 NEWLISTX=listp2
{
!! >=2 gates
LOOPIF listp2.e4 GATEDBY gates1 NEWLISTX=listp3
{
!! >=3 gates
LOOPIF listp3.e4 GATEDBY gates1 NEWLISTX=listp4
{
!! >=4 gates
LOOPIF listp4.e4 GATEDBY gates1
{
!! ...at least 5 gates satisfied in gamlist -- update all parameters
INC triple2d(gamlist.e4,gamlist.e4)
GOTO endloop1
}
LOOPFAIL
{
!! =4 gates
!! ...no gates satisfied in listp4
LOOPIF $a=gamlist.e4 GATEDBY gates1
{
INC triple2d($a.e4,listp4.e4)
INC triple2d(listp4.e4,$a.e4)
}
INC triple2d(listp4.e4,listp4.e4)
GOTO endloop1
}
}
LOOPFAIL
{
!! =3 gates
!! ...no gates satisfied in listp3 so listp3 contains just the x parameters
INC triple2d(listp3.e4,listp3.e4)
GOTO endloop1
}
}
}
}
LABEL endloop1
*RUNFILES
COMP1 RUN1
COMP1 RUN2
COMP2 RUN3
*FINISH