musrfit 1.10.0
PRunNonMusr Class Reference

Class for fitting general x-y data sets (non-μSR time series). More...

#include <PRunNonMusr.h>

Inheritance diagram for PRunNonMusr:
Collaboration diagram for PRunNonMusr:

Public Member Functions

 PRunNonMusr ()
 Default constructor creating an empty, invalid non-μSR run object.
 
 PRunNonMusr (PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData)
 Main constructor initializing a non-μSR run from MSR file and data.
 
virtual ~PRunNonMusr ()
 Virtual destructor (no cleanup needed for this class).
 
virtual Double_t CalcChiSquare (const std::vector< Double_t > &par)
 Calculates χ² between non-μSR data and theory.
 
virtual Double_t CalcChiSquareExpected (const std::vector< Double_t > &par)
 Calculates expected χ² (NOT IMPLEMENTED for non-μSR).
 
virtual Double_t CalcMaxLikelihood (const std::vector< Double_t > &par)
 Calculates maximum likelihood (NOT IMPLEMENTED for non-μSR).
 
virtual void CalcTheory ()
 Evaluates theory function (empty implementation for non-μSR).
 
virtual UInt_t GetNoOfFitBins ()
 Returns the number of x-y points within the fit range.
 
virtual void SetFitRangeBin (const TString fitRange)
 Sets fit range in bin units (NOT SUPPORTED for non-μSR).
 
virtual UInt_t GetXIndex ()
 Returns the x-axis column index from MSR file specification.
 
virtual UInt_t GetYIndex ()
 Returns the y-axis column index from MSR file specification.
 
- Public Member Functions inherited from PRunBase
 PRunBase ()
 Default constructor.
 
 PRunBase (PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag)
 Constructor initializing run from MSR file and raw data.
 
virtual ~PRunBase ()
 Virtual destructor.
 
virtual void SetFitRange (PDoublePairVector fitRange)
 Sets the fit time range for this run.
 
virtual UInt_t GetRunNo ()
 Returns the run number (0-based index in MSR file).
 
virtual PRunDataGetData ()
 Returns pointer to processed data container.
 
virtual void CleanUp ()
 Cleans up internal data structures.
 
virtual Bool_t IsValid ()
 Returns validity status of this run object.
 

Protected Member Functions

virtual Bool_t PrepareData ()
 Main data preparation orchestrator for non-μSR data.
 
virtual Bool_t PrepareFitData ()
 Prepares x-y data for fitting.
 
virtual Bool_t PrepareViewData ()
 Prepares x-y data for viewing/plotting.
 
- Protected Member Functions inherited from PRunBase
virtual void DeadTimeCorrection (std::vector< PDoubleVector > &histos, PUIntVector &histoNo)
 carry out dead time correction
 
virtual void CalculateKaiserFilterCoeff (Double_t wc, Double_t A, Double_t dw)
 Calculates Kaiser window FIR filter coefficients for RRF smoothing.
 
virtual void FilterTheo ()
 Applies Kaiser FIR filter to theory values for RRF fits.
 

Private Attributes

PRawRunDatafRawRunData
 Pointer to raw run data handler (not owned).
 
UInt_t fNoOfFitBins
 Number of x-y points within fit range (fFitStartTime ≤ x ≤ fFitEndTime)
 
Int_t fPacking
 Data point averaging/grouping factor.
 
Bool_t fTheoAsData
 Theory calculation mode flag.
 
Int_t fStartTimeBin
 Index of first data point in fit range.
 
Int_t fEndTimeBin
 Index of last data point in fit range (inclusive).
 

Additional Inherited Members

- Protected Attributes inherited from PRunBase
Bool_t fValid
 Flag indicating if run object initialized successfully; false if any error occurred.
 
EPMusrHandleTag fHandleTag
 Operation mode: kFit (fitting), kView (display only), kEmpty (uninitialized)
 
Int_t fRunNo
 Run number (0-based index in MSR file RUN blocks)
 
PMsrHandlerfMsrInfo
 Pointer to MSR file handler (owned externally, not deleted here)
 
PMsrRunBlockfRunInfo
 Pointer to this run's RUN block settings within fMsrInfo.
 
PRunDataHandlerfRawData
 Pointer to raw data handler (owned externally, not deleted here)
 
PRunData fData
 Processed data container: background-corrected, packed, with theory values.
 
Double_t fTimeResolution
 Time resolution of raw histogram data in microseconds (μs), e.g., 0.01953125 μs for PSI GPS.
 
PMetaData fMetaData
 Experimental metadata extracted from data file header (magnetic field, temperature, beam energy)
 
PDoubleVector fT0s
 Time-zero bin values for all histograms in this run (forward, backward, etc.)
 
std::vector< PDoubleVectorfAddT0s
 Time-zero bin values for additional runs to be added to main run.
 
Double_t fFitStartTime
 Fit range start time in microseconds (μs) relative to t0.
 
Double_t fFitEndTime
 Fit range end time in microseconds (μs) relative to t0.
 
PDoubleVector fFuncValues
 Cached values of user-defined functions from FUNCTIONS block, evaluated at current parameters.
 
std::unique_ptr< PTheoryfTheory
 Theory function evaluator (smart pointer, automatically deleted)
 
PDoubleVector fKaiserFilter
 Kaiser window FIR filter coefficients for smoothing RRF theory curves.
 

Detailed Description

Class for fitting general x-y data sets (non-μSR time series).

PRunNonMusr extends the musrfit framework to handle arbitrary x-y data that doesn't originate from μSR experiments. This allows users to leverage musrfit's powerful fitting engine, theory functions, and MINUIT interface for general curve fitting tasks.

Purpose and Use Cases

This fit type is designed for:

  • General time-series data: Any x vs. y measurements
  • Non-μSR physics: Other experimental data (e.g., optical, electrical, thermal)
  • Reusing μSR theory functions: Apply exponentials, oscillations, relaxations to non-μSR data
  • Custom data analysis: Fit arbitrary functional forms to experimental data
  • Method validation: Test fitting procedures on simulated or benchmark data

Data Structure

Unlike μSR fits, non-μSR data is provided as simple x-y pairs:

  • x-axis: Independent variable (time, temperature, field, voltage, etc.)
  • y-axis: Dependent variable (signal, counts, current, etc.)
  • Errors: Optional error bars on y-values
  • No histograms: Data is already processed, not raw detector counts
  • No t0: No time-zero concept (not time-differential μSR)
  • No asymmetry: Direct fitting of y vs. x

Data Input Formats

Non-μSR data can be loaded from:

  • ASCII files: Space/tab-separated columns (x, y, err)
  • DB files: Database format with metadata
  • MuSonRoot files: Special ROOT structure for non-μSR data

ASCII format example:

# x-axis y-axis error
0.0 100.5 3.2
0.1 95.3 3.1
0.2 90.8 3.0
...

MSR File Configuration

Example MSR file RUN block for non-μSR data:

RUN data/mydata.dat DB PSI MUSR-ROOT (name beamline)
fittype 12 (NonMusr)
map 1 2 (x-index, y-index in data columns)
xy-data 0 1 (column 0 = x, column 1 = y)
packing 1 (usually 1 for pre-processed data)
fit 0.0 10.0 (fit range in x-axis units)

Theory Functions

All standard musrfit theory functions can be used:

  • Exponentials: decay, growth, stretched exponentials
  • Oscillations: cosine, sine, damped oscillations
  • Relaxations: static/dynamic Gaussian/Lorentzian Kubo-Toyabe
  • Polynomials: backgrounds, baselines
  • User functions: Custom C++ functions

Theory is evaluated at the x-values from the data file.

Key Differences from μSR Fits

FeatureμSR FitsNon-μSR Fits
Data typeRaw histogramsProcessed x-y pairs
Time zero (t0)RequiredNot applicable
BackgroundEstimated/subtractedIncluded in y-data
AsymmetryCalculatedNot applicable
PackingRebin histogramsAverage x-y points
Fit rangeTime (μs)x-axis units (arbitrary)
ADDRUNSupportedNOT supported

Limitations

  • No ADDRUN: Cannot combine multiple non-μSR data sets
  • No maximum likelihood: Only χ² fitting supported (not implemented for non-μSR)
  • No expected χ²: Not implemented (unclear definition for general data)
  • Simple error handling: Assumes independent Gaussian errors

Analysis Workflow

  1. Prepare Data: Format as x-y(-error) columns in ASCII/DB file
  2. Create MSR File: Specify file, fit type (12), xy-data indices, fit range
  3. Define Theory: Use standard THEORY block functions
  4. Run Fit: musrfit performs χ² minimization via MINUIT
  5. Analyze Results: Standard parameter extraction, error analysis, plotting
See also
PRunSingleHisto for standard μSR single histogram fits
PRunBase for base class interface and common functionality

Definition at line 132 of file PRunNonMusr.h.

Constructor & Destructor Documentation

◆ PRunNonMusr() [1/2]

PRunNonMusr::PRunNonMusr ( )

Default constructor creating an empty, invalid non-μSR run object.

Initializes all member variables to default values:

  • Bin counts set to 0
  • Packing set to 1 (no packing for x-y data)
  • Handle tag set to kEmpty
  • Raw data pointer set to nullptr

This constructor is needed for creating vectors of PRunNonMusr objects. The resulting object cannot be used until properly initialized via the main constructor.

Initializes all member variables to default/safe values:

  • fNoOfFitBins = 0 (no bins to fit)
  • fPacking = 1 (no data averaging)
  • fStartTimeBin = 0 (first data point)
  • fEndTimeBin = 0 (no range)
  • fHandleTag = kEmpty (uninitialized)
  • fRawRunData = nullptr (no data loaded)

This constructor is needed for creating vectors of PRunNonMusr objects. The resulting object cannot be used until properly initialized via the main constructor.

See also
PRunNonMusr(PMsrHandler*, PRunDataHandler*, UInt_t, EPMusrHandleTag, Bool_t)

Definition at line 54 of file PRunNonMusr.cpp.

References fEndTimeBin, PRunBase::fHandleTag, fNoOfFitBins, fPacking, fRawRunData, fStartTimeBin, kEmpty, and PRunBase::PRunBase().

◆ PRunNonMusr() [2/2]

PRunNonMusr::PRunNonMusr ( PMsrHandler * msrInfo,
PRunDataHandler * rawData,
UInt_t runNo,
EPMusrHandleTag tag,
Bool_t theoAsData )

Main constructor initializing a non-μSR run from MSR file and data.

Main constructor initializing a non-μSR run from MSR file and x-y data.

Performs initialization for general x-y data fitting:

  1. Base Class Initialization:
    • Calls PRunBase constructor with MSR/data handlers
    • Initializes theory engine
  2. Raw Data Loading:
    • Retrieves raw data using run name from MSR file
    • Validates data was successfully loaded
    • Marks run invalid if data cannot be loaded
  3. Data Preparation:
    • Calls PrepareData() to process x-y data
    • Extracts x-y columns based on map/xy-data specification
    • Applies packing if specified
    • Sets up fit range in x-axis units

The object is marked as invalid (fValid=false) if:

  • Raw data file cannot be loaded
  • PrepareData() fails (invalid column indices, missing data, etc.)
Parameters
msrInfoPointer to MSR file handler (must remain valid)
rawDataPointer to raw data handler for loading data files
runNoRun number (0-based index in MSR file RUN blocks)
tagOperation mode: kFit (fitting), kView (display/plotting)
theoAsDataTheory mode: true = at data points, false = high-resolution
Warning
Check IsValid() after construction before using for fitting
See also
PrepareData() for data processing details

Performs comprehensive initialization for general curve fitting:

  1. Base Class Initialization:
    • Calls PRunBase constructor with MSR/data handlers
    • Initializes theory engine and parameter mappings
    • Sets up FUNCTIONS block evaluation
  2. Raw Data Loading:
    • Retrieves raw x-y data using run name from MSR file
    • Calls fRawData->GetRunData(*runName)
    • Validates data was successfully loaded
    • If loading fails → marks run invalid, prints error
  3. Data Preparation:
    • Calls PrepareData() to process x-y data
    • Extracts x-y columns based on MSR file specification
    • Applies packing to average data points
    • Sets up fit range boundaries
    • If preparation fails → marks run invalid

The object is marked as invalid (fValid=false) if:

  • Raw data file cannot be loaded (file not found, wrong format, etc.)
  • PrepareData() fails (invalid column indices, missing packing, etc.)

Key features for non-μSR:

  • No histogram processing (data is already x-y pairs)
  • No time-zero determination (not time-differential)
  • No background subtraction (included in y-data)
  • No asymmetry calculation (direct y vs. x fitting)
Parameters
msrInfoPointer to MSR file handler (must remain valid for object lifetime)
rawDataPointer to raw data handler for loading data files
runNoRun number (0-based index in MSR file RUN blocks)
tagOperation mode: kFit (fitting), kView (display/plotting)
theoAsDataTheory mode: true = at data x-values, false = high-resolution (minimal effect for non-μSR)
Warning
Always check IsValid() after construction before using for fitting
See also
PrepareData() for data processing details
PRunBase constructor for base class initialization

Definition at line 113 of file PRunNonMusr.cpp.

References PRunBase::fRawData, fRawRunData, PRunBase::fRunInfo, fTheoAsData, PRunBase::fValid, if(), PrepareData(), and PRunBase::PRunBase().

◆ ~PRunNonMusr()

PRunNonMusr::~PRunNonMusr ( )
virtual

Virtual destructor (no cleanup needed for this class).

Destructor (no cleanup needed for non-μSR).

Raw data pointer (fRawRunData) is not owned by this class and is not deleted. Base class destructor handles cleanup of theory objects and other shared resources.

The fRawRunData pointer is not owned by this class and is not deleted here. It is managed by the PRunDataHandler and will be cleaned up externally.

Base class destructor (PRunBase) handles cleanup of:

  • Theory engine objects
  • Parameter mapping structures
  • Function value caches

Definition at line 143 of file PRunNonMusr.cpp.

Member Function Documentation

◆ CalcChiSquare()

Double_t PRunNonMusr::CalcChiSquare ( const std::vector< Double_t > & par)
virtual

Calculates χ² between non-μSR data and theory.

Calculates χ² between non-μSR x-y data and theory.

Computes the chi-squared statistic for x-y data:

\[ \chi^2 = \sum_{i={\rm start}}^{\rm end} \frac{(y_i^{\rm data} - y_i^{\rm theory})^2}{\sigma_i^2} \]

where:

  • y_i^data is the measured y-value at x_i
  • y_i^theory is the theory function evaluated at x_i
  • σ_i is the error on y_i (from data file or assumed)
  • Sum runs over all points within fit range (fFitStartTime ≤ x ≤ fFitEndTime)

Algorithm:

  1. Evaluate FUNCTIONS block for user-defined functions
  2. Loop over data points from fStartTimeBin to fEndTimeBin
  3. For each point:
    • Get x-value from fData.GetX()
    • Evaluate theory at that x-value: fTheory->Func(x, par, fFuncValues)
    • Compute weighted squared difference
  4. Sum contributions to get total χ²

Unlike μSR fits, this operates on x-y data directly (not histograms). The x-axis can represent any independent variable (time, temperature, field, etc.), not just time in microseconds.

Parameters
parParameter vector from MINUIT with current parameter values
Returns
Chi-squared value (sum of weighted squared residuals)
Note
No OpenMP parallelization in this implementation (typically smaller data sets)
See also
CalcMaxLikelihood() - NOT IMPLEMENTED for non-μSR

Computes the chi-squared statistic for general x-y data:

\[ \chi^2 = \sum_{i={\rm start}}^{\rm end} \frac{(y_i - f(x_i))^2}{\sigma_i^2} \]

where:

  • x_i is the independent variable (arbitrary units)
  • y_i is the measured dependent variable
  • f(x_i) is the theory function evaluated at x_i
  • σ_i is the error on y_i (from data file)

Algorithm:

  1. Evaluate FUNCTIONS block:
    • Loop over user-defined functions
    • Compute function values using current parameters
    • Store in fFuncValues for use by theory
  2. Calculate χ² sum:
    • Loop from fStartTimeBin to fEndTimeBin (inclusive)
    • For each data point i: a. Get x-value: x = fData.GetX()->at(i) b. Evaluate theory at x: theo = fTheory->Func(x, par, fFuncValues) c. Get data and error: y = fData.GetValue()->at(i), σ = fData.GetError()->at(i) d. Compute contribution: Δχ² = (y - theo)² / σ²
    • Sum all contributions

Key differences from μSR fits:

  • x-axis is arbitrary (not necessarily time in μs)
  • Theory evaluated on-demand (not pre-calculated on grid)
  • Loop end is INCLUSIVE (i <= fEndTimeBin)
  • No OpenMP parallelization (simpler, smaller data sets)
Parameters
parParameter vector from MINUIT with current parameter values
Returns
Chi-squared value (minimize during fitting)
See also
CalcMaxLikelihood() - NOT IMPLEMENTED for non-μSR
PrepareData() for x-y data loading and fit range setup

Implements PRunBase.

Definition at line 189 of file PRunNonMusr.cpp.

References PRunBase::fData, fEndTimeBin, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, PRunBase::fRunInfo, fStartTimeBin, and PRunBase::fTheory.

◆ CalcChiSquareExpected()

Double_t PRunNonMusr::CalcChiSquareExpected ( const std::vector< Double_t > & par)
virtual

Calculates expected χ² (NOT IMPLEMENTED for non-μSR).

This method is not implemented for general x-y data because the concept of "expected χ²" depends on the underlying statistical distribution, which is not well-defined for arbitrary non-μSR data (unlike Poisson-distributed histogram counts in μSR).

Calling this method prints a warning message and returns 0.0.

Parameters
parParameter vector from MINUIT
Returns
Always returns 0.0
Note
Implementation would require assumptions about data statistics

This method is not implemented because the concept of "expected χ²" requires knowledge of the underlying statistical distribution of the data, which is not well-defined for general x-y data.

For μSR histogram data, the expected χ² can be calculated based on Poisson statistics. For arbitrary non-μSR data, the appropriate statistical model depends on the data source:

  • Counting experiments → Poisson
  • Averaged measurements → Gaussian
  • Other experiments → problem-specific distributions

Without knowing the data's statistical nature, a meaningful implementation cannot be provided.

Parameters
parParameter vector from MINUIT (unused)
Returns
Always returns 0.0
Note
Prints "not implemented yet" message to stdout

Implements PRunBase.

Definition at line 235 of file PRunNonMusr.cpp.

◆ CalcMaxLikelihood()

Double_t PRunNonMusr::CalcMaxLikelihood ( const std::vector< Double_t > & par)
virtual

Calculates maximum likelihood (NOT IMPLEMENTED for non-μSR).

Maximum likelihood fitting is not implemented for general x-y data because:

  • The appropriate likelihood function depends on the data's statistical distribution
  • Unlike μSR histograms (Poisson), non-μSR data can have various error models
  • Gaussian errors → equivalent to χ² (no advantage)
  • Other distributions require user-specified likelihood functions

Calling this method prints a warning message and returns 1.0.

Parameters
parParameter vector from MINUIT
Returns
Always returns 1.0
Note
Only χ² fitting is supported for non-μSR data

Maximum likelihood fitting is not implemented for general x-y data because:

  1. Distribution-dependent: The likelihood function depends on the underlying statistical distribution of the data points, which varies:
    • Poisson: For counting experiments (like μSR histograms)
    • Gaussian: For averaged measurements with known errors
    • Other: Problem-specific distributions (binomial, exponential, etc.)
  2. Gaussian case equivalence: If errors are Gaussian, maximum likelihood is mathematically equivalent to χ² minimization (already implemented).
  3. Implementation complexity: Supporting arbitrary likelihood functions would require users to specify the distribution, adding complexity without clear benefit for most non-μSR applications.

For general x-y data with Gaussian errors, use χ² fitting via CalcChiSquare(). For non-Gaussian statistics, users should implement custom fitting outside musrfit.

Parameters
parParameter vector from MINUIT (unused)
Returns
Always returns 1.0
Note
Prints "not implemented yet" message to stdout
See also
CalcChiSquare() for standard least-squares fitting (recommended for non-μSR)

Implements PRunBase.

Definition at line 273 of file PRunNonMusr.cpp.

◆ CalcTheory()

void PRunNonMusr::CalcTheory ( )
virtual

Evaluates theory function (empty implementation for non-μSR).

For non-μSR data, theory calculation is performed directly in CalcChiSquare() rather than pre-calculating and storing theory values. This is because:

  • Theory is evaluated at arbitrary x-values (from data file)
  • No high-resolution grid needed (data already defines x-points)
  • Simpler to evaluate on-demand during χ² calculation

This method exists to satisfy the PRunBase interface but does nothing.

See also
CalcChiSquare() for on-demand theory evaluation

For non-μSR data, theory calculation is performed on-demand within CalcChiSquare() rather than pre-calculating and storing theory values.

This design choice is made because:

  • Theory is evaluated at arbitrary x-values from the data file
  • No need for high-resolution theory grid (data defines x-points)
  • Simpler and more efficient to evaluate during χ² loop
  • Avoids storing redundant theory array

This empty method exists solely to satisfy the PRunBase interface requirement.

See also
CalcChiSquare() for on-demand theory evaluation at each data point

Implements PRunBase.

Definition at line 299 of file PRunNonMusr.cpp.

◆ GetNoOfFitBins()

UInt_t PRunNonMusr::GetNoOfFitBins ( )
virtual

Returns the number of x-y points within the fit range.

Calculates and returns the number of x-y points within the fit range.

Counts data points where fFitStartTime ≤ x ≤ fFitEndTime. This count is used for:

  • Degrees of freedom: ν = N_points - N_params
  • Reduced χ²: χ²_red = χ² / ν
  • Statistical quality assessment

The method loops through all x-values in fData.GetX() and counts those within the specified fit range.

Returns
Number of data points within fit range
See also
GetNoOfFitBins() implementation for counting algorithm

Counts data points where fFitStartTime ≤ x ≤ fFitEndTime (both inclusive). This count is essential for:

  • Degrees of freedom: ν = N_points - N_params
  • Reduced χ²: χ²_red = χ² / ν
  • Statistical quality assessment: χ²/ν ≈ 1 indicates good fit

Algorithm:

  1. Reset counter: fNoOfFitBins = 0
  2. Loop through all x-values in fData.GetX()
  3. For each x-value:
    • If fFitStartTime ≤ x ≤ fFitEndTime → increment counter
  4. Return final count

The fit range (fFitStartTime, fFitEndTime) is specified in the MSR file RUN or GLOBAL block "fit" entry, in the same units as the x-axis data.

Returns
Number of data points within fit range
Note
This method recalculates the count each time it's called (not cached), allowing for dynamic fit range changes.

Definition at line 330 of file PRunNonMusr.cpp.

References PRunBase::fData, PRunBase::fFitEndTime, PRunBase::fFitStartTime, and fNoOfFitBins.

◆ GetXIndex()

UInt_t PRunNonMusr::GetXIndex ( )
virtual

Returns the x-axis column index from MSR file specification.

Extracts the x-data column index from:

  • "xy-data" entry in RUN block (preferred)
  • "map" entry first value (fallback)
  • Default: 0 (first column)

The index specifies which column in the data file contains the independent variable (x-axis values).

Returns
Column index for x-axis data (0-based)
See also
GetYIndex() for y-axis column

Returns the x-axis data index.

return:

  • x-index

Definition at line 640 of file PRunNonMusr.cpp.

References fRawRunData, and PRunBase::fRunInfo.

Referenced by PrepareFitData(), and PrepareViewData().

◆ GetYIndex()

UInt_t PRunNonMusr::GetYIndex ( )
virtual

Returns the y-axis column index from MSR file specification.

Extracts the y-data column index from:

  • "xy-data" entry in RUN block (preferred)
  • "map" entry second value (fallback)
  • Default: 1 (second column)

The index specifies which column in the data file contains the dependent variable (y-axis values to be fitted).

Returns
Column index for y-axis data (0-based)
See also
GetXIndex() for x-axis column

Returns the y-axis data index.

return:

  • y-index

Definition at line 681 of file PRunNonMusr.cpp.

References fRawRunData, and PRunBase::fRunInfo.

Referenced by PrepareFitData(), and PrepareViewData().

◆ PrepareData()

Bool_t PRunNonMusr::PrepareData ( )
protectedvirtual

Main data preparation orchestrator for non-μSR data.

Coordinates the data loading and preprocessing pipeline:

  1. Checks for ADDRUN (warns if present - not supported for non-μSR)
  2. Retrieves packing parameter from RUN or GLOBAL block
  3. Retrieves fit range from RUN or GLOBAL block
  4. Dispatches to PrepareFitData() or PrepareViewData() based on tag

Key validation:

  • ADDRUN presence → warning (ignored)
  • Missing packing → error (required)
  • Missing fit range → acceptable (will use all data)
Returns
True if data preparation succeeds, false on error
See also
PrepareFitData() for fitting mode processing
PrepareViewData() for viewing mode processing

Prepare data for fitting or viewing.

return:

  • true if everthing went smooth
  • false, otherwise.

Implements PRunBase.

Definition at line 353 of file PRunNonMusr.cpp.

References PRunBase::fFitEndTime, PRunBase::fFitStartTime, PRunBase::fHandleTag, PRunBase::fMsrInfo, fPacking, PRunBase::fRunInfo, PRunBase::fValid, kFit, kView, PMUSR_UNDEFINED, PrepareFitData(), and PrepareViewData().

Referenced by PRunNonMusr().

◆ PrepareFitData()

Bool_t PRunNonMusr::PrepareFitData ( )
protectedvirtual

Prepares x-y data for fitting.

Performs data processing for curve fitting:

  1. Determines x-y column indices via GetXIndex() and GetYIndex()
  2. Loads x-y(-error) data from file
  3. Applies packing if specified:
    • packing = 1: Use data as-is (no averaging)
    • packing > 1: Average consecutive points in groups of packing
  4. Packing algorithm for x-values: midpoint of packed range
  5. Packing algorithm for y-values: sum of packed points
  6. Packing algorithm for errors: sqrt(sum of squared errors)
  7. Counts bins within fit range (fFitStartTime ≤ x ≤ fFitEndTime)
  8. Determines fStartTimeBin and fEndTimeBin indices

Packing example (packing=3):

  • Raw: x=[0, 1, 2, 3, 4, 5], y=[10, 12, 11, 15, 14, 13]
  • Packed: x=[1, 4], y=[33, 42] (midpoint, sum)
Returns
True on success, false if data loading fails
See also
PrepareViewData() for viewing mode (may differ in processing)

Prepare data for fitting.

return:

  • true if everthing went smooth
  • false, otherwise.

Definition at line 402 of file PRunNonMusr.cpp.

References PRunBase::fData, fEndTimeBin, PRunBase::fFitEndTime, PRunBase::fFitStartTime, fNoOfFitBins, fPacking, fRawRunData, fStartTimeBin, GetXIndex(), and GetYIndex().

Referenced by PrepareData().

◆ PrepareViewData()

Bool_t PRunNonMusr::PrepareViewData ( )
protectedvirtual

Prepares x-y data for viewing/plotting.

Similar to PrepareFitData() but optimized for visualization:

  • May use different packing for display
  • May extend beyond fit range for context
  • Less stringent validation

The exact implementation mirrors PrepareFitData() for non-μSR, but the separation allows future customization for viewing.

Returns
True on success, false if data loading fails
See also
PrepareFitData() for fitting mode processing

Prepare data for viewing.

return:

  • true if everthing went smooth
  • false, otherwise.

Definition at line 465 of file PRunNonMusr.cpp.

References PRunBase::fData, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, fNoOfFitBins, fPacking, fRawRunData, PRunBase::fRunInfo, fTheoAsData, PRunBase::fTheory, PMsrPlotStructure::fTmax, PMsrPlotStructure::fTmin, PMsrPlotStructure::fUseFitRanges, GetXIndex(), and GetYIndex().

Referenced by PrepareData().

◆ SetFitRangeBin()

virtual void PRunNonMusr::SetFitRangeBin ( const TString fitRange)
inlinevirtual

Sets fit range in bin units (NOT SUPPORTED for non-μSR).

This method is not meaningful for non-μSR data because:

  • Fit range is specified in x-axis units (not bins)
  • No "first good bin" or "last good bin" concept (no t0)
  • x-values can be non-uniform (arbitrary spacing)

This empty implementation exists to satisfy the PRunBase interface. Use SetFitRange(PDoublePairVector) in the base class instead.

Parameters
fitRangeFit range string (ignored)
See also
PRunBase::SetFitRange() for proper fit range specification

Definition at line 310 of file PRunNonMusr.h.

Member Data Documentation

◆ fEndTimeBin

Int_t PRunNonMusr::fEndTimeBin
private

Index of last data point in fit range (inclusive).

Points to the last x-y pair where x ≤ fFitEndTime. Used as loop end in CalcChiSquare() (inclusive: i <= fEndTimeBin).

Note
Unlike μSR fits, this is INCLUSIVE (≤), not exclusive (<)

Definition at line 476 of file PRunNonMusr.h.

Referenced by CalcChiSquare(), PrepareFitData(), and PRunNonMusr().

◆ fNoOfFitBins

UInt_t PRunNonMusr::fNoOfFitBins
private

Number of x-y points within fit range (fFitStartTime ≤ x ≤ fFitEndTime)

Definition at line 425 of file PRunNonMusr.h.

Referenced by GetNoOfFitBins(), PrepareFitData(), PrepareViewData(), and PRunNonMusr().

◆ fPacking

Int_t PRunNonMusr::fPacking
private

Data point averaging/grouping factor.

Number of consecutive raw data points to average together:

  • 1: No packing (use all points as-is)
  • > 1: Average groups of packing points

Packing reduces the number of data points, improving:

  • Signal-to-noise ratio (averaging reduces noise)
  • Fit speed (fewer points to evaluate)

But decreases:

  • Resolution (fewer x-values)

Source priority:

  1. RUN block "packing" entry
  2. GLOBAL block "packing" entry
  3. ERROR if neither specified

Definition at line 446 of file PRunNonMusr.h.

Referenced by PrepareData(), PrepareFitData(), PrepareViewData(), and PRunNonMusr().

◆ fRawRunData

PRawRunData* PRunNonMusr::fRawRunData
private

Pointer to raw run data handler (not owned).

Provides access to loaded x-y data from file. Retrieved via fRawData->GetRunData(*runName) during construction.

Contains the fDataNonMusr structure with:

  • GetData(): Vector of vectors for data columns (x, y, etc.)
  • GetErrData(): Vector of vectors for error columns
Warning
Not owned by this class - do not delete

Definition at line 423 of file PRunNonMusr.h.

Referenced by GetXIndex(), GetYIndex(), PrepareFitData(), PrepareViewData(), PRunNonMusr(), and PRunNonMusr().

◆ fStartTimeBin

Int_t PRunNonMusr::fStartTimeBin
private

Index of first data point in fit range.

Points to the first x-y pair where x ≥ fFitStartTime. Used as loop start in CalcChiSquare().

Definition at line 466 of file PRunNonMusr.h.

Referenced by CalcChiSquare(), PrepareFitData(), and PRunNonMusr().

◆ fTheoAsData

Bool_t PRunNonMusr::fTheoAsData
private

Theory calculation mode flag.

Controls theory grid resolution (currently not used for non-μSR):

  • true: Theory at data x-values only (efficient)
  • false: Theory on high-resolution grid (smooth plotting)

For non-μSR, theory is always evaluated at data x-values during CalcChiSquare(), so this flag has minimal effect.

Definition at line 458 of file PRunNonMusr.h.

Referenced by PrepareViewData(), and PRunNonMusr().


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