Relies on: ADCs Structure Sunsort
C include file: hitsubs.h
FORTRAN include files: subs.i and hitsubs.i
This package provides a fast way to identify which parts of a large detector system have been involved in an event. This, coupled with the almost object orientated approach of the Structure package, provides a very flexible and sophisticated approach to processing events. The clever way in which it is coded avoids many of the overheads associated with traditional sorting approaches, consequently it can be faster than a standard sort code (particularly when the event processing is simple so standard sort codes spend most of their time finding which detector elements have fired).
This package activates the following variables in struct
detectors
:
gain, offset, threshmin and threshmax may be read and written. value may also be read and written, but it's usually treated as read only as its contents are reset for each event. hits and hitlist must never be written to.
When an event is processed with this package, it first finds which ADCs have been hit, it propagates the hits up the tree so that at each level, the hit variable holds the number of immediate sub-elements that were hit. For example, if in an event in the example experiment structure given in the description of the structure package caused signala, signalat, signalb and signalbt of the first pssd to be hit, and signale and signalet of the second monitor to be hit, then those elements would have hit set to one and all other signal elements would have hit set to zero. The first pssd would have hit set to four, the second pssd would have hit set to zero, the first monitor would have hit set to zero and the second monitor would have hit set to two. At the top level, experiment would have hit set to two.
The members of hitlist could be used to traverse the experiment
structure to find just the elements that have been hit and to process
them, but in practice, it's much easier to use the
detector_event()
call which does all the hard work for
you and then calls the right routine for the detector type that's been
hit. The key to getting fast processing is to get this detector
processing working properly. See the section Detector Routines later
for more details.
This routine initialises the markhits package for use. It must be
called before markhits()
or markhitslist()
is called.
On entry to the C routine, dp should point to the top of the experiment tree. The FORTRAN routine always refers to the top of the default experiment tree.
On entry nadcs should hold the highest ADC number used in the experiment.
Returns 0 on success and <0 on failure.
This routine marks the experiment tree with which elements have been
hit. It then propagates the hits up the tree so that every element has
the correct hits value. adc should be the adc array that
was passed to the sort code. This call is deprecated, it's much faster
to call markhitslist()
.
This routine does the same thing as markhits only faster. Adclist and adc should be the list of which adcs have fired, and their values as passed to the sort code.
Load the gains and offsets from the file specified in filename. The file should consist of a series of lines of the form:
adc gain offset
where adc is the adc number (integer) and gain
and offset are the (real) gain and offset to use for that
adc. Lines in the file that start with #
or that are
blank are ignored. This call returns 0 if all went well, 1 if there
was an error. If this call isn't made, or if the file couldn't be
found then the gains and offsets will default to 1.0 and 0.0
respectively. Similarly, any adcs not mentioned in the file will have
their gains and offsets default to 1.0 and 0.0.
Similar to loadgainoffsets except it loads the thresholds from file. The file format is
adc min maxThe defaults values for min and max are 1 and something slightly over 250,000,000 respectively. If you feel that hits which give a reading of zero are important and should be processed, then you should set the minimum threshold to 0.
Process an event by calling the event handling routines set with setdetprocs. Only those elements that were hit in this event are called. Proc is an integer that is passed to the detector routines to allow you to chose what processing is done. See the section Detector Routines later for more details. The return value is that of the last detector routine that was called.
The C routine should pass the top of the experiment tree in dp. The FORTRAN routine always refers to the top of the default experiment tree.
Dumps out which bits of the event structure have been hit and the value of hits. Also, for those elements which have adcs associated with them (that is, have had their adcnum set to something other than -1), it dumps the adc number, the raw value and the processed value.
You can pass a pointer to the top of a sub-tree in the C routine to just dump out part of an experiment. The FORTRAN routine always dumps out the whole experiment.
Routine to generate some standard spectra very quickly.
sp2_channsa and sp2_channst hold the numbers of the 2d spectra used for the plots of energy like signals and time like signals respectively.
On entry, plot_type should be set equal to one of the following symbols to get the listed effect.
To do: Find a more flexible way of specifying which channels are ADCs and which are TDCs.
The following get and set routines are provided for use in FORTRAN codes. Their syntax is the same as similar routines provided in the ADCs and Structure packages.