|
CAEN MCA
0.99.10
SDK for Hexagon
|
In order to use the library, just include the CAENMCA.h header in your project:
To link your code with the library, the instructions depends on your operating system
By default the installer puts libraries and headers into the system folders. To use the library into your project, just add the parameter -lCAENMCA to the linker. For example:
An example make project is included in the source directory, under <sourcedir>/MCALibTest. To get started, you may try to build it:
By default the installer puts DLL files into the system folders. You may find a copy also into your install directory, at <installdir>/lib. To use the library into your project, just add the following stuff into your Visual Studio project C/C++ properties:
CAENMCA.h path (by default <installdir>/include)and this into the Linker properties:
CAENMCA.lib path (by default <installdir>/lib/<platform>)CAENMCA.libAn example Visual Studio project is included in the install directory, under <installdir>\MCALibTest. To get started, you may try to copy it to your user directory, and open it in Visual Studio.
C:\Program Files\CAEN\Digitizers\CAENMCA. In case you have chosen a different location, you have to adjust the Visual Studio project accordingly.The connection with a device in your network is established using CAEN_MCA_OpenDevice(). The function returns an handle that can be used later to interact with the system. For example, this connects to a local instance of the Hexagon Server:
Eventually, the connection should be closed by CAEN_MCA_CloseDevice(). This also free all the allocated memory:
You can connect only once per device:
From Handle article on Wikipedia:
In computer programming, a handle is an abstract reference to a resource. Handles are used when application software references blocks of memory or objects managed by another system [...]. A resource handle [...] can be a pointer that allows access to further information.
In this library, handles are pointers to instances of abstract data types. In a object-oriented programming analogy, they can be seen just as pointers to objects a certain class.
Several types of handle exist, represented by the following class diagram:
The function CAEN_MCA_GetChildHandle() can be used to get handles to child objects, given a handle. The only exception is to get the library handle, when no input handle is needed as first parameter, and the index can be any number:
The handle of the device is returned by CAEN_MCA_OpenDevice(). Additionally, with the index returned by by the last argument of that function it is possible to get the same handle using CAEN_MCA_GetChildHandle() with the library as first argument. Anyway, the first opened device has always index 0:
CAEN_MCA_GetChildHandle() can be used only for children, and not for other descendants. For example, it is possible to get the channel handles from the device handle:
but not from the library handle:
For parameters, a convenient function CAEN_MCA_GetChildHandleByName() is provided, which can be used with a string instead of a numeric index. It is implemented using hash tables, and the performances are almost identical. Numeric indexes of parameters exist but are not published.
For example, we can get a handle to the parameter "PARAM_CH_THRESHOLD" of the Channel 0:
Note that CAEN_MCA_GetChildHandleByName() can be used also for other handle types (except for CAEN_MCA_HANDLE_COLLECTION). In these cases, the index is just the literal version of the index, except for CAEN_MCA_HANDLE_DEVICE, where it represents the hostname used in CAEN_MCA_OpenDevice():
The function CAEN_MCA_GetAncestorHandle() can be used to get the the handle of an ancestor of the provided handle. For example, we can get the Channel 0 handle from a parameter of the Channel 0, as well as the device handle:
In case no ancestor of the requested type are found, the function returns NULL:
Data retrieve from MCA is managed using the functions CAEN_MCA_SetData() (or its va_list version CAEN_MCA_SetDataV()) and CAEN_MCA_GetData() (or its va_list version CAEN_MCA_GetDataV()). The expected arguments are:
Similarly to Data related functions, Commands are managed using the function CAEN_MCA_SendCommand() (or its va_list version CAEN_MCA_SendCommandV()). The expected arguments are:
The order of the variadic arguments is specified by the order of the value of its relative mask. For example, if the mask sets the bits with mask = (MASK_A | MASK_B), where MASK_A = 0x1 and MASK_B = 0x4 then you must append the variable relative to MASK_A first, and then the one relative to MASK_B. Note that since the bitwise-OR operator is commutative, the order in which you specify the bits of the mask does not matter at all, like in this example:
The type of the variadic arguments is specified in the mask documentation: it is the type to be used by CAEN_MCA_SetData(). In CAEN_MCA_GetData() functions, you have to pass a pointer to allocated memory of that type (except for arrays).
In this examples, the same data DATAMASK_VALUE_NUMERIC of CAEN_MCA_DATA_PARAMETER_VALUE is used both with CAEN_MCA_SetData() and CAEN_MCA_GetData(). As reported in the relative documentation, that data requires a double variable as argument. In the first case, pass just the variable as argument:
In the second case, pass a pointer where to store the result:
A special case of handles is represented by the collections. Collections are "transparent" elements of the class diagram tree shown in the Handle class diagram. Each object has a collection for every type of child, and every child is contained in the relative collections. For example, the handles of type CAEN_MCA_HANDLE_HVCHANNEL are contained in a special collection belonging to the handle of type CAEN_MCA_HANDLE_DEVICE:
The array containing the handles of the collection, as well as its length, can be obtained in this way:
To start acquisition:
To stop acquisition:
where handle can be either a device handle or a channel handle.
To set an automatic stop criteria, set the following four parameters (if the parameter is set to zero, the stop criteria is disabled):
To set status:
or, alternatively:
To get status:
To get extended status bitmask:
where the meaning of each bit can be printed in this way:
To get the active range:
Once we have the active range, monitor parameters like VMon can be read:
Note that monitor parameters can be accessed only from the currently active range. To get information about the other ranges, get the handle of a range:
then, use CAEN_MCA_DATA_HVRANGE_INFO:
Parameters are values that can be set at runtime to change the behaviour and the state of the device. The full list of the supported parameters, grouped by handle, can be found at Supported parameters.
The list of supported parameter of a given handle can be retrieved also at runtime:
To get a parameter handle given its codename:
To get extended parameter information:
To get the value of parameters with type CAEN_MCA_PARAMETER_TYPE_RANGE:
To set the value of parameters with type CAEN_MCA_PARAMETER_TYPE_RANGE:
To get the value of parameters with type CAEN_MCA_PARAMETER_TYPE_LIST:
To set the value of parameters with type CAEN_MCA_PARAMETER_TYPE_LIST:
Save the current configuration:
Load a saved configuration:
Delete a saved configuration:
Change configurations database path:
NOTE: the change is not persistent, you need to set path every time the library is reloaded. The previous database is left unchanged and not copied to the new location.
Read the value of a register:
Get a spectrum handle:
Get an energy spectrum:
Set the number of bins:
Spectra are saved at stop and periodically during the run. Set the auto-save period (the default is 5 seconds):
Set the remote filename where to save che spectrum:
Get a ROI handle:
Get the entries in a ROI:
Set range of a ROI:
Clear a spectrum and its ROIs:
The gain stabilization can be enabled for the energy spectrum in order to compensate for possible temperature variation effects.
Enable/Disable the gain stabilizer:
Set the ROI used by the gain stabilizer (this ROI defines the stabilization peak):
Set the update time for the gain stabilizer:
Reset the gain stabilizer:
Enable waveforms:
Get waveforms:
Get a MCS spectrum handle:
Get a MCS spectrum:
Set the number of bins:
Set the dwell time:
Set the MCS counting mode (MCS on ICR, MCS on Ext.Signal, MCS on SCA):
Set the MCS acquisition mode: MCS REPLACE (replace bin contents after a sweep), MCS SUM (sum bin contents after a sweep), MCS REPLACE AND SUM (replace bin contents after first sweep, then sum)
Enable/Disable hardware and software Dwell
Enable/Disable hardware and software Sweep
Clear a MCS spectrum:
Send a Sweep command to a MCS spectrum:
This tool can be used to find the best values for the coincidence parameters (coincidence window length and coincidence delay), in order to configure the board channels to work in coincidence/anticoincidence mode. When the DT spectrum is enabled, it is filled with the time difference DT between the timestamps of the events collected by the board channels. The plot is always centered in DT = 0 and its range is given by [-(Nbins/2 * DTstep), Nbins/2 * DTstep], where Nbins is the number of bins and DTstep is the time value corresponding to a single bin.
Set the number of DT spectrum bins:
Set the time interval for the DT spectrum:
Before enabling the DT spectrum, the user should set the reference channel for DT calculations:
Enable the coincidence mode for both channels and set a big value for the coincidence window length:
How to read the DT spectrum from the board:
Clear the DT spectrum:
This feature can be used to get a list of the events, or save it to a remote file. An event is made of:
Three buffers (one per each type of data) are allocated on acquisition start with size DATAMASK_LIST_MAXNEVTS. When the buffers have been filled, behaviour depends on the selected mode:
A reset occurs as soon as you call CAEN_MCA_DATA_LIST_MODE on CAEN_MCA_GetData() to get any of:
At stop, events in the buffer are written to file (if in file mode) and then freed.
A new acquisition will overwrite the existing file if the filename is not changed.
Enable or disable list mode:
Set the save mode:
In case of save mode set to CAEN_MCA_SAVEMODE_FILE_ASCII or CAEN_MCA_SAVEMODE_FILE_BINARY, this set the data to save into the remote file:
Set the maximum number of events to store in the server internal buffers:
This is an example to get and parse lists:
Find Hexagon devices on your network, a special command::CAEN_MCA_DATA_DISCOVEREDDEVICES on CAEN_MCA_GetData() is provided: