NSCL DDAS 12.2-009
Support for XIA DDAS at FRIB
Public Member Functions | List of all members
CPixieRunUtilities Class Reference

Manage list-mode histogram and baseline runs for a Pixie-16 system. More...

#include <CPixieRunUtilities.h>

Public Member Functions

 CPixieRunUtilities ()
 Constructor. More...
 
 ~CPixieRunUtilities ()
 Destructor. More...
 
int BeginHistogramRun (int module, int nChannels)
 Begin a histogram (MCA) run for a single module. Explicitly sets module synchronization to OFF. More...
 
int EndHistogramRun (int module)
 End a histogram (MCA) run for a single module. Assumes module synchronization is OFF but only stops a run in a single module. More...
 
int ReadHistogram (int module, int channel)
 Read energy histogram from single channel. More...
 
int BeginBaselineRun (int module, int nChannels)
 Begin a baseline run. More...
 
int EndBaselineRun (int module)
 "End" a baseline run. More...
 
int ReadBaseline (int module, int channel)
 Acquire baselines and read baseline data from a single channel. More...
 
int ReadModuleStats (int module)
 Read statistics for a single module after a run is ended. More...
 
void SetUseGenerator (bool mode)
 Set the use of the generator for offline data. More...
 
void SetLastErrorMessage (const char *msg)
 Set the last error message. Used by the extern "C" shims when their catch-all fires. More...
 
unsigned int * GetHistogramData ()
 Get the histogram data from a list-mode run. More...
 
unsigned int * GetBaselineData ()
 Get the baseline run data. More...
 
bool GetRunActive ()
 Get the current run status. More...
 
int GetHistogramLength (int module)
 Get the histogram length for a module. More...
 
int GetMaxBaselines (int module)
 Get the maximum number of baselines for a module. More...
 
const char * GetLastErrorMessage ()
 Get the reason text from the most recent failed operation. More...
 

Detailed Description

Manage list-mode histogram and baseline runs for a Pixie-16 system.

This class provides functionality to start and stop runs as well as read data from the modules and return it to the caller.

Constructor & Destructor Documentation

◆ CPixieRunUtilities()

CPixieRunUtilities::CPixieRunUtilities ( )

Constructor.

The CPixieRunUtilities class has ownership of a CDataGenerator object and is responsible for managing it.

◆ ~CPixieRunUtilities()

CPixieRunUtilities::~CPixieRunUtilities ( )

Destructor.

Member Function Documentation

◆ BeginBaselineRun()

int CPixieRunUtilities::BeginBaselineRun ( int  module,
int  nChannels 
)

Begin a baseline run.

Parameters
moduleModule number.
nChannelsChannels per module.
Returns
int
Return values
0Always.

Baseline acquisition is not a "run" in the same sense that histogram runs or list mode data taking is a "run" to the API (no begin/end functions, no run status change). However, in order for a user to accumulate enough baseline statistics to make judgements about e.g. manually setting baseline cuts, it needs to be treated as such in our manager. The active run flag is set to true when taking a baseline "run."

The baseline data itself is stored internally as a histogram of values in [0, histLength). This data structure is reset on begin.

◆ BeginHistogramRun()

int CPixieRunUtilities::BeginHistogramRun ( int  module,
int  nChannels 
)

Begin a histogram (MCA) run for a single module. Explicitly sets module synchronization to OFF.

Parameters
moduleModule number.
nChannelsChannels per module.
Returns
int
Return values
0Success.
!=0XIA API error code.
Todo:
Disable multiple modules from running in non-sync mode.

◆ EndBaselineRun()

int CPixieRunUtilities::EndBaselineRun ( int  module)

"End" a baseline run.

Parameters
moduleModule number.
Returns
int
Return values
0Always.

Really all we need to do here is set the active run flag to false.

◆ EndHistogramRun()

int CPixieRunUtilities::EndHistogramRun ( int  module)

End a histogram (MCA) run for a single module. Assumes module synchronization is OFF but only stops a run in a single module.

Parameters
moduleModule number.
Returns
int
Return values
0Run end attempted; may return 0 even if the run did not stop within the retry limit.
!=0XIA API error code on failure.

If the run cannot be ended on the first attempt, retry 10 times before reporting that the run could not be ended properly. Generally speaking, this is caused when one or more channels has a very high trigger rate.

◆ GetBaselineData()

unsigned int * CPixieRunUtilities::GetBaselineData ( )
inline

Get the baseline run data.

Returns
Pointer to the underlying baseline storage.

◆ GetHistogramData()

unsigned int * CPixieRunUtilities::GetHistogramData ( )
inline

Get the histogram data from a list-mode run.

Returns
Pointer to the underlying histogram storage.

◆ GetHistogramLength()

int CPixieRunUtilities::GetHistogramLength ( int  module)

Get the histogram length for a module.

Parameters
moduleModule number (zero-indexed).
Returns
The histogram length for the module or XIA error code if failed.

It is assumed that all channels on a module have the same histogram length. Since this function cannot be called until after the system is booted, there is no need to check for that condition here. The caller assumes responsibility for making sure the module number is valid.

◆ GetLastErrorMessage()

const char * CPixieRunUtilities::GetLastErrorMessage ( )
inline

Get the reason text from the most recent failed operation.

Returns
Pointer to the stored message; empty string if none.

◆ GetMaxBaselines()

int CPixieRunUtilities::GetMaxBaselines ( int  module)

Get the maximum number of baselines for a module.

Parameters
moduleModule number (zero-indexed).
Returns
The maximum number of baseline values which can be read out at once for this module or XIA error code if failed.

It is assumed that all channels on a module have the same max baseline size. Since this function cannot be called until after the system is booted, there is no need to check for that condition here. The caller assumes responsibility for making sure the module number is valid.

◆ GetRunActive()

bool CPixieRunUtilities::GetRunActive ( )
inline

Get the current run status.

Returns
bool True if a run is active, false otherwise.

◆ ReadBaseline()

int CPixieRunUtilities::ReadBaseline ( int  module,
int  channel 
)

Acquire baselines and read baseline data from a single channel.

Parameters
moduleModule number.
channelChannel number on the module.
Returns
int
Return values
0Success.
!=0XIA API error code on failure.

Acquire baseline values for all channels on a module using Pixie16AcquireBaselines() and update the internal storage for baseline data. The single channel baseline data we want, specified by the input channel parameter, is copied into a local variable which is accessible via a getter function.

Todo:
(ASC 7/14/23): Why not just have the getter take a channel as an input parameter and return the correct baseline data. It seems unnecessary to maintain a separate copy.

◆ ReadHistogram()

int CPixieRunUtilities::ReadHistogram ( int  module,
int  channel 
)

Read energy histogram from single channel.

Parameters
moduleModule number.
channelChannel number on module to read histogram from.
Returns
int
Return values
0Success.
!=0XIA API error code.

Histogram data comes either from the module itself if running in online mode or from the data generator.

Note
The data generator is primarily used to debug plot elements, curve fitting and display options. It will ignore any histogram settings (EMin, BinFactor) from the DSP.

◆ ReadModuleStats()

int CPixieRunUtilities::ReadModuleStats ( int  module)

Read statistics for a single module after a run is ended.

Parameters
moduleModule number.
Returns
int
Return values
0Success.
!=0XIA API error code.

XIA API major verson > 3 does not guarantee a fixed-size statistics block. We must use the API function Pixie16GetStatisticsSize() to determine the stats block size and dynamically allocate memory for the statistics prior to reading them.

◆ SetLastErrorMessage()

void CPixieRunUtilities::SetLastErrorMessage ( const char *  msg)
inline

Set the last error message. Used by the extern "C" shims when their catch-all fires.

Parameters
msgMessage to store.

◆ SetUseGenerator()

void CPixieRunUtilities::SetUseGenerator ( bool  mode)
inline

Set the use of the generator for offline data.

Parameters
modeSet the generator use flag to this value.

The documentation for this class was generated from the following files: