|
mupp 1.1.0
|
Script interpreter for mupp batch processing. More...
#include <PmuppScript.h>


Public Slots | |
| int | executeScript () |
| Executes all script commands sequentially. | |
Signals | |
| void | finished () |
| Signal emitted when script execution completes. | |
Public Member Functions | |
| PmuppScript (QStringList script) | |
| Constructor. Initializes the script interpreter. | |
| void | setLoadPath (const QString cmd) |
| Sets the load path for input data files. | |
| QString | getLoadPath () |
| Gets the current load path. | |
| void | setSavePath (const QString cmd) |
| Sets the save path for output files. | |
| QString | getSavePath () |
| Gets the current save path. | |
| int | loadCollection (const QString str) |
| Loads a data collection from file. | |
| int | select (const QString str) |
| Selects a specific collection for plotting. | |
| int | selectAll () |
| Selects all loaded collections for plotting. | |
| int | addX (const QString str) |
| Adds a parameter to the X-axis. | |
| int | addY (const QString str) |
| Adds one or more parameters to the Y-axis. | |
| int | plot (const QString str) |
| Creates a plot file by generating and executing a ROOT macro. | |
| int | macro (const QString str, const QString plotFln="") |
| Generates a ROOT macro for plotting. | |
| int | var_cmd (const QString str, int script_idx=-1) |
| Processes a variable definition command. | |
Private Member Functions | |
| bool | foundLabel (PmuppCollection *coll, const QString label) |
| Checks if a parameter label exists in a collection. | |
| bool | foundVariable (const QString var) |
| Checks if a variable is defined in the variable handler. | |
| int | getVarIndex (const QString var) |
| Gets the index of a variable in the handler vector. | |
| void | minMax (QVector< double > dvec, double &min, double &max) |
| Finds minimum and maximum values in a data vector. | |
| QString | getNicerLabel (const QString label) |
| Converts parameter labels to prettier ROOT format. | |
| int | getCollectionIndex (const QString var_name) |
| Gets the collection index associated with a variable. | |
| QString | getPythonBlock (int start_idx=-1) |
| Returns the verbatim <python> ... </python> block of the script. | |
Private Attributes | |
| std::unique_ptr< PmuppAdmin > | fAdmin |
| administration object for configuration | |
| QStringList | fScript |
| list of script commands to execute | |
| std::unique_ptr< PParamDataHandler > | fParamDataHandler |
| handler for parameter data collections | |
| int | fSelected |
| selection state: -2=none, -1=all, >=0=specific index | |
| PmuppPlotEntry | fPlotEntry |
| single plot configuration (for specific selection) | |
| QVector< PmuppPlotEntry > | fPlotInfo |
| vector of all plot configurations (for all selections) | |
| bool | fNorm |
| normalization flag (true = normalize Y-data to max value) | |
| QString | fLoadPath |
| directory path for loading input data files | |
| QString | fSavePath |
| directory path for saving output files | |
| QVector< PVarHandler > | fVarHandler |
| vector of variable expression handlers | |
Script interpreter for mupp batch processing.
PmuppScript provides a command-line scripting interface for mupp, enabling automated batch processing of parameter data analysis and visualization. The class parses and executes script commands, managing data collections, plot configurations, variable definitions, and ROOT macro generation.
Script execution workflow:
Command categories:
Error handling: Methods return 0 on success, negative values on error. Specific error codes indicate different failure modes.
Definition at line 117 of file PmuppScript.h.
| PmuppScript::PmuppScript | ( | QStringList | script | ) |
Constructor. Initializes the script interpreter.
Constructor for the script interpreter.
| script | list of script commands to execute |
Initializes the script execution environment with default settings:
| script | list of script commands to be executed |
Definition at line 95 of file PmuppScript.cpp.
| int PmuppScript::addX | ( | const QString | str | ) |
Adds a parameter to the X-axis.
Adds a parameter label to the X-axis.
| str | x command string with parameter label |
Configures the X-axis (independent variable) for the plot. The label can be either:
Behavior depends on selection state:
Validation:
| str | x command string (format: "x <label>") |
Definition at line 420 of file PmuppScript.cpp.
| int PmuppScript::addY | ( | const QString | str | ) |
Adds one or more parameters to the Y-axis.
Adds one or more parameter labels to the Y-axis.
| str | y command string with parameter label(s) |
Configures the Y-axis (dependent variable(s)) for the plot. Multiple Y-axis parameters can be specified in a single command, enabling multi-curve plots.
Each label can be either:
Behavior depends on selection state:
Validation:
| str | y command string (format: "y <label1> [label2] [label3] ...") |
Definition at line 533 of file PmuppScript.cpp.
|
slot |
Executes all script commands sequentially.
Processes each command in the script list, maintaining state and accumulating plot configurations. Emits finished() signal when complete or on error.
Processes each command in the script list, dispatching to appropriate handler methods based on command type. Maintains state throughout execution including:
Command dispatch table:
Emits finished() signal upon completion or error.
Definition at line 136 of file PmuppScript.cpp.
|
signal |
Signal emitted when script execution completes.
|
private |
Checks if a parameter label exists in a collection.
| coll | pointer to collection to search |
| label | parameter label to find |
Searches the first run of the collection for a parameter matching the given label. Assumes all runs in a collection have the same parameter structure.
| coll | pointer to collection to search |
| label | parameter label to find |
Definition at line 1131 of file PmuppScript.cpp.
|
private |
Checks if a variable is defined in the variable handler.
| var | variable name to search for |
Searches the variable handler vector for a variable with the specified name. Used to validate variable references in x and y commands.
| var | variable name to search for |
Definition at line 1156 of file PmuppScript.cpp.
|
private |
Gets the collection index associated with a variable.
Gets the collection index a variable is linked to.
| var_name | variable name |
Scans the script for the 'col' command linking the given variable name to a collection and returns that collection index.
| var_name | the variable name to look up |
Definition at line 1322 of file PmuppScript.cpp.
|
inline |
|
private |
Converts parameter labels to prettier ROOT format.
Converts parameter labels to publication-quality ROOT format.
| label | original parameter label |
Transforms standard parameter names into formatted labels suitable for publication plots, including:
Special case handling:
| label | original parameter label string |
Definition at line 1243 of file PmuppScript.cpp.
|
private |
Returns the verbatim <python> ... </python> block of the script.
| start_idx | scan fScript from this index onwards (exclusive). Used so that multiple <python> blocks each pair with the preceding 'var' declaration. Defaults to -1 (start from the beginning). |
The script reader stores each python block as a single list entry. When a 'var X = python' declaration is being processed, the matching block is the first <python> ... </python> entry that comes after the declaration's position in the script. This pairs each declaration with the block that actually defines X (and XErr) and lets multiple python blocks coexist.
| start_idx | position of the calling 'var' command in fScript; the scan begins at start_idx+1. Pass -1 to scan from the beginning. |
Definition at line 1302 of file PmuppScript.cpp.
|
inline |
|
private |
Gets the index of a variable in the handler vector.
| var | variable name to search for |
Searches for a variable by name and returns its position in the fVarHandler vector. Used during macro generation to retrieve variable values.
| var | variable name to search for |
Definition at line 1181 of file PmuppScript.cpp.
| int PmuppScript::loadCollection | ( | const QString | str | ) |
Loads a data collection from file.
| str | load command string with filename |
Parses the load command to extract the filename, prepends the load path, and reads the parameter data file via the PParamDataHandler.
Processing steps:
| str | load command string (format: "load filename.ext") |
Definition at line 301 of file PmuppScript.cpp.
| int PmuppScript::macro | ( | const QString | str, |
| const QString | plotFln = "" ) |
Generates a ROOT macro for plotting.
Generates a ROOT C++ macro for plotting.
| str | macro command string with macro filename |
| plotFln | optional plot output filename (for SaveAs in macro) |
Creates a complete, standalone ROOT macro that can be executed independently. The macro includes:
Generated content:
Data handling:
Styling:
| str | macro command string (format: "macro filename.C") |
| plotFln | optional output plot filename (adds SaveAs to macro) |
Definition at line 751 of file PmuppScript.cpp.
|
private |
Finds minimum and maximum values in a data vector.
| dvec | data vector to analyze |
| min | output parameter: minimum value |
| max | output parameter: maximum value |
Scans through the data vector to determine the range. Used for automatic axis range calculation in plot generation.
| dvec | data vector to analyze |
| min | output parameter: minimum value in vector |
| max | output parameter: maximum value in vector |
Definition at line 1205 of file PmuppScript.cpp.
| int PmuppScript::plot | ( | const QString | str | ) |
Creates a plot file by generating and executing a ROOT macro.
| str | plot command string with output filename |
This method performs the complete workflow for batch plot creation:
Supported output formats (via ROOT):
The method configures environment variables (LD_LIBRARY_PATH/ DYLD_LIBRARY_PATH) to ensure ROOT finds its libraries.
| str | plot command string (format: "plot output_filename.ext") |
Definition at line 662 of file PmuppScript.cpp.
| int PmuppScript::select | ( | const QString | str | ) |
Selects a specific collection for plotting.
| str | select command string with collection identifier |
Parses the select command to identify a collection by either:
The selected collection becomes the target for subsequent x and y commands. Sets fSelected to the collection index.
| str | select command string (format: "select <index|name>") |
Definition at line 336 of file PmuppScript.cpp.
| int PmuppScript::selectAll | ( | ) |
Selects all loaded collections for plotting.
Enables batch plotting mode where subsequent x and y commands apply to all collections. Sets fSelected to -1 (all-selected state).
This mode is useful for creating overlay plots showing multiple data sets with the same parameter axes.
Definition at line 381 of file PmuppScript.cpp.
| void PmuppScript::setLoadPath | ( | const QString | cmd | ) |
Sets the load path for input data files.
| cmd | loadPath command string with path specification |
Parses the loadPath command string and extracts the directory path. Supports environment variable expansion: variables prefixed with '$' are replaced with their values from the system environment.
Path processing:
Example: "loadPath $HOME/data/musrfit/" → "/home/user/data/musrfit/"
| cmd | loadPath command string including path specification |
Definition at line 210 of file PmuppScript.cpp.
| void PmuppScript::setSavePath | ( | const QString | cmd | ) |
Sets the save path for output files.
| cmd | savePath command string with path specification |
Parses the savePath command string and extracts the directory path. Uses the same environment variable expansion mechanism as setLoadPath().
Path processing:
Example: "savePath $HOME/plots/" → "/home/user/plots/"
| cmd | savePath command string including path specification |
Definition at line 256 of file PmuppScript.cpp.
| int PmuppScript::var_cmd | ( | const QString | str, |
| int | script_idx = -1 ) |
Processes a variable definition command.
| str | var command string with variable expression |
| script_idx | position of this command inside fScript; used to locate the matching <python> ... </python> block (the one following the declaration). Defaults to -1 (search from start). |
Variables enable defining derived quantities as mathematical expressions combining collection parameters. For example:
Processing steps:
Error handling:
Integration with col command: The "col" command links variables to specific collections, enabling variable resolution during plot generation.
| str | var command string (format: "var <name> <expression>") |
Definition at line 1030 of file PmuppScript.cpp.
|
private |
administration object for configuration
Definition at line 230 of file PmuppScript.h.
|
private |
directory path for loading input data files
Definition at line 239 of file PmuppScript.h.
|
private |
normalization flag (true = normalize Y-data to max value)
Definition at line 238 of file PmuppScript.h.
|
private |
handler for parameter data collections
Definition at line 232 of file PmuppScript.h.
|
private |
single plot configuration (for specific selection)
Definition at line 235 of file PmuppScript.h.
|
private |
vector of all plot configurations (for all selections)
Definition at line 236 of file PmuppScript.h.
|
private |
directory path for saving output files
Definition at line 240 of file PmuppScript.h.
|
private |
list of script commands to execute
Definition at line 231 of file PmuppScript.h.
|
private |
selection state: -2=none, -1=all, >=0=specific index
Definition at line 233 of file PmuppScript.h.
|
private |
vector of variable expression handlers
Definition at line 242 of file PmuppScript.h.