CAENcard

Name

CAENcard -- Support for the CAEN 32 bit digitizers

Synopsis


#include <CAENcard.h>
        
 class CAENcard {

  CAENcard(int slotNum = -1, int crateNum = 0, bool fGeo = true, long nBase = 0);

  const int getPhysicalCrate();
  const int getSlot();
  const bool isGeo();
  const unsigned long getBase();
  const int getSerial();
  const int getHardwareRev();
  int cardType();
  int getFirmware();
  int getCrate();
  void setCrate(int crateNum);
  void setThreshold(int ch, int threshold);
  void keepUnderThresholdData()();
  void discardUnderThresholdData();
  void keepOverflowData();
  void discardOverflowData();
  void keepInvalidData();
  void discardInvalidData();
  void commonStart();
  void commonStop();
  void setRange(int range);
  void setPedestalCurrent(int ped);
  void cardOff();
  void cardOn();
  void channelOff(int ch);
  void channelOn(int ch);
  void resetEventCounter();
  void clearData();
  void reset();
  void dataPresent();
  bool gdataPresent();
  bool Busy();
  bool gBusy();
  bool MEBFull();
  bool MEBEmpty();
  int readEvent(void* buf);
  int readEvent(DAQWordBuffer& wbuf, int offset);
  int readEvent(DAQWordBufferPtr& wp);
  int getIped();
  void setFastClearWindow(int n);
  void enableSmallThresholds();
  void disableSmallThresholds();
  int EventCount();
}

Description

This class provides support for several 32 channel CAEN VME digitizers. The CAEN V775, V785, V792, V862, 11785 are essentially software compatible (they are all based on the same base board of a 32 channel peak sensing ADC with differing daughter board front ends.

These modules have both 16 and 32 channel versions. The 16 channel versions look exactly like the 32 channel versions except that only the even channels have been populated.

Some modules are capable of geographic addressing. In this mode, the base address of the module is determined by the VME slot in which it is installed. To be used in geographical addressing mode, the module must have three connectors to the backplane as must the backplane as the slot number is encoded on the middle connector of the backplane.

Public member functions

CAENcard(int slotNum=-1, int crateNum=0, bool fGeo=true, long nBase=0);

Constructs a CAENcard object to communicate with a digitizer. slotNum is the geographical address of the module, fGeo is true, this is the slot the module is installed. If not, this is the geographical address that is assigned to the module in software (virtual slot).

crateNum is the VME crate number. If omitted, this is assumed to be 0, which is suitable for a single crate system. See the reference page for cratelocator for information about how to determine which crate is which

If fGeo is false, the module requires a nBase parameter to specify the base address set in the rotary switches of the module. Otherwise, the module's bases address is gotten from the physical slot of the crate.

int getPhysicalCrate(void);

Returnst the crate number the module is specified to be installed in. This is the crateNum parameter passed to the constructor.

int getSlot(void);

Returns the module virtual slot number. This is just the value of the slotNum parameter given to the constructor for this module.

bool isGeo(void);

Returns true if the module was constructed via a geograhpical address. false is returned if base addressing was used to construct the module.

unsigned long getBase(void);

Returns the module base address. This value is only well defined if geographical addressing was not used to construct the module.

int getSerial(void);

Returns the serial number of the module. This is the same as the number stamped on the serial number tag on the faceplate of the module.

int getHardwareRev(void);

Returns the hardware version register from the module PROM. It is not clear to me what this is or what the format is.

int cardType(void);

Returns the model number of the card, e.g. 785 for a V785 peak sensing adc. Submodel information (e.g. N for NIM) is not returned by this function.

int getFirmware(void);

Returns the firmware revision of the module. This is the version of the firmware chip plugged into the lower left hand side of the module as you hold it connectors facing to the left. The firmware is returned as a 16 bit number with the top byte the major version (the part to the left of the decimal point), the bottom byte the minor version. So a return value of 0x0901 corresponds to firmware revision 9.01.

int getCrate(void);

Returns the value of the crate register of the module. At construction time, this is programmed to be the physical crate number. Calling setCrate, however can change the value of this register making it a virtual crate number.

void setCrate(int crateNum);

Sets the crate register of the module to crateNum This value will be reported as the module crate number in the data returned from the module.

void setThreshold(int ch, int threshold);

Sets the threshold of one or all channels to threshold. What this means depends on whether small or large thresholds are enabled (the default is large thresholds). If small thresholds are enabled, the threshold value is multiplied by 2 and applied to the incoming data. Large threshold multiply this value by 16.

If the ch value is not -1, it designates the channel to program (remember that a 16 channel module only uses the even numbered channels of the digitizer so ignore the front panel numbering). If -1 all threshold registers are set to the common value threshold

void keepUnderThresholdData(void);

If called, the module will not supress data that is under the threshold.

void discardUnderThresholdData(void);

If called the module will supress data that is under the threshold value. A key to getting this module to work efficiently is to set appropriate threshold values and then to call this function. If this is not done, you will get 34 longwords of data from this module for each event, rather than only receiving channels that have useful data.

void keepOverflowData(void);

If called, the module will retain data that has overflowed. This is usually important for a TDC. Overflow data indicates a channel did not have an input and over-ranged.

void discardOverflowData(void);

If this is called, the module will discard data that has overflowed. This is mostly useful for TDC modules, to discard overranged times.

void keepInvalidData(void);

I'm not 100% sure what effect this has on the module. If data are invalid (whatever that means), they will nonetheless appear in the data stream from the module (presumably with the valid bit clear).

void discardInvalidData(void);

Again see above. If data are invalid they will be discarded from the data stream.

void commonStart(void);

If the module is a TDC it is set in common start mode. The gate input is a start and the individual channel inputs stop that channel. If the module is not a TDC, a std::string exception will be thrown explaining this fact.

void commonStop(void);

If the module is a TDC, it is set to common stop mode. Individual channel inputs are individual starts while the common stop is the module Gate input. If the module is not a TDC, this function throws a std:string exception.

void setRange(int range);

Sets the range of the module if it is a TDC. See the CAEN module hardware book for more information about this parameter which is programmed without interpretation into the range register. If the module is not a TDC, a std::string exception will be thrown.

void setPedestalCurrent(int ped);

This sets the pedestal compensation current for QDC modules. If the module is not a QDC a std::string exception is thrown. QDC's operate by integrating charge on a capacitor. As the charge is integrating during the gate, it is also leaking, as capacitors are imperfect. For sufficiently long gate times it is possible to distort the charge integration unless an initial charge is injected to compensate for the leakage. This function sets the amount of charge initially injected. The value should be larger for longer gates, and smaller for smaller gates.

void cardOff(void);

This function disables the module completely. The action is the same as setting all channels to disabled.

void cardOn(void);

This function re-enables a card that has been disabled by a call to cardOff.

void channelOff(int ch);

Turns off channel ch. The specified channel will no longer contribute data.

void channelOn(int ch);

Enables the channel specified by ch if it has previously been disabled by a call to channelOff

void resetEventCounter(void);

Reset the module's event counter. The event counter can be read via EventCount. The event counter is also placed in the trailer longword of each event that contributes data to the output stream.

void clearData (void);

Clears any buffered events from the module. Remember that the module is a multievent digiitizer. If you are attempting to run it in single event mode, you need to clear the data between each event to ensure that any events that have leaked in your dead time have been cleared from the system.

void reset(void);

Perform a soft reset on the module.

bool dataPresent(void);

Returns true if the module's data buffer is not empty (that is there is at least one complete event int he buffer.

bool gdataPresent(void);

If the control bus of several modules is bussed together, this function returns true if any of the modules on that bus has data.

bool Busy(void);

Returns true if the module is busy. The module can be busy either because it is actively digitizing an event (6microseconds), or because the multi event buffer is full (until at least one event is read out or the module is cleared).

bool gBusy(void);

Returns true if the gBusy pin on the external control bus is asserted. If the control bus is bussed with other modules, this is true if any module in the control bus is busy.

bool MEBFull(void);

Returns true if the multiple event buffer int he module is full.

bool MEBEmpty(void);

Returns true if the module's multi-event buffer is empty.

int readEvent(void* buf);

Reads a single event from the module into the buffer pointed to by buf. The buffer must be at least 34 longwords long. The return value is the number of bytes that were placed in the buffer. This could be zero.

int readEvent(DAQWordBuffer& wbuf, int offset);

Reads an event in to the spectrodaq buffer wbuf The event is placed at word offset offset from the start of the buffer. The return value is the number of 16 bit words read to the buffer. This could be 0.

int getIped(void);

Returns the value of the pedestal injection current register for QDC modules. Throws a std::string exception for non QDCs.

void setFastClearWindow(int n);

Sets the module fast clear register value to n. This register determines how long after the gate input the module may be cleared without providing data.

void enableSmallThresholds(void);

Turns on small threshold mode. The values programmed into the channel thresholds will be multiplied by 2 and then applied as the threshold for a valid conversion.

void disableSmallThresholds(void);

Turns off small threhodls. Threshold values for each channel will be multiplied by 16 before being applied.

Types and public data

The following data types defined in <spectrodaq.h> are used by this module:

DAQWordBuffer

A spectrodaq buffer of word wide items.

DAQWordBufferPtr

A pointer like object into a DAQWordBuffer object.

The following constants are defined in the header that are useful when treating data from the digitizers:

CAEN_DATUM_TYPE

A mask of the bits in data from the digitizer that isolates the data word type field.

CAEN_HEADER

Data type field value for event headers. If (datum & CAEN_DATUM_TYPE) == CAEN_HEADER then datum is a CAEN module event header.

CAEN_DATA

Data type field value for channel data.

CAEN_FOOTER

Data type field value for end of event data footer longwords.

CAEN_INVALID

Data type field value for longwords returned when reading an event buffer that has no data.

Exceptions

Many functions throw std::string exceptions.

Examples

Create a CAENcard module in geographical mode:

Example 1. Creating a CAENcard geographically


#include <CAENcard.h>
…
   CAENcard* pCard = new CAENcard(5);
…
                    

Example 2. Setting a TDC to common stop mode


#include <iostream>
#include <string>
#include <CAENcard.h>
…
    CAENcard* pCard;
…
    try {
      pCard->commonStart();
    }
    catch (string msg) {
      cerr << "Failed to set module  in common start mode";
      cerr << " module type: V" << pCard->cardType() << endl;
      cerr << "Message: " << msg <<; endl;
      cerr.flush();
      throw;
    }   
…
                    

Example 3. Reading out a CAEN 785 e.g.


#include <CAENcard.h>
#include <spectrodaq.h>
#define CAENTIMEOUT 50
…
   CAENcard* pModule;
…
   for(int i =0; i < CAENTIMEOUT; i++) {
     if (pModule->dataPresent()) {
       break;
     }
   }
   if (pModule->dataPresent()) {
      pModule->readEvent(bufpt);
   }    
…
                

SEE ALSO

The relevant CAEN hardware module documentation, http://www.caen.it has current online versions of most of their manuals. An old V785 manual is online at the NSCL at http://groups.nscl.msu.edu/nscl_library/manuals/caen/MOD.V785.pdf