Tailoring the Readout Skeleton |
|
The Readout program is tailored by adding code to the file skeleton.cpp which was obtained from the Readout distribution.
This document describes:
· initevt
Performs all operations needed to initialize the digitization hardware. This function has no associated buffer, therefore, no data can be read or logged within this function.
<macros.h> defines support macros for each supported CAMAC electronics module. The sample below uses them to initialize a Lecroy Fast encoding Readout ADC for CAMAC readout in zero suppressed mode.
INITFERA(0,
/* Branch in which FERA lives. */
2,
/* Crate in which FERA lives */
3, /* Slot in which FERA
lives. */
FERA_CSR | /* Select
CAMAC sequential Readout */
FERA_CPS | /* Enable
Pedestal Subtraction */
FERA_CCE | /* Enable
compression readout */
5, /* Set virtual slot
number to 5 */
ped); /* Pointer to an array of 16 pedestal
values */
Should perform any initializations required to read out scalers. Scalers are readout periodically as determined by the set scaler, set frequency commands. At present the following scaler modules are supported: LeCroy LRS2551 and LRS4434 scalers. In the future we will support the CAEN V830 VME scaler as well. <macros.h> provides support for both of these scalers. The code fragment below show show to initialize one 12 channel LRS2551 and one 32 channel scaler for readout:
INIT4434(0, 2, 16); /* branch, crate, slot */
INIT2551(0, 2, 17); /* branch, crate, slot */
Called after events have been read out to perform any post readout clear/cleanup. Note this is also called just prior to starting the run to ensure the hardware is in a known clean condition. The Clear NIMOUT supplies signals which can be plugged into a module's clear input such that all modules are simulaneously cleared. The code below shows a FERA which was not wired like this cleared:
CLRFERA(0,2,3); /* Crate branch slot */
Called to clear the scalers after an incremental readout or before the run begins. Scalers are read and cleared to prevent overflows. The code below shows how to clear the set of scalers which were initialized in the sample iniscl().
CLR4434(0, 2, 16);
/* branch, crate, slot */
CLR2551(0, 2, 17); /* branch, crate, slot */
Called to read out an event. The DAQWordBufferPtr can be treated essentially like a pointer. It is an object which represents a pointer into the event buffer. The target of all of the Read operations is this buffer pointer.
The function is expected to return the number of words actually read into the buffer. This value must be less than the value returned by evtmax(), or else a fatal error will be declared. By convention, data are read in packets. Each packet contains a related set of data. Depending on the hardware and experimental requirements, related may mean a set of common digitizer types or it may mean a set of data from a related segment of a detector. Packets have the form shown below:
Packet Size |
Packet ID |
First Data Word |
... |
Last Data Word |
Each packet has a header consisting of the packet size in words followed by the Packet ID (which identifies what the packet contains). The packet header is followed by whatever you put into the buffer. The sample code below reads out a pair of FERA's in compressed mode putting them in a packet with type 0xf:
VPacket(0xf); /* Start writing a variable length packet */
READFERAALL(0, 2, 2); /* Fera in physical B=0,C=2,N=2 */
READFERAALL(0, 2, 3); /* And the next slot */
EndVPacket; /* Terminate the packet */
Called to read out the incremental scalers. The reads are directed at pBuffer. nScalers is the number of scalers which have been requested. The function is expeted to return the number of words read into the buffer. Note that the buffer is temporary storage which is processed by the caller before creating an actual scaler buffer. The code fragment below shows how to read the two scalers which are initialized in iniscl above.
READALL4434(0,2,16);
READALL2551(0,2,17);
Returns the size of the largest event which could ever be read by this code. This is used to determine when to dismiss the buffer as full. The fragment below assumes that we are reading a pair of FERA's into a packet. The Fera's can each give 17 words (16 channels + 1 word header), and the packet itself has 2 words of overhead:
return 17*2+2;