(Old) Trigger Programming for Hall A Spectrometers


   Notes on Trigger Programming for e94104 and e98108 (* ONLY *)
   ============================================================

 For earlier experiments search the README* files on adaq
 account in the trigger directory.  For later experiments,
 go back to the daq_trig.html page.

 update March 11, 2001, R. Michaels

 I. Overview

 Starting Jan 2001, the main triggers (T1 on R-arm
 and T3 on L-arm) do not need an MLU.  Instead they
 are formed from an overlap of S1 and S2 scintllators.
 This is described later.

 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.

 New for e98108 in March 2001, if I manage to set it up
 during the break between experiments, are two other triggers:

       T6 = T3.and.Some-combination-of-A1-A2 (see below)
       T7 = coincidence of T6 and T1.

 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 can also be used to
 form additional triggers like T6 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


 For e98108, the provision to use aerogel detectors A1 and A2
 will exist, *IF* I manage to get it set up in the break between
 experiments.  Assuming I do, the logic will affect two new
 triggers, T6 and T7, and will NOT affect any other triggers.
 T6 is defined as T3 plus some conditional on A1,A2.  T7 is
 the coincidence of T6 and T1.  So, T6 is like a "aerogel"
 version of T3, and T7 is analogous to T5.  One may keep prescaled
 samples of all the triggers and use the trigger latch pattern
 (see below) to determine the pattern of triggers.  

 There are 9 combinations of A1,A2 allowed in T6.  They are
 selected from the 3 possibilities for each of A1 and A2: 
 1) require to be true (i.e. above threshold); 2) required to 
 be false (below threshold), or 3) don't care (either 1 or 2).  
 By "A1" I mean the analog  sum of the A1 detector, similarly 
 for A2.

 The thresholds on the A1-sum and A2-sum signals can be set
 using the "expert mode" of trigsetup, see the setup directions
 at http::/hallaweb.jlab.org/equipment/daq/trigger.html.
 The thresholds are controlled on the 12th and 13th channels
 of the module "cherL_disc" in crate 2, slot 4.  In this discrim-
 inator, the first 10 channels are gas-Cerenkov, 11th is gas-C sum, 
 12 and 13 are A1 and A2 sum signals.  If the defaults need to be 
 changed, one may carefully change the trigger database so that 
 they are downloaded each time.  As I write this, the default is 
 30 mV, which is pretty low.

 The A1,A2 logic works as follows.  The signals from A1 and A2
 arrive at a Memory Lookup Unit (LeCroy 2373 MLU) about 20 nsec 
 earlier than the scintillator trigger T3.  The MLU is programmed 
 in transparent mode, which means it makes an output as soon
 as the logic on its inputs are satisfied, and the timing of
 the output follows the timing of the latest input (in this case
 T3).  The buttons in trigsetup simply choose which MLU file
 to download.

 The timing at the trigger supervisor will be such that T5 arrives
 first, and T3 will arrive before T6,T7.  Thus they lower trigger
 numbers may take 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.


 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 

    Bits
         1 = S-ray  (ignore it)
         2 = S1-or
         3 = S2-or
         4 = Gas-Cerenk (if it exists) 
         5 = main trigger (overlap of S1,S2)
         6 = A1  (L-arm, will be plugged in during April 2001 break)
         7 = A2  (L-arm,  ditto)

    T2, T4 logic
      Ignore S-ray
      Veto if main trigger exists.
      Require S1-or or S2-or.  Don't require Cerenkov.

    T6 logic
      Ignore S-ray
      Require main trigger (based on S1, S2 scintillators)
      Additionally require some combination of A1,A2 chosen by
      the 'trigsetup' GUI.

    Generate T2, T4 with

        mlu2_t2_generate.dat
        mlu2_t4_generate.dat

    Generate T6 with script described below (section III).

        
 III. Technical Details of MLU Programming

The following script generated the MLU files for e94104.
                                                 =======
#!/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


For e98108, the script for T6 and T4 on Left is below:
    ======

#!/bin/sh
# Directory is adaql1:~atrig/trigger/mlu
# MLU bit inputs are 1) S-Ray; 2) S1; 3) S2; 4) Gas-C;  5) T1; 6) A1; 7) A2  
# Bit outputs are 1 & 3 = (new) T6;  2 & 4 = T4
#
# Resulting file:
# mlu2_a1a2_KN.data  K,N = a1,a2  0 = false, 1 = dont care, 2 = true
#
# 
ubar="_"
gendat="gen.dat"
n0=0
n1=1
n2=2
for i in $n0 $n1 $n2 ; do
  for j in $n0 $n1 $n2 ; do
     genfile=mlu2_a1a2_$i$j$ubar$gendat
     mlufile=mlu2_a1a2_$i$j.data
     echo "Generating file = $genfile  Resulting MLU file = $mlufile"
     XYmlu -f $genfile
     mlu_compress mlu.data
     rm mlu.data
     mv mlu_compress.out $mlufile
  done
done


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

  Appendix -- MLU utilities routines 
              (Ported to Linux, Jan 2001)

  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