|
musrfit 1.10.0
|
Handles the musrfit XML startup configuration file (musrfit_startup.xml). More...
#include <PStartupHandler.h>


Public Member Functions | |
| PStartupHandler (bool reset_startup_file=false) | |
| Constructor that locates and parses the musrfit startup configuration file. | |
| virtual | ~PStartupHandler () |
| Destructor releasing allocated resources. | |
| virtual void | OnStartDocument () |
| SAX callback: Called when XML document parsing begins. Initializes all configuration variables to default values. | |
| virtual void | OnEndDocument () |
| SAX callback: Called when XML document parsing ends. Triggers CheckLists() to ensure all required settings have values. | |
| virtual void | OnStartElement (const Char_t *, const TList *) |
| SAX callback: Called when an XML start element is encountered. | |
| virtual void | OnEndElement (const Char_t *) |
| SAX callback: Called when an XML end element is encountered. | |
| virtual void | OnCharacters (const Char_t *) |
| SAX callback: Called with element text content. | |
| virtual void | OnComment (const Char_t *) |
| SAX callback: Called when XML comment is found (unused). | |
| virtual void | OnWarning (const Char_t *) |
| SAX callback: Called when XML parser issues a warning. | |
| virtual void | OnError (const Char_t *) |
| SAX callback: Called when XML parser encounters an error. | |
| virtual void | OnFatalError (const Char_t *) |
| SAX callback: Called when XML parser encounters a fatal error. | |
| virtual void | OnCdataBlock (const Char_t *, Int_t) |
| SAX callback: Called for CDATA blocks (unused). | |
| virtual Bool_t | StartupFileFound () |
| Checks if the startup configuration file was successfully located. | |
| virtual TString | GetStartupFilePath () |
| Returns the full path to the located startup configuration file. | |
| virtual void | CheckLists () |
| Validates configuration lists and fills missing entries with defaults. | |
| virtual PMsrFourierStructure | GetFourierDefaults () |
| Returns Fourier transform default settings. | |
| virtual const PRunNameTemplateList | GetRunNameTemplateList () |
| Returns the list of instrument-specific run name templates. | |
| virtual const PStringVector | GetDataPathList () const |
| Returns the list of data file search paths. | |
| virtual const PIntVector | GetMarkerList () const |
| Returns the list of ROOT marker codes for plotting. | |
| virtual const PIntVector | GetColorList () const |
| Returns the list of ROOT color codes for plotting. | |
Private Types | |
| enum | EKeyWords { eEmpty , eComment , eDataPath , eRunNameTemplate , eOptions , eFourierSettings , eUnits , eFourierPower , eApodization , ePlot , ePhase , ePhaseIncrement , eRootSettings , eMarkerList , eMarker , eColorList , eColor } |
| Enumeration of XML element types for SAX parser state machine. More... | |
Private Member Functions | |
| Bool_t | StartupFileExists (Char_t *fln) |
| Checks if a file exists at the specified path. | |
| Bool_t | WriteDefaultStartupFile (bool reset_startup_file=false) |
| Creates or overwrites a startup file with default configuration. | |
Private Attributes | |
| EKeyWords | fKey |
| Current XML element type (SAX parser state) | |
| Bool_t | fStartupFileFound |
| True if musrfit_startup.xml was located. | |
| TString | fStartupFilePath |
| Full path to located startup file (empty if not found) | |
| TString | fCurrentInstrumentName |
| Instrument name from run_name_template inst attribute. | |
| PMsrFourierStructure | fFourierDefaults |
| Fourier transform default settings structure. | |
| PStringVector | fDataPathList |
| List of directories to search for data files. | |
| PRunNameTemplateList | fRunNameTemplate |
| List of instrument-specific run name patterns. | |
| PIntVector | fMarkerList |
| List of ROOT TMarker style codes for plotting. | |
| PIntVector | fColorList |
| List of ROOT TColor codes (from RGB) for plotting. | |
Handles the musrfit XML startup configuration file (musrfit_startup.xml).
PStartupHandler is responsible for locating, parsing, and providing access to the musrfit startup configuration file. This XML file contains default settings that customize musrfit behavior across different installations and user preferences.
The musrfit_startup.xml file stores:
The startup file is searched in the following locations (first found wins):
./musrfit_startup.xml$HOME/.musrfit/musrfit_startup.xml$MUSRFITPATH/musrfit_startup.xml$ROOTSYS/bin/musrfit_startup.xml (with warning)If no file is found, a default configuration is automatically created in $HOME/.musrfit/musrfit_startup.xml.
Run name templates use placeholders for automatic file path construction:
yyyy% : 4-digit year (e.g., 2024)yy% : 2-digit year (e.g., 24)rrrr% : 4-digit run number with leading zerosrrrrr% : 5-digit run number with leading zerosExample: dyyyy%/tdc/root/deltat_tdc_gps_yyyy_rrrr%.root → d2024/tdc/root/deltat_tdc_gps_2024_1234.root
This class implements the TQObject signal/slot mechanism to handle SAX parser callbacks. The parser events trigger the following methods:
Definition at line 162 of file PStartupHandler.h.
|
private |
Enumeration of XML element types for SAX parser state machine.
Used by OnStartElement() to set parsing context and by OnCharacters() to determine how to interpret element content.
Definition at line 301 of file PStartupHandler.h.
| PStartupHandler::PStartupHandler | ( | bool | reset_startup_file = false | ) |
Constructor that locates and parses the musrfit startup configuration file.
Constructor that locates and optionally resets the musrfit startup configuration.
Searches for musrfit_startup.xml in standard locations and parses it if found. If no file is found, creates a default configuration in $HOME/.musrfit/.
Search order:
| reset_startup_file | If true and file is found, rewrites it with default content. Useful for restoring corrupted or outdated configurations. |
Searches for the musrfit_startup.xml configuration file in standard locations and initializes the handler. If no file is found, creates a default configuration.
Search Order:
./musrfit_startup.xml$HOME/.musrfit/musrfit_startup.xml$MUSRFITPATH/musrfit_startup.xml$ROOTSYS/bin/musrfit_startup.xml (with warning)File Creation: If no startup file is found in any location, a default configuration is automatically created at $HOME/.musrfit/musrfit_startup.xml. This includes:
Reset Mode: When reset_startup_file=true and a file is found, the existing file is overwritten with default content. This is useful for:
| reset_startup_file | If true, overwrites existing startup file with defaults. If false (default), uses existing file or creates new one. |
Definition at line 148 of file PStartupHandler.cpp.
References fStartupFileFound, fStartupFilePath, startup_path_name, StartupFileExists(), and WriteDefaultStartupFile().
|
virtual |
Destructor releasing allocated resources.
Destructor that releases all allocated configuration data.
Clears all configuration vectors:
Clears all configuration vectors to free memory:
Definition at line 246 of file PStartupHandler.cpp.
References fColorList, fDataPathList, fMarkerList, and fRunNameTemplate.
|
virtual |
Validates configuration lists and fills missing entries with defaults.
Validates configuration lists and populates empty ones with defaults.
Called at end of XML parsing to ensure all required lists have values. If a list is empty, populates it with sensible defaults:
Called at the end of XML parsing (OnEndDocument) to ensure all required configuration lists have values. If any list is empty after parsing, it is populated with sensible defaults.
Default Data Paths: Standard PSI facility data directories:
Default Markers: ROOT TMarker style codes for distinguishing multiple data sets:
Default Colors: Standard plotting colors (RGB → ROOT color code):
Definition at line 765 of file PStartupHandler.cpp.
References fColorList, fDataPathList, and fMarkerList.
Referenced by OnEndDocument().
|
inlinevirtual |
Returns the list of ROOT color codes for plotting.
Definition at line 292 of file PStartupHandler.h.
References fColorList.
|
inlinevirtual |
Returns the list of data file search paths.
Definition at line 280 of file PStartupHandler.h.
References fDataPathList.
|
inlinevirtual |
Returns Fourier transform default settings.
Definition at line 268 of file PStartupHandler.h.
References fFourierDefaults.
|
inlinevirtual |
Returns the list of ROOT marker codes for plotting.
Definition at line 286 of file PStartupHandler.h.
References fMarkerList.
|
inlinevirtual |
Returns the list of instrument-specific run name templates.
Definition at line 274 of file PStartupHandler.h.
References fRunNameTemplate.
|
inlinevirtual |
Returns the full path to the located startup configuration file.
Definition at line 251 of file PStartupHandler.h.
References fStartupFilePath.
|
virtual |
SAX callback: Called for CDATA blocks (unused).
SAX callback invoked when a CDATA section is encountered.
| str | CDATA content |
| len | Length of CDATA content |
Currently does nothing. CDATA sections in the startup file are not used. CDATA sections would typically be used for content containing special characters that would otherwise need escaping.
| str | CDATA content (without <![CDATA[ and ]]> delimiters) |
| len | Length of the CDATA content in characters |
Definition at line 727 of file PStartupHandler.cpp.
|
virtual |
SAX callback: Called with element text content.
SAX callback invoked with text content between XML element tags.
| str | Text content between XML tags (the actual configuration values) |
Processes element content based on the current parsing state (fKey) set by OnStartElement(). Each element type has specific parsing logic and validation.
Element Processing:
| str | Text content between XML tags |
Definition at line 452 of file PStartupHandler.cpp.
References eApodization, eColor, eDataPath, eFourierPower, eMarker, ePhase, ePhaseIncrement, ePlot, eRunNameTemplate, eUnits, fColorList, fCurrentInstrumentName, fDataPathList, fFourierDefaults, fKey, fMarkerList, FOURIER_APOD_MEDIUM, FOURIER_APOD_NONE, FOURIER_APOD_STRONG, FOURIER_APOD_WEAK, FOURIER_PLOT_IMAG, FOURIER_PLOT_PHASE, FOURIER_PLOT_POWER, FOURIER_PLOT_REAL, FOURIER_PLOT_REAL_AND_IMAG, FOURIER_UNIT_CYCLES, FOURIER_UNIT_FREQ, FOURIER_UNIT_GAUSS, FOURIER_UNIT_TESLA, fRunNameTemplate, PRunNameTemplate::instrument, and PRunNameTemplate::runNameTemplate.
|
virtual |
SAX callback: Called when XML comment is found (unused).
SAX callback invoked when an XML comment is encountered.
| str | Comment text |
Currently does nothing. XML comments in the startup file are ignored.
| str | Comment text content (without <!-- and –> delimiters) |
Definition at line 637 of file PStartupHandler.cpp.
|
virtual |
SAX callback: Called when XML document parsing ends. Triggers CheckLists() to ensure all required settings have values.
SAX callback invoked at the end of XML document parsing.
Finalizes configuration by calling CheckLists() to ensure all required settings have values. If any list is empty after parsing, it will be populated with default values.
Definition at line 311 of file PStartupHandler.cpp.
References CheckLists().
|
virtual |
SAX callback: Called when an XML end element is encountered.
SAX callback invoked when an XML end element tag is encountered.
| str | Element name (unused, resets parsing state) |
Resets the parsing state (fKey) to eEmpty, indicating that any subsequent character data should be ignored until the next start element is found.
| str | XML element name (unused, state is always reset to eEmpty) |
Definition at line 395 of file PStartupHandler.cpp.
|
virtual |
SAX callback: Called when XML parser encounters an error.
SAX callback invoked when the XML parser encounters an error.
| str | Error message (output to stderr) |
Outputs the error message to stderr with a "PStartupHandler **ERROR**" prefix. Errors indicate significant parsing problems such as:
| str | Error message from the XML parser |
Definition at line 681 of file PStartupHandler.cpp.
|
virtual |
SAX callback: Called when XML parser encounters a fatal error.
SAX callback invoked when the XML parser encounters a fatal error.
| str | Fatal error message (output to stderr) |
Outputs the error message to stderr with a "PStartupHandler **FATAL ERROR**" prefix. Fatal errors indicate unrecoverable parsing failures such as:
| str | Fatal error message from the XML parser |
Definition at line 705 of file PStartupHandler.cpp.
|
virtual |
SAX callback: Called when XML document parsing begins. Initializes all configuration variables to default values.
SAX callback invoked at the start of XML document parsing.
Initializes all configuration variables to default values before parsing begins. This ensures a clean state even if the same handler is reused.
Initialization:
Definition at line 279 of file PStartupHandler.cpp.
References eEmpty, fFourierDefaults, fKey, FOURIER_APOD_NONE, FOURIER_PLOT_REAL_AND_IMAG, and FOURIER_UNIT_GAUSS.
|
virtual |
SAX callback: Called when an XML start element is encountered.
SAX callback invoked when an XML start element tag is encountered.
| str | Element name (e.g., "data_path", "marker", "units") |
| attributes | XML attributes (used for inst attribute in run_name_template) |
Identifies the element type and sets the parsing state (fKey) accordingly. This state is used by OnCharacters() to determine how to process element content.
Recognized Elements:
data_path → eDataPath (data file search directory)run_name_template → eRunNameTemplate (with inst attribute extraction)marker → eMarker (ROOT marker style code)color → eColor (RGB color specification)units → eUnits (Fourier frequency units)fourier_power → eFourierPower (zero-padding power)apodization → eApodization (windowing function)plot → ePlot (Fourier plot type)phase → ePhase (Fourier phase value)phase_increment → ePhaseIncrement (phase adjustment step)Attribute Handling: For run_name_template elements, extracts the inst attribute value and stores it in fCurrentInstrumentName for use when processing the element content.
| str | XML element name (tag name without angle brackets) |
| attributes | TList of TXMLAttr objects containing element attributes |
Definition at line 349 of file PStartupHandler.cpp.
References eApodization, eColor, eDataPath, eFourierPower, eMarker, ePhase, ePhaseIncrement, ePlot, eRunNameTemplate, eUnits, fCurrentInstrumentName, and fKey.
|
virtual |
SAX callback: Called when XML parser issues a warning.
SAX callback invoked when the XML parser generates a warning.
| str | Warning message (output to stderr) |
Outputs the warning message to stderr with a "PStartupHandler **WARNING**" prefix. Warnings typically indicate non-fatal issues such as:
| str | Warning message from the XML parser |
Definition at line 658 of file PStartupHandler.cpp.
|
private |
Checks if a file exists at the specified path.
Checks if a file exists and is readable at the specified path.
| fln | Full path to check |
Attempts to open the file for reading to verify its existence and accessibility. The file is immediately closed after the check.
| fln | Full filesystem path to the file to check |
Definition at line 834 of file PStartupHandler.cpp.
Referenced by PStartupHandler().
|
inlinevirtual |
Checks if the startup configuration file was successfully located.
Definition at line 244 of file PStartupHandler.h.
References fStartupFileFound.
|
private |
Creates or overwrites a startup file with default configuration.
Creates or overwrites a startup configuration file with default content.
Writes a complete musrfit_startup.xml with:
| reset_startup_file | If true, overwrites existing file at fStartupFilePath. If false, creates new file at $HOME/.musrfit/musrfit_startup.xml. |
Writes a complete musrfit_startup.xml file containing comprehensive default settings for the musrfit package. This method is called when:
File Location:
Default Content Includes:
Data Paths:
Run Name Templates:
Fourier Settings:
ROOT Settings:
| reset_startup_file | If true, overwrites existing file at fStartupFilePath. If false, creates new file at $HOME/.musrfit/musrfit_startup.xml. |
Definition at line 899 of file PStartupHandler.cpp.
References fStartupFilePath, and startup_path_name.
Referenced by PStartupHandler().
|
private |
List of ROOT TColor codes (from RGB) for plotting.
Definition at line 329 of file PStartupHandler.h.
Referenced by CheckLists(), GetColorList(), OnCharacters(), and ~PStartupHandler().
|
private |
Instrument name from run_name_template inst attribute.
Definition at line 324 of file PStartupHandler.h.
Referenced by OnCharacters(), and OnStartElement().
|
private |
List of directories to search for data files.
Definition at line 326 of file PStartupHandler.h.
Referenced by CheckLists(), GetDataPathList(), OnCharacters(), and ~PStartupHandler().
|
private |
Fourier transform default settings structure.
Definition at line 325 of file PStartupHandler.h.
Referenced by GetFourierDefaults(), OnCharacters(), and OnStartDocument().
|
private |
Current XML element type (SAX parser state)
Definition at line 321 of file PStartupHandler.h.
Referenced by OnCharacters(), OnEndElement(), OnStartDocument(), and OnStartElement().
|
private |
List of ROOT TMarker style codes for plotting.
Definition at line 328 of file PStartupHandler.h.
Referenced by CheckLists(), GetMarkerList(), OnCharacters(), and ~PStartupHandler().
|
private |
List of instrument-specific run name patterns.
Definition at line 327 of file PStartupHandler.h.
Referenced by GetRunNameTemplateList(), OnCharacters(), and ~PStartupHandler().
|
private |
True if musrfit_startup.xml was located.
Definition at line 322 of file PStartupHandler.h.
Referenced by PStartupHandler(), and StartupFileFound().
|
private |
Full path to located startup file (empty if not found)
Definition at line 323 of file PStartupHandler.h.
Referenced by GetStartupFilePath(), PStartupHandler(), and WriteDefaultStartupFile().