mupp 1.1.0
Loading...
Searching...
No Matches
PParamDataHandler Class Reference

Central manager class for loading and accessing parameter collections. More...

#include <Pmupp.h>

Inheritance diagram for PParamDataHandler:
Collaboration diagram for PParamDataHandler:

Signals

void newData ()
 Signal emitted when new data has been successfully loaded.
 

Public Member Functions

 PParamDataHandler ()
 Default constructor.
 
int GetNoOfCollections ()
 Gets the total number of loaded collections.
 
void NewCollection (const QString name)
 Creates and adds an empty collection with the specified name.
 
bool ReadParamFile (const QStringList fln, QString &errorMsg)
 Reads parameter file(s) and loads them into collections.
 
PmuppCollection ReadDbFile (const QString fln, bool &valid, QString &errorMsg)
 Reads and parses a db-format parameter file.
 
PmuppCollection ReadColumnParamFile (const QString fln, bool &valid, QString &errorMsg)
 Reads and parses a column-based parameter file (dat/txt format).
 
PmuppCollection GetCollection (const int idx, bool &valid)
 Retrieves a collection by index (by value).
 
PmuppCollection GetCollection (const QString name, bool &valid)
 PParamDataHandler::GetCollection. Get collection by name.
 
PmuppCollectionGetCollection (const int idx)
 PParamDataHandler::GetCollection. Get a pointer of the requested collection.
 
PmuppCollectionGetCollection (const QString name)
 PParamDataHandler::GetCollection. Get collection pointer by name.
 
int GetCollectionIndex (const QString name)
 PParamDataHandler::GetCollectionIndex. Get the collection index of a given collection name.
 
QString GetCollectionName (const int idx)
 PParamDataHandler::GetCollectionName.
 
QVector< double > GetValues (QString collName, QString paramName)
 Retrieves all values for a specific parameter across all runs.
 
QVector< double > GetPosErr (QString collName, QString paramName)
 Retrieves all positive errors for a specific parameter across all runs.
 
QVector< double > GetNegErr (QString collName, QString paramName)
 Retrieves all negative errors for a specific parameter across all runs.
 
void RemoveCollection (QString name)
 Removes a collection from the handler by name.
 
void ReplaceCollection (PmuppCollection coll, int idx)
 Replaces a collection at the specified index.
 
void Dump ()
 Dumps all collection data to stdout for debugging.
 

Private Slots

void readFromStdOut ()
 Slot to handle standard output from msr2data process.
 
void readFromStdErr ()
 Slot to handle standard error from msr2data process.
 
void processDone (int, QProcess::ExitStatus)
 Slot to handle completion of msr2data process.
 

Private Member Functions

bool analyzeFileList (const QStringList &fln, QString &collectionName, QStringList &arg, QString &workDir, QString &errorMsg)
 Analyzes a list of msr-files to prepare arguments for msr2data.
 

Private Attributes

std::unique_ptr< QProcess > fProc
 process handle for invoking msr2data when msr files need conversion
 
QVector< PmuppCollectionfCollection
 vector containing all loaded collections
 

Detailed Description

Central manager class for loading and accessing parameter collections.

The PParamDataHandler class is responsible for managing all loaded parameter collections in mupp. It provides functionality for:

  • Reading and parsing parameter files (db, dat, msr formats)
  • Managing multiple collections simultaneously
  • Providing access to parameter data by collection and parameter name
  • Handling conversion of msr files via msr2data external process

This class acts as the primary interface between the data storage and the GUI or scripting components of mupp. It maintains a vector of all loaded collections and provides various query methods to extract parameter values and errors.

File format support:

  • .db files: muSR database format with structured parameter entries
  • .dat/.txt files: Column-based parameter files
  • .msr files: muSR fit input files (converted via msr2data)

Definition at line 306 of file Pmupp.h.

Constructor & Destructor Documentation

◆ PParamDataHandler()

PParamDataHandler::PParamDataHandler ( )
inline

Default constructor.

Definition at line 313 of file Pmupp.h.

Member Function Documentation

◆ analyzeFileList()

bool PParamDataHandler::analyzeFileList ( const QStringList & fln,
QString & collectionName,
QStringList & arg,
QString & workDir,
QString & errorMsg )
private

Analyzes a list of msr-files to prepare arguments for msr2data.

When parameter data is provided as msr-files (muSR fit input files), this function analyzes their structure to extract run numbers and extensions, preparing the argument list needed to invoke the msr2data external tool for conversion to db format.

The function expects msr-files with names following the pattern: <runNumber><extension>.msr where <extension> starts with '_'. All msr-files in the list must have the same extension.

Parameters
flnlist of msr-file paths to be analyzed
collectionNameoutput parameter: name for the resulting db/dat collection file
argoutput parameter: argument list to be passed to msr2data
workDiroutput parameter: working directory where files are located
errorMsgoutput parameter: error message if analysis fails
Returns
true if analysis is successful, false otherwise

Definition at line 252 of file Pmupp.cpp.

◆ Dump()

void PParamDataHandler::Dump ( )

Dumps all collection data to stdout for debugging.

Prints a formatted representation of all loaded collections, including collection names, run numbers, run names, and all parameters with their values and errors. This is primarily used for debugging and verification purposes.

Output format shows:

  • Collection separator and name
  • For each run: run number, run name
  • For each parameter: name, value, negative error, positive error

Definition at line 1165 of file Pmupp.cpp.

◆ GetCollection() [1/4]

PmuppCollection * PParamDataHandler::GetCollection ( const int idx)

PParamDataHandler::GetCollection. Get a pointer of the requested collection.

Parameters
idxof the collection
Returns
requested pointer to the collection on success.

Definition at line 848 of file Pmupp.cpp.

◆ GetCollection() [2/4]

PmuppCollection PParamDataHandler::GetCollection ( const int idx,
bool & valid )

Retrieves a collection by index (by value).

Returns a copy of the collection at the specified index position. If the index is out of range, returns an empty collection and sets valid to false.

Parameters
idxzero-based index of the collection to retrieve
validoutput parameter: set to true if collection found, false otherwise
Returns
copy of the requested collection, or an empty collection if not found
See also
GetCollection(const QString, bool&), GetCollection(const int)

Definition at line 827 of file Pmupp.cpp.

◆ GetCollection() [3/4]

PmuppCollection * PParamDataHandler::GetCollection ( const QString name)

PParamDataHandler::GetCollection. Get collection pointer by name.

Parameters
nameof the requested collection
Returns
pointer of the requested collection on success, nullptr otherwise

Definition at line 893 of file Pmupp.cpp.

◆ GetCollection() [4/4]

PmuppCollection PParamDataHandler::GetCollection ( const QString name,
bool & valid )

PParamDataHandler::GetCollection. Get collection by name.

Parameters
nameof the requested collection
validtrue if found
Returns
requested collection on success.

Definition at line 865 of file Pmupp.cpp.

◆ GetCollectionIndex()

int PParamDataHandler::GetCollectionIndex ( const QString name)

PParamDataHandler::GetCollectionIndex. Get the collection index of a given collection name.

Parameters
nameof the requested collection
Returns
index of the requested collection on success, otherwise -1.

Definition at line 918 of file Pmupp.cpp.

◆ GetCollectionName()

QString PParamDataHandler::GetCollectionName ( const int idx)

PParamDataHandler::GetCollectionName.

Parameters
idx
Returns

Definition at line 938 of file Pmupp.cpp.

◆ GetNegErr()

QVector< double > PParamDataHandler::GetNegErr ( QString collName,
QString paramName )

Retrieves all negative errors for a specific parameter across all runs.

This method extracts the negative (lower) error values of a named parameter from all runs in the specified collection. The returned vector has one entry per run, in the order they appear in the collection.

Used in conjunction with GetValues() and GetPosErr() for plotting parameters with asymmetric error bars.

Parameters
collNamename of the collection to query
paramNamename of the parameter whose negative errors to extract
Returns
vector of negative error values, one per run in the collection. Returns an empty vector if the collection or parameter is not found.
See also
GetValues(), GetPosErr()

Definition at line 1077 of file Pmupp.cpp.

◆ GetNoOfCollections()

int PParamDataHandler::GetNoOfCollections ( )
inline

Gets the total number of loaded collections.

Returns
the count of collections currently managed

Definition at line 319 of file Pmupp.h.

◆ GetPosErr()

QVector< double > PParamDataHandler::GetPosErr ( QString collName,
QString paramName )

Retrieves all positive errors for a specific parameter across all runs.

This method extracts the positive (upper) error values of a named parameter from all runs in the specified collection. The returned vector has one entry per run, in the order they appear in the collection.

Used in conjunction with GetValues() for plotting parameters with error bars.

Parameters
collNamename of the collection to query
paramNamename of the parameter whose positive errors to extract
Returns
vector of positive error values, one per run in the collection. Returns an empty vector if the collection or parameter is not found.
See also
GetValues(), GetNegErr()

Definition at line 1022 of file Pmupp.cpp.

◆ GetValues()

QVector< double > PParamDataHandler::GetValues ( QString collName,
QString paramName )

Retrieves all values for a specific parameter across all runs.

This method extracts the central values of a named parameter from all runs in the specified collection. The returned vector has one entry per run, in the order they appear in the collection.

This is useful for plotting parameter evolution (e.g., relaxation rate vs. temperature) where each run represents a different experimental condition.

Parameters
collNamename of the collection to query
paramNamename of the parameter to extract (e.g., "alpha", "lambda")
Returns
vector of parameter values, one per run in the collection. Returns an empty vector if the collection or parameter is not found.
See also
GetPosErr(), GetNegErr()

Definition at line 968 of file Pmupp.cpp.

◆ NewCollection()

void PParamDataHandler::NewCollection ( const QString name)

Creates and adds an empty collection with the specified name.

This method creates a new empty collection and adds it to the handler's collection vector. The collection can then be populated with runs later.

Parameters
namethe name to assign to the new collection

Definition at line 223 of file Pmupp.cpp.

◆ newData

void PParamDataHandler::newData ( )
signal

Signal emitted when new data has been successfully loaded.

This signal is emitted after parameter files have been read and collections have been added to the handler. Connected slots can update their displays or perform other actions in response.

◆ processDone

void PParamDataHandler::processDone ( int exitCode,
QProcess::ExitStatus exitStatus )
privateslot

Slot to handle completion of msr2data process.

This slot is connected to the finished signal of the QProcess used to run msr2data. It checks the exit status and logs errors if the process crashed or exited with a non-zero exit code.

Parameters
exitCodethe exit code returned by the process
exitStatusindicates whether the process exited normally or crashed

Definition at line 1225 of file Pmupp.cpp.

◆ ReadColumnParamFile()

PmuppCollection PParamDataHandler::ReadColumnParamFile ( const QString fln,
bool & valid,
QString & errorMsg )

Reads and parses a column-based parameter file (dat/txt format).

The column format is a simple text format where:

  • First line: Header with column names
  • Following lines: Data values (one row per run)
  • Columns are whitespace-separated

Column naming conventions:

  • Parameter names without suffix: parameter values
  • Names ending with "Err": symmetric errors
  • Names ending with "PosErr": positive (upper) errors
  • Names ending with "NegErr": negative (lower) errors
  • Column named "RUN": run number identifier

Error handling supports both symmetric (single error column) and asymmetric (separate PosErr/NegErr columns) error specifications.

Parameters
flnpath to the dat/txt-file to be read
validoutput parameter: set to true on success, false on failure
errorMsgoutput parameter: error message describing any failures
Returns
a PmuppCollection object containing all runs and parameters from the file. Returns an empty collection if reading fails (valid will be false).
See also
ReadParamFile(), ReadDbFile()

Definition at line 679 of file Pmupp.cpp.

◆ ReadDbFile()

PmuppCollection PParamDataHandler::ReadDbFile ( const QString fln,
bool & valid,
QString & errorMsg )

Reads and parses a db-format parameter file.

The db format is a structured text format containing parameter data with metadata sections. The file structure includes:

  • Title and abstract sections (ignored by this parser)
  • Data-tags section (ignored)
  • Parameter entries section (following "\\-e" marker)
  • Each parameter: name=value, posError, negError, unused
  • Run entries: runNumber, title

The function validates that all runs have the same number of parameters to ensure data consistency.

Parameters
flnpath to the db-file to be read
validoutput parameter: set to true on success, false on failure
errorMsgoutput parameter: error message describing any failures
Returns
a PmuppCollection object containing all runs and parameters from the file. Returns an empty collection if reading fails (valid will be false).
See also
ReadParamFile(), ReadColumnParamFile()

Definition at line 499 of file Pmupp.cpp.

◆ readFromStdErr

void PParamDataHandler::readFromStdErr ( )
privateslot

Slot to handle standard error from msr2data process.

This slot is connected to the readyReadStandardError signal of the QProcess used to run msr2data. It reads and logs all output from the process's stderr.

Definition at line 1209 of file Pmupp.cpp.

◆ readFromStdOut

void PParamDataHandler::readFromStdOut ( )
privateslot

Slot to handle standard output from msr2data process.

This slot is connected to the readyReadStandardOutput signal of the QProcess used to run msr2data. It reads and logs all output from the process's stdout.

Definition at line 1196 of file Pmupp.cpp.

◆ ReadParamFile()

bool PParamDataHandler::ReadParamFile ( const QStringList fln,
QString & errorMsg )

Reads parameter file(s) and loads them into collections.

This is the main entry point for loading parameter data. It handles multiple file formats (msr, db, dat) and dispatches to the appropriate reader function. For msr-files, it invokes msr2data to convert them to db format first.

File format handling:

Multiple files can be loaded in a single call. Each file becomes a separate collection in the handler.

Parameters
flnlist of file names (with paths) to be loaded
errorMsgoutput parameter: error message if reading fails
Returns
true on success, false on any error
See also
ReadDbFile(), ReadColumnParamFile(), analyzeFileList()

Definition at line 346 of file Pmupp.cpp.

◆ RemoveCollection()

void PParamDataHandler::RemoveCollection ( QString name)

Removes a collection from the handler by name.

Searches for a collection with the specified name and removes it from the internal collection vector. If multiple collections have the same name, only the first match is removed.

Parameters
namethe name of the collection to be removed

Definition at line 1123 of file Pmupp.cpp.

◆ ReplaceCollection()

void PParamDataHandler::ReplaceCollection ( PmuppCollection coll,
int idx )

Replaces a collection at the specified index.

Replaces an existing collection with a new one at the given index position. If the index is out of range, no action is taken.

Parameters
collthe new collection to insert
idxthe index position where the collection should be replaced

Definition at line 1143 of file Pmupp.cpp.

Member Data Documentation

◆ fCollection

QVector<PmuppCollection> PParamDataHandler::fCollection
private

vector containing all loaded collections

Definition at line 355 of file Pmupp.h.

◆ fProc

std::unique_ptr<QProcess> PParamDataHandler::fProc
private

process handle for invoking msr2data when msr files need conversion

Definition at line 354 of file Pmupp.h.


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