Chapter 2. Setting up the software
CAEN_CHANNELMASK and CAEN_CHANNELSHIFT
These two values are used to extract the channel number of a conversion from a conversion
word (type CAEN_DATA). The code below shows how to do this:
unsigned long channelNumber = (datum & CAEN_CHANNELMASK) >> CAEN_CHANNELSHIFT;
CAEN_DATAMASK
CAEN_DATAMASK can be used to extract the conversion value from an adc conversion longword
(longword with type CAEN_DATA). For example:
unsigned long conversion = datum & CAEN_DATAMASK;
Î The inline function getLong returns a longword of data pointed to by a
TranslatorPointer<UShort_t>. The longword is assumed to be big endian by word, that is the
first word contains the high order bytes. The bytes within each word are appropriately managed by
the TranslatorPointer object. Inline functions are preferred to #define macros in C++. The
usually have the same execution efficiency without some of the strange argument substitution
problems that a #define macro may have.
Ï The main task of the constructor is to initialize data elements. In C++ where possible, this should be
done with initializers, rather than with code in the body of the constructor. Note, however, that
regardless of the order of initializers in your constructor, they are executed in the order in which the
members are declared in the class definition. The only initializer worth explaining in this code is the
one for the CTreeParameterArray& member data m_rawData. This constructor dynamically
allocates a new object and points the reference at it. The parameters of the constructor are in turn the
base name of the array, The preferred number of bins for spectra created on this parameter, the low
and high limits of the range of values this parameter can have, the units of measure of the parameter,
the number of elements in the array and the index of the base element of the array (it is possible to
give a CTreeParameterArray any integer base index desired.
Ñ This section of code should appear in essentially all event processor operator() functions. p is an
object that acts very much like a UShort_t*. However it transparently does any byte order swapping
required between the binary representations of the system that created the buffer and the system that
is runing SpecTcl. This "pointer" is then used to extract the size of the body of the event from the
buffer. One of the responsibilities of at least one event processor is to report the size of the event in
bytes to the SpecTcl framework. The CAnalyzer object reference rAnalyzer is actually a
reference to an object of type CTclAnalyzer. This object has a member function called
SetEventSize which allows you to inform the framework of the event size. Since any event
processor can and in many cases should be written to run with little or no knowledge of other event
processors in the pipeline, by convention we have every event processor informing the framework of
theevent size in this way.
Ò This code extracts the packet size and id of each packet encountered in the while loop. The size is
used to skip to the next packet in the event.
(10) This if checks for packets that match the id we’ve been told to unpack (m_nId).
(11) A try .. catch block in C++ executes code in the body of the try block. If the code raises an
exception, a matching exception handling catch block is searched for at this an higher call levels. If
24
Kommentare zu diesen Handbüchern