Tuda logbooks General E1104 ISACII E1195 E1103 E1147 S1287 S1203 S1233 S1284 S1447 23Na(a,p) S1540 S1381  S1847 Catania
  S1284  ELOG logo
Message ID: 2     Entry time: Fri Nov 29 16:00:09 2013
Author: Naomi 
Type:  
Category: General 
Subject: MIDASUK sort 

1) some info is written in tuda/Documents/READMEs/readme.MIDASsort

MIDAS Main Menu -> Sorting -> MIDASsort

enter sort.f file in Sortfile window and compile with Compile Sortfile

- example file sort3.f with the variables.dat file that contains gain, offset, calibration and other variables, is attached below.

- the base code which just unpacks data without sorting it, sort.f is also attached

- make sure you have the correct path for the variables.dat file in sort3.f

- Note that this variables.dat file was downloaded on a Mac OSX and which adds extra invisible characters at the end of each line and therefore won't be read in properly in MIDASsort.

for online sorting go to Input Media -> Online

for offline sorting go to Input Media -> Disc, the Disc Info. Browse file, Add it and Save and Quit

hit Start button to run sort file. the output is printed in the terminal running MIDAS-session

in Spectrum Directory Browser or Spectrum Viewer go to Resource -> SortSas the Redisplay. here you'll see all spectra created in sort.f

you can add a spectrum title files like the example given below in the Spectrum Directory Browser via Actions -> Apply title and then Options -> Details

- you can add titles for the Resource -> hist spectra with the another title file

if the spectra don't refresh properly Select all and Actions -> Delete in Spectrum Directory Browser and then Start the sorting program 

 

2) you can view online spectra in Spectrum Directory Browser -> Resource -> hist

remember to Select all and Actions -> zero and deselect if you want to view only the current run, otherwise you are seeing the spectra of incremented runs

 

3) to get gain, offset and calibration coefficients go to tuda/Documents/READMEs/readme.calibration

you need to have pulsar runs with amplitude varied from 90,000 to 10,000 in step size of 10,000 and the peaks should span the entire spectrum if possible and all contain ~1000 counts

you need 3-alpha calibration source runs

- gain and offsets are calculated for ADCs and offsets only for TDCs since clock is the same and there are offsets due to cable lengths, hence delay times

- Tom did this for us since we couldn't figure out the first step in the readme file using the peakfind program. The correct syntax for future knowledge is:

peakfind -spectrum <spectrum file name> -limit <low limit> <high limit> -fwhm <fwhm> -accept <accept>

 

4) to view scalars during run go to VME Module Control -> CEN V560 scalar and wait 10 s for refresh rate

 

5) meaning of c and w variables in sort3.f

c(0) and c(1) are calibration constants

c(8) and c(9) are used in equation pi (particle identification) which uses the total energy of S2 delE and E

c(8)=b is based on the semi-empirical range formula of charged particles in the detector r=(a*E)^b. You can find the values in the Knoll book of F. Goulding paper.

c(9) stretches the spectrum and can be a value between 0.5 and 5

w(0) and w(1) are windows for the (front strip - back strip) S2 delE values which should be a Gaussian peak centered around 2048, an arbitrary value so that the center is not around 0.

w(2) and w(3) are the same but for S2 E

w(17) and w(18) are windows used to select a particle type from the equation pi

w(19) and w(20) ignore. was used for a second delE and E detector in a previous experiment

 

6) summary of spectra created and used in sort3.f:

0-351 1D ADC histograms

3100-3115 1D scalar histograms

3000 1D channels w/ hits

3003 2D ADC ch vs ADC histo ch

3006 1D multiplicity + (3000 + number of good delE hits) + (3100 + number of good E hits)

3050 2D S2 delE front vs back

3060 1D S2 delE (front - back)

3051 2D S2 delE good front vs back

3061 1D S2 delE good (front - back)

3052 2D S2 E front vs back

3062 1D S2 E (front - back)

3053 2D S2 E good front vs back

3063 1D S2 E good (front - back)

4000 2D S2 energy vs annulus strip + (48 + energy vs annulus strip)

4010 2D S2 delE vs E

4011 1D pi

4012 2D pi vs tot energy

4013 1D total energy of selected particle using gates w(17) and w(18)

 

7) unpacking raw data in sort.f

ADC channels are put into channels 0-999

ADCs have 32 channels each and the first module is in the right slot of the VME crate.

TDC channels are put into channels 1000-1999 and ADC channel 1 corresponds to TDC channel 1001

TDC have 128 channels but only 112 channels are used. The first 16 are empty. So channels 16-127 from TDC#1 are put into channel 1000-1111 and from TDC#2 into channel 1112-1223, etc

Attachment 1: sort3.f  33 kB  | Hide | Hide all | Show all
*trigger
128  
*oned
0..351  s 4096
1000..1335  s 512
3000  s 1024	
3001  s 1024	
3002  s 1024	
3006  s 4096	
3060..3067  s 4096
3100..3115  s 16384
4011  s 1024
4013  s 1024
4015  s 1024
4017  s 1024
*twod
2000..2335  s 512 512
3003  s 512 512
3004  s 512 512
3005  s 512 512
3050..3057  s 512 512
4000..4007  s 512 512
4010  s 512 512
4012  s 512 512
4014  s 512 512
4016  s 512 512
*vars
*sort
C----67---------------------------------------------------------------72------80
C http://npg.dl.ac.uk/MIDAS/manual/MIDASsortHOWTO/info.pdf
      SUBROUTINE init

      IMPLICIT none

      SAVE
C
C     External functions
C
      EXTERNAL de_1h_al, de_1h_cd2, dtime, elab2ex, gate2d, path_factor
      EXTERNAL s2order, s2_1_theta, s2_3_theta
C
      INTEGER and, gate2d, int, rshift, s2order
C
      REAL de_1h_al, de_1h_cd2, dtime, elab2ex, float, path_factor, rand
      REAL s2_1_theta, s2_3_theta
C
C     Parameter variables
C
      INTEGER maxadcs
      PARAMETER (maxadcs = 2200)
      INTEGER adcs_max
      PARAMETER (adcs_max = 11*32)
      INTEGER tdcs_max
      PARAMETER (tdcs_max = 3*112) !not 3*127?
      INTEGER maxscalers
      PARAMETER (maxscalers = 16)
      INTEGER maxepics
      PARAMETER (maxepics = 64)
      INTEGER event_prescaler
      PARAMETER (event_prescaler = 1000000)
      INTEGER scaler_prescaler
      PARAMETER (scaler_prescaler = 1000000)
      INTEGER epics_prescaler
      PARAMETER (epics_prescaler = 1000000)
C
      LOGICAL csm
      PARAMETER (csm = .true.)
C
C     Local variables	!**********************************************
C
      INTEGER channel, counter_old(0:maxscalers-1), data(0:maxadcs-1)
      INTEGER epics_counter, events, events_old, gate1(18), good_s2_1
      INTEGER good_s2_1_back(0:63), good_s2_1_front(0:63), good_s2_2
      INTEGER good_s2_2_back(0:63), good_s2_2_front(0:63), i
      INTEGER*2 i2(2)
      INTEGER i4, ierr, iflag, ireturn, ix, iy, j, k, l, monitor(0:9)
      INTEGER monitor_old(0:9), m_adc, m_tdc, scaler(0:maxscalers-1)
      INTEGER scaler_old(0:maxscalers-1), sc_counter, sector
      INTEGER sum(0:maxscalers-1), type, w(0:31)
C
      LOGICAL good_s2_1_event, good_s2_2_event, hit(0:maxadcs-1)
C
      REAL c(0:31), de1, de2, dt, e(0:adcs_max-1), e1, e2, ediff
      REAL epics(0:maxepics-1), event_rate, e_lab, e_x
      REAL gain(0:maxadcs-1), lt, offset(0:maxadcs-1), pi, r4
      REAL rate(0:maxscalers-1), temp, time(2)

C
C     Namelists
C
      NAMELIST /variables/ offset, gain, c, w
C
C     Common variables
C
      INTEGER*2 adc_data(0:maxadcs-1)
C
      COMMON /fdata/ adc_data
C
C     Common variables
C
      INTEGER*2 adcs(0:maxadcs-1)
C
      COMMON /fid/ adcs
C
C     Common variables
C
      INTEGER noadcs
C
      COMMON /fmult/ noadcs
C
      EQUIVALENCE  ( i4, i2( 1 ) )

C     MIDAS polygon
C     {{396 96} {404 109} {421 124} {448 144} {475 144} {454 129} {432 113} {416 96}}
C
!**********************************************
      DATA gate1 /396, 96,404,109,421,124,448,144,475,144,454,129,
     +            432,113,416, 96, -1, -1/

C----67---------------------------------------------------------------72------80

      WRITE ( 6, * ) ' *** S1284 - sort3 - November 2013'
      WRITE ( 6, * ) ' *** Entry init commences'

C     Initialise arrays for unpacked event data.

      DO i = 0, maxadcs - 1
       data( i ) = 0
       hit( i ) = .FALSE.
      ENDDO

C     Initialise gains/offsets

      DO i = 0, maxadcs - 1
       gain( i ) = 1.0
       offset( i ) = 0.0
      ENDDO

C     Initialise constants/1D windows

      DO i = 0, 31
       c( i ) = 1.0
       w( i ) = 0
      ENDDO

C     Initialise scalers

      DO i = 0, maxscalers - 1
       scaler( i ) = 0
       scaler_old( i ) = 0
       counter_old( i ) = 0
       rate( i ) = 0.0
      ENDDO

C     Initialise counters

      sc_counter = 0
      epics_counter = 0
      events = 0
      events_old = 0
      channel = 0

      DO i = 0, 9
       monitor( i ) = 0
       monitor_old( i ) = 0
      ENDDO

      OPEN( 1, FILE = '/home/tuda/S1284/calibration/variables.dat',
     + IOSTAT = ierr )
      IF ( ierr.NE.0 ) THEN
       WRITE( 6, * ) ' *** OPEN I/O error:', ierr
       RETURN
      ENDIF
      READ( 1, NML = variables, IOSTAT = ierr )
      IF ( ierr.NE.0 ) THEN
       WRITE( 6, * ) ' *** READ I/O error:', ierr
      ENDIF
      CLOSE( 1, IOSTAT = ierr )
      IF ( ierr.NE.0 ) THEN
       WRITE( 6, * ) ' *** CLOSE I/O error:', ierr
       RETURN
      ENDIF      

C     Display program variables

      DO i = 0, adcs_max-1, 8
       WRITE( 6, 9001 ) i, i+7, ( gain( j ), j = i, i+7 )
      ENDDO

      DO i = 0, adcs_max-1, 8
       WRITE( 6, 9002 ) i, i+7, ( offset( j ), j = i, i+7 )
      ENDDO

      DO i = 1000, 1000+tdcs_max-1, 8
       WRITE( 6, 9002 ) i, i+7, ( offset( j ), j = i, i+7 )
      ENDDO

      DO i = 0, 31, 8
       WRITE( 6, 9003 ) i, i+7, ( c( j ), j = i, i+7 )
      ENDDO

      DO i = 0, 31, 8
       WRITE( 6, 9004 ) i, i+7, ( w( j ), j = i, i+7 )
      ENDDO

      WRITE ( 6, * ) ' *** Entry init ends'

      RETURN

C----67---------------------------------------------------------------72------80

      ENTRY sortin

      events = events + 1

      IF ( MOD( events, event_prescaler ).EQ.0 ) THEN
       rate = FLOAT( events - events_old ) / dtime(time)
       WRITE( 6, * ) ' *** event:', events, ' (', rate,' events/s)'
       events_old = events
      ENDIF

C     Convert Eurogam type 0 ID to (a more) logical channel number.
C	ADC data	channels 0-999
C	TDC data	channels 1000-1999
C	Scaler data	channels 2000-2099
C	EPICS data	channels 2100-2199

      call egid2logical( noadcs, adcs, adc_data, type, csm )

C----67---------------------------------------------------------------72------80
C     Event data.

      IF ( MOD( events, event_prescaler ).EQ.0 ) THEN
       WRITE( 6, * ) ' *** Packed event:', events, ' noadcs:', noadcs
       DO i = 0, noadcs - 1
        WRITE( 6, 9050 ) adcs( i ), adc_data( i )
       ENDDO
      ENDIF

C     Unpack event data from packed data arrays.
c If you want to write events in ascii format do it here event number = 'events'

      DO i = 0, noadcs - 1
       IF ( adcs( i ).GE.0 .AND. adcs( i ).LT.maxadcs ) THEN
        data( adcs( i ) ) = adc_data( i )
        hit( adcs( i ) ) = .TRUE.
       ENDIF
      ENDDO

      IF ( MOD( events, event_prescaler ).EQ.0 ) THEN
       WRITE( 6, * ) ' *** Unpacked event:', events
       DO i = 0, adcs_max-1, 16
c        WRITE(6,9060) i, i+15, (data(j),hit(j),j=i,i+15)
       ENDDO
       DO i = 1000, 1000+tdcs_max-1, 16
c        WRITE(6,9060) i, i+15, (data(j),hit(j),j=i,i+15)
       ENDDO
      ENDIF

C----67---------------------------------------------------------------72------80
C     Scaler data.

      IF ( AND( X'00000002', type ).EQ.2 ) THEN

C       IF ( MOD( sc_counter, scaler_prescaler ).EQ.0 ) THEN
C        WRITE( 6, 9010 ) sc_counter
C        DO i = 0, maxscalers-1, 4
C         WRITE( 6, 9020 ) i, i+3, ( scaler(j),
C     +                    1.0E-03 * rate(j), j = i, i+3 )
C        ENDDO
C       ENDIF

       j = 0

       DO  i = 2000, 2000 + ( 2 * maxscalers ) - 1, 2
        i2( 1 ) = data( i + 1 )
        i2( 2 ) = data( i )
        scaler( j ) = i4
        j = j + 1
       ENDDO

C      Scalers are reset at the start of each run.
C
C      Note that scalers do not necessarily increase monotonically
C      from event to event - this probably indicates that the most
C      frequently changing (least significant) bits are not stable
C      at readout.

       IF ( scaler( 2 )+100.LT.counter_old( 2 ) ) THEN
        DO i = 0, maxscalers - 1
         sum( i ) = sum( i ) + counter_old( i )
         counter_old( i ) = 0
        ENDDO
       ELSE
        DO i = 0, maxscalers - 1
         counter_old( i ) = scaler( i )
        ENDDO
       ENDIF

       IF ( scaler( 2 ).LT.scaler_old( 2 ) ) THEN
... 857 more lines ...
Attachment 2: variables.dat  10 kB  | Show | Hide all | Show all
Attachment 3: S1284_sort_spectrum_titles.txt  3 kB  | Show | Hide all | Show all
Attachment 4: S1284_VME_spectrum_titles.txt  1 kB  | Hide | Hide all | Show all
s9418#1.adc0 dE1 p+n strip 0 ADC
s9418#2.adc15 dE1 p+n strip 47 ADC
s9418#2.adc16 dE1 n+n strip 0 ADC
s9418#2.adc31 dE1 n+n strip 15 ADC

s9418#3.adc0 E1 p+n strip 0 ADC
s9418#4.adc15 E1 p+n strip 47 ADC
s9418#4.adc16 E1 n+n strip 0 ADC
s9418#4.adc31 E1 n+n strip 15 ADC

s9418#5.adc0 dE2 p+n strip 0 ADC
s9418#6.adc15 dE2 p+n strip 47 ADC
s9418#6.adc16 dE2 n+n strip 0 ADC
s9418#6.adc31 dE2 n+n strip 15 ADC

s9418#7.adc0 E2 p+n strip 0 ADC
s9418#8.adc15 E2 p+n strip 47 ADC
s9418#8.adc16 E2 n+n strip 0 ADC
s9418#8.adc31 E2 n+n strip 15 ADC

s9418#9.adc0 LEDA-0 strip 0 ADC
s9418#9.adc15 LEDA-0 strip 15 ADC
s9418#9.adc16 LEDA-1 strip 0 ADC
s9418#9.adc31 LEDA-1 strip 15 ADC
s9418#10.adc0 LEDA-2 strip 0 ADC
s9418#10.adc15 LEDA-2 strip 15 ADC
s9418#10.adc16 LEDA-3 strip 0 ADC
s9418#10.adc31 LEDA-3 strip 15 ADC

s9418#11.adc0 PIN photodiode 1 ADC
s9418#11.adc1 PIN photodiode 2 ADC
s9418#11.adc2 PIN photodiode 3 ADC
s9418#11.adc3 PIN photodiode 4 ADC

v1190#1.tdc16 dE1 p+n strip 0 TDC
v1190#1.tdc63 dE1 p+n strip 47 TDC
v1190#1.tdc64 dE1 n+n strip 0 TDC
v1190#1.tdc79 dE1 n+n strip 15 TDC

v1190#1.tdc80 E1 p+n strip 0 TDC
v1190#1.tdc127 E1 p+n strip 47 TDC
v1190#2.tdc16 E1 n+n strip 0 TDC
v1190#2.tdc31 E1 n+n strip 15 TDC

v1190#2.tdc32 dE2 p+n strip 0 TDC
v1190#2.tdc79 dE2 p+n strip 47 TDC
v1190#2.tdc80 dE2 n+n strip 0 TDC
v1190#2.tdc95 dE2 n+n strip 15 TDC

v1190#2.tdc96 E2 p+n strip 0 TDC
v1190#3.tdc31 E2 p+n strip 47 TDC
v1190#3.tdc32 E2 n+n strip 0 TDC
v1190#3.tdc47 E2 n+n strip 15 TDC

v1190#3.tdc48 LEDA-0 strip 0 TDC
v1190#3.tdc63 LEDA-0 strip 15 TDC
v1190#2.tdc64 LEDA-1 strip 0 TDC
v1190#2.tdc79 LEDA-1 strip 15 TDC
v1190#3.tdc80 LEDA-2 strip 0 TDC
v1190#3.tdc95 LEDA-2 strip 15 TDC
v1190#3.tdc96 LEDA-3 strip 0 TDC
v1190#3.tdc111 LEDA-3 strip 15 TDC

v1190#3.tdc112 PIN photodiode 1 TDC
v1190#3.tdc113 PIN photodiode 2 TDC
v1190#3.tdc114 PIN photodiode 3 TDC
v1190#3.tdc115 PIN photodiode 4 TDC
Attachment 5: sort.f  12 kB  | Hide | Hide all | Show all
*trigger
128  
*oned
0..351  s 4096
*twod
*vars
*sort
C----67---------------------------------------------------------------72------80
      SUBROUTINE init

      IMPLICIT none

      SAVE
C
C     External functions
C
      EXTERNAL dtime
C
      INTEGER int, rshift, s2order
C
      REAL dtime, float, rand
C
C     Parameter variables
C
      INTEGER maxadcs
      PARAMETER (maxadcs = 2200)
      INTEGER adcs_max
      PARAMETER (adcs_max = 11*32)
      INTEGER tdcs_max
      PARAMETER (tdcs_max = 3*112)
      INTEGER maxscalers
      PARAMETER (maxscalers = 32)
      INTEGER maxepics
      PARAMETER (maxepics = 64)
      INTEGER event_prescaler
      PARAMETER (event_prescaler = 1000000)
      INTEGER scaler_prescaler
      PARAMETER (scaler_prescaler = 1000000)
      INTEGER epics_prescaler
      PARAMETER (epics_prescaler = 1000000)
C
      LOGICAL csm
      PARAMETER (csm = .true.)
C
C     Local variables
C
      INTEGER data(0:maxadcs-1), epics_counter, events, events_old, i
      INTEGER*2 i2(2)
      INTEGER i4, ierr, iflag, ireturn, j, k, m_adc, sc_counter, type
      INTEGER w(0:31)
C
      LOGICAL hit(0:maxadcs-1)
C
      REAL c(0:31), gain(0:maxadcs-1), offset(0:maxadcs-1), r4, rate
      REAL time(2)
C
C     Namelists
C
      NAMELIST /variables/ gain, offset, c, w
C
C     Common variables
C
      INTEGER*2 adc_data(0:maxadcs-1)
C
      COMMON /fdata/ adc_data
C
C     Common variables
C
      INTEGER*2 adcs(0:maxadcs-1)
C
      COMMON /fid/ adcs
C
C     Common variables
C
      INTEGER noadcs
C
      COMMON /fmult/ noadcs
C
      EQUIVALENCE  ( i4, i2( 1 ) )
C
C----67---------------------------------------------------------------72------80

      WRITE ( 6, * ) ' *** S1284 - sort - November 2013'
      WRITE ( 6, * ) ' *** Entry init commences'

C     Initialise arrays for unpacked event data.

      DO i = 0, maxadcs - 1
       data( i ) = 0
       hit( i ) = .FALSE.
      ENDDO

C     Initialise gains/offsets

      DO i = 0, maxadcs - 1
       gain( i ) = 1.0
       offset( i ) = 0.0
      ENDDO

C     Initialise constants/1D windows

      DO i = 0, 31
       c( i ) = 1.0
       w( i ) = 0
      ENDDO

C     Initialise counters

      sc_counter = 0
      epics_counter = 0
      events = 0
      events_old = 0

C     Read program variables via NAMELIST I/O

      OPEN( 1, FILE = '',
     + IOSTAT = ierr )
      IF ( ierr.NE.0 ) THEN
       WRITE( 6, * ) ' *** OPEN I/O error:', ierr
       RETURN
      ENDIF
      READ( 1, NML = variables, IOSTAT = ierr )
      IF ( ierr.NE.0 ) THEN
       WRITE( 6, * ) ' *** READ I/O error:', ierr
      ENDIF
      CLOSE( 1, IOSTAT = ierr )
      IF ( ierr.NE.0 ) THEN
       WRITE( 6, * ) ' *** CLOSE I/O error:', ierr
       RETURN
      ENDIF      

C     Display program variables

      DO i = 0, adcs_max-1, 8
       WRITE( 6, 9001 ) i, i+7, ( gain( j ), j = i, i+7 )
      ENDDO

      DO i = 0, adcs_max-1, 8
       WRITE( 6, 9002 ) i, i+7, ( offset( j ), j = i, i+7 )
      ENDDO

      DO i = 1000, 1000+tdcs_max-1, 8
       WRITE( 6, 9002 ) i, i+7, ( offset( j ), j = i, i+7 )
      ENDDO

      DO i = 0, 31, 8
       WRITE( 6, 9003 ) i, i+7, ( c( j ), j = i, i+7 )
      ENDDO

      DO i = 0, 31, 8
       WRITE( 6, 9004 ) i, i+7, ( w( j ), j = i, i+7 )
      ENDDO

      WRITE ( 6, * ) ' *** Entry init ends'

      RETURN

C----67---------------------------------------------------------------72------80

      ENTRY sortin

      events = events + 1

      IF ( MOD( events, event_prescaler ).EQ.0 ) THEN
       rate = FLOAT( events - events_old ) / dtime(time)
       WRITE( 6, * ) ' *** event:', events, ' (', rate,' events/s)'
       events_old = events
      ENDIF

C     Convert Eurogam type 0 ID to (a more) logical channel number.
C	ADC data	channels 0-999
C	TDC data	channels 1000-1999
C	Scaler data	channels 2000-2099
C	EPICS data	channels 2100-2199

      call egid2logical( noadcs, adcs, adc_data, type, csm )

C----67---------------------------------------------------------------72------80
C     Event data.

      IF ( MOD( events, event_prescaler ).EQ.0 ) THEN
       WRITE( 6, * ) ' *** Packed event:', events, ' noadcs:', noadcs
       DO i = 0, noadcs - 1
        WRITE( 6, 9050 ) adcs( i ), adc_data( i )
       ENDDO
      ENDIF

C     Unpack event data from packed data arrays.

      DO i = 0, noadcs - 1
       IF ( adcs( i ).GE.0 .AND. adcs( i ).LT.maxadcs ) THEN
        data( adcs( i ) ) = adc_data( i )
        hit( adcs( i ) ) = .TRUE.
       ENDIF
      ENDDO

      IF ( MOD( events, event_prescaler ).EQ.0 ) THEN
       WRITE( 6, * ) ' *** Unpacked event:', events
       DO i = 0, adcs_max-1, 16
        WRITE(6,9060) i, i+15, (data(j),hit(j),j=i,i+15)
       ENDDO
       DO i = 1000, 1000+tdcs_max-1, 16
        WRITE(6,9060) i, i+15, (data(j),hit(j),j=i,i+15)
       ENDDO
      ENDIF

C----67---------------------------------------------------------------72------80
C     Scaler data.

      IF ( AND( X'00000002', type ).EQ.2 ) THEN

       sc_counter = sc_counter + 1

C----67---------------------------------------------------------------72------80
C     EPICS data.

      ELSEIF ( AND( X'00000004', type ).EQ.4 ) THEN

       epics_counter = epics_counter + 1

C----67---------------------------------------------------------------72------80
C     Unexpected data type.

      ELSEIF ( AND( X'00000008', type ).EQ.8 ) THEN

       RETURN

C     If event does not contain any ADC/TDC data return.

      ELSEIF ( AND( X'00000001', type ).NE.1 ) THEN

       RETURN

      ENDIF

C----67---------------------------------------------------------------72------80
C     Sort unpacked event data

      m_adc = 0

C----67---------------------------------------------------------------72------80
C     ADCs

      DO i = 0, adcs_max-1
       IF ( hit( i ) ) THEN
        m_adc = m_adc + 1    
       ENDIF
      ENDDO

c      IF ( m_adc.GT.16 ) GOTO 1000

C      IF ( m_adc.LT.16 ) GOTO 1000  ! use this line to get rid of alpha source

      DO i = 0, adcs_max - 1
       IF ( hit( i ) ) THEN
        j = INT( c(0) * gain(i) * (data(i) - offset(i)) + rand(iflag) )
        CALL inc1d( i, j )
       ENDIF
      ENDDO

C----67---------------------------------------------------------------72------80      
C     Re-initialise unpacked data arrays using the packed data arrays.
C     Note: assumes packed data arrays are not modified by event.

 1000 CONTINUE

      DO i = 0, noadcs - 1
       data( adcs( i ) ) = 0
       hit( adcs( i ) ) = .FALSE.
      ENDDO

      RETURN

C----67---------------------------------------------------------------72------80      

      ENTRY finish
      WRITE ( 6, * ) ' *** Entry finish '
      RETURN

C----67---------------------------------------------------------------72------80

 9001 FORMAT( '   gain(', i4, '-', i4, ')', 8f8.5 )
 9002 FORMAT( ' offset(', i4, '-', i4, ')', 8f8.2 )
 9003 FORMAT( '      c(', i4, '-', i4, ')', 8f8.3 )
 9004 FORMAT( '      w(', i4, '-', i4, ')', 8i8 )
 9010 FORMAT(/' *** scaler event: ', i10 )
 9020 FORMAT( ' scaler(', i2, '-', i2, ')', 8(1x,i10) )
 9030 FORMAT(/' ***  epics event:', i10 )
 9040 FORMAT( '  epics(', i2, '-', i2, ')', 8(1x,g13.6) )
 9050 FORMAT( 2(1x,i4) )
 9060 FORMAT( 2(1x,i4), 16(1x,i4,1x,l1) )

C----67---------------------------------------------------------------72------80

      END

C----67---------------------------------------------------------------72------80

      SUBROUTINE egid2logical( noadcs, adcs, adc_data, type, csm )

... 209 more lines ...
ELOG V2.9.2-2455