musrfit 1.10.0
PMsrHandler Class Reference

MSR file parser and manager for the musrfit framework. More...

#include <PMsrHandler.h>

Collaboration diagram for PMsrHandler:

Public Member Functions

 PMsrHandler (const Char_t *fileName, PStartupOptions *startupOptions=0, const Bool_t fourierOnly=false)
 Constructor that initializes the MSR handler.
 
virtual ~PMsrHandler ()
 Destructor that cleans up all data structures.
 
virtual Int_t ReadMsrFile ()
 Reads and parses the MSR file.
 
virtual Int_t WriteMsrLogFile (const Bool_t messages=true)
 Writes an MSR log file (.mlog) with parsed MSR content.
 
virtual Int_t WriteMsrFile (const Char_t *filename, std::map< UInt_t, TString > *commentsPAR=0, std::map< UInt_t, TString > *commentsTHE=0, std::map< UInt_t, TString > *commentsFUN=0, std::map< UInt_t, TString > *commentsRUN=0)
 Writes an MSR file from internal data structures.
 
virtual TString * GetMsrTitle ()
 Returns pointer to MSR file title string.
 
virtual PMsrParamListGetMsrParamList ()
 Returns pointer to fit parameter list.
 
virtual PMsrLinesGetMsrTheory ()
 Returns pointer to THEORY block lines.
 
virtual PMsrLinesGetMsrFunctions ()
 Returns pointer to FUNCTIONS block lines.
 
virtual PMsrGlobalBlockGetMsrGlobal ()
 Returns pointer to GLOBAL block settings.
 
virtual PMsrRunListGetMsrRunList ()
 Returns pointer to list of RUN blocks.
 
virtual PMsrLinesGetMsrCommands ()
 Returns pointer to COMMANDS block lines.
 
virtual PMsrFourierStructureGetMsrFourierList ()
 Returns pointer to FOURIER block settings.
 
virtual PMsrPlotListGetMsrPlotList ()
 Returns pointer to list of PLOT blocks.
 
virtual PMsrStatisticStructureGetMsrStatistic ()
 Returns pointer to STATISTIC block.
 
virtual TString * GetMsrFileDirectoryPath ()
 Returns pointer to MSR file directory path.
 
virtual UInt_t GetNoOfRuns ()
 Returns the number of RUN blocks in MSR file.
 
virtual UInt_t GetNoOfParams ()
 Returns the number of fit parameters in FITPARAMETER block.
 
virtual const TString & GetFileName () const
 Returns the MSR file name.
 
virtual void SetMsrTitle (const TString &title)
 
virtual Bool_t SetMsrParamValue (UInt_t i, Double_t value)
 
virtual Bool_t SetMsrParamStep (UInt_t i, Double_t value)
 
virtual Bool_t SetMsrParamPosErrorPresent (UInt_t i, Bool_t value)
 
virtual Bool_t SetMsrParamPosError (UInt_t i, Double_t value)
 
virtual void SetMsrT0Entry (UInt_t runNo, UInt_t idx, Double_t bin)
 
virtual void SetMsrAddT0Entry (UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Double_t bin)
 
virtual void SetMsrDataRangeEntry (UInt_t runNo, UInt_t idx, Int_t bin)
 
virtual void SetMsrBkgRangeEntry (UInt_t runNo, UInt_t idx, Int_t bin)
 
virtual void CopyMsrStatisticBlock ()
 Flags that STATISTIC block should be copied as-is (for musrt0)
 
virtual void SetMsrStatisticConverged (Bool_t converged)
 
virtual void SetMsrStatisticMin (Double_t min)
 
virtual void SetMsrStatisticNdf (UInt_t ndf)
 
virtual Int_t GetNoOfFuncs ()
 Returns the number of user-defined functions in FUNCTIONS block.
 
virtual UInt_t GetFuncNo (Int_t idx)
 
virtual UInt_t GetFuncIndex (Int_t funNo)
 
virtual Bool_t CheckMapAndParamRange (UInt_t mapSize, UInt_t paramSize)
 
virtual Double_t EvalFunc (UInt_t i, std::vector< Int_t > map, std::vector< Double_t > param, PMetaData metaData)
 
virtual UInt_t GetNoOfFitParameters (UInt_t idx)
 
virtual Int_t ParameterInUse (UInt_t paramNo)
 
virtual void GetGroupingString (Int_t runNo, TString detector, TString &groupingStr)
 
virtual Bool_t EstimateN0 ()
 
virtual std::string GetLastErrorMsg ()
 

Private Member Functions

virtual Bool_t HandleFitParameterEntry (PMsrLines &line)
 Parses FITPARAMETER block entries.
 
virtual Bool_t HandleTheoryEntry (PMsrLines &line)
 Parses THEORY block entries.
 
virtual Bool_t HandleFunctionsEntry (PMsrLines &line)
 Parses FUNCTIONS block entries.
 
virtual Bool_t HandleGlobalEntry (PMsrLines &line)
 Parses GLOBAL block entries.
 
virtual Bool_t HandleRunEntry (PMsrLines &line)
 Parses RUN block entries.
 
virtual Bool_t HandleCommandsEntry (PMsrLines &line)
 Parses COMMANDS block entries.
 
virtual Bool_t HandleFourierEntry (PMsrLines &line)
 Parses FOURIER block entries.
 
virtual Bool_t HandlePlotEntry (PMsrLines &line)
 Parses PLOT block entries.
 
virtual Bool_t HandleStatisticEntry (PMsrLines &line)
 Parses STATISTIC block entries.
 
virtual void FillParameterInUse (PMsrLines &theory, PMsrLines &funcs, PMsrLines &run)
 Determines which parameters are used in theory and functions.
 
virtual void InitFourierParameterStructure (PMsrFourierStructure &fourier)
 Initializes Fourier parameter structure with default values.
 
virtual void RemoveComment (const TString &str, TString &truncStr)
 Removes comments from MSR file line.
 
virtual Bool_t ParseFourierPhaseValueVector (PMsrFourierStructure &fourier, const TString &str, Bool_t &error)
 Parses Fourier phase value vector.
 
virtual Bool_t ParseFourierPhaseParVector (PMsrFourierStructure &fourier, const TString &str, Bool_t &error)
 Parses Fourier phase parameter vector.
 
virtual Bool_t ParseFourierPhaseParIterVector (PMsrFourierStructure &fourier, const TString &str, Bool_t &error)
 Parses Fourier phase parameter iteration vector.
 
virtual Bool_t FilterNumber (TString str, const Char_t *filter, Int_t offset, Int_t &no)
 Extracts number from string with specific filter pattern.
 
virtual UInt_t NeededPrecision (Double_t dval, UInt_t precLimit=13)
 Calculates precision needed for formatting a double value.
 
virtual UInt_t LastSignificant (Double_t dval, UInt_t precLimit=6)
 Finds position of last significant digit in a double value.
 
virtual void MakeDetectorGroupingString (TString str, PIntVector &group, TString &result, Bool_t includeDetector=true)
 Creates detector grouping string from integer vector.
 
virtual TString BeautifyFourierPhaseParameterString ()
 Formats Fourier phase parameter string for display.
 
virtual void CheckLegacyLifetimecorrection ()
 Checks for deprecated lifetimecorrection syntax and warns user.
 
virtual Bool_t CheckRunBlockIntegrity ()
 Validates RUN block structure and consistency.
 
virtual Bool_t CheckUniquenessOfParamNames (UInt_t &parX, UInt_t &parY)
 Checks that all parameter names are unique.
 
virtual Bool_t CheckMaps ()
 Validates that all map indices are within parameter range.
 
virtual Bool_t CheckFuncs ()
 Validates user-defined functions syntax and parameter usage.
 
virtual Bool_t CheckHistoGrouping ()
 Checks histogram grouping consistency across runs.
 
virtual Bool_t CheckAddRunParameters ()
 Validates addrun parameter references.
 
virtual Bool_t CheckRRFSettings ()
 Validates RRF (Rotating Reference Frame) settings.
 
virtual Bool_t CheckRealFFT ()
 Checks if real FFT requirements are met.
 
virtual void CheckMaxLikelihood ()
 Validates maximum likelihood fit settings.
 

Private Attributes

Bool_t fFourierOnly
 Flag indicating Fourier transform only mode (for musrFT)
 
PStartupOptionsfStartupOptions
 Pointer to startup options from musrfit_startup.xml.
 
TString fFileName
 MSR file name (with path)
 
TString fMsrFileDirectoryPath
 Directory path of the MSR file.
 
TString fTitle
 MSR file title string.
 
PMsrParamList fParam
 List of fit parameters with values, errors, constraints.
 
PMsrLines fTheory
 Theory block lines defining asymmetry/relaxation functions.
 
PMsrLines fFunctions
 User-defined functions block lines.
 
PMsrGlobalBlock fGlobal
 Global block settings (fit type, data format, etc.)
 
PMsrRunList fRuns
 List of RUN blocks with data file specifications.
 
PMsrLines fCommands
 MINUIT commands block lines.
 
PMsrFourierStructure fFourier
 Fourier transform parameters and settings.
 
PMsrPlotList fPlots
 List of PLOT blocks with plotting parameters.
 
PMsrStatisticStructure fStatistic
 Fit statistics (χ², NDF, convergence status)
 
Int_t fMsrBlockCounter
 Counter to track current MSR block during parsing.
 
std::unique_ptr< PFunctionHandlerfFuncHandler
 Handler for parsing and evaluating user-defined functions.
 
PIntVector fParamInUse
 Flags indicating which parameters are actually used in theory/functions.
 
Bool_t fCopyStatisticsBlock
 If true, copy old statistics block (musrt0); if false, write new one (musrfit)
 
std::stringstream fLastErrorMsg
 Stream accumulating error messages during parsing.
 

Detailed Description

MSR file parser and manager for the musrfit framework.

PMsrHandler is the central class for managing MSR (Muon Spin Rotation/Relaxation) files used throughout the musrfit suite. It provides comprehensive functionality for:

File Operations:

  • Reading and parsing MSR files with full syntax validation
  • Writing MSR files with fitted parameters and statistics
  • Generating log files (.mlog) for debugging
  • Preserving user comments during file I/O

Data Management:

  • Fit parameters (values, errors, constraints, names)
  • Theory definitions (fit functions for asymmetry/relaxation)
  • User-defined functions (mathematical expressions)
  • Global settings (fit type, data format, etc.)
  • Run configurations (data files, histograms, ranges)
  • MINUIT commands (fit strategy, precision, etc.)
  • Fourier transform parameters
  • Plot settings
  • Fit statistics (χ², degrees of freedom, convergence)

Validation and Integrity Checking:

  • Parameter name uniqueness verification
  • Theory-to-parameter mapping validation
  • Histogram grouping consistency checks
  • RRF (Rotating Reference Frame) configuration validation
  • Function syntax and parameter usage verification
  • Map index range checking
  • Legacy lifetimecorrection detection

MSR File Structure: An MSR file contains the following blocks (in order):

  1. TITLE - Brief description of the fit
  2. FITPARAMETER - Fit parameters with initial values and constraints
  3. THEORY - Asymmetry/relaxation function definitions
  4. FUNCTIONS (optional) - User-defined mathematical functions
  5. GLOBAL (optional) - Global fit settings
  6. RUN - Data file specifications and fit ranges
  7. COMMANDS - MINUIT fitting commands
  8. FOURIER (optional) - Fourier transform settings
  9. PLOT (optional) - Plotting parameters
  10. STATISTIC - Fit results (χ², NDF, convergence)

Usage Example:

// Reading an MSR file
PMsrHandler handler("run1234.msr");
if (handler.ReadMsrFile() == PMUSR_SUCCESS) {
PMsrParamList *params = handler.GetMsrParamList();
// Access and modify parameters
handler.SetMsrParamValue(0, 12.5);
// Perform fit (in calling code)
// ...
// Update statistics and write results
handler.SetMsrStatisticMin(chisq);
handler.SetMsrStatisticNdf(ndf);
handler.WriteMsrFile("run1234_fitted.msr");
}
#define PMUSR_SUCCESS
Successful operation completion.
Definition PMusr.h:53
std::vector< PMsrParamStructure > PMsrParamList
Definition PMusr.h:1022
PMsrHandler(const Char_t *fileName, PStartupOptions *startupOptions=0, const Bool_t fourierOnly=false)
Constructor that initializes the MSR handler.
See also
PMusr.h for MSR data structure definitions
PFunctionHandler for user-defined function evaluation
PStartupOptions for configuration settings

Definition at line 115 of file PMsrHandler.h.

Constructor & Destructor Documentation

◆ PMsrHandler()

PMsrHandler::PMsrHandler ( const Char_t * fileName,
PStartupOptions * startupOptions = 0,
const Bool_t fourierOnly = false )

Constructor that initializes the MSR handler.

Constructor for PMsrHandler.

Parameters
fileNamePath to MSR file to read/write
startupOptionsOptional startup configuration (from musrfit_startup.xml)
fourierOnlyIf true, only parse Fourier-related blocks (for musrFT)

Initializes all internal data structures and extracts the directory path from the MSR file name. The directory path is used for resolving relative paths in the MSR file (e.g., for data files).

Initialization includes:

  • Setting default values for all MSR blocks
  • Initializing statistics structure (invalid, χ² mode, min=-1, ndf=0)
  • Extracting file directory path from file name
  • Setting block counter to 0
Parameters
fileNamePath to MSR file (absolute or relative)
startupOptionsOptional pointer to startup configuration from musrfit_startup.xml
fourierOnlyIf true, only parse Fourier-related blocks (used by musrFT tool)
Note
If fileName contains "/" characters, the directory path is extracted and stored in fMsrFileDirectoryPath; otherwise defaults to "./"

Definition at line 67 of file PMsrHandler.cpp.

References fCopyStatisticsBlock, fFileName, fFourierOnly, fMsrBlockCounter, fMsrFileDirectoryPath, fStartupOptions, fStatistic, and fTitle.

◆ ~PMsrHandler()

PMsrHandler::~PMsrHandler ( )
virtual

Destructor that cleans up all data structures.

Clears all vectors and releases memory:

  • Parameter list
  • Theory lines
  • Functions lines
  • Run configurations
  • MINUIT commands
  • Plot settings
  • Statistics data
  • Parameter usage flags

The unique_ptr member (fFuncHandler) is automatically cleaned up.

Definition at line 115 of file PMsrHandler.cpp.

References fCommands, fFunctions, fParam, fParamInUse, fPlots, fRuns, fStatistic, and fTheory.

Member Function Documentation

◆ BeautifyFourierPhaseParameterString()

TString PMsrHandler::BeautifyFourierPhaseParameterString ( )
privatevirtual

Formats Fourier phase parameter string for display.

Returns the Fourier phase string if the phase is either of type phase parX0 sep ... sep parXn where sep = ',' or phase par(X0, offset, #param)

Returns
Fourier phase parameter string if phase parameter(s) is(are) given, "??" otherwise

Definition at line 6988 of file PMsrHandler.cpp.

References fFourier.

Referenced by WriteMsrFile(), and WriteMsrLogFile().

◆ CheckAddRunParameters()

Bool_t PMsrHandler::CheckAddRunParameters ( )
privatevirtual

Validates addrun parameter references.

In case addrun is present check that if addt0's are given there are as many addt0's than addrun's.

return:

  • true if either no addt0 present, or # of addrun's == # of addt0's.
  • false otherwise

Definition at line 6612 of file PMsrHandler.cpp.

References fLastErrorMsg, and fRuns.

Referenced by ReadMsrFile().

◆ CheckFuncs()

Bool_t PMsrHandler::CheckFuncs ( )
privatevirtual

Validates user-defined functions syntax and parameter usage.

Checks if fun entries found in the theory- and run-block are also present in the functions-block.

return:

  • true if fun entries or present in the FUNCTIONS block
  • false otherwise

Definition at line 6472 of file PMsrHandler.cpp.

References fFourierOnly, fFunctions, FilterNumber(), fRuns, fTheory, and MSR_PARAM_FUN_OFFSET.

Referenced by ReadMsrFile().

◆ CheckHistoGrouping()

Bool_t PMsrHandler::CheckHistoGrouping ( )
privatevirtual

Checks histogram grouping consistency across runs.

Checks if histogram grouping makes any sense.

return:

  • true if histogram grouping seems OK
  • false otherwise

Definition at line 6566 of file PMsrHandler.cpp.

References fRuns.

Referenced by ReadMsrFile().

◆ CheckLegacyLifetimecorrection()

void PMsrHandler::CheckLegacyLifetimecorrection ( )
privatevirtual

Checks for deprecated lifetimecorrection syntax and warns user.

Checks for lifetimecorrection flags in the RUN-blocks and if present, transfer it to the PLOT-blocks. This is needed since originally the lifetimecorrection was (miss)placed in the RUN-blocks rather than in the PLOT-blocks where it most naturally would have been expected.

Definition at line 7056 of file PMsrHandler.cpp.

References fPlots, and fRuns.

Referenced by ReadMsrFile().

◆ CheckMapAndParamRange()

virtual Bool_t PMsrHandler::CheckMapAndParamRange ( UInt_t mapSize,
UInt_t paramSize )
inlinevirtual

Checks if map and parameter ranges are valid for functions.

Parameters
mapSizeSize of map vector
paramSizeNumber of available parameters
Returns
true if ranges are valid

Definition at line 322 of file PMsrHandler.h.

References fFuncHandler.

◆ CheckMaps()

Bool_t PMsrHandler::CheckMaps ( )
privatevirtual

Validates that all map indices are within parameter range.

Checks if map entries found in the theory- or function-block are also present in the run-block.

return:

  • true if maps or OK
  • false otherwise

Definition at line 6362 of file PMsrHandler.cpp.

References fFunctions, FilterNumber(), fRuns, fTheory, and MSR_PARAM_MAP_OFFSET.

Referenced by ReadMsrFile().

◆ CheckMaxLikelihood()

void PMsrHandler::CheckMaxLikelihood ( )
privatevirtual

Validates maximum likelihood fit settings.

If log max likelihood is requested, make sure that all run blocks are of single histogram type. If this is not the case, fall back to chisq, since for asymmetry/non-muSR fit, log max likelihood is not defined.

Definition at line 6644 of file PMsrHandler.cpp.

References fGlobal, fLastErrorMsg, fRuns, fStatistic, MSR_FITTYPE_MU_MINUS, and MSR_FITTYPE_SINGLE_HISTO.

Referenced by ReadMsrFile().

◆ CheckRealFFT()

Bool_t PMsrHandler::CheckRealFFT ( )
privatevirtual

Checks if real FFT requirements are met.

Checks for FOURIER plot REAL, if all necessary parameters are given.

Returns
true if all necessary parameters are given; false otherwise.

Definition at line 6767 of file PMsrHandler.cpp.

References fFourier, fLastErrorMsg, FOURIER_PLOT_POWER, and fPlots.

Referenced by ReadMsrFile().

◆ CheckRRFSettings()

Bool_t PMsrHandler::CheckRRFSettings ( )
privatevirtual

Validates RRF (Rotating Reference Frame) settings.

Make sure that if RRF settings are found in the GLOBAL section, the fit types in the RUN blocks correspond.

Definition at line 6669 of file PMsrHandler.cpp.

References fGlobal, fRuns, MSR_FITTYPE_ASYM_RRF, MSR_FITTYPE_SINGLE_HISTO_RRF, and RRF_FREQ_UNDEF.

Referenced by ReadMsrFile().

◆ CheckRunBlockIntegrity()

Bool_t PMsrHandler::CheckRunBlockIntegrity ( )
privatevirtual

Validates RUN block structure and consistency.

Checks the consistency of each RUN block, i.e. are the necessary parameters set and present, etc.

return:

  • true if the RUN blocks fulfill the minimal requirements.
  • false otherwise

Definition at line 5985 of file PMsrHandler.cpp.

References fFourierOnly, fGlobal, fParam, fRuns, GetNoOfFuncs(), MSR_PARAM_FUN_OFFSET, PMUSR_UNDEFINED, PRUN_ASYMMETRY, PRUN_ASYMMETRY_BNMR, PRUN_ASYMMETRY_RRF, PRUN_MU_MINUS, PRUN_NON_MUSR, PRUN_SINGLE_HISTO, PRUN_SINGLE_HISTO_RRF, and RRF_UNIT_UNDEF.

Referenced by ReadMsrFile().

◆ CheckUniquenessOfParamNames()

Bool_t PMsrHandler::CheckUniquenessOfParamNames ( UInt_t & parX,
UInt_t & parY )
privatevirtual

Checks that all parameter names are unique.

Checks if all the fit parameters are unique. If not parX, parY will show the first occurence of equal fit parameter names.

return:

  • true if the fit parameter names are unique.
  • false otherwise
Parameters
parXindex of the 1st fit parameter name for which there is a counter part.
parYindex of the counter part fit parameter name.

Definition at line 6333 of file PMsrHandler.cpp.

References fParam.

Referenced by ReadMsrFile().

◆ CopyMsrStatisticBlock()

virtual void PMsrHandler::CopyMsrStatisticBlock ( )
inlinevirtual

Flags that STATISTIC block should be copied as-is (for musrt0)

Definition at line 282 of file PMsrHandler.h.

References fCopyStatisticsBlock.

◆ EstimateN0()

Bool_t PMsrHandler::EstimateN0 ( )
virtual

Estimates N0 parameter for single histogram fits.

Uses data amplitude at t=0 to provide initial N0 estimate, improving fit convergence for single histogram fits.

Returns
true on success

returns if N0 shall be estimated

Definition at line 6847 of file PMsrHandler.cpp.

References fStartupOptions.

◆ EvalFunc()

virtual Double_t PMsrHandler::EvalFunc ( UInt_t i,
std::vector< Int_t > map,
std::vector< Double_t > param,
PMetaData metaData )
inlinevirtual

Evaluates a user-defined function.

Parameters
iFunction index
mapParameter mapping vector
paramParameter value vector
metaDataExperimental metadata (field, temperature, etc.)
Returns
Evaluated function value

Definition at line 334 of file PMsrHandler.h.

References fFuncHandler.

◆ FillParameterInUse()

void PMsrHandler::FillParameterInUse ( PMsrLines & theory,
PMsrLines & funcs,
PMsrLines & run )
privatevirtual

Determines which parameters are used in theory and functions.

Fills the fParamInUse vector. An element of the vector will be 0 if the fit parameter is not used at all, otherwise it will be > 0.

Parameters
theorymsr-file THEROY block lines
funcsmsr-file FUNCTIONS block lines
runmsr-file RUN blocks lines

Definition at line 5642 of file PMsrHandler.cpp.

References FilterNumber(), fParam, fParamInUse, MSR_PARAM_FUN_OFFSET, MSR_PARAM_MAP_OFFSET, and ParameterInUse().

Referenced by ReadMsrFile().

◆ FilterNumber()

Bool_t PMsrHandler::FilterNumber ( TString str,
const Char_t * filter,
Int_t offset,
Int_t & no )
privatevirtual

Extracts number from string with specific filter pattern.

Used to filter numbers from a string of the structure strX, where X is a number. The filter string is used to define the offset to X. It is used to filter strings like: map1 or fun4. At the moment only the filter strings 'map', 'fun', and 'par' are supported.

return:

  • true if successful
  • false otherwise
Parameters
strinput string
filterfilter string
offsetit is used to offset to found number, e.g. strX -> no = X+offset
nofiltered number

Definition at line 4052 of file PMsrHandler.cpp.

Referenced by CheckFuncs(), CheckMaps(), FillParameterInUse(), HandlePlotEntry(), HandleRunEntry(), and WriteMsrLogFile().

◆ GetFileName()

virtual const TString & PMsrHandler::GetFileName ( ) const
inlinevirtual

Returns the MSR file name.

Definition at line 202 of file PMsrHandler.h.

References fFileName.

◆ GetFuncIndex()

virtual UInt_t PMsrHandler::GetFuncIndex ( Int_t funNo)
inlinevirtual

Gets function index from function number.

Parameters
funNoFunction number
Returns
Function index (0-based)

Definition at line 313 of file PMsrHandler.h.

References fFuncHandler.

Referenced by PTheory::PTheory(), and WriteMsrLogFile().

◆ GetFuncNo()

virtual UInt_t PMsrHandler::GetFuncNo ( Int_t idx)
inlinevirtual

Gets function number by index.

Parameters
idxFunction index (0-based)
Returns
Function number as defined in FUNCTIONS block

Definition at line 305 of file PMsrHandler.h.

References fFuncHandler.

◆ GetGroupingString()

void PMsrHandler::GetGroupingString ( Int_t runNo,
TString detector,
TString & groupingStr )
virtual

Generates a grouping string for histogram display.

Parameters
runNoRun block number
detectorDetector identifier ("forward" or "backward")
groupingStrOutput grouping string

returns the forward/backward grouping string.

Parameters
runNomsr-file run block number
detectortag telling which set to be used. Possible are: 'forward' and 'backward'
groupingStrcompressed grouping information.

Definition at line 6821 of file PMsrHandler.cpp.

References fRuns, and MakeDetectorGroupingString().

◆ GetLastErrorMsg()

virtual std::string PMsrHandler::GetLastErrorMsg ( )
inlinevirtual

Returns the last error message as a string

Returns
Error message string

Definition at line 374 of file PMsrHandler.h.

References fLastErrorMsg.

◆ GetMsrCommands()

virtual PMsrLines * PMsrHandler::GetMsrCommands ( )
inlinevirtual

Returns pointer to COMMANDS block lines.

Definition at line 185 of file PMsrHandler.h.

References fCommands.

Referenced by PFitter::PFitter().

◆ GetMsrFileDirectoryPath()

virtual TString * PMsrHandler::GetMsrFileDirectoryPath ( )
inlinevirtual

Returns pointer to MSR file directory path.

Definition at line 194 of file PMsrHandler.h.

References fMsrFileDirectoryPath.

◆ GetMsrFourierList()

virtual PMsrFourierStructure * PMsrHandler::GetMsrFourierList ( )
inlinevirtual

Returns pointer to FOURIER block settings.

Definition at line 187 of file PMsrHandler.h.

References fFourier.

◆ GetMsrFunctions()

virtual PMsrLines * PMsrHandler::GetMsrFunctions ( )
inlinevirtual

Returns pointer to FUNCTIONS block lines.

Definition at line 179 of file PMsrHandler.h.

References fFunctions.

◆ GetMsrGlobal()

virtual PMsrGlobalBlock * PMsrHandler::GetMsrGlobal ( )
inlinevirtual

Returns pointer to GLOBAL block settings.

Definition at line 181 of file PMsrHandler.h.

References fGlobal.

Referenced by PRunSingleHistoRRF::PRunSingleHistoRRF().

◆ GetMsrParamList()

virtual PMsrParamList * PMsrHandler::GetMsrParamList ( )
inlinevirtual

◆ GetMsrPlotList()

virtual PMsrPlotList * PMsrHandler::GetMsrPlotList ( )
inlinevirtual

Returns pointer to list of PLOT blocks.

Definition at line 189 of file PMsrHandler.h.

References fPlots.

◆ GetMsrRunList()

virtual PMsrRunList * PMsrHandler::GetMsrRunList ( )
inlinevirtual

Returns pointer to list of RUN blocks.

Definition at line 183 of file PMsrHandler.h.

References fRuns.

Referenced by PTheory::PTheory().

◆ GetMsrStatistic()

virtual PMsrStatisticStructure * PMsrHandler::GetMsrStatistic ( )
inlinevirtual

Returns pointer to STATISTIC block.

Definition at line 191 of file PMsrHandler.h.

References fStatistic.

◆ GetMsrTheory()

virtual PMsrLines * PMsrHandler::GetMsrTheory ( )
inlinevirtual

Returns pointer to THEORY block lines.

Definition at line 177 of file PMsrHandler.h.

References fTheory.

Referenced by PTheory::PTheory().

◆ GetMsrTitle()

virtual TString * PMsrHandler::GetMsrTitle ( )
inlinevirtual

Returns pointer to MSR file title string.

Definition at line 173 of file PMsrHandler.h.

References fTitle.

◆ GetNoOfFitParameters()

UInt_t PMsrHandler::GetNoOfFitParameters ( UInt_t idx)
virtual

Gets the number of fit parameters used in a specific theory line.

Parameters
idxTheory line index
Returns
Number of parameters used

Calculate the number of fit parameters.

Parameters
idxrun block index

Definition at line 5445 of file PMsrHandler.cpp.

References fFunctions, fParam, fRuns, fTheory, MSR_PARAM_FUN_OFFSET, and status.

◆ GetNoOfFuncs()

virtual Int_t PMsrHandler::GetNoOfFuncs ( )
inlinevirtual

Returns the number of user-defined functions in FUNCTIONS block.

Definition at line 297 of file PMsrHandler.h.

References fFuncHandler.

Referenced by CheckRunBlockIntegrity().

◆ GetNoOfParams()

virtual UInt_t PMsrHandler::GetNoOfParams ( )
inlinevirtual

Returns the number of fit parameters in FITPARAMETER block.

Definition at line 200 of file PMsrHandler.h.

References fParam.

◆ GetNoOfRuns()

virtual UInt_t PMsrHandler::GetNoOfRuns ( )
inlinevirtual

Returns the number of RUN blocks in MSR file.

Definition at line 197 of file PMsrHandler.h.

References fRuns.

◆ HandleCommandsEntry()

Bool_t PMsrHandler::HandleCommandsEntry ( PMsrLines & lines)
privatevirtual

Parses COMMANDS block entries.

Just copies the COMMAND block lines.

return:

  • true
Parameters
linesis a list of lines containing the command block

Definition at line 4091 of file PMsrHandler.cpp.

References fCommands, and fFourierOnly.

Referenced by ReadMsrFile().

◆ HandleFitParameterEntry()

Bool_t PMsrHandler::HandleFitParameterEntry ( PMsrLines & lines)
privatevirtual

Parses FITPARAMETER block entries.

The routine analyze a parameter line and, if the possible parameter list is OK (what this means see below), it adds the parameter to the parameter list.

Possible cases:

No Name Value Step/Neg_Error Pos_Error Boundary_Low Boundary_High
x x x x x x x -> 7 Parameters, e.g. after a MINOS fit
x x x x x -> 5 Parameters, e.g. after a MINOS fit
without boundaries
x x x x -> 4 Parameters, e.g. after MIGRAD fit
without boundaries, or
when starting

return:

  • true is fit parameter lines are OK.
  • false otherwise
Parameters
linesis a list of lines containing the fitparameter block

Definition at line 2840 of file PMsrHandler.cpp.

References fLastErrorMsg, PMsrParamStructure::fLowerBoundary, PMsrParamStructure::fLowerBoundaryPresent, PMsrParamStructure::fName, PMsrParamStructure::fNo, PMsrParamStructure::fNoOfParams, fParam, PMsrParamStructure::fPosError, PMsrParamStructure::fPosErrorPresent, PMsrParamStructure::fStep, PMsrParamStructure::fUpperBoundary, PMsrParamStructure::fUpperBoundaryPresent, and PMsrParamStructure::fValue.

Referenced by ReadMsrFile().

◆ HandleFourierEntry()

◆ HandleFunctionsEntry()

Bool_t PMsrHandler::HandleFunctionsEntry ( PMsrLines & lines)
privatevirtual

Parses FUNCTIONS block entries.

Parses the FUNCTIONS block of the msr-file.

return:

  • true if the parsing was successful.
  • false otherwise
Parameters
linesis a list of lines containing the functions block

Definition at line 3079 of file PMsrHandler.cpp.

References fFourierOnly, fFuncHandler, and fFunctions.

Referenced by ReadMsrFile().

◆ HandleGlobalEntry()

◆ HandlePlotEntry()

◆ HandleRunEntry()

Bool_t PMsrHandler::HandleRunEntry ( PMsrLines & lines)
privatevirtual

◆ HandleStatisticEntry()

Bool_t PMsrHandler::HandleStatisticEntry ( PMsrLines & lines)
privatevirtual

Parses STATISTIC block entries.

Handles the STATISTIC block of a msr-file.

return:

  • true if successful
  • false otherwise
Parameters
linesis a list of lines containing the statistic block

Definition at line 5339 of file PMsrHandler.cpp.

References fFourierOnly, fStatistic, and status.

Referenced by ReadMsrFile().

◆ HandleTheoryEntry()

Bool_t PMsrHandler::HandleTheoryEntry ( PMsrLines & lines)
privatevirtual

Parses THEORY block entries.

Just stores the THEORY block lines.

return:

  • true always
Parameters
linesis a list of lines containing the theory block

Definition at line 3055 of file PMsrHandler.cpp.

References fFourierOnly, and fTheory.

Referenced by ReadMsrFile().

◆ InitFourierParameterStructure()

◆ LastSignificant()

UInt_t PMsrHandler::LastSignificant ( Double_t dval,
UInt_t precLimit = 6 )
privatevirtual

Finds position of last significant digit in a double value.

Gets the last significant digit down to precLimit.

Parameters
dvalvalue for which the last signigicant digit shall be found
precLimitprecision limit

return: last significant digit down to precLimit

Definition at line 6899 of file PMsrHandler.cpp.

Referenced by WriteMsrFile(), and WriteMsrLogFile().

◆ MakeDetectorGroupingString()

void PMsrHandler::MakeDetectorGroupingString ( TString str,
PIntVector & group,
TString & result,
Bool_t includeDetector = true )
privatevirtual

Creates detector grouping string from integer vector.

encodes the detector grouping vector.

Parameters
str'forward' or 'backward'
groupdetector grouping vector to be encoded
resultencoded detector grouping string
includeDetectorif true, the detector information is included

Definition at line 6941 of file PMsrHandler.cpp.

Referenced by GetGroupingString(), and WriteMsrLogFile().

◆ NeededPrecision()

UInt_t PMsrHandler::NeededPrecision ( Double_t dval,
UInt_t precLimit = 13 )
privatevirtual

Calculates precision needed for formatting a double value.

Calculates the needed precision of Double_t values for WriteMsrLogFile and WriteMsrFile of the fit range. If a precision of > precLimit decimal places is needed, a warning is placed and a value of precLimit is returned.

Parameters
dvalvalue for which the precision has to be estimated
precLimitprecision limit

return: needed precision

Definition at line 6867 of file PMsrHandler.cpp.

Referenced by WriteMsrLogFile().

◆ ParameterInUse()

Int_t PMsrHandler::ParameterInUse ( UInt_t paramNo)
virtual

Checks if a parameter is used in theory or functions.

Parameters
paramNoParameter number (1-based as in MSR file)
Returns
1 if used, 0 if unused, -1 on error

Needed for the following purpose: if minuit is minimizing, it varies all the parameters of the parameter list (if not fixed), even if a particular parameter is NOT used at all. This is stupid! Hence one has to check if the parameter is used at all and if not, it has to be fixed.

return:

  • 0 if the parameter is not used.
  • a value > 0 if the parameter is used.
Parameters
paramNoparameter number

Definition at line 2807 of file PMsrHandler.cpp.

References fParam, and fParamInUse.

Referenced by FillParameterInUse().

◆ ParseFourierPhaseParIterVector()

Bool_t PMsrHandler::ParseFourierPhaseParIterVector ( PMsrFourierStructure & fourier,
const TString & str,
Bool_t & error )
privatevirtual

Parses Fourier phase parameter iteration vector.

examines if str has the form 'phase par(X0, offset, #params)' or 'phase parR(X0, offset, #params)'. If this form is found, fill in parX0 ... parXN to fourier.fPhaseParamNo, and in case of 'parR' also set the fourier.fPhaseRef accordingly.

Parameters
fouriermsr-file Fourier structure
strstring to be analyzed
errorflag needed to propagate a fatal error
Returns
true if a phase parameter iterator form is found, otherwise return false

Definition at line 4346 of file PMsrHandler.cpp.

References fLastErrorMsg, PMsrFourierStructure::fPhaseParamNo, and PMsrFourierStructure::fPhaseRef.

Referenced by HandleFourierEntry().

◆ ParseFourierPhaseParVector()

Bool_t PMsrHandler::ParseFourierPhaseParVector ( PMsrFourierStructure & fourier,
const TString & str,
Bool_t & error )
privatevirtual

Parses Fourier phase parameter vector.

examines if str has the form 'phase parX0 [sep parX1 ... sep parXN]'. Also allowed is that instead of parXn only one of the parameters could have the form parRn which markes a reference phase for relative phase fittings. If this form is found, fill in parX0 ... parXN to fourier.fPhaseParamNo, and in case a parR is present, set the fourier.fPhaseRef accordingly.

Parameters
fouriermsr-file Fourier structure
strstring to be analyzed
errorflag needed to propagate a fatal error
Returns
true if a phase parameter form is found, otherwise return false

Definition at line 4237 of file PMsrHandler.cpp.

References fLastErrorMsg, PMsrFourierStructure::fPhaseParamNo, and PMsrFourierStructure::fPhaseRef.

Referenced by HandleFourierEntry().

◆ ParseFourierPhaseValueVector()

Bool_t PMsrHandler::ParseFourierPhaseValueVector ( PMsrFourierStructure & fourier,
const TString & str,
Bool_t & error )
privatevirtual

Parses Fourier phase value vector.

examines if str has the form 'phase val0 [sep val1 ... sep valN]'. If this form is found, fill in val0 ... valN to fFourier.fPhase vector.

Parameters
fouriermsr-file Fourier structure
strstring to be analyzed
errorflag needed to propagate a fatal error
Returns
true if a phase value form is found, otherwise return false

Definition at line 4172 of file PMsrHandler.cpp.

References fLastErrorMsg, and PMsrFourierStructure::fPhase.

Referenced by HandleFourierEntry().

◆ ReadMsrFile()

Int_t PMsrHandler::ReadMsrFile ( )
virtual

Reads and parses the MSR file.

Reads and parses the MSR file.

Performs comprehensive parsing of all MSR file blocks including TITLE, FITPARAMETER, THEORY, FUNCTIONS, GLOBAL, RUN, COMMANDS, FOURIER, PLOT, and STATISTIC blocks. Validates consistency and reports detailed error messages on failure.

Returns
PMUSR_SUCCESS on success, negative error code on failure
See also
PMUSR_MSR_FILE_NOT_FOUND
PMUSR_MSR_SYNTAX_ERROR

Performs comprehensive parsing of all MSR file blocks in the following order:

  1. TITLE - File description
  2. FITPARAMETER - Fit parameters with values, errors, and constraints
  3. THEORY - Asymmetry/relaxation function definitions
  4. FUNCTIONS (optional) - User-defined mathematical functions
  5. GLOBAL (optional) - Global fit settings
  6. RUN - Data file specifications and fit ranges
  7. COMMANDS - MINUIT fitting commands
  8. FOURIER (optional) - Fourier transform parameters
  9. PLOT (optional) - Plotting parameters
  10. STATISTIC - Fit results (χ², NDF, convergence)

After parsing, performs extensive validation:

  • Checks for legacy lifetimecorrection syntax
  • Validates RUN block integrity (required fields, grouping consistency)
  • Verifies parameter name uniqueness
  • Checks map index validity
  • Validates user-defined functions
  • Verifies histogram grouping consistency
  • Checks addrun parameter references
  • Validates RRF (Rotating Reference Frame) settings
  • Checks real FFT requirements
  • Validates maximum likelihood settings

Error Handling:

  • Detailed error messages are written to stderr
  • Error messages are accumulated in fLastErrorMsg for programmatic access
  • Returns line number where error occurred for syntax errors
Returns
  • PMUSR_SUCCESS (0) if parsing succeeded
  • PMUSR_MSR_FILE_NOT_FOUND if file cannot be opened
  • PMUSR_MSR_SYNTAX_ERROR if syntax error encountered
  • Positive line number if parsing error occurred at specific line
Note
In Fourier-only mode (fFourierOnly=true), only relevant blocks are parsed
See also
HandleFitParameterEntry, HandleTheoryEntry, HandleRunEntry for block parsing

Definition at line 174 of file PMsrHandler.cpp.

References CheckAddRunParameters(), CheckFuncs(), CheckHistoGrouping(), CheckLegacyLifetimecorrection(), CheckMaps(), CheckMaxLikelihood(), CheckRealFFT(), CheckRRFSettings(), CheckRunBlockIntegrity(), CheckUniquenessOfParamNames(), fCommands, fFileName, fFourier, fFourierOnly, FillParameterInUse(), fLastErrorMsg, PMsrLineStructure::fLine, PMsrLineStructure::fLineNo, fMsrBlockCounter, fParam, fStatistic, fTitle, HandleCommandsEntry(), HandleFitParameterEntry(), HandleFourierEntry(), HandleFunctionsEntry(), HandleGlobalEntry(), HandlePlotEntry(), HandleRunEntry(), HandleStatisticEntry(), HandleTheoryEntry(), InitFourierParameterStructure(), MSR_TAG_COMMANDS, MSR_TAG_FITPARAMETER, MSR_TAG_FOURIER, MSR_TAG_FUNCTIONS, MSR_TAG_GLOBAL, MSR_TAG_PLOT, MSR_TAG_RUN, MSR_TAG_STATISTIC, MSR_TAG_THEORY, PMUSR_MSR_FILE_NOT_FOUND, PMUSR_MSR_SYNTAX_ERROR, and PMUSR_SUCCESS.

Referenced by PMsr2Data::GetSingleRunMsrFile().

◆ RemoveComment()

void PMsrHandler::RemoveComment ( const TString & str,
TString & truncStr )
privatevirtual

Removes comments from MSR file line.

Removes a potentially present comment from str and returns the truncated string in truncStr. A comment starts with '#'

Parameters
stroriginal string which might contain a comment
truncStrstring from which the comment has been removed

Definition at line 4147 of file PMsrHandler.cpp.

Referenced by HandleFourierEntry().

◆ SetMsrAddT0Entry()

void PMsrHandler::SetMsrAddT0Entry ( UInt_t runNo,
UInt_t addRunIdx,
UInt_t histoIdx,
Double_t bin )
virtual

Sets a time-zero bin for an addrun histogram.

Parameters
runNoRun block number (0-based)
addRunIdxIndex of addrun entry
histoIdxHistogram index within addrun
binTime-zero bin value

Sets a t0 value for an addrun entry.

Parameters
runNomsr-file run number
addRunIdxmsr-file addrun index, e.g. if 2 addruns are present addRunIdx can take the values 0 or 1.
histoIdxmsr-file histogram index for an addrun.
bint0 bin value.

Definition at line 2721 of file PMsrHandler.cpp.

References fLastErrorMsg, and fRuns.

◆ SetMsrBkgRangeEntry()

void PMsrHandler::SetMsrBkgRangeEntry ( UInt_t runNo,
UInt_t idx,
Int_t bin )
virtual

Sets a background range bin entry for a specific run.

Parameters
runNoRun block number (0-based)
idxBackground range index (0=start, 1=end, etc.)
binBackground range bin value

Sets the background range entries for a given runNo and a given histogram index idx.

Parameters
runNomsr-file run number
idx0=start bin index, 1=end bin index
binbackground range bin value

Definition at line 2779 of file PMsrHandler.cpp.

References fLastErrorMsg, and fRuns.

◆ SetMsrDataRangeEntry()

void PMsrHandler::SetMsrDataRangeEntry ( UInt_t runNo,
UInt_t idx,
Int_t bin )
virtual

Sets a data range bin entry for a specific run.

Parameters
runNoRun block number (0-based)
idxData range index (0=start, 1=end, etc.)
binData range bin value

Sets the data range entries for a given runNo and a given histogram index idx.

Parameters
runNomsr-file run number
idx0=start bin index, 1=end bin index
bindata range bin value

Definition at line 2756 of file PMsrHandler.cpp.

References fLastErrorMsg, and fRuns.

◆ SetMsrParamPosError()

Bool_t PMsrHandler::SetMsrParamPosError ( UInt_t idx,
Double_t value )
virtual

Sets the positive error value for a parameter (asymmetric errors).

Parameters
iParameter index (0-based)
valuePositive error value
Returns
true on success, false if index out of range

Sets the fit parameter positive error value at positon idx.

return:

  • true if idx is within range
  • false if idx is larger than the fit parameter vector.
Parameters
idxindex fo the fit parameter positive error value
valuefit parameter positive error value to be set.

Definition at line 2665 of file PMsrHandler.cpp.

References fLastErrorMsg, and fParam.

◆ SetMsrParamPosErrorPresent()

Bool_t PMsrHandler::SetMsrParamPosErrorPresent ( UInt_t idx,
Bool_t value )
virtual

Sets whether positive error is present for a parameter.

Parameters
iParameter index (0-based)
valueTrue if positive error is defined
Returns
true on success, false if index out of range

Sets the flag whether the fit parameter positive error value is persent. This at positon idx.

return:

  • true if idx is within range
  • false if idx is larger than the fit parameter vector.
Parameters
idxindex fo the fit parameter positive error value
valuefit parameter positive error value present.

Definition at line 2637 of file PMsrHandler.cpp.

References fLastErrorMsg, and fParam.

◆ SetMsrParamStep()

Bool_t PMsrHandler::SetMsrParamStep ( UInt_t idx,
Double_t value )
virtual

Sets the step size (or error) of a fit parameter.

Parameters
iParameter index (0-based)
valueNew step/error value
Returns
true on success, false if index out of range

Sets the fit parameter step value (initial step size for minuit2) at positon idx. After a successful fit, the negative error will be writen.

return:

  • true if idx is within range
  • false if idx is larger than the fit parameter vector.
Parameters
idxindex fo the fit parameter step value
valuefit parameter step value to be set.

Definition at line 2609 of file PMsrHandler.cpp.

References fLastErrorMsg, and fParam.

◆ SetMsrParamValue()

Bool_t PMsrHandler::SetMsrParamValue ( UInt_t idx,
Double_t value )
virtual

Sets the value of a fit parameter.

Parameters
iParameter index (0-based)
valueNew parameter value
Returns
true on success, false if index out of range

Sets the fit parameter value at position idx.

return:

  • true if idx is within range
  • false if idx is larger than the fit parameter vector.
Parameters
idxindex of the fit parameter value.
valuefit parameter value to be set.

Definition at line 2580 of file PMsrHandler.cpp.

References fLastErrorMsg, and fParam.

◆ SetMsrStatisticConverged()

virtual void PMsrHandler::SetMsrStatisticConverged ( Bool_t converged)
inlinevirtual

Sets whether fit converged in STATISTIC block

Parameters
convergedTrue if fit converged successfully

Definition at line 286 of file PMsrHandler.h.

References fStatistic.

◆ SetMsrStatisticMin()

virtual void PMsrHandler::SetMsrStatisticMin ( Double_t min)
inlinevirtual

Sets the minimum χ² (or max likelihood) in STATISTIC block

Parameters
minMinimum value

Definition at line 290 of file PMsrHandler.h.

References fStatistic.

◆ SetMsrStatisticNdf()

virtual void PMsrHandler::SetMsrStatisticNdf ( UInt_t ndf)
inlinevirtual

Sets the number of degrees of freedom in STATISTIC block

Parameters
ndfDegrees of freedom

Definition at line 294 of file PMsrHandler.h.

References fStatistic.

◆ SetMsrT0Entry()

void PMsrHandler::SetMsrT0Entry ( UInt_t runNo,
UInt_t idx,
Double_t bin )
virtual

Sets a time-zero bin entry for a specific run.

Parameters
runNoRun block number (0-based)
idxHistogram index within t0 list
binTime-zero bin value

Sets the t0 entries for a given runNo and a given histogram index idx.

Parameters
runNomsr-file run number
idxmsr-file histogram index
bint0 bin value

Definition at line 2691 of file PMsrHandler.cpp.

References fLastErrorMsg, and fRuns.

◆ SetMsrTitle()

virtual void PMsrHandler::SetMsrTitle ( const TString & title)
inlinevirtual

Sets the MSR file title

Parameters
titleNew title string

Definition at line 206 of file PMsrHandler.h.

References fTitle.

◆ WriteMsrFile()

Int_t PMsrHandler::WriteMsrFile ( const Char_t * filename,
std::map< UInt_t, TString > * commentsPAR = 0,
std::map< UInt_t, TString > * commentsTHE = 0,
std::map< UInt_t, TString > * commentsFUN = 0,
std::map< UInt_t, TString > * commentsRUN = 0 )
virtual

Writes an MSR file from internal data structures.

Writes MSR file with updated parameters and results.

Writes a complete MSR file, optionally preserving user comments from specific blocks. Typically called after fitting to save fitted parameters and statistics.

Parameters
filenameOutput MSR file path
commentsPAROptional comments for FITPARAMETER block (line number → comment)
commentsTHEOptional comments for THEORY block
commentsFUNOptional comments for FUNCTIONS block
commentsRUNOptional comments for RUN block
Returns
PMUSR_SUCCESS on success, negative error code on failure

Creates a complete MSR file with all blocks, typically called after fitting to save updated parameter values, errors, and fit statistics. The file includes properly formatted blocks in the standard MSR file order.

MSR File Structure Written:

  1. TITLE block
  2. FITPARAMETER block (with fitted values and errors)
  3. THEORY block
  4. FUNCTIONS block (if functions are defined)
  5. GLOBAL block (if global settings exist)
  6. RUN blocks (one per run)
  7. COMMANDS block
  8. FOURIER block (if Fourier parameters are defined)
  9. PLOT blocks (if plot settings exist)
  10. STATISTIC block (with fit results)

Comment Preservation: The comment maps allow preserving user comments from specific MSR blocks. Comments are inserted before the corresponding line based on the map key (line number). This is useful when updating MSR files while maintaining documentation.

Formatting:

  • Parameters: Right-aligned numbers, left-aligned names and values
  • Precision: 6 significant digits for floating-point values
  • Boundaries: Properly formatted lower/upper limits
  • Separators: Dashed lines between major sections
Parameters
filenameOutput MSR file path
commentsPAROptional map of line number → comment for FITPARAMETER block
commentsTHEOptional map of line number → comment for THEORY block
commentsFUNOptional map of line number → comment for FUNCTIONS block
commentsRUNOptional map of line number → comment for RUN blocks
Returns
  • PMUSR_SUCCESS if file written successfully
  • PMUSR_MSR_FILE_WRITE_ERROR if output file cannot be opened
Note
Comments are removed from the maps after being written
The STATISTIC block content depends on fCopyStatisticsBlock flag
See also
WriteMsrLogFile for writing debug/verification log files
SetMsrStatisticMin, SetMsrStatisticNdf for updating statistics

Definition at line 1695 of file PMsrHandler.cpp.

References BeautifyFourierPhaseParameterString(), fCommands, fFourier, fFunctions, fGlobal, FOURIER_APOD_MEDIUM, FOURIER_APOD_NONE, FOURIER_APOD_STRONG, FOURIER_APOD_WEAK, FOURIER_PLOT_IMAG, FOURIER_PLOT_PHASE, FOURIER_PLOT_PHASE_OPT_REAL, FOURIER_PLOT_POWER, FOURIER_PLOT_REAL, FOURIER_PLOT_REAL_AND_IMAG, FOURIER_UNIT_CYCLES, FOURIER_UNIT_FREQ, FOURIER_UNIT_GAUSS, FOURIER_UNIT_TESLA, fParam, fPlots, fRuns, fStatistic, fTheory, fTitle, LastSignificant(), MSR_FITTYPE_ASYM, MSR_FITTYPE_ASYM_RRF, MSR_FITTYPE_BNMR, MSR_FITTYPE_MU_MINUS, MSR_FITTYPE_NON_MUSR, MSR_FITTYPE_SINGLE_HISTO, MSR_FITTYPE_SINGLE_HISTO_RRF, MSR_PARAM_FUN_OFFSET, MSR_PLOT_ASYM, MSR_PLOT_ASYM_RRF, MSR_PLOT_BNMR, MSR_PLOT_MU_MINUS, MSR_PLOT_NON_MUSR, MSR_PLOT_SINGLE_HISTO, MSR_PLOT_SINGLE_HISTO_RRF, PMUSR_MSR_FILE_WRITE_ERROR, PMUSR_SUCCESS, PMUSR_UNDEFINED, RRF_UNIT_G, RRF_UNIT_kHz, RRF_UNIT_Mcs, RRF_UNIT_MHz, and RRF_UNIT_T.

◆ WriteMsrLogFile()

Int_t PMsrHandler::WriteMsrLogFile ( const Bool_t messages = true)
virtual

Writes an MSR log file (.mlog) with parsed MSR content.

Writes a log file with MSR file content and parsing information.

Creates a .mlog file containing the parsed MSR structure, useful for debugging and verifying parameter interpretation.

Parameters
messagesIf true, includes informational messages in log
Returns
PMUSR_SUCCESS on success, negative error code on failure

Creates a log file with the same base name as the MSR file but with .mlog extension. The log file contains the parsed and formatted MSR structure, which is useful for:

  • Debugging MSR file parsing
  • Verifying parameter interpretation
  • Checking fit range calculations
  • Reviewing theory and function definitions

The log file format mirrors the MSR file structure but with:

  • Standardized formatting and precision
  • Expanded parameter values
  • Calculated fit ranges (in bins and microseconds)
  • Resolved function definitions
  • Complete statistics (if available)

Processing includes:

  • Re-reading original MSR file to preserve comments and structure
  • Identifying missing tags (t0, background, data) in RUN blocks
  • Formatting numeric values with appropriate precision
  • Writing all MSR blocks in canonical format
Parameters
messagesIf true, includes additional informational messages about the statistics block. Set to false when called from musrt0 to suppress messages.
Returns
  • PMUSR_SUCCESS if log file written successfully
  • PMUSR_MSR_LOG_FILE_WRITE_ERROR if MSR or log file cannot be opened
  • PMUSR_MSR_SYNTAX_ERROR if syntax error encountered during processing
Note
The log file name is constructed by replacing the MSR file extension with ".mlog" (e.g., "run1234.msr" → "run1234.mlog")
See also
WriteMsrFile for writing updated MSR files

Definition at line 443 of file PMsrHandler.cpp.

References BeautifyFourierPhaseParameterString(), fFileName, fFourier, fFuncHandler, fGlobal, FilterNumber(), FOURIER_APOD_MEDIUM, FOURIER_APOD_NONE, FOURIER_APOD_STRONG, FOURIER_APOD_WEAK, FOURIER_PLOT_IMAG, FOURIER_PLOT_PHASE, FOURIER_PLOT_PHASE_OPT_REAL, FOURIER_PLOT_POWER, FOURIER_PLOT_REAL, FOURIER_PLOT_REAL_AND_IMAG, FOURIER_UNIT_CYCLES, FOURIER_UNIT_FREQ, FOURIER_UNIT_GAUSS, FOURIER_UNIT_TESLA, fParam, fPlots, fRuns, fStartupOptions, fStatistic, fTheory, fTitle, GetFuncIndex(), LastSignificant(), MakeDetectorGroupingString(), MSR_FITTYPE_ASYM, MSR_FITTYPE_ASYM_RRF, MSR_FITTYPE_BNMR, MSR_FITTYPE_MU_MINUS, MSR_FITTYPE_NON_MUSR, MSR_FITTYPE_SINGLE_HISTO, MSR_FITTYPE_SINGLE_HISTO_RRF, MSR_PARAM_FUN_OFFSET, MSR_PLOT_ASYM, MSR_PLOT_ASYM_RRF, MSR_PLOT_BNMR, MSR_PLOT_MU_MINUS, MSR_PLOT_NON_MUSR, MSR_PLOT_SINGLE_HISTO, MSR_PLOT_SINGLE_HISTO_RRF, MSR_TAG_COMMANDS, MSR_TAG_FITPARAMETER, MSR_TAG_FOURIER, MSR_TAG_FUNCTIONS, MSR_TAG_GLOBAL, MSR_TAG_PLOT, MSR_TAG_RUN, MSR_TAG_STATISTIC, MSR_TAG_THEORY, MSR_TAG_TITLE, NeededPrecision(), PMUSR_MSR_LOG_FILE_WRITE_ERROR, PMUSR_MSR_SYNTAX_ERROR, PMUSR_SUCCESS, and PMUSR_UNDEFINED.

Member Data Documentation

◆ fCommands

PMsrLines PMsrHandler::fCommands
private

MINUIT commands block lines.

Definition at line 388 of file PMsrHandler.h.

Referenced by GetMsrCommands(), HandleCommandsEntry(), ReadMsrFile(), WriteMsrFile(), and ~PMsrHandler().

◆ fCopyStatisticsBlock

Bool_t PMsrHandler::fCopyStatisticsBlock
private

If true, copy old statistics block (musrt0); if false, write new one (musrfit)

Definition at line 399 of file PMsrHandler.h.

Referenced by CopyMsrStatisticBlock(), and PMsrHandler().

◆ fFileName

TString PMsrHandler::fFileName
private

MSR file name (with path)

Definition at line 380 of file PMsrHandler.h.

Referenced by GetFileName(), PMsrHandler(), ReadMsrFile(), and WriteMsrLogFile().

◆ fFourier

PMsrFourierStructure PMsrHandler::fFourier
private

Fourier transform parameters and settings.

Definition at line 389 of file PMsrHandler.h.

Referenced by BeautifyFourierPhaseParameterString(), CheckRealFFT(), GetMsrFourierList(), HandleFourierEntry(), ReadMsrFile(), WriteMsrFile(), and WriteMsrLogFile().

◆ fFourierOnly

Bool_t PMsrHandler::fFourierOnly
private

Flag indicating Fourier transform only mode (for musrFT)

Definition at line 377 of file PMsrHandler.h.

Referenced by CheckFuncs(), CheckRunBlockIntegrity(), HandleCommandsEntry(), HandleFunctionsEntry(), HandleRunEntry(), HandleStatisticEntry(), HandleTheoryEntry(), PMsrHandler(), and ReadMsrFile().

◆ fFuncHandler

std::unique_ptr<PFunctionHandler> PMsrHandler::fFuncHandler
private

Handler for parsing and evaluating user-defined functions.

Definition at line 395 of file PMsrHandler.h.

Referenced by CheckMapAndParamRange(), EvalFunc(), GetFuncIndex(), GetFuncNo(), GetNoOfFuncs(), HandleFunctionsEntry(), and WriteMsrLogFile().

◆ fFunctions

PMsrLines PMsrHandler::fFunctions
private

User-defined functions block lines.

Definition at line 385 of file PMsrHandler.h.

Referenced by CheckFuncs(), CheckMaps(), GetMsrFunctions(), GetNoOfFitParameters(), HandleFunctionsEntry(), WriteMsrFile(), and ~PMsrHandler().

◆ fGlobal

PMsrGlobalBlock PMsrHandler::fGlobal
private

Global block settings (fit type, data format, etc.)

Definition at line 386 of file PMsrHandler.h.

Referenced by CheckMaxLikelihood(), CheckRRFSettings(), CheckRunBlockIntegrity(), GetMsrGlobal(), HandleGlobalEntry(), WriteMsrFile(), and WriteMsrLogFile().

◆ fLastErrorMsg

◆ fMsrBlockCounter

Int_t PMsrHandler::fMsrBlockCounter
private

Counter to track current MSR block during parsing.

Definition at line 393 of file PMsrHandler.h.

Referenced by PMsrHandler(), and ReadMsrFile().

◆ fMsrFileDirectoryPath

TString PMsrHandler::fMsrFileDirectoryPath
private

Directory path of the MSR file.

Definition at line 381 of file PMsrHandler.h.

Referenced by GetMsrFileDirectoryPath(), and PMsrHandler().

◆ fParam

◆ fParamInUse

PIntVector PMsrHandler::fParamInUse
private

Flags indicating which parameters are actually used in theory/functions.

Definition at line 397 of file PMsrHandler.h.

Referenced by FillParameterInUse(), ParameterInUse(), and ~PMsrHandler().

◆ fPlots

PMsrPlotList PMsrHandler::fPlots
private

List of PLOT blocks with plotting parameters.

Definition at line 390 of file PMsrHandler.h.

Referenced by CheckLegacyLifetimecorrection(), CheckRealFFT(), GetMsrPlotList(), HandlePlotEntry(), WriteMsrFile(), WriteMsrLogFile(), and ~PMsrHandler().

◆ fRuns

◆ fStartupOptions

PStartupOptions* PMsrHandler::fStartupOptions
private

Pointer to startup options from musrfit_startup.xml.

Definition at line 378 of file PMsrHandler.h.

Referenced by EstimateN0(), PMsrHandler(), and WriteMsrLogFile().

◆ fStatistic

◆ fTheory

PMsrLines PMsrHandler::fTheory
private

Theory block lines defining asymmetry/relaxation functions.

Definition at line 384 of file PMsrHandler.h.

Referenced by CheckFuncs(), CheckMaps(), GetMsrTheory(), GetNoOfFitParameters(), HandleTheoryEntry(), WriteMsrFile(), WriteMsrLogFile(), and ~PMsrHandler().

◆ fTitle

TString PMsrHandler::fTitle
private

MSR file title string.

Definition at line 382 of file PMsrHandler.h.

Referenced by GetMsrTitle(), PMsrHandler(), ReadMsrFile(), SetMsrTitle(), WriteMsrFile(), and WriteMsrLogFile().


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