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 |
*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 ...
|