|
musrfit 1.10.0
|
Class for fitting single histogram data in a Rotating Reference Frame (RRF). More...
#include <PRunSingleHistoRRF.h>


Public Member Functions | |
| PRunSingleHistoRRF () | |
| Default constructor creating an empty, invalid RRF single histogram run object. | |
| PRunSingleHistoRRF (PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData) | |
| Main constructor initializing RRF single histogram run from MSR file and data. | |
| virtual | ~PRunSingleHistoRRF () |
| Virtual destructor releasing allocated resources. | |
| virtual Double_t | CalcChiSquare (const std::vector< Double_t > &par) |
| Calculates χ² between RRF-transformed data and theory. | |
| virtual Double_t | CalcChiSquareExpected (const std::vector< Double_t > &par) |
| Calculates expected χ² using theory variance instead of data variance. | |
| virtual Double_t | CalcMaxLikelihood (const std::vector< Double_t > &par) |
| Calculates maximum likelihood (not yet implemented for RRF). | |
| virtual void | CalcTheory () |
| Evaluates theory function at all data points for viewing/plotting. | |
| virtual UInt_t | GetNoOfFitBins () |
| Returns the number of bins included in the current fit range. | |
| virtual void | SetFitRangeBin (const TString fitRange) |
| Sets fit range using bin-offset syntax from COMMANDS block. | |
| virtual Int_t | GetStartTimeBin () |
| Returns the first bin index in the fit range. | |
| virtual Int_t | GetEndTimeBin () |
| Returns the last bin index in the fit range (exclusive). | |
| virtual void | CalcNoOfFitBins () |
| Calculates start/end bin indices from fit time range. | |
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 PRunData * | GetData () |
| 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 RRF single histogram analysis. | |
| virtual Bool_t | PrepareFitData (PRawRunData *runData, const UInt_t histoNo) |
| Performs full RRF transformation for fitting. | |
| virtual Bool_t | PrepareViewData (PRawRunData *runData, const UInt_t histoNo) |
| Prepares RRF 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 Member Functions | |
| virtual Bool_t | GetProperT0 (PRawRunData *runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo) |
| Determines and validates t0 values for all histograms. | |
| virtual Bool_t | GetProperDataRange () |
| Determines valid data range (first/last good bins). | |
| virtual void | GetProperFitRange (PMsrGlobalBlock *globalBlock) |
| Determines fit time range from MSR file settings. | |
| virtual Double_t | GetMainFrequency (PDoubleVector &data) |
| Finds the dominant precession frequency in raw data. | |
| virtual Double_t | EstimateN0 (Double_t &errN0, Double_t freqMax) |
| Estimates initial normalization N₀ from lifetime-corrected data. | |
| virtual Bool_t | EstimateBkg (UInt_t histoNo) |
| Estimates background from pre-t0 bins. | |
Private Attributes | |
| Double_t | fN0EstimateEndTime |
| End time (μs) for N₀ estimation window. Rounded to integer number of oscillation cycles based on main frequency. | |
| UInt_t | fNoOfFitBins |
| Number of RRF-packed bins within fit range [fStartTimeBin, fEndTimeBin) | |
| Double_t | fBackground |
| Estimated or fixed background level in counts/bin (before packing) | |
| Double_t | fBkgErr |
| Statistical error on background estimate (std dev of background region) | |
| Int_t | fRRFPacking |
| RRF packing factor from GLOBAL block (number of raw bins averaged together) | |
| Bool_t | fTheoAsData |
| Theory resolution mode: true = at data points only, false = 8× finer grid for smooth Fourier transforms. | |
| Int_t | fGoodBins [2] |
| Good bin range: [0] = first good bin (fgb), [1] = last good bin (lgb). Used for COMMANDS block fit range specification. | |
| Int_t | fStartTimeBin |
| First bin index in fit range (inclusive, 0-based in RRF-packed data) | |
| Int_t | fEndTimeBin |
| Last bin index in fit range (exclusive: loop as i < fEndTimeBin) | |
| PDoubleVector | fForward |
| Forward detector histogram data (progressively transformed during preparation) | |
| PDoubleVector | fM |
| Lifetime-corrected histogram: M(t) = [N(t) - B] × exp(+t/τ_μ). Used for N₀ estimation. | |
| PDoubleVector | fMerr |
| Error on M(t): σ_M = exp(+t/τ_μ) × √(N(t) + σ_B²). Includes background error. | |
| PDoubleVector | fW |
| Weights for N₀ estimation: W(t) = 1/σ_M². Used in weighted average. | |
| PDoubleVector | fAerr |
| Asymmetry errors before RRF packing. Used for packed error calculation. | |
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) | |
| PMsrHandler * | fMsrInfo |
| Pointer to MSR file handler (owned externally, not deleted here) | |
| PMsrRunBlock * | fRunInfo |
| Pointer to this run's RUN block settings within fMsrInfo. | |
| PRunDataHandler * | fRawData |
| 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< PDoubleVector > | fAddT0s |
| 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< PTheory > | fTheory |
| Theory function evaluator (smart pointer, automatically deleted) | |
| PDoubleVector | fKaiserFilter |
| Kaiser window FIR filter coefficients for smoothing RRF theory curves. | |
Class for fitting single histogram data in a Rotating Reference Frame (RRF).
PRunSingleHistoRRF implements single histogram analysis with Rotating Reference Frame transformation. This technique is essential for high transverse field (TF) μSR measurements where the precession frequency is too high to resolve directly.
The Problem with High-Field μSR:
The RRF Solution:
Data processing steps:
The factor of 2 in step 5 compensates for the loss of the counter-rotating component when the high-frequency part is suppressed by packing.
Theory function in RRF: The polarization function P(t) transforms as:
![\[P_{\rm RRF}(t) = 2 \cdot P(t) \cdot \cos(\omega_{\rm RRF} t + \phi_{\rm RRF})
\]](form_35.png)
For a simple oscillation P(t) = A·cos(ωt + φ)·exp(-λt), this becomes:
![\[P_{\rm RRF}(t) = A \cdot [\cos((\omega - \omega_{\rm RRF})t + \phi - \phi_{\rm RRF}) + \text{high freq.}] \cdot e^{-\lambda t}
\]](form_36.png)
After RRF packing, only the low-frequency component Δω = ω - ω_RRF remains.
RRF analysis REQUIRES the following entries in the GLOBAL block:
RRF asymmetry error (unpacked):
![\[\sigma_{A}(t) = \frac{e^{t/\tau_\mu}}{N_0} \sqrt{N(t) + \left(\frac{N(t)-B}{N_0}\right)^2 \sigma_{N_0}^2}
\]](form_37.png)
After RRF packing (n bins):
![\[\sigma_{A_{\rm RRF}}^{\rm packed} = \frac{\sqrt{2}}{n} \sqrt{\sum_{i=1}^{n} \sigma_{A}^2(t_i)}
\]](form_38.png)
The √2 factor accounts for the doubling in the RRF transformation.
High-TF μSR experiments:
Definition at line 144 of file PRunSingleHistoRRF.h.
| PRunSingleHistoRRF::PRunSingleHistoRRF | ( | ) |
Default constructor creating an empty, invalid RRF single histogram run object.
Default constructor for RRF single histogram fitting class.
Initializes member variables to default/invalid states:
This constructor exists for container compatibility. The resulting object cannot be used until properly initialized.
Initializes all member variables to safe default values:
Definition at line 74 of file PRunSingleHistoRRF.cpp.
References fBackground, fBkgErr, fGoodBins, fN0EstimateEndTime, fNoOfFitBins, fRRFPacking, fTheoAsData, and PRunBase::PRunBase().
| PRunSingleHistoRRF::PRunSingleHistoRRF | ( | PMsrHandler * | msrInfo, |
| PRunDataHandler * | rawData, | ||
| UInt_t | runNo, | ||
| EPMusrHandleTag | tag, | ||
| Bool_t | theoAsData ) |
Main constructor initializing RRF single histogram run from MSR file and data.
Main constructor for RRF single histogram fitting and viewing.
Performs comprehensive validation and initialization:
| msrInfo | Pointer to MSR file handler (must remain valid) |
| rawData | Pointer to raw data handler for histogram loading |
| runNo | Run number (0-based index in MSR file RUN blocks) |
| tag | Operation mode: kFit (fitting), kView (display/plotting) |
| theoAsData | Theory resolution: true = at data points, false = 8× finer grid |
Constructs a fully initialized RRF single histogram run object by:
GLOBAL Block Requirements: The RRF fit type requires the following entries in the GLOBAL block:
rrf_freq: Rotation frequency with unit (e.g., "13.554 T", "183.7 MHz")rrf_packing: Number of bins to average (integer)rrf_phase: (optional) Initial phase in degreesError Handling: If any validation fails, the constructor:
| msrInfo | Pointer to MSR file handler (NOT owned, must outlive this object) |
| rawData | Pointer to raw run data handler (NOT owned, must outlive this object) |
| runNo | Zero-based index of the RUN block in the MSR file |
| tag | Operation mode: kFit (fitting) or kView (viewing/plotting) |
| theoAsData | If true, theory calculated only at data points (for viewing); if false, theory uses finer time grid (8× data resolution) |
Definition at line 133 of file PRunSingleHistoRRF.cpp.
References fGoodBins, fN0EstimateEndTime, fNoOfFitBins, fRRFPacking, fTheoAsData, PRunBase::fValid, PMsrHandler::GetMsrGlobal(), PMsrGlobalBlock::GetRRFPacking(), PMsrGlobalBlock::GetRRFUnit(), if(), PMsrGlobalBlock::IsPresent(), PrepareData(), and PRunBase::PRunBase().
|
virtual |
Virtual destructor releasing allocated resources.
Destructor for RRF single histogram fitting class.
Clears the forward histogram vector. Base class handles theory objects.
Cleans up dynamically allocated memory:
Base class destructor (PRunBase) handles cleanup of:
Definition at line 194 of file PRunSingleHistoRRF.cpp.
References fForward.
|
virtual |
Calculates χ² between RRF-transformed data and theory.
Calculates χ² between RRF-transformed data and theory (least-squares fit metric).
Computes chi-squared for RRF single histogram fitting:
![\[\chi^2 = \sum_{i=t_{\rm start}}^{t_{\rm end}} \frac{[A_{\rm RRF}^{\rm data}(t_i) - A_{\rm RRF}^{\rm theory}(t_i)]^2}{\sigma_i^2}
\]](form_39.png)
Algorithm:
OpenMP Parallelization:
| par | Parameter vector from MINUIT minimizer |
Computes the standard chi-square goodness-of-fit statistic for RRF asymmetry:
![\[\chi^2 = \sum_{i=t_{\rm start}}^{t_{\rm end}} \frac{[A_{\rm RRF}^{\rm data}(t_i) - A_{\rm RRF}^{\rm theory}(t_i)]^2}{\sigma_i^2}
\]](form_39.png)
Unlike standard single histogram fitting, no explicit N₀ or exponential decay factors appear since the RRF transformation already produces dimensionless asymmetry with properly propagated errors.
Algorithm:
OpenMP Parallelization: When compiled with OpenMP (HAVE_GOMP defined):
| par | Parameter vector from MINUIT minimizer, containing current estimates of all fit parameters |
Implements PRunBase.
Definition at line 240 of file PRunSingleHistoRRF.cpp.
References PRunBase::fData, fEndTimeBin, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, PRunBase::fRunInfo, fStartTimeBin, and PRunBase::fTheory.
|
virtual |
Calculates expected χ² using theory variance instead of data variance.
Computes expected chi-squared where the error estimate comes from the theory prediction rather than the data:
![\[\chi^2_{\rm exp} = \sum_{i} \frac{[A_{\rm RRF}^{\rm data}(t_i) - A_{\rm RRF}^{\rm theory}(t_i)]^2}{A_{\rm RRF}^{\rm theory}(t_i)}
\]](form_40.png)
This is useful for diagnostic purposes to check fit quality.
| par | Parameter vector from MINUIT |
Computes the expected chi-square where the error estimate in the denominator comes from the theory prediction rather than the data:
![\[\chi^2_{\rm exp} = \sum_{i=t_{\rm start}}^{t_{\rm end}} \frac{[A_{\rm RRF}^{\rm data}(t_i) - A_{\rm RRF}^{\rm theory}(t_i)]^2}{A_{\rm RRF}^{\rm theory}(t_i)}
\]](form_107.png)
This metric is useful for:
Algorithm: Same as CalcChiSquare() but uses theory value as variance estimate instead of measured error bars. OpenMP parallelization is applied when available.
| par | Parameter vector from MINUIT minimizer |
Implements PRunBase.
Definition at line 307 of file PRunSingleHistoRRF.cpp.
References PRunBase::fData, fEndTimeBin, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, PRunBase::fRunInfo, fStartTimeBin, and PRunBase::fTheory.
|
virtual |
Calculates maximum likelihood (not yet implemented for RRF).
Calculates maximum likelihood for RRF data (NOT YET IMPLEMENTED).
Maximum likelihood estimation for RRF data is more complex due to the transformation from Poisson-distributed counts to RRF asymmetry. Currently returns 0.0.
| par | Parameter vector from MINUIT |
Maximum likelihood estimation for RRF single histogram data is more complex than for raw histograms due to the non-linear transformation from Poisson-distributed counts to RRF asymmetry.
Theoretical Background: For raw histogram data, the likelihood is:
![\[\mathcal{L} = \prod_i \frac{\mu_i^{n_i} e^{-\mu_i}}{n_i!}
\]](form_108.png)
where 

For RRF-transformed data, the error propagation through the transformation must be properly accounted for in the likelihood function.
Current Implementation: Returns 0.0 (not implemented). Use χ² minimization (CalcChiSquare) instead.
| par | Parameter vector from MINUIT minimizer (unused) |
Implements PRunBase.
Definition at line 379 of file PRunSingleHistoRRF.cpp.
|
virtual |
Calculates start/end bin indices from fit time range.
Converts fit range times (μs) to RRF-packed bin indices:
Also updates fNoOfFitBins = fEndTimeBin - fStartTimeBin.
Converts the fit range from time (μs) to RRF-packed bin indices. This method is called whenever the fit range may have changed.
Conversion Formulas:
![\[i_{\rm start} = \lceil \frac{t_{\rm start} - t_{\rm data,0}}{\Delta t_{\rm data}} \rceil
\]](form_113.png)
![\[i_{\rm end} = \lfloor \frac{t_{\rm end} - t_{\rm data,0}}{\Delta t_{\rm data}} \rfloor + 1
\]](form_114.png)
where:


Bounds Checking:
Side Effects: Updates member variables:
Definition at line 631 of file PRunSingleHistoRRF.cpp.
References PRunBase::fData, fEndTimeBin, PRunBase::fFitEndTime, PRunBase::fFitStartTime, fNoOfFitBins, and fStartTimeBin.
Referenced by GetNoOfFitBins(), and PrepareFitData().
|
virtual |
Evaluates theory function at all data points for viewing/plotting.
Calculates RRF theory values using current fit parameters stored in the MSR parameter list. The theory function P(t) is evaluated at each data time point and results are stored in fData for display.
Calculates the theoretical RRF asymmetry using the current MSR parameter values and stores results in fData for display. This method is called after fitting to generate the theory curve overlay.
Algorithm:
Theory Function: The theory is evaluated directly in the RRF frame. The THEORY block should specify the low-frequency RRF signal (after transformation), not the laboratory-frame high-frequency precession.
Example THEORY block for RRF analysis:
where the frequency in TFieldCos is the difference frequency (ω - ω_RRF).
Implements PRunBase.
Definition at line 424 of file PRunSingleHistoRRF.cpp.
References PRunBase::fData, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, PRunBase::fRunInfo, and PRunBase::fTheory.
|
privatevirtual |
Estimates background from pre-t0 bins.
Estimates background level and error from pre-t0 histogram bins.
Calculates background level and error from specified background range:
| histoNo | Histogram index (for error messages) |
Calculates the background (random coincidences, accidentals) from a specified range of histogram bins, typically before t0. The background range is adjusted to span an integer number of accelerator RF cycles for proper averaging.
Accelerator RF Periods:
Algorithm:


Output Information: Prints diagnostic messages:
| histoNo | Forward histogram number (for error message context) |
Definition at line 1717 of file PRunSingleHistoRRF.cpp.
References ACCEL_PERIOD_PSI, ACCEL_PERIOD_RAL, ACCEL_PERIOD_TRIUMF, fBackground, fBkgErr, fForward, PRunBase::fRunInfo, and PRunBase::fTimeResolution.
Referenced by PrepareFitData().
|
privatevirtual |
Estimates initial normalization N₀ from lifetime-corrected data.
Estimates initial normalization N₀ from lifetime-corrected histogram data.
Calculates N₀ as weighted average of M(t) over initial time window:
![\[N_0 = \frac{\sum_{i=0}^{n} M(t_i)}{n}
\]](form_41.png)
The window length is chosen to include an integer number of complete oscillation cycles (based on freqMax) within fN0EstimateEndTime.
Error estimate:
![\[\sigma_{N_0} = \frac{\sqrt{\sum w_i^2 \sigma_{M_i}^2}}{\sum w_i}
\]](form_42.png)
| errN0 | [out] Estimated error on N₀ |
| freqMax | Main precession frequency (MHz) for window calculation |
Calculates N₀ by averaging the lifetime-corrected signal M(t) over an initial time window. The window is chosen to span an integer number of complete precession cycles to minimize bias from oscillations.
N₀ Estimation Formula:
![\[N_0 = \frac{1}{n} \sum_{i=0}^{n-1} M(t_i)
\]](form_125.png)
where M(t) = [N(t) - B] × exp(+t/τ_μ) is the lifetime-corrected histogram stored in fM vector.
Window Determination: The end bin is calculated to include an integer number of oscillation cycles:
![\[n_{\rm end} = {\rm round}\left( \left\lceil \frac{T \cdot f_{\rm max}}{2\pi} \right\rceil \cdot \frac{2\pi}{f_{\rm max} \cdot \Delta t} \right)
\]](form_126.png)
where:
Error Estimation:
![\[\sigma_{N_0} = \frac{\sqrt{\sum_{i=0}^{n-1} w_i^2 \sigma_{M_i}^2}}{\sum_{i=0}^{n-1} w_i}
\]](form_127.png)
where w_i = 1/σ_M_i² are the weights stored in fW vector.
Output Information: Prints diagnostic message: "N₀ = value (error)"
| errN0 | [out] Reference to store the estimated error on N₀ |
| freqMax | Main precession frequency (MHz) from GetMainFrequency() |
Definition at line 1644 of file PRunSingleHistoRRF.cpp.
References fM, fMerr, fN0EstimateEndTime, PRunBase::fTimeResolution, and fW.
Referenced by PrepareFitData().
|
inlinevirtual |
Returns the last bin index in the fit range (exclusive).
Definition at line 312 of file PRunSingleHistoRRF.h.
References fEndTimeBin.
|
privatevirtual |
Finds the dominant precession frequency in raw data.
Finds the dominant precession frequency in raw histogram data.
Performs Fourier transform on raw histogram data to identify the main muon precession frequency:
The frequency is used to:
| data | Raw histogram data vector |
Performs Fourier analysis on the raw histogram to identify the main muon spin precession frequency. This is essential for:
Algorithm:
Frequency Search Constraints:
Output Information: The method prints diagnostic information:
| data | Raw histogram data vector (counts per bin) |
Definition at line 1553 of file PRunSingleHistoRRF.cpp.
References F_APODIZATION_STRONG, fGoodBins, FOURIER_UNIT_FREQ, PRunBase::fT0s, and PRunBase::fTimeResolution.
Referenced by PrepareFitData().
|
virtual |
Returns the number of bins included in the current fit range.
Triggers CalcNoOfFitBins() to ensure bin count is current, then returns the cached value.
Triggers CalcNoOfFitBins() to ensure the bin count is current based on the latest fit range settings, then returns the cached value.
The number of fit bins is needed for:
Definition at line 473 of file PRunSingleHistoRRF.cpp.
References CalcNoOfFitBins(), and fNoOfFitBins.
|
privatevirtual |
Determines valid data range (first/last good bins).
Determines valid data range (first/last good bins) for analysis.
Establishes analysis boundaries in order of priority:
Validates that range is sensible (start < end, within histogram bounds).
Establishes the boundaries of usable histogram data through a priority cascade. The data range defines which bins contain valid signal (after t0, before noise/overflow).
Data Range Search Priority:
Validation:
Result: Sets fGoodBins[0] (first good bin) and fGoodBins[1] (last good bin). These are used for:
Definition at line 1361 of file PRunSingleHistoRRF.cpp.
References fForward, fGoodBins, PRunBase::fMsrInfo, PRunBase::fRunInfo, PRunBase::fT0s, and PRunBase::fTimeResolution.
Referenced by PrepareData().
|
privatevirtual |
Determines fit time range from MSR file settings.
Extracts fit range in order of priority:
Converts bin-based specifications to time using t0 and time resolution.
| globalBlock | GLOBAL block with default fit settings |
Extracts the fit range (time window for parameter extraction) through a priority cascade. Supports both time-based and bin-based specifications.
Fit Range Formats:
fit 0.1 8.0 (in microseconds relative to t0)fit fgb+100 lgb-500 (bins relative to good bins)Search Priority:
Bin-to-Time Conversion:
![\[t_{\rm start} = ({\rm fgb} + n_0 - t_0) \times \Delta t
\]](form_111.png)
![\[t_{\rm end} = ({\rm lgb} - n_1 - t_0) \times \Delta t
\]](form_112.png)
where Δt = fTimeResolution (raw, before RRF packing).
Result: Sets fFitStartTime and fFitEndTime in microseconds relative to t0. These define the range used in χ² calculation.
| globalBlock | Pointer to GLOBAL block for fallback fit range settings |
Definition at line 1480 of file PRunSingleHistoRRF.cpp.
References PRunBase::fFitEndTime, PRunBase::fFitStartTime, fGoodBins, PRunBase::fRunInfo, PRunBase::fT0s, PRunBase::fTimeResolution, PMsrGlobalBlock::GetFitRange(), PMsrGlobalBlock::GetFitRangeOffset(), PMsrGlobalBlock::IsFitRangeInBin(), PMUSR_UNDEFINED, and PMsrGlobalBlock::SetFitRange().
Referenced by PrepareData().
|
privatevirtual |
Determines and validates t0 values for all histograms.
Determines and validates t0 values for all histograms in the run.
Searches for t0 in order of priority:
Also handles addt0 for addrun histograms.
| runData | Raw run data for histogram access |
| globalBlock | GLOBAL block with default t0 values |
| histoNo | Vector of histogram indices to process |
Searches for time-zero (t0) values through a priority cascade and performs validation. t0 marks the muon arrival time and is critical for proper timing alignment.
t0 Search Priority:
Algorithm:
Addrun Handling: When multiple runs are co-added (addrun), each additional run needs its own t0 value for proper time alignment:
Validation:
| runData | Pointer to raw run data for histogram access and data file t0 |
| globalBlock | Pointer to GLOBAL block for fallback t0 values |
| histoNo | Vector of histogram indices (0-based) for forward grouping |
Definition at line 1204 of file PRunSingleHistoRRF.cpp.
References PRunBase::fAddT0s, PRunBase::fRawData, PRunBase::fRunInfo, PRunBase::fT0s, PRawRunData::GetDataBin(), PMsrGlobalBlock::GetT0Bin(), PRawRunData::GetT0Bin(), PRawRunData::GetT0BinEstimated(), and PMsrGlobalBlock::GetT0BinSize().
Referenced by PrepareData().
|
inlinevirtual |
Returns the first bin index in the fit range.
Definition at line 306 of file PRunSingleHistoRRF.h.
References fStartTimeBin.
|
protectedvirtual |
Main data preparation orchestrator for RRF single histogram analysis.
Coordinates loading and preprocessing of histogram data:
Coordinates the loading and preprocessing of histogram data before RRF transformation. This method handles all operations common to both fitting and viewing modes.
Processing Steps:
Run Addition (addrun): When multiple runs are specified in the RUN block, histograms are co-added with t0 alignment:
Detector Grouping: When multiple forward histograms are specified, they are summed with t0 alignment to form a single combined histogram.
Implements PRunBase.
Definition at line 696 of file PRunSingleHistoRRF.cpp.
References PRunBase::DeadTimeCorrection(), PRunBase::fAddT0s, fForward, PRunBase::fHandleTag, PRunBase::fMetaData, PRunBase::fMsrInfo, PRunBase::fRawData, PRunBase::fRunInfo, PRunBase::fT0s, PRunBase::fTimeResolution, PRunBase::fValid, PRawRunData::GetDataBin(), PRawRunData::GetEnergy(), PRawRunData::GetField(), PRawRunData::GetNoOfTemperatures(), GetProperDataRange(), GetProperFitRange(), GetProperT0(), PRawRunData::GetTemperature(), PRawRunData::GetTimeResolution(), PRawRunData::IsPresent(), kFit, kView, PrepareFitData(), and PrepareViewData().
Referenced by PRunSingleHistoRRF().
|
protectedvirtual |
Performs full RRF transformation for fitting.
Performs full RRF transformation on histogram data for fitting.
Transforms raw histogram to RRF asymmetry through these steps:
| runData | Raw run data handler |
| histoNo | Forward histogram number (0-based) |
Takes the pre-processed histogram (grouping and addrun already applied) and transforms it into RRF asymmetry suitable for fitting. This is the core method implementing the RRF analysis technique.
Processing Steps:
1. Frequency Analysis:
2. Background Handling:
3. Lifetime Correction:
![\[M(t) = [N(t) - B] \cdot e^{+t/\tau_\mu}
\]](form_117.png)


4. N₀ Estimation:
5. Asymmetry Extraction:
![\[A(t) = \frac{M(t)}{N_0} - 1
\]](form_120.png)
Error propagation:
![\[\sigma_A(t) = \frac{e^{+t/\tau_\mu}}{N_0} \sqrt{N(t) + \left(\frac{N(t)-B}{N_0}\right)^2 \sigma_{N_0}^2}
\]](form_121.png)
6. RRF Rotation:
![\[A_{\rm RRF}(t) = 2 \cdot A(t) \cdot \cos(\omega_{\rm RRF} t + \phi_{\rm RRF})
\]](form_122.png)
7. RRF Packing:


8. Time Grid Setup:
| runData | Raw run data handler (for background estimation) |
| histoNo | Forward histogram number (0-based, for background error messages) |
Definition at line 905 of file PRunSingleHistoRRF.cpp.
References CalcNoOfFitBins(), EstimateBkg(), EstimateN0(), fAerr, fBackground, fBkgErr, PRunBase::fData, fForward, fGoodBins, fM, fMerr, PRunBase::fMsrInfo, fRRFPacking, PRunBase::fRunInfo, PRunBase::fT0s, PRunBase::fTimeResolution, fW, GetMainFrequency(), PMsrGlobalBlock::GetRRFFreq(), PMsrGlobalBlock::GetRRFPhase(), PMUON_LIFETIME, and PMUSR_UNDEFINED.
Referenced by PrepareData(), and PrepareViewData().
|
protectedvirtual |
Prepares RRF data for viewing/plotting.
Prepares RRF-transformed data for viewing/plotting.
Similar to PrepareFitData() but additionally:
| runData | Raw run data handler |
| histoNo | Forward histogram number |
Takes the pre-processed histogram and prepares both data and theory curves for display. This method is used when the operation mode is kView rather than kFit.
Processing Steps:
1. Data Preparation:
2. View Packing Check:
3. Theory Grid Setup: Determines theory evaluation resolution:
Time grid:
4. Theory Evaluation:
Theory Function: The theory is evaluated directly in the RRF frame. The THEORY block should specify the low-frequency signal after RRF transformation, not the laboratory-frame high-frequency precession.
| runData | Raw run data handler (passed to PrepareFitData) |
| histoNo | Forward histogram number (passed to PrepareFitData) |
Definition at line 1091 of file PRunSingleHistoRRF.cpp.
References PRunBase::fData, fForward, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, fRRFPacking, PRunBase::fRunInfo, fTheoAsData, PRunBase::fTheory, and PrepareFitData().
Referenced by PrepareData().
|
virtual |
Sets fit range using bin-offset syntax from COMMANDS block.
Parses fit range specification in the format:
where fgb = first good bin, lgb = last good bin, and nXY are offsets.
Converts bin specification to time using:
| fitRange | String containing FIT_RANGE specification |
Allows dynamic modification of the fit range during fitting, as specified in the COMMANDS block. This is used for systematic studies where the fit range needs to be varied.
Syntax:
where:
fgb = first good bin (symbolic, replaced by actual value)lgb = last good bin (symbolic, replaced by actual value)+n0 = positive offset added to fgb-n1 = positive offset subtracted from lgbConversion to Time:
![\[t_{\rm start} = ({\rm fgb} + n_0 - t_0) \times \Delta t
\]](form_111.png)
![\[t_{\rm end} = ({\rm lgb} - n_1 - t_0) \times \Delta t
\]](form_112.png)
where Δt is the raw time resolution (before RRF packing).
Multiple Run Handling:
Example:
| fitRange | String containing FIT_RANGE specification from COMMANDS block |
Definition at line 530 of file PRunSingleHistoRRF.cpp.
References PRunBase::fFitEndTime, PRunBase::fFitStartTime, fGoodBins, PRunBase::fRunNo, PRunBase::fT0s, and PRunBase::fTimeResolution.
|
private |
Asymmetry errors before RRF packing. Used for packed error calculation.
Definition at line 431 of file PRunSingleHistoRRF.h.
Referenced by PrepareFitData().
|
private |
Estimated or fixed background level in counts/bin (before packing)
Definition at line 417 of file PRunSingleHistoRRF.h.
Referenced by EstimateBkg(), PrepareFitData(), and PRunSingleHistoRRF().
|
private |
Statistical error on background estimate (std dev of background region)
Definition at line 418 of file PRunSingleHistoRRF.h.
Referenced by EstimateBkg(), PrepareFitData(), and PRunSingleHistoRRF().
|
private |
Last bin index in fit range (exclusive: loop as i < fEndTimeBin)
Definition at line 425 of file PRunSingleHistoRRF.h.
Referenced by CalcChiSquare(), CalcChiSquareExpected(), CalcNoOfFitBins(), and GetEndTimeBin().
|
private |
Forward detector histogram data (progressively transformed during preparation)
Definition at line 427 of file PRunSingleHistoRRF.h.
Referenced by EstimateBkg(), GetProperDataRange(), PrepareData(), PrepareFitData(), PrepareViewData(), and ~PRunSingleHistoRRF().
|
private |
Good bin range: [0] = first good bin (fgb), [1] = last good bin (lgb). Used for COMMANDS block fit range specification.
Definition at line 422 of file PRunSingleHistoRRF.h.
Referenced by GetMainFrequency(), GetProperDataRange(), GetProperFitRange(), PrepareFitData(), PRunSingleHistoRRF(), PRunSingleHistoRRF(), and SetFitRangeBin().
|
private |
Lifetime-corrected histogram: M(t) = [N(t) - B] × exp(+t/τ_μ). Used for N₀ estimation.
Definition at line 428 of file PRunSingleHistoRRF.h.
Referenced by EstimateN0(), and PrepareFitData().
|
private |
Error on M(t): σ_M = exp(+t/τ_μ) × √(N(t) + σ_B²). Includes background error.
Definition at line 429 of file PRunSingleHistoRRF.h.
Referenced by EstimateN0(), and PrepareFitData().
|
private |
End time (μs) for N₀ estimation window. Rounded to integer number of oscillation cycles based on main frequency.
Definition at line 414 of file PRunSingleHistoRRF.h.
Referenced by EstimateN0(), PRunSingleHistoRRF(), and PRunSingleHistoRRF().
|
private |
Number of RRF-packed bins within fit range [fStartTimeBin, fEndTimeBin)
Definition at line 416 of file PRunSingleHistoRRF.h.
Referenced by CalcNoOfFitBins(), GetNoOfFitBins(), PRunSingleHistoRRF(), and PRunSingleHistoRRF().
|
private |
RRF packing factor from GLOBAL block (number of raw bins averaged together)
Definition at line 419 of file PRunSingleHistoRRF.h.
Referenced by PrepareFitData(), PrepareViewData(), PRunSingleHistoRRF(), and PRunSingleHistoRRF().
|
private |
First bin index in fit range (inclusive, 0-based in RRF-packed data)
Definition at line 424 of file PRunSingleHistoRRF.h.
Referenced by CalcChiSquare(), CalcChiSquareExpected(), CalcNoOfFitBins(), and GetStartTimeBin().
|
private |
Theory resolution mode: true = at data points only, false = 8× finer grid for smooth Fourier transforms.
Definition at line 420 of file PRunSingleHistoRRF.h.
Referenced by PrepareViewData(), PRunSingleHistoRRF(), and PRunSingleHistoRRF().
|
private |
Weights for N₀ estimation: W(t) = 1/σ_M². Used in weighted average.
Definition at line 430 of file PRunSingleHistoRRF.h.
Referenced by EstimateN0(), and PrepareFitData().