musredit 1.0.0
Loading...
Searching...
No Matches
PMsr2DataDialog Class Reference

Dialog for configuring msr2data batch processing parameters. More...

#include <PMsr2DataDialog.h>

Inheritance diagram for PMsr2DataDialog:
Collaboration diagram for PMsr2DataDialog:

Public Slots

void runListEntered (const QString &)
 Handles run list text field activation.
 
void runListFileNameEntered (const QString &)
 Handles run list file name text field activation.
 
void templateRunEntered (const QString &)
 Handles template run number text field activation.
 
void createMsrFileOnlyChanged (int)
 Handles "Create msr-File only" checkbox state changes.
 
void fitOnlyChanged (int)
 Handles "Fit Only" checkbox state changes.
 
void helpContent ()
 Opens online help for msr2data.
 

Public Member Functions

 PMsr2DataDialog (PMsr2DataParam *msr2DataParam, const QString helpUrl)
 Constructs the msr2data configuration dialog.
 
virtual int getRunTag ()
 Returns the run input method tag.
 
virtual PMsr2DataParamgetMsr2DataParam ()
 Retrieves all msr2data parameters from the dialog.
 

Private Slots

void globalOptionSet (bool checked)
 Enforces mutual exclusivity between global and global+ options.
 
void globalPlusOptionSet (bool checked)
 Enforces mutual exclusivity between global+ and global options.
 

Private Attributes

int fRunTag
 Run input method: -1=invalid, 0=direct list, 1=file name.
 
PMsr2DataParamfMsr2DataParam
 Pointer to parameter structure for msr2data configuration.
 
QString fHelpUrl
 URL to online msr2data documentation.
 

Detailed Description

Dialog for configuring msr2data batch processing parameters.

This dialog collects all necessary input parameters for B.M. Wojek's msr2data program, which automates the fitting of multiple µSR data runs. The tool uses a template msr file to generate individual fit files for each run and optionally extracts fit results to database or column files.

Run Selection:
Users can specify runs to process in two ways:
  • Direct run list: Comma-separated run numbers (e.g., "123,125-130,145")
  • Run list file: Path to a file containing run numbers
Template System:
A template run number defines an existing msr file used as a pattern for creating msr files for all runs in the list. The template's RUN blocks are updated with new run numbers while preserving the fit structure.
Processing Modes:
  • Create msr files only: Generate msr files without fitting
  • Fit only: Fit existing msr files (no template needed)
  • Full processing: Create msr files and fit them
Global Fitting:
  • global: Fit with shared parameters across runs (standard global fit)
  • global+: Enhanced global fitting with additional constraints
Output Options:
  • Database file: Append fit results to a structured database
  • Column file: Write results in columnar format
  • YAML output: Export fit results in YAML format
  • Per-run chi-square: Include individual run chi-square values
Note
The dialog enforces mutual exclusivity between conflicting options (e.g., create-only vs. fit-only, global vs. global+).
See also
PMsr2DataParam Structure holding all msr2data parameters
musredit For the main editor application

Definition at line 97 of file PMsr2DataDialog.h.

Constructor & Destructor Documentation

◆ PMsr2DataDialog()

PMsr2DataDialog::PMsr2DataDialog ( PMsr2DataParam * msr2DataParam,
const QString helpUrl )

Constructs the msr2data configuration dialog.

Constructor - Initializes the msr2data configuration dialog.

Initializes the dialog with existing msr2data parameters and sets up all UI controls including text fields, checkboxes, and validators. The dialog is configured as modal and establishes signal-slot connections for option interdependencies.

Parameters
msr2DataParamPointer to the parameter structure containing previously saved msr2data settings. The dialog will populate fields with these values and update them when the user accepts the dialog.
helpUrlURL string pointing to online msr2data documentation. If empty, the help button will show a placeholder message.
See also
getMsr2DataParam() Retrieves updated parameters after dialog acceptance
PMsr2DataParam Data structure definition

Sets up the complete user interface for msr2data parameter configuration. The initialization process includes:

  1. UI Setup: Loads the dialog layout from Qt Designer UI file
  2. Modal Configuration: Sets the dialog as modal to ensure completion
  3. Field Population: Fills all text fields from saved parameters
  4. Validation: Installs integer validator on template run number field
  5. Checkbox States: Restores all checkbox states from saved configuration
  6. Signal Connections: Establishes slots for option interdependencies

The dialog handles a comprehensive set of msr2data parameters:

Run Input:

  • Direct run list (comma-separated, ranges allowed)
  • Run list file path
  • Template run number for msr file generation
  • msr file extension (e.g., ".msr")

Output Configuration:

  • Database output file name
  • Parameter list for output
  • Write/recreate database file options
  • Column data and YAML output formats

Processing Options:

  • Create msr files only (no fitting)
  • Fit only (use existing msr files)
  • Chain fitting (sequential parameter passing)
  • Global/Global+ fitting modes (mutually exclusive)

Advanced Options:

  • Estimate N0 from data
  • Keep MINUIT2 output files
  • Per-run block chi-square values
  • Title from data file
  • Ignore data header information
  • Open files after fitting
Parameters
msr2DataParamPointer to PMsr2DataParam structure containing previously saved msr2data settings. Must not be nullptr. The dialog will populate UI controls from this structure and update it when accepted.
helpUrlURL string for online msr2data documentation. If empty, the help button will display a placeholder message.
Note
The template run number field only accepts integer input via QIntValidator.
The OK button is set as the default button for convenient dialog acceptance.
Signal connections enforce mutual exclusivity between global and global+.
See also
getMsr2DataParam() Retrieves updated parameters after dialog acceptance
globalOptionSet() Handles global checkbox interactions
globalPlusOptionSet() Handles global+ checkbox interactions

Definition at line 114 of file PMsr2DataDialog.cpp.

Member Function Documentation

◆ createMsrFileOnlyChanged

void PMsr2DataDialog::createMsrFileOnlyChanged ( int buttonState)
slot

Handles "Create msr-File only" checkbox state changes.

Slot: Handles "Create msr-File only" checkbox changes.

Called when the create-only checkbox is toggled. If checked, automatically unchecks "Fit Only" since these modes are mutually exclusive.

Parameters
buttonStateQt checkbox state (Qt::Checked or Qt::Unchecked).
See also
fitOnlyChanged() For the complementary option

Called when the user toggles the create-msr-file-only checkbox. This mode generates msr files from the template without performing fits, which is useful for reviewing generated files before batch fitting.

Since creating files only and fitting only are mutually exclusive operations, checking this option automatically unchecks "Fit Only".

Workflow for create-only mode:

  1. Specify run list (direct or file)
  2. Provide template run number
  3. Check "Create msr-File only"
  4. Execute to generate msr files
  5. Review generated files
  6. Optionally run again with "Fit Only" to perform fits
Parameters
buttonStateQt checkbox state (Qt::Checked or Qt::Unchecked).
See also
fitOnlyChanged() Complementary method for the fit-only option

Definition at line 386 of file PMsr2DataDialog.cpp.

◆ fitOnlyChanged

void PMsr2DataDialog::fitOnlyChanged ( int buttonState)
slot

Handles "Fit Only" checkbox state changes.

Slot: Handles "Fit Only" checkbox changes.

Called when the fit-only checkbox is toggled. If checked, automatically unchecks "Create msr-File only" and clears the template run number since fitting existing files doesn't require a template.

Parameters
buttonStateQt checkbox state (Qt::Checked or Qt::Unchecked).
See also
createMsrFileOnlyChanged() For the complementary option

Called when the user toggles the fit-only checkbox. This mode fits existing msr files without generating new ones, which is useful for refitting after manual msr file modifications or after initial create-only generation.

When fit-only mode is enabled:

  • "Create msr-File only" is automatically unchecked (mutually exclusive)
  • Template run number field is cleared (no template needed)

Fit-only mode workflow:

  1. Specify run list (direct or file)
  2. Ensure msr files exist for all runs
  3. Check "Fit Only"
  4. Execute to fit existing msr files

This is particularly useful for:

  • Refitting after parameter adjustments
  • Fitting manually created msr files
  • Two-stage workflow (create, review, then fit)
Parameters
buttonStateQt checkbox state (Qt::Checked or Qt::Unchecked).
See also
createMsrFileOnlyChanged() Complementary method for the create-only option
templateRunEntered() Clears fit-only when template is provided

Definition at line 421 of file PMsr2DataDialog.cpp.

◆ getMsr2DataParam()

PMsr2DataParam * PMsr2DataDialog::getMsr2DataParam ( )
virtual

Retrieves all msr2data parameters from the dialog.

Retrieves all msr2data parameters from dialog UI controls.

Collects values from all UI controls and updates the internal PMsr2DataParam structure. This includes:

  • Run list specifications (direct list or file)
  • Template run number
  • msr file extension
  • Output file names and parameter list
  • All checkbox options (header writing, estimation, fitting modes, etc.)

This method is typically called after the dialog is accepted to obtain the complete configuration for launching msr2data.

Returns
PMsr2DataParam* Pointer to the updated parameter structure. The caller owns this structure and must manage its lifetime.
Note
The returned pointer is the same as the one passed to the constructor, just with updated values.
See also
PMsr2DataParam For the complete parameter structure definition

Collects values from all text fields and checkboxes in the dialog and updates the internal PMsr2DataParam structure. This method provides a complete snapshot of the user's msr2data configuration.

The collected parameters include:

Run Specification:

  • runList: Direct run list string (e.g., "123,125-130,145")
  • runListFileName: Path to file containing run numbers
  • msrFileExtension: File extension for msr files (e.g., ".msr")
  • templateRunNo: Template run number for msr file generation (-1 if empty)

Output Configuration:

  • dbOutputFileName: Database file path for fit results
  • paramList: Comma-separated list of parameters to extract
  • writeDbHeader: Write header line to database file
  • writeColumnData: Output results in column format
  • yamlOut: Generate YAML format output
  • perRunBlockChisq: Include per-run chi-square values

Processing Control:

  • createMsrFileOnly: Generate msr files without fitting
  • fitOnly: Fit existing msr files (no template needed)
  • chainFit: Pass parameters sequentially between runs
  • global: Standard global fitting mode
  • globalPlus: Enhanced global fitting mode

Advanced Options:

  • estimateN0: Estimate initial asymmetry from data
  • keepMinuit2Output: Preserve MINUIT2 output files
  • recreateDbFile: Overwrite existing database file
  • ignoreDataHeaderInfo: Skip data file header parsing
  • titleFromDataFile: Extract title from data file
  • openFilesAfterFitting: Open result files in default applications
Returns
PMsr2DataParam* Pointer to the updated parameter structure. This is the same pointer passed to the constructor, with all fields updated from the dialog UI. The caller retains ownership.
Note
This method is typically called after the dialog is accepted via OK button.
Empty template run number field is converted to -1 to indicate no template.
The method performs no validation; all values are accepted as entered.
See also
PMsr2DataDialog::PMsr2DataDialog() Where the parameter structure is initialized
PMsr2DataParam Structure definition with all field descriptions

Definition at line 222 of file PMsr2DataDialog.cpp.

◆ getRunTag()

virtual int PMsr2DataDialog::getRunTag ( )
inlinevirtual

Returns the run input method tag.

Indicates which method was used to specify the run list:

  • -1: Invalid or no input provided
  • 0: Direct run list entered in the text field
  • 1: Run list file name provided

This tag helps the caller determine how to interpret the run information when processing the dialog results.

Returns
int representing the run input method (see details).
See also
runListEntered() Sets tag to 0
runListFileNameEntered() Sets tag to 1

Definition at line 138 of file PMsr2DataDialog.h.

◆ globalOptionSet

void PMsr2DataDialog::globalOptionSet ( bool checked)
privateslot

Enforces mutual exclusivity between global and global+ options.

Private slot: Enforces global/global+ mutual exclusivity (global side).

Called when the "global" checkbox is toggled. If global is checked, automatically unchecks global+ since these fitting modes cannot be used simultaneously.

Parameters
checkedtrue if the global checkbox is now checked.
See also
globalPlusOptionSet() For the complementary option

Called when the "global" checkbox state changes. Global and global+ are mutually exclusive fitting modes that cannot be used simultaneously:

  • global: Standard global fitting where parameters marked as "global" in the msr file are shared across all runs in the fit. All runs are fitted simultaneously with shared parameters constrained to have identical values.
  • global+: Enhanced global fitting mode with additional features for complex multi-run scenarios (see msr2data documentation for details).

When global is checked, this method automatically unchecks global+ to prevent conflicting mode selection.

Parameters
checkedtrue if the global checkbox is now checked, false otherwise.
Note
This slot is connected to the global checkbox clicked signal in the constructor.
See also
globalPlusOptionSet() Complementary method handling global+ checkbox

Definition at line 498 of file PMsr2DataDialog.cpp.

◆ globalPlusOptionSet

void PMsr2DataDialog::globalPlusOptionSet ( bool checked)
privateslot

Enforces mutual exclusivity between global+ and global options.

Private slot: Enforces global/global+ mutual exclusivity (global+ side).

Called when the "global+" checkbox is toggled. If global+ is checked, automatically unchecks global since these fitting modes cannot be used simultaneously.

Parameters
checkedtrue if the global+ checkbox is now checked.
See also
globalOptionSet() For the complementary option

Called when the "global+" checkbox state changes. Global and global+ are mutually exclusive fitting modes that cannot be used simultaneously:

  • global: Standard global fitting where parameters marked as "global" in the msr file are shared across all runs in the fit.
  • global+: Enhanced global fitting mode with extended capabilities for handling more complex global fitting scenarios with additional constraints and parameter relationships.

When global+ is checked, this method automatically unchecks global to prevent conflicting mode selection.

Parameters
checkedtrue if the global+ checkbox is now checked, false otherwise.
Note
This slot is connected to the global+ checkbox clicked signal in the constructor.
See also
globalOptionSet() Complementary method handling global checkbox

Definition at line 530 of file PMsr2DataDialog.cpp.

◆ helpContent

void PMsr2DataDialog::helpContent ( )
slot

Opens online help for msr2data.

Opens online help documentation for msr2data.

Attempts to open the msr2data documentation in the default web browser. The documentation covers command-line options, template system usage, global fitting, and output formats.

See also
PMsr2DataDialog::PMsr2DataDialog() Where helpUrl is initialized

Attempts to open the msr2data help URL in the user's default web browser using QDesktopServices::openUrl(). The documentation typically covers:

  • Command-line syntax and options
  • Template system usage and requirements
  • Run list formats and specifications
  • Global and global+ fitting modes
  • Output file formats (database, column, YAML)
  • Parameter extraction and mapping
  • Chain fitting for sequential parameter passing
  • Batch processing best practices
  • Troubleshooting common issues

Error handling:

  • If fHelpUrl is empty: displays an information dialog with a placeholder message indicating future help availability
  • If the browser fails to open: displays a critical error dialog with the URL formatted as a clickable hyperlink for manual access

The URL is parsed in TolerantMode to handle various URL formats flexibly.

Note
This slot is connected to the help button click signal in the UI.
The dialog remains open after help is displayed, allowing users to reference documentation while configuring parameters.
See also
PMsr2DataDialog::PMsr2DataDialog() Where fHelpUrl is initialized
QDesktopServices::openUrl() For the browser opening mechanism

Definition at line 461 of file PMsr2DataDialog.cpp.

◆ runListEntered

void PMsr2DataDialog::runListEntered ( const QString & str)
slot

Handles run list text field activation.

Slot: Handles direct run list entry.

Called when the user enters text in the direct run list field. Clears the run list file name field to ensure only one input method is active, and sets the run tag to indicate direct list entry.

Parameters
strThe run list string (e.g., "123,125-130,145").
See also
runListFileNameEntered() For the alternative input method
getRunTag() Returns the set run tag value

Called when the user enters text in the direct run list field. Ensures that only one run input method is active by clearing the run list file name field if it contains text. Sets the run tag to 0 to indicate direct list input mode.

The run list accepts various formats:

  • Single runs: "123"
  • Multiple runs: "123,125,130"
  • Ranges: "123-130"
  • Combined: "123,125-130,145"
Parameters
strThe run list string entered by the user. Empty strings are ignored.
Note
This method enforces mutual exclusivity with runListFileNameEntered().
The run tag value can be retrieved via getRunTag() after dialog acceptance.
See also
runListFileNameEntered() Alternative run input method
getRunTag() Returns the active input method indicator

Definition at line 276 of file PMsr2DataDialog.cpp.

◆ runListFileNameEntered

void PMsr2DataDialog::runListFileNameEntered ( const QString & str)
slot

Handles run list file name text field activation.

Slot: Handles run list file name entry.

Called when the user enters a file name containing run numbers. Clears the direct run list field to ensure only one input method is active, and sets the run tag to indicate file-based input.

Parameters
strPath to the run list file.
See also
runListEntered() For the alternative input method
getRunTag() Returns the set run tag value

Called when the user enters a file path in the run list file name field. Ensures that only one run input method is active by clearing the direct run list field if it contains text. Sets the run tag to 1 to indicate file-based input mode.

The run list file should contain run numbers in simple format:

  • One run per line
  • Ranges allowed (e.g., "123-130")
  • Comments starting with '#'
  • Blank lines ignored

Example run list file:

# Temperature series
123
125-130
145
Parameters
strThe file path entered by the user. Empty strings are ignored.
Note
This method enforces mutual exclusivity with runListEntered().
The file path is not validated by this method; validation occurs during msr2data execution.
The run tag value can be retrieved via getRunTag() after dialog acceptance.
See also
runListEntered() Alternative run input method
getRunTag() Returns the active input method indicator

Definition at line 320 of file PMsr2DataDialog.cpp.

◆ templateRunEntered

void PMsr2DataDialog::templateRunEntered ( const QString & str)
slot

Handles template run number text field activation.

Slot: Handles template run number entry.

Called when the user enters a template run number. Automatically disables the "Fit Only" checkbox since a template implies msr file creation.

Parameters
strThe template run number string.
Note
Template run numbers must be valid integers representing existing msr files.

Called when the user enters a template run number. The template run specifies an existing msr file that will be used as a pattern for generating msr files for all runs in the run list.

Since providing a template implies the intent to create new msr files, this method automatically unchecks the "Fit Only" checkbox to ensure consistency. The fit-only mode assumes existing msr files and doesn't use templates.

The template run number must correspond to an existing, valid msr file. The template's structure (FITPARAMETER, THEORY, RUN blocks) will be preserved, with RUN block numbers updated for each processed run.

Parameters
strThe template run number string. Must be a valid integer. Non-empty values automatically disable fit-only mode.
Note
The integer validator ensures only numeric input is accepted.
Empty string is allowed to clear the template (for fit-only mode).
See also
fitOnlyChanged() Complementary method that clears template when fit-only mode is enabled

Definition at line 356 of file PMsr2DataDialog.cpp.

Member Data Documentation

◆ fHelpUrl

QString PMsr2DataDialog::fHelpUrl
private

URL to online msr2data documentation.

Definition at line 272 of file PMsr2DataDialog.h.

◆ fMsr2DataParam

PMsr2DataParam* PMsr2DataDialog::fMsr2DataParam
private

Pointer to parameter structure for msr2data configuration.

Definition at line 271 of file PMsr2DataDialog.h.

◆ fRunTag

int PMsr2DataDialog::fRunTag
private

Run input method: -1=invalid, 0=direct list, 1=file name.

Definition at line 270 of file PMsr2DataDialog.h.


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