DRAGON Analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
vme::V792 Class Reference

#include <Vme.hxx>

Public Member Functions

 V792 ()
 Calls reset(),.
 
bool unpack (const midas::Event &event, const char *bankName, bool reportMissing=false)
 Unpack ADC data from a midas event. More...
 
void reset ()
 Reset data fields to default values.
 
int32_t get_data (int16_t ch) const
 Get a data value, with bounds checking. More...
 

Public Attributes

int16_t n_ch
 Number of channels present in an event.
 
int32_t count
 Event counter.
 
bool overflow
 Is any channel an overflow?
 
bool underflow
 Is any channel under threshold?
 
int16_t data [MAX_CHANNELS]
 Array of event data.
 

Static Public Attributes

static const uint16_t DATA_BITS = 0x0
 Code to specify a data buffer.
 
static const uint16_t HEADER_BITS = 0x2
 Code to specify a header buffer.
 
static const uint16_t FOOTER_BITS = 0x4
 Code to specify a footer buffer.
 
static const uint16_t INVALID_BITS = 0x6
 Code to specify an invalid buffer.
 
static const uint16_t MAX_CHANNELS = 32
 Number of data channels availible in the ADC.
 

Private Member Functions

bool unpack_data_buffer (const uint32_t *const pbuffer)
 Unpack event data from a caen 32 channel adc. More...
 
bool unpack_buffer (const uint32_t *const pbuffer, const char *bankName)
 Unpack a Midas data buffer from a CAEN ADC. More...
 

Detailed Description

CAEN v792 ADC

Definition at line 194 of file Vme.hxx.

Member Function Documentation

◆ get_data()

int32_t vme::V792::get_data ( int16_t  ch) const

Get a data value, with bounds checking.

Parameters
chChannel number to get data from Returns the data value stored at ch. If ch is out of bounds of the internal array, prints a warning message and returns dragon::DR_NO_DATA.

Definition at line 383 of file Vme.cxx.

References dragon::NoData< T >::value().

384 {
385  /*!
386  * \param ch Channel number to get data from
387  * Returns the data value stored at \e ch. If \e ch is out of bounds
388  * of the internal array, prints a warning message and returns dragon::DR_NO_DATA.
389  */
390  if (ch >= 0 && ch < MAX_CHANNELS) return data [ch];
391  else {
392  dutils::Warning("V792::get_data")
393  << "Channel number " << ch << " out of bounds (valid range: [0, "
394  << MAX_CHANNELS -1 << "]\n";
396  }
397 }
static const uint16_t MAX_CHANNELS
Number of data channels availible in the ADC.
Definition: Vme.hxx:205
Specialized Strm class to print warning messages.
int16_t data[MAX_CHANNELS]
Array of event data.
Definition: Vme.hxx:227
static const T value()
Get the throwaway value.
Definition: Valid.hxx:46
Here is the call graph for this function:

◆ unpack()

bool vme::V792::unpack ( const midas::Event event,
const char *  bankName,
bool  reportMissing = false 
)

Unpack ADC data from a midas event.

Searches for a bank tagged by bankName and then proceeds to loop over the data contained in the bank and extract into the appropriate class data fields.

Parameters
[in]eventThe midas event to unpack
[in]bankNameName of the bank to unpack
[in]reportMissingFalse specifies to silently return if bankName isn't found in the event. True specifies to print a warning message if this is the case.
Returns
True if the event was successfully unpacked, false otherwise

Definition at line 459 of file Vme.cxx.

460 {
461  /*!
462  * Searches for a bank tagged by \e bankName and then proceeds to loop over the data contained
463  * in the bank and extract into the appropriate class data fields.
464  *
465  * \param [in] event The midas event to unpack
466  * \param [in] bankName Name of the bank to unpack
467  * \param [in] reportMissing False specifies to silently return if \e bankName isn't found in
468  * the event. True specifies to print a warning message if this is the case.
469  * \returns True if the event was successfully unpacked, false otherwise
470  */
471  int bank_len;
472  uint32_t* pbank32 =
473  event.GetBankPointer<uint32_t>(bankName, &bank_len, reportMissing, true);
474 
475  // Loop over all data words in the bank
476  bool ret = true;
477  for (int i=0; i< bank_len; ++i) {
478  bool success = unpack_buffer(pbank32++, bankName);
479  if(!success) ret = false;
480  }
481  return ret;
482 }
bool unpack_buffer(const uint32_t *const pbuffer, const char *bankName)
Unpack a Midas data buffer from a CAEN ADC.
Definition: Vme.cxx:420

◆ unpack_buffer()

bool vme::V792::unpack_buffer ( const uint32_t *const  pbuffer,
const char *  bankName 
)
private

Unpack a Midas data buffer from a CAEN ADC.

Parameters
[in]pbufferPointer to the buffer word
[in]bankName of the midas bank being unpacked
Returns
True if the buffer was successfully unpacked, false otherwise

V792 buffers are 32 bit words. Bits 24-26 specify the type of data contained in the buffer. In this function, we read the buffer type and then handle appropriately.

case DATA_BITS : See unpack_data_buffer()

case HEADER_BITS: read number of channels (n_ch) in the event from bits 6 - 13

case FOOTER_BITS: read event counter (count) from bits 0 - 23

case INVALID_BITS: bail out

Bail out if we read an unknown buffer code

Definition at line 420 of file Vme.cxx.

421 {
422  /*!
423  * \param [in] pbuffer Pointer to the buffer word
424  * \param [in] bank Name of the midas bank being unpacked
425  * \returns True if the buffer was successfully unpacked, false otherwise
426  *
427  * V792 buffers are 32 bit words. Bits 24-26 specify the type of data contained
428  * in the buffer. In this function, we read the buffer type and then handle appropriately.
429  */
430  bool success = true;
431  uint32_t type = (*pbuffer >> 24) & READ3;
432 
433  switch (type) {
434  case DATA_BITS: /// case DATA_BITS : See unpack_data_buffer()
435  success = unpack_data_buffer(pbuffer);
436  break;
437  case HEADER_BITS: /// case HEADER_BITS: read number of channels (n_ch) in the event from bits 6 - 13
438  n_ch = (*pbuffer >> 6) & READ8;
439  break;
440  case FOOTER_BITS: /// case FOOTER_BITS: read event counter (count) from bits 0 - 23
441  count = (*pbuffer >> 0) & READ24;
442  break;
443  case INVALID_BITS: /// case INVALID_BITS: bail out
444  dutils::Error("vme::V792::unpack_buffer", __FILE__, __LINE__)
445  << DRAGON_ERR_FILE_LINE << "Bank name: \"" << bankName
446  << "\": Read INVALID_BITS code from a CAEN ADC output buffer. Skipping...\n";
447  success = false;
448  break;
449  default: /// Bail out if we read an unknown buffer code
450  dutils::Error("vme::V792::unpack_buffer", __FILE__, __LINE__)
451  << DRAGON_ERR_FILE_LINE << "Bank name: \"" << bankName
452  << "\": Unknown ADC buffer code: 0x" << std::hex << type << ". Skipping...\n";
453  success = false;
454  break;
455  }
456  return success;
457 }
static const uint16_t FOOTER_BITS
Code to specify a footer buffer.
Definition: Vme.hxx:201
static const uint16_t INVALID_BITS
Code to specify an invalid buffer.
Definition: Vme.hxx:203
static const uint16_t HEADER_BITS
Code to specify a header buffer.
Definition: Vme.hxx:199
int16_t n_ch
Number of channels present in an event.
Definition: Vme.hxx:219
bool unpack_data_buffer(const uint32_t *const pbuffer)
Unpack event data from a caen 32 channel adc.
Definition: Vme.cxx:399
static const uint16_t DATA_BITS
Code to specify a data buffer.
Definition: Vme.hxx:197
#define DRAGON_ERR_FILE_LINE
For printing in-place file & line messages.
int32_t count
Event counter.
Definition: Vme.hxx:221
Specialized Strm class to print error messages.

◆ unpack_data_buffer()

bool vme::V792::unpack_data_buffer ( const uint32_t *const  pbuffer)
private

Unpack event data from a caen 32 channel adc.

Parameters
[in]pbufferPointer to the data buffer word.

A data buffer encodes the conversion value (i.e. integrated charge or peak pulse height) for a single ADC channel. See below for bitpacking instructions.

Bit 12 is an overflow tag

Bit 13 is an underflow tag

Bits 16-20 tell the channel number of the conversion

Bits 0 - 11 encode the converted value

Definition at line 399 of file Vme.cxx.

400 {
401  /*!
402  * \param [in] pbuffer Pointer to the data buffer word.
403  *
404  * A data buffer encodes the conversion value (i.e. integrated charge or peak pulse height)
405  * for a single ADC channel. See below for bitpacking instructions.
406  */
407  overflow = (*pbuffer >> 12) & READ1; /// Bit 12 is an overflow tag
408  underflow = (*pbuffer >> 13) & READ1; /// Bit 13 is an underflow tag
409  uint16_t ch = (*pbuffer >> 16) & READ5; /// Bits 16-20 tell the channel number of the conversion
410  if (ch >= MAX_CHANNELS) {
411  dutils::Error("vme::V792::unpack_data_buffer", __FILE__, __LINE__)
412  << DRAGON_ERR_FILE_LINE << "Read a channel number (" << ch
413  << ") which is >= the maximum (" << MAX_CHANNELS << "). Skipping...\n";
414  return false;
415  }
416  data[ch] = (*pbuffer >> 0) & READ12; /// Bits 0 - 11 encode the converted value
417  return true;
418 }
bool overflow
Is any channel an overflow?
Definition: Vme.hxx:223
static const uint16_t MAX_CHANNELS
Number of data channels availible in the ADC.
Definition: Vme.hxx:205
bool underflow
Is any channel under threshold?
Definition: Vme.hxx:225
#define DRAGON_ERR_FILE_LINE
For printing in-place file & line messages.
Specialized Strm class to print error messages.
int16_t data[MAX_CHANNELS]
Array of event data.
Definition: Vme.hxx:227

The documentation for this class was generated from the following files: