Detectors#

Routines for querying information about physical detectors.

int xiaGetDetectorItem(char *alias, char *name, void *value)#

Retrieves information from a detector’s configuration. All of the names listed in below may be retrieved using this routine.

Detector Items

Name

Type

Description

number_of_channels

unsigned int

The number of detector elements. Must be added first.

channel{n}_gain

double

The preamplifier gain in mV/keV for channel n (0-based).

channel{n}_polarity

char *

Polarity of channel n. “+” and “pos” indicate positive polarity. “-” and “neg” indicate negative polarity.

type

char *

The type of preamplifier this detector has. “reset” or “rc_feedback”.

type_value

double

The value associated with the preamplifier type. For reset detectors pass in the value of the reset time in us. For RC feedback detectors, pass the 1/e decay time in microseconds.

Param[in] alias:

A valid detector alias

Param[in] name:

Name from the detector items table to get.

Param[out] value:

Void pointer to the variable in which the returned data will be stored. See the detector items list above for the correct data type to allocate for each name.

Returns:

A status code indicating the result of the operation.

Return values:
  • XIA_NO_ALIAS – Specified alias does not exist

  • XIA_BAD_VALUEvalue could not be converted to the required type.

  • XIA_BAD_NAMEname is not a valid detector item.

Example Usage

int status;
double gain;

/* Create a detector w/ alias detector1 here and then add all of the
 * the necessary information to it. We will only retrieve the gain
 * here, but the others follow the same pattern.
 */

status = xiaGetDetectorItem("detector1", "channel0_gain", (void *)&gain);
if (status != XIA_SUCCESS) {
    /* ERROR getting channel 0 gain */
}

printf("Gain (channel 0) = %lf\n", gain);
int xiaGetDetectors(char *detectors[])#

Gets a list of aliases of the detectors defined in the system.

The caller must allocate for detectors. Typically this is done by calling xiaGetNumDetectors() and using the number of detectors to initialize a string array. Allocate a char* of length MAXALIAS_LEN for each detector.

Param[out] detectors:

A string array of the proper length: number of detectors times MAXALIAS_LEN.numDet by MAXALIAS_LEN (defined in handel_generic.h).

Returns:

A status code indicating the result of the operation.

Return values:

XIA_SUCCESS – Successful execution.

Example Usage

int status;
unsigned int numDet = 0;
unsigned int i;
char **detectors = NULL;

/* Assume that a system has already been loaded. */
status = xiaGetNumDetectors(&numDet);
if (status != XIA_SUCCESS) {
    /* ERROR getting number of detectors */
}

/* Allocate the memory we need for the string array */
detectors = (char **)malloc(numDet * sizeof(char *));
if (detectors == NULL) {
    /* ERROR allocating memory for detectors */
}

for (i = 0; i < numDet; i++) {
    detectors[i] = (char *)malloc(MAXALIAS_LEN * sizeof(char));
    if (detectors[i] == NULL) {
        /* ERROR allocating memory for detectors[i] */
    }
}

status = xiaGetDetectors(detectors);
if (status != XIA_SUCCESS) {
    /* ERROR getting detectors list */
}

for (i = 0; i < numDet; i++) {
    printf("detectors[%u] = %s\n", i, detectors[i]);
}

for (i = 0; i < numDet; i++) {
    free((void *)detectors[i]);
}

free((void *)detectors);
detectors = NULL;
int xiaGetDetectors_VB(unsigned int index, char *alias)#

This routine serves as a replacement for xiaGetDetectors() for use with Visual Basic or other languages that will not allow an array of strings to be passed into the Handel DLL. The standard idiom is to get the number of detectors in the system with a call to xiaGetNumDetectors() and to then loop from 0 to numDetectors- 1 to get all of the detector aliases in the system.

Param[in] index:

The index of the detector alias to get. Ranges from 0 to numDetectors-1.

Param[out] alias:

A pointer to the character array to hold the requested detector alias.

Returns:

A status code indicating the result of the operation.

Return values:
  • XIA_SUCCESS – Successful execution.

  • XIA_BAD_INDEX – If the requested index was out of range.

Example Usage

int status;
unsigned int numDetectors = 0;
unsigned int i;
char **aliases = NULL;

/* Assume that a valid system has been setup */
status = xiaGetNumDetectors(&numDetectors);
if (status != XIA_SUCCESS) {
    /* ERROR getting # of detectors in system */
}

/* Must allocate proper amount of memory */
aliases = (char **)malloc(numDetectors * sizeof(char *));
if (aliases == NULL) {
    /* ERROR allocating memory for aliases array */
}

for (i = 0; i < numDetectors; i++) {
    aliases[i] = (char *)malloc(MAXALIAS_LEN * sizeof(char));
    if (aliases[i] == NULL) {
        /* ERROR allocating memory for aliases[i] */
    }
}

for (i = 0; i < numDetectors; i++) {
    status = xiaGetDetectors(i, aliases[i]);
    if (status != XIA_SUCCESS) {
        /* ERROR getting detector alias at index i */
    }
}

for (i = 0; i < numDetectors; i++) {
    printf("Detector alias at index = %u: %s", i, aliases[i]);
}

for (i = 0; i < numDetectors; i++) {
    free((void *)aliases[i]);
}

free(aliases);
int xiaGetNumDetectors(unsigned int *numDet)#

Gets the number of detectors currently defined in the system.

Param[out] numDet:

Pointer to an unsigned integer that will hold the number of detectors.

Returns:

A status code indicating the result of the operation.

Return values:
  • XIA_SUCCESS – Successful execution.

  • Non-Zero Integer – If there was an error.

Example Usage

int status;
unsigned int numDet = 0;

/**
 * Assume that a system has already been created or loaded and that it defines
 * two detectors.
 */
status = xiaGetNumDetectors(&numDet);

if (status != XIA_SUCCESS) {
    /* ERROR getting number of detectors */
}

printf("There are currently %u detector(s) defined.\n", numDet);