Pulse Processing

This example shows a simple pulse processing code example.

*FORMATS !##############################################################

grt[1:63] (e1,e2)          ! Read GRT4 energy value from MWD
posxy[255] (x,y,nstep)           ! Position table
fadcs[260:350] (pulse(250))      ! GRT4 (14 bits 80Mhz)
 
*DATA  !################################################################

gatemap  2D  coincidence[512,512]
(181 155 186 160 198 148 203 132 189 125 182 136)

valuearray pulse[512]         ! Initialise pulseshape array

valuearray grtenergies[1:37]     ! Initialise energy array
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

valuearray grtbases[1:37]     ! Initialise base array
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

*SPECTRA !##############################################################

fadchiti          128  32  ! FADC hit pattern
fadchito          128  32  ! FADC hit pattern
grtid             256  32  ! GRT ID
foldf             128  32  ! FADC fold (should be 1)
foldgrt           128  32  ! Fold grt
multge            128  32  ! Segment multiplicity
gehighi[1:40]     8192  32  ! Energy
grtenergyi[1:40] 8192  32  ! Energy from grt4
grttot           8192  32

! ============ Pulse Shapes ================
pulseshape[1:40]  512 2D 32     ! Shapes
pulses[1:37]      256 32
! ============ Position Table ==============

posx               	  4096 32   ! x position (ungated)
posy             	  4096 32   ! y position (ungated)
position	        128 2D 32   ! Raw position matrix

*COMMANDS !#############################################################

!-------------------------------------------------------------------
! Reinitialise the arrays each event
!-------------------------------------------------------------------

doloop loop1 from 1 to 37 step 1
 {
 grtenergies(loop1) = -1
 }

!-------------------------------------------------------------------
! Increment the position matrix: density of photon interaction
!-------------------------------------------------------------------

inc posx(posxy.x)             ! Position x (vertical)
inc posy(posxy.y)             ! Position y (horizontal)
posxx = (posxy.x/20)	      ! Step corresponds to the scan step
posyy = (posxy.y/20)	      ! 
inc position(posxx,posyy)

!-------------------------------------------------------------------
! Now let us look at the data ....
!-------------------------------------------------------------------

createlist fadclist from fadcs
mult = number(fadclist)
inc foldf(mult)

loopif $f = fadclist valid
 {
 mult = 0
 energy = 0
 adcvalue = 0

 numfadc = group($f)
 numfadc = numfadc - 259      ! Renumber 1->37
 numbase = numfadc
 inc fadchiti(numfadc)

 ! User routine to calculate energy ...
 !-------------------------------------------------------------------
 exec fadc_12bit $f numfadc energy init 0
 !-------------------------------------------------------------------

 inc fadchito(numfadc)                 ! Output hit pattern
 
 if numbase lt 37
 {
  doloop loop1 from 1 to 250 step 1    ! Generate pulse histogram
  {
   a = $f.pulse[loop1]
   a = ((a/15)+50)
   inc pulseshape(loop1,a) indexed numbase
   set pulses(loop1) indexed numbase = a
  }
 }

 grtbases(numbase) = adcvalue

 if numfadc le 37
 {
    inc gehighi(energy) indexed numfadc
 }

} ! Close main loop

multgrt = 0
createlist grtlist from grt
multgrt = number(grtlist)
inc foldgrt(multgrt)

loopif $g = grtlist valid
 {
 groupno = group($g)
 groupno = groupno - 3
 inc grtid(groupno)

 temp = $g.e2 / 4
 if temp gt 5              ! Arbitrary 0 cutoff
  {
    inc grtenergyi(temp) indexed groupno  ! Raw energu
    grtenergies(groupno) = temp           ! Store the energies
  }
 else
  {
    grtenergies(groupno) = 0           ! Store the energies
  }
 }
 
! ========================================================
! ============ Now lets Analyse the Data =================
! ========================================================

mult = 0
doloop loop1 from 1 to 36 step 1
{
 temp = grtenergies(loop1)
 if temp ge 5 
 {
  mult = mult + 1
  hitsegment = loop1
  inc grttot(temp)
 }
}
inc multge(mult)     ! Increment segment multiplicity

end

*RUNFILES !###########################################################

DISC /net/npr3/d1/CALIB/Run6_0

*FINISH !#############################################################