DDASToys for NSCLDAQ  6.2-000
Classes | Public Member Functions | List of all members

Manage fit configuration information. More...

#include <Configuration.h>

Public Member Functions

 Configuration ()
 Constructor.
 
 ~Configuration ()
 Destructor.
 
void readConfigFile ()
 Read the configuration file. More...
 
void readTemplateFile ()
 Read the formatted tempalate data from a file. More...
 
bool fitChannel (unsigned crate, unsigned slot, unsigned channel)
 Check the map and determine if the channel should be fit. More...
 
std::pair< unsigned, unsigned > getFitLimits (unsigned crate, unsigned slot, unsigned channel)
 Get the (inclusive) fit limits for a single crate/slot/channel combination. More...
 
unsigned getSaturationValue (unsigned crate, unsigned slot, unsigned channel)
 Get the ADC saturation value for a single crate/slot/channel combination. More...
 
std::string getModelPath (unsigned crate, unsigned slot, unsigned channel)
 Get the ML inference model path for a single crate/slot/channel combination. More...
 
std::vector< std::string > getModelList ()
 Get the list of unique model names specified in the configuration file. More...
 
std::vector< double > getTemplate ()
 Return the template data. More...
 
unsigned getTemplateAlignPoint ()
 Return the template alignment point. More...
 

Detailed Description

Manage fit configuration information.

This class is a configuration manager for the DDASToys programs. It is responsible for opening and reading data from configuration files pointed to by environment variables and managing the configuration data. The class defines a map of channel information for fitting. The map index is a unique channel identifier and the value is a class object containing the fit limits, ADC satutration value and any additional info required by the fitters (e.g., the location of a PyTorch model for ML inference).

Member Function Documentation

◆ fitChannel()

bool ddastoys::Configuration::fitChannel ( unsigned  crate,
unsigned  slot,
unsigned  channel 
)

Check the map and determine if the channel should be fit.

Parameters
crateThe crate ID.
slotThe slot ID.
channelThe channel ID.
Returns
True if this channel trace should be fit (its in the map), false otherwise.

Its up to caller to ensure that there is a map entry for this channel. Caller should exit with failure message if we attempt to fit an unmapped channel.

◆ getFitLimits()

std::pair< unsigned, unsigned > ddastoys::Configuration::getFitLimits ( unsigned  crate,
unsigned  slot,
unsigned  channel 
)

Get the (inclusive) fit limits for a single crate/slot/channel combination.

Parameters
crateThe crate ID.
slotThe slot ID.
channelThe channel ID.
Returns
Pair of [low, high] fit limits (inclusive).

◆ getModelList()

std::vector< std::string > ddastoys::Configuration::getModelList ( )

Get the list of unique model names specified in the configuration file.

Returns
Vector of unique model paths.

As a consequence of the sort-and-erase idiom used to uniquify the model list, the model paths names are sorted in the returned vector and may be in a different order than how they appear in the configuration file. It is the responsibilty of the caller to deal with this.

◆ getModelPath()

std::string ddastoys::Configuration::getModelPath ( unsigned  crate,
unsigned  slot,
unsigned  channel 
)

Get the ML inference model path for a single crate/slot/channel combination.

Parameters
crateThe crate ID.
slotThe slot ID.
channelThe channel ID.
Returns
Path to the ML inference model.

◆ getSaturationValue()

unsigned ddastoys::Configuration::getSaturationValue ( unsigned  crate,
unsigned  slot,
unsigned  channel 
)

Get the ADC saturation value for a single crate/slot/channel combination.

Parameters
crateThe crate ID.
slotThe slot ID.
channelThe channel ID.
Returns
The saturation value of the trace for this channel.

◆ getTemplate()

std::vector<double> ddastoys::Configuration::getTemplate ( )
inline

Return the template data.

Returns
The template trace data.

◆ getTemplateAlignPoint()

unsigned ddastoys::Configuration::getTemplateAlignPoint ( )
inline

Return the template alignment point.

Returns
The template trace alignment point.

◆ readConfigFile()

void ddastoys::Configuration::readConfigFile ( )

Read the configuration file.

Exceptions
std::invalid_argumentIf there are errors processing the file, including an inability to open the file.

Lines in the configuration file can be empty or have as their first non-blank character "#" in which case they are ignored. All other lines specify channels that should be fit and must contain six whitespace integers and one string: crate slot channel low high saturation model. The crate, slot, and channel are unsigned integers used to identify a channel to fit. Low and high specify the inclusive limits of the trace to fit in samples. The saturation value defines a limit above which the trace data points will not be fit. Most commonly this saturation value is set to the saturation value of the ADC. The last parameter is a string specifying a path to a PyTorch model for the machine-learning inference fitting. Not all parameters are used by each fitting method but default values must be provided. Please refer to the following:

Warning
While all parameters must be specified in the configuration, depending on the fitting method, some of them may be ignored in parts of the code. Specifically, the machine-learning inference fitting will ignore the fit limits, as it requires the input data to be the same shape as the training data which is assumed to be the full acquired trace. The traceview plotter will use these low and high limits to draw the fit so in practice it is best to set them to sensible values. Non-ML based fitting methods will ignore the model parameter. An empty string ("") is a vaild input in the configuration file.

◆ readTemplateFile()

void ddastoys::Configuration::readTemplateFile ( )

Read the formatted tempalate data from a file.

Exceptions
std::length_errorIf the number of template data points is different than what the configuration file expects.
std::invalid_arugmentIf the alignment point of the template is not contained in the trace (e.g. align to sample 100 on a 100 sample trace [0, 99]).
std::invalid_argumentIf the template data file cannot be opened.

Lines in the configuration file can be empty or have as their first non-blank character "#" in which case they are ignored. The first line consists of two whitespace-separated unsigned integer values which define the template metadata: the alignment point and the number of points in the template trace. The remaining lines in the configuration file contain the floating point template trace data itself.


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