How to create Chained block transfer groups.

The CAEN 32 channel digitization module supports a high performance readout mode called Chained Block Transfer (CBLT). To use a set of modules in CBLT, you must place them in contiguous slots in a single crate. More than one chain block transfer group can be created per crate.

The hardware distinguishes between three types of modules in a CBLT block:

To use CBLT groups you must:

  1. Construct a CBLT chain.
  2. Initialize Modules in a CBLT chain.
  3. Read the modules.

Note:
At this time due to hardware issues that are being resolved, CBLT chains are read out under program control. This is not as efficient as our goal which is to use DMA to read these chains.

Construct a CBLT chain.

The first step to using CBLT chains is to create a chain of modules. At present, all modules must be initialized in either Geographical or physical base address mode (no mixing allowed within the group). See Constructing a module object. for a discussion of geographical and physical base addressing.

The constructor CCAENChain::CCAENChain constructs CBLT groups. The sample code below constructs a geographical cblt group consisting of modules in slots 4,5 and 6, crate 0.

   #include <CCAENChain.h>
   #include <CAENcard.h>
   #include <vector>
   ...
      vector<unsigned long> dummy;
      CCAENChain* pChain = new CCAENChain(4,6, dummy, 0 true);
   ...   

The constructor CCAENChain::CCAENChain creates three CAENcard objects that are all constructed geographically in slots 4,5, and 6 of crate 0. These are programmed to act as a CBLT group.

The code sample below shows how to construct a CBLT group consisting of three modules at 0x100000, 0x200000, and 0x300000 respectively. The modules are programmed for virtual slots 4,5, and 6.

   #include <CCAENChain.h>
   #include <CAENcard.h>
   #include <vector>
   ...
      vector<unsigned long> bases;
      bases.push_back(0x100000);
      bases.push_back(0x200000);
      bases.push_back(0x300000);
      CCAENChain* pChain = new CCAENChain(4,6, bases, 0, false);
   ...       

Initialize Modules in a CBLT chain.

Once constructed, the modules must be initialized. To be initialized, you must:
  1. Get access to the module object.
  2. Call CAENcard initialization member functions

You may gain access to a module in the group either by treating the chain as an array (indexing the chain object returns a pointer to a module), or you can retrieve a vector of CAENcard pointers.

The code fragment below shows how to index the chain to get access to its members.

   #include <CCAENChain.h>
   #include <CAENcard.h>
   #include <vector>
   ...
      CCAENChain* pChain;
   ...
      CCAENChain&  rChain(*pChain);
      bool done  = false;
      int  index = 0;
      while (!done) {
         try {
           CAENcard* pModule = rChain[index];
           InitializeAModule(pModule, index);
         } catch(CRangeError re) {
             done = true;
         }
         index++;
      }
   ...    

Note:
Please note that:
  1. rChain is a reference to chain pointed to by pChain. See any good book on C++ for a complete discussion of references.
  2. If you attempt to index off the end of the chain, the indexing operator will throw a range exception. This is caught in order to know when to terminate the loop.
  3. InitializeAModule is user written code that presumably initializes a module given its index into the set of modules in the chain.
The code fragment below shows how to retrieve all of the chain members in a vector and then initialize each member as in the previous example.

   #include <CCAENChain.h>
   #include <CAENcard.h>
   #include <vector>
   ...
     CCAENChain* pChain;
   ...
     vector<CAENcard*> vCards = pChain->getCards();
     int               nCards = vCards.size();
     for (int i = 0; i < nCards; i++) {
       InitializeAModule(vCards[i], i);
    }
   ...

The detailed functions avialable to you at initialization time are described at the page: . In addtion to these, the CCAENChain::ClearData member clears the data buffers of all cards in the CBLT group.

Read the modules.

At present, you can only do a ChainRead into a local user buffer. In the future, this will be extended to allow you to read from a CBLT group directly into the final event buffer.

The sample code below shows you how to read into a user buffer and copy the data into the final buffer. bufpt is assumed to be the DAQWordBufferPtr that points to the final event buffer.

   #include <CCAENChain.h>
   ...
      CCAENChain* pChain;
   ...
      int nMaxBytes = pChain->getMaxBytes();
      int nMaxLongs = nMaxBytes/sizeof(unsigned long);
      unsigned long lBuffer[nMaxLongs];
      int nRead = pChain->ReadEvent(lBuffer);
      unsigned short* pBuffer = (unsigned short*)lBuffer;
      for(int i =0; i < nRead; i++) {
        *bufpt = *pBuffer++;
        ++bufpt;
      }
   ...

Generated on Wed Sep 17 08:38:10 2008 for NSCL Device support. by  doxygen 1.5.1