Gain command

Gain coefficients must be specified in the *DATA section.

A sortword can be gain matched using coefficients stored in a GAINWORD element (first format); the indexth element of gain-array-name (second and third formats). For the third format, the gain array must be a member of an ARRAYLIST in the *DATA section, where array-index specifies the gain array used via it's index in the arraylist. Indices start from zero.

In the fourth format of the command the words in group-param-list-name are all gain-matched with the corresponding parameters in gain-array-name indexed by absolute group number, i.e. if the particular item in group n is present in the event it is gain matched with the nth set of gain matching parameters defined in the gain array. The fifth format is similar to this but allows the particular gain array used to be selected via an index into an arraylist where array-index can be an expression.

An expression may also be supplied as an optional shift-factor argument to be applied to each of the gain coefficients. This is useful for making a Doppler shift correction when the original gain coefficients have been derived from source measurements.

Example

The value of a word is modified according to:

word = a + b* word + c* word2

The calculation includes a randomisation process which adjusts the result by at most one channel in order to produce a smooth function.

Gain drifts may be automatically adjusted by adding an *AUTOGAIN section.

Example

*FORMATS
ge[1:35] (e20,e4,ft,co,bgoe,bgot,hitpat)
*DATA
GAINARRAY gegains
1  (-.3 0.09 0.004)
2  (0.6 0.10 0.002)
  ...
*COMMANDS
CREATELIST gelist FROM ge
GAIN gelist.e4 gegains

will gain match all the E4 adcs associated with each GE group number.


Example

*FORMATS
clovers1[81:110]  (bgop, A1, A2tag:3,A2dat:13, A3)
*DATA
GAINARRAY segA                                      !! segment A
    81     (-6.4294434      0.9705133    0.0000000)
    82     (-1.8133545      0.9134621    0.0000000)
    83     ( 2.0946655      1.0252383    0.0000000)
  ...
*COMMANDS
CREATELIST clist1 FROM clovers1
loopif $c1=clist1 valid
   {
   groupno = group($c1)
   inc clgroups(groupno)
   select ($c1.a2tag)                  !! check tag to see which seg fired
   (1)  {                                    !! segment A
        gain $c1.a2dat segA indexed $c1
        }
   (2)  {                                    !! segment B
        gain $c1.a2dat segB indexed $c1
        }
   (3)  {                                    !! segment C
        gain $c1.a2dat segC indexed $c1
        }
   (4)  {                                    !! segment D
        gain $c1.a2dat segD indexed $c1
        }
   }

will gain match all the a2dat adcs associated with each clovers1 group number, where the gainarray used is found by checking a2tag to determine which element of the detector has fired.


Example

CREATELIST qlist FROM clover
LOOPIF $q=qlist VALID
 {
 detid = GROUP($q) - 30
 capmult = NWORDS($q)/3
 SELECT (capmult)
 (1) {                                        ! Single hit
     capid = $q.Atag
     theta = qthetas(detid,capid)
     gfac  = (2.0)/((1.0)+(cos(theta)*beta))
     GAIN $q.Agehigh qgains[detid] INDEXED capid FACTOR gfac ! GM ener
     GAIN $q.Agetime qgainst[detid] INDEXED capid      !gain match TAC
     INC esum($q.Agehigh)
     }
 (2) {                                        ! Double hit
     capid0 = $q.Atag
     capid1 = $q.Btag
     theta0 = qthetas(detid,capid0)
     theta1 = qthetas(detid,capid1)
     theta2 = (theta0 + theta1)/2.0
     costh  = cos(theta2)
     gfac = 2.0/(1.0 + costh*beta)
     GAIN $q.Agehigh qgains[detid] INDEXED capid0 FACTOR gfac
     GAIN $q.Bgehigh qgains[detid] INDEXED capid1 FACTOR gfac
     GAIN $q.Agetime qgainst[detid] INDEXED capid0     !gain match TAC
     GAIN $q.Bgetime qgainst[detid] INDEXED capid1     !gain match TAC
     INC esum($q.Agehigh + $q.Bgehigh)
     }
  }

will gain match and Doppler correct all single and double hit energies and times for the group clover, updating the shifted energies into the spectrum esum.