Trigger Programming for Hall A Spectrometers


   Notes on Trigger Programming for e94104, e98108, and e00102
   ===========================================================

 For other experiments search the README* files on adaq
 account in the trigger directory.

 update Oct 4, 2001
 experts:  R. Michaels and  B. Reitz

 I. Overview

 The main triggers (T1 on R-arm and T3 on L-arm)
 and T3 on L-arm) are formed from an overlap of S1 and 
 S2 scintillators.  This is described in detail below.

 The triggers are

       T1 = Main R-arm trigger
       T2 = Loose R-arm trigger, for measuring efficiency
       T3 = Main L-arm trigger
       T4 = Loose L-arm trigger, for measuring efficiency
       T5 = coincidence of T1 and T3.

 In addition, the old S-Ray trigger (involving MLU) will
 be formed, but not put into trigger supervisor, hence no
 events of that type.  Instead the S-Ray trigger will only
 be put into a scaler, its rate should be similar to the
 main trigger.

 The MLU is used to form T2 and T4.  It could possible be used 
 to form additional triggers that require other detectors.

 Let us first describe the MAIN TRIGGER, T1 and T3, which
 is based on scintillators.  First the Left and Right PMTs
 are AND'd.  There are then 6 signals from each scintillator
 planes S1 and S2 (the result of L+R).  These 6 are OR'd to 
 make one signal each from S1 and S2.  Finally, the trigger 
 is the AND of these two signals.  Here is an ASCII diagram:

 S1 - paddle 1 - Left   --\
 S1 - paddle 1 - Right  ---AND -->
 S1 - paddle 2 - Left   --\       \ 
 S1 - paddle 2 - Right  ---AND --> \ OR of S1
   paddle 3... 6                    \
                                     \ 
                                      \ AND -------> T1 (T3)         
                                      /
                                    / 
 S2 - paddle 1 - Left   --\        / OR of S2 
 S2 - paddle 1 - Right  ---AND -->
   paddle 2... 6

 The timing at the trigger supervisor will be such that T5 arrives
 thus it takes priority in deciding the event type.  However,
 one may look at the trigger latch pattern to see which triggers
 coexist.

 A ``trigger latch pattern'' in the datastream shows the
 pattern of triggers which co-exist in an event.  This is
 a TDC 1877 (multi-hit with up to 6 hits, a 5 microsec 
 window, one trigger on each of 12 channels, each channel
 a separate trigger) which shows on channels 1-12 the
 trigger 1-12 AFTER prescaling.  So, if a T5 is accompanied
 by a T3 which survived prescaling, one would see a signal
 on channels 3 & 5 with the appropriate timing.  This 
 trigger latch pattern is called ``spare7'' in the detector
 map.

 How the coincidence time is measured, and some explanation of
 the glitchy features seen there, are explained in this document:
 ctime.ps (postscript).

 Electronics deadtime is a complicated issue.  There can be losses
 in the trigger electronics, but also smearing of distributions
 (TDCs, etc), and pileup in VDCs.  To provide a handle on some
 of these things we have implemented a scheme to measure the
  electronics deadtime.



 II. MLU Programming -- Concepts

 MLU#1

     Generate S-Ray pattern

        mlu1_Sray_left_generate.dat
        mlu1_Sray_right_generate.dat
        (left and right spectrometers)
   R-arm has bit 14 bad, hence different.

     Generate S1-or and S2-or
   (same files, though bit 14 bad on R-arm).

        s1or_generate.dat
        s2or_generate.dat

    Since Jan 1, the S-Ray trigger plays no role anymore,
    but it is put into scalers to count.

  MLU#2 

  This MLU is run in strobed mode with the strobe coming from
  the OR of S1, S2.  That means that at least one of S1,S2 planes
  must fire.

    Bits
         1 = S1-or
         2 = S2-or
         3 = Gas-Cerenk (if exists), or S0-PMT#1 (if exists)
         4 = S0-PMT#2 

    T2, T4 logic
      Ignore S-ray
      Veto if main trigger exists.
      For e94104 and e98108:  Require S1-or or S2-or.  
      Don't require Cerenkov.
      For e99117 and e97103:  Require 2 out of 3 from
      among S1-or, S2-or, and Cerenkov-or.
      For e00102:  Require 2 out of 3 from among 
      S1-or, S2-or, and S0.  S0 requires both of its
      ends to fire.

    Generate T2, T4 with

        mlu2_t2_generate.dat
        mlu2_t4_generate.dat

    These generation files have changed slightly since Jan 2001.
    For convenience I have saved the mlu2* files that were generated
    and used:
    mlu2_t2_e94104.data, mlu2_t4_e94104.data  used by e94104 and e98108
    mlu2_cer_t2t4.data  used by e99117 and e97103
    mlu2_s0_t2t4.data  used by e00102

        
 III. Technical Details of MLU Programming

The following is a typical script for generating the MLU files.

#!/bin/sh
# Directory is adaql1:~atrig/trigger/mlu
# Make Sray for left spectrometer
XYmlu -f mlu1_Sray_left_generate.dat
mlu_compress mlu.data
rm mlu.data
mv mlu_compress.out mlu1_Sray_left.data
# Make s1or and s2or (used for both spectr.)
XYmlu -f s1or_generate.dat
mlu_compress mlu.data
rm mlu.data
mv mlu_compress.out s1or.data
XYmlu -f s2or_generate.dat
mlu_compress mlu.data
rm mlu.data
mv mlu_compress.out s2or.data
# merge to form mlu1_left
mlu_bitmerge mlu1_Sray_left.data s1or.data
mv mlu_bitmerge.out temp.data
mlu_bitmerge temp.data s2or.data
mv mlu_bitmerge.out mlu1_left.data
# Make Sray for right spectrometer
XYmlu -f mlu1_Sray_right_generate.dat
mlu_compress mlu.data
rm mlu.data
mv mlu_compress.out mlu1_Sray_right.data
# merge to form mlu2_right
mlu_bitmerge mlu1_Sray_right.data s1or.data
mv mlu_bitmerge.out temp.data
mlu_bitmerge temp.data s2or.data
mv mlu_bitmerge.out mlu1_right.data
rm temp.data
# make MLU2 file for t2
XYmlu -f mlu2_t2_generate.dat
mlu_compress mlu.data
rm mlu.data
mv mlu_compress.out mlu2_t2.data
# make MLU2 file for t4
XYmlu -f mlu2_t4_generate.dat
mlu_compress mlu.data
rm mlu.data
mv mlu_compress.out mlu2_t4.data


=======================================================

  Appendix -- MLU utilities routines 

  Type the name of the utility without arguments and
  it will introduce itself, and explain its usage.

    XYmlu -- takes a pattern like 10xx01 and
    generates all mlu entries.  1=bit must be true;
    0=bit must be false; x=bit may be 0 or 1.
    There is a Y option, but it is little used
    and not too important.

    btst -- Examines a pattern of bits 

    mlu_compress -- Takes an mlu file and
    examines all pairs of line-entries.  If the
    two line entries are identical, one is kept,
    the other discarded (this isn't really necessary
    but speeds up the download).  Also the bit-wise
    OR of 2nd components is taken if first components
    are identical.

    mlu_compare -- Compares two mlu files
    to see what is different.  If no optional
    argument is given, any difference in the 
    file are noted.  If an argument is given
    (any number), only the first entry of each
    pair are compared.

    mlu_bitmerge -- Merges two mlu files.  For
    each pair of line entries "X1 Y1" from file 1
    and "X2 Y2" from file2, if X1=X2, then the
    two entries are merged to form bit-wise OR
    of Y1,Y2, i.e. we get "X3 Y3" where Y3 = Y1 | Y2.

This page maintained by rom@jlab.org