Building the readout program.Editing the Readout SkeletonMaxSizeRead

Read

Whenever a trigger is sent to the computer, the readout program will iterate through all registered event segments, calling their Read functions. The segements are visited in the order in which they were registered to the readout program. Each segment is expected to read a portion of the event, format it and place it into the buffer. The entire event will consist of the a leading word count followed by the data placed in the buffer by each event segment.

It is not mandatory that an event segment place data in the buffer. Event segments may decide that there's no data worth recording and leave the event untouched. Our example will do this if the hit pattern from the TDC indicates there are no valid channels.

The readout code is shown below:

  /*!
    Read out the event segment.
    \param rbuf (DAQWordBufferPtr& [out])
        A pointer like object to the data buffer. rbuf supports *
	and [].
    \retval DAQWordBufferPtr&  The buffer pointer advanced to the next 
    free word of the buffer.
*/
DAQWordBufferPtr&
MyEventSegment::Read(DAQWordBufferPtr& rBuf)
{
  // If the TDC pattern register is zero, suppress the segment:

  if(camread16(m_nB, m_nC, m_nTdc, 1, 6) == 0) return rBuf;

  // start the packet:

  rBuf = m_MyPacket.Begin(rBuf);

  // For each data word in the TDC, read the corresponding ADC
  // channel and package it up.

  while(qtst(m_nB)) {
    unsigned short tdc = camread16(m_nB, m_nC, m_nTdc, 0, 4);
    if(qtst(m_nB)) {
      unsigned channel   = (tdc >> 13) & 0xf;
      unsigned short adc = camread16(m_nB, m_nC, m_nAdc, 0, 0);
      *rBuf = 4;
      ++rBuf;
      *rBuf = channel;
      ++rBuf;
      *rBuf = tdc & 0xfff;
      ++rBuf;
      *rBuf = adc & 0xfff;
      ++rBuf;
    }
  }
  // Close the packet:

  m_MyPacket.End(rBuf);

  return rBuf;
}

  

Report documentation errors to Ron Fox (fox@nscl.msu.edu)or NSCL's Bugzilla page

Building the readout program.Editing the Readout SkeletonMaxSizeRead