musrfit 1.10.0
PRunAsymmetryRRF Class Reference

Class for handling μSR asymmetry fits in the Rotating Reference Frame (RRF). More...

#include <PRunAsymmetryRRF.h>

Inheritance diagram for PRunAsymmetryRRF:
Collaboration diagram for PRunAsymmetryRRF:

Public Member Functions

 PRunAsymmetryRRF ()
 Default constructor.
 
 PRunAsymmetryRRF (PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData)
 Main constructor for RRF asymmetry fitting.
 
virtual ~PRunAsymmetryRRF ()
 Destructor.
 
virtual Double_t CalcChiSquare (const std::vector< Double_t > &par)
 Calculates chi-square for the RRF asymmetry fit.
 
virtual Double_t CalcChiSquareExpected (const std::vector< Double_t > &par)
 Calculates expected chi-square (for statistical analysis).
 
virtual Double_t CalcMaxLikelihood (const std::vector< Double_t > &par)
 Calculates maximum likelihood estimator.
 
virtual void CalcTheory ()
 Calculates theoretical RRF asymmetry function.
 
virtual UInt_t GetNoOfFitBins ()
 Returns the number of bins used in the fit.
 
virtual void SetFitRangeBin (const TString fitRange)
 Sets the fit range in bins (can be changed dynamically via COMMAND block).
 
virtual Int_t GetStartTimeBin ()
 Returns the first bin used in the fit.
 
virtual Int_t GetEndTimeBin ()
 Returns the last bin used in the fit.
 
virtual void CalcNoOfFitBins ()
 Calculates the number of bins to be fitted.
 
- 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 ()
 Prepares all data for RRF fitting or viewing.
 
virtual Bool_t PrepareFitData ()
 Prepares RRF data specifically for fitting.
 
virtual Bool_t PrepareViewData (PRawRunData *runData, UInt_t histoNo[2])
 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

Bool_t SubtractFixBkg ()
 Subtracts fixed background from histograms.
 
Bool_t SubtractEstimatedBkg ()
 Estimates and subtracts background from histograms.
 
virtual Bool_t GetProperT0 (PRawRunData *runData, PMsrGlobalBlock *globalBlock, PUIntVector &forwardHisto, PUIntVector &backwardHistoNo)
 Retrieves proper t0 values for all histograms.
 
virtual Bool_t GetProperDataRange (PRawRunData *runData, UInt_t histoNo[2])
 Retrieves proper data range for histograms.
 
virtual void GetProperFitRange (PMsrGlobalBlock *globalBlock)
 Determines the proper fit range from global block.
 

Private Attributes

UInt_t fAlphaBetaTag
 Tag indicating α/β configuration: 1=both unity, 2=α free/β unity, 3=α unity/β free, 4=both free.
 
UInt_t fNoOfFitBins
 Number of bins included in the fit after RRF packing.
 
Int_t fRRFPacking
 RRF packing factor from GLOBAL block (required for RRF analysis)
 
Bool_t fTheoAsData
 If true, theory calculated only at data points; if false, extra points for nicer Fourier transforms.
 
PDoubleVector fForward
 Forward detector histogram data.
 
PDoubleVector fForwardErr
 Forward detector histogram errors.
 
PDoubleVector fBackward
 Backward detector histogram data.
 
PDoubleVector fBackwardErr
 Backward detector histogram errors.
 
Int_t fGoodBins [4]
 Good bin boundaries: [0]=forward first, [1]=forward last, [2]=backward first, [3]=backward last.
 
Int_t fStartTimeBin
 First bin index for fitting (after RRF transformation)
 
Int_t fEndTimeBin
 Last bin index for fitting (after RRF transformation)
 

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 handling μSR asymmetry fits in the Rotating Reference Frame (RRF).

PRunAsymmetryRRF extends PRunBase to handle asymmetry fitting where data is transformed into a rotating reference frame. This technique is particularly useful for analyzing high-frequency oscillations in μSR spectra by mixing the signal with a reference frequency.

The RRF transformation:

\[ A_{\rm RRF}(t) = A(t) \cdot 2\cos(\omega_{\rm RRF} t + \phi_{\rm RRF}) \]

where:

  • $ A(t) $ is the standard asymmetry: $ A(t) = \frac{F(t) - \alpha B(t)}{F(t) + \alpha B(t)} $
  • $ \omega_{\rm RRF} $ is the RRF frequency (specified in PLOT block)
  • $ \phi_{\rm RRF} $ is the RRF phase (specified in PLOT block)

Key features:

  • Transforms high-frequency oscillations to lower frequencies
  • Requires special RRF packing parameter from GLOBAL block
  • Supports α/β correction parameters (same as PRunAsymmetry)
  • Applies Kaiser FIR filtering to theory curves for smooth visualization

The RRF technique is essential for:

  • High transverse field (TF) measurements
  • Analyzing fast precession frequencies
  • Improving signal-to-noise in specific frequency ranges
See also
PRunAsymmetry for standard (non-RRF) asymmetry fitting
PRunBase for the base class providing common functionality

Definition at line 65 of file PRunAsymmetryRRF.h.

Constructor & Destructor Documentation

◆ PRunAsymmetryRRF() [1/2]

PRunAsymmetryRRF::PRunAsymmetryRRF ( )

Default constructor.

Default constructor that initializes all member variables.

Sets all counters and indices to default/invalid values. This constructor creates an invalid instance that requires proper initialization via the main constructor.

Definition at line 61 of file PRunAsymmetryRRF.cpp.

References fGoodBins, fNoOfFitBins, fRRFPacking, fTheoAsData, and PRunBase::PRunBase().

◆ PRunAsymmetryRRF() [2/2]

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

Main constructor for RRF asymmetry fitting.

Main constructor that initializes RRF asymmetry fitting.

Parameters
msrInfoPointer to MSR file handler
rawDataPointer to raw run data handler
runNoRun number within the MSR file
tagOperation mode (kFit for fitting, kView for viewing)
theoAsDataIf true, calculate theory only at data points; if false, calculate additional points for Fourier

Performs comprehensive initialization for rotating reference frame analysis:

  1. Validates RRF packing parameter from GLOBAL block (required for RRF)
  2. Validates α parameter (required for asymmetry)
  3. Validates β parameter (optional, defaults to 1)
  4. Determines α/β configuration tag (1-4)
  5. Calls PrepareData() to load and process histogram data with RRF transformation

The α/β tag determines the asymmetry calculation method:

  • Tag 1: α=1, β=1 (no corrections)
  • Tag 2: α≠1, β=1 (forward/backward correction)
  • Tag 3: α=1, β≠1 (alternative correction)
  • Tag 4: α≠1, β≠1 (both corrections)

RRF packing must be specified in the GLOBAL block (e.g., "rrf_packing 50"). This parameter controls the rebinning after RRF transformation and is essential for proper signal extraction in the rotating frame.

Parameters
msrInfoPointer to MSR file handler
rawDataPointer to raw run data handler
runNoRun number within the MSR file
tagOperation mode (kFit or kView)
theoAsDataIf true, calculate theory only at data points

Definition at line 102 of file PRunAsymmetryRRF.cpp.

References fGoodBins, PRunBase::fMsrInfo, fRRFPacking, PRunBase::fRunInfo, fTheoAsData, PRunBase::fValid, PMsrHandler::GetMsrParamList(), if(), MSR_PARAM_FUN_OFFSET, and PRunBase::PRunBase().

◆ ~PRunAsymmetryRRF()

PRunAsymmetryRRF::~PRunAsymmetryRRF ( )
virtual

Destructor.

Destructor that cleans up histogram data.

Clears all four histogram vectors (forward/backward × data/errors) to free memory.

Definition at line 204 of file PRunAsymmetryRRF.cpp.

References fBackward, fBackwardErr, fForward, and fForwardErr.

Member Function Documentation

◆ CalcChiSquare()

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

Calculates chi-square for the RRF asymmetry fit.

Calculates chi-square for RRF asymmetry fit.

Parameters
parParameter vector from MINUIT
Returns
Chi-square value

Computes χ² by comparing the measured RRF-transformed asymmetry with theory: χ² = Σ[(A_RRF,data - A_RRF,theory)²/σ²]

The RRF asymmetry has already been calculated in PrepareData() by applying the transformation: A_RRF(t) = A(t) · 2cos(ω_RRF·t + φ_RRF)

The theory function is similarly transformed and includes α/β corrections:

  • Tag 1 (α=β=1): A = f(t)
  • Tag 2 (α≠1, β=1): A = [f(t)(α+1) - (α-1)] / [(α+1) - f(t)(α-1)]
  • Tag 3 (α=1, β≠1): Uses β correction
  • Tag 4 (α≠1, β≠1): Uses both α and β corrections

Supports OpenMP parallelization for faster calculation.

Parameters
parParameter vector from MINUIT minimizer
Returns
Chi-square value

Implements PRunBase.

Definition at line 235 of file PRunAsymmetryRRF.cpp.

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

◆ CalcChiSquareExpected()

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

Calculates expected chi-square (for statistical analysis).

Calculates expected chi-square value.

Parameters
parParameter vector from MINUIT
Returns
Expected chi-square value

This function is currently not implemented for RRF asymmetry fits because the expected chi-square calculation for RRF-transformed asymmetry data requires a complex statistical treatment. The RRF transformation introduces correlations between adjacent bins that complicate the expected value calculation.

Parameters
parParameter vector from MINUIT minimizer
Returns
Always returns 0.0 (placeholder value)
Todo
Implement proper expected chi-square calculation for RRF asymmetry fits

Implements PRunBase.

Definition at line 342 of file PRunAsymmetryRRF.cpp.

◆ CalcMaxLikelihood()

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

Calculates maximum likelihood estimator.

Calculates maximum likelihood estimator for RRF asymmetry fit.

Parameters
parParameter vector from MINUIT
Returns
Maximum likelihood value

Maximum likelihood estimation provides an alternative to χ² minimization and can be more appropriate for low-count data. However, the proper likelihood function for RRF-transformed μSR asymmetry data is complex and not yet implemented.

Parameters
parParameter vector from MINUIT minimizer
Returns
Placeholder value of 1.0
Todo
Implement proper Poisson-based maximum likelihood for RRF asymmetry fits

Implements PRunBase.

Definition at line 362 of file PRunAsymmetryRRF.cpp.

◆ CalcNoOfFitBins()

void PRunAsymmetryRRF::CalcNoOfFitBins ( )
virtual

Calculates the number of bins to be fitted.

Calculates the number of bins included in the current RRF fit range.

Determines fNoOfFitBins based on the fit range and RRF-packed data availability.

Determines fStartTimeBin and fEndTimeBin from the fit time range (fFitStartTime, fFitEndTime) and RRF-transformed data time grid. Ensures that bin indices remain within valid bounds. The result is stored in fNoOfFitBins.

This calculation accounts for:

  • RRF-packed data time step and start time
  • Rounding effects (ceiling for start, floor for end)
  • Boundary conditions (clips to [0, RRF data size])

Definition at line 495 of file PRunAsymmetryRRF.cpp.

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

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

◆ CalcTheory()

void PRunAsymmetryRRF::CalcTheory ( )
virtual

Calculates theoretical RRF asymmetry function.

Calculates theoretical RRF asymmetry values for the current parameters.

Computes the theory values in the rotating reference frame based on current parameters and applies the RRF transformation.

Computes the expected RRF asymmetry A_RRF(t) for all data points based on the current parameter values and the user-defined theory function. The calculation depends on the α/β correction mode:

  • Tag 1 (α=1, β=1): A(t) = f(t)
  • Tag 2 (α≠1, β=1): A(t) = [f(t)(α+1) - (α-1)] / [(α+1) - f(t)(α-1)]
  • Tag 3 (α=1, β≠1): A(t) = f(t)(β+1) / [2 - f(t)(β-1)]
  • Tag 4 (α≠1, β≠1): A(t) = [f(t)(αβ+1) - (α-1)] / [(α+1) - f(t)(αβ-1)]

where f(t) is the raw theory function from the THEORY block.

Note: The RRF transformation is applied during data preparation (PrepareViewData), not here. This function calculates the standard asymmetry theory which is then transformed to the rotating frame during visualization.

The calculated values are stored in fData for plotting and comparison with measured RRF data.

Implements PRunBase.

Definition at line 534 of file PRunAsymmetryRRF.cpp.

References fAlphaBetaTag, PRunBase::fData, PRunBase::fFuncValues, PRunBase::fMetaData, PRunBase::fMsrInfo, PRunBase::fRunInfo, PRunBase::fTheory, and MSR_PARAM_FUN_OFFSET.

◆ GetEndTimeBin()

virtual Int_t PRunAsymmetryRRF::GetEndTimeBin ( )
inlinevirtual

Returns the last bin used in the fit.

Returns
End time bin index

Definition at line 135 of file PRunAsymmetryRRF.h.

References fEndTimeBin.

◆ GetNoOfFitBins()

UInt_t PRunAsymmetryRRF::GetNoOfFitBins ( )
virtual

Returns the number of bins used in the fit.

Returns the number of bins included in the RRF fit.

Returns
Number of fit bins

Calculates and returns the number of RRF-transformed data bins that fall within the current fit range. This value is used for determining degrees of freedom and is recalculated when the fit range changes (e.g., via COMMAND block).

Returns
Number of data bins included in the fit

Definition at line 381 of file PRunAsymmetryRRF.cpp.

References CalcNoOfFitBins(), and fNoOfFitBins.

◆ GetProperDataRange()

Bool_t PRunAsymmetryRRF::GetProperDataRange ( PRawRunData * runData,
UInt_t histoNo[2] )
privatevirtual

Retrieves proper data range for histograms.

Determines the "good bins" range for data analysis from RUN block, GLOBAL block, or estimates (in priority order).

Parameters
runDataPointer to raw run data
histoNoArray of histogram numbers [0]=forward, [1]=backward
Returns
True on success, false on error

Get the proper data range, i.e. first/last good bin (fgb/lgb).

  1. get fgb/lgb from the RUN block
  2. if fgb/lgb still undefined, try to get it from the GLOBAL block
  3. if fgb/lgb still undefined, try to estimate them.
Parameters
runDataraw run data needed to perform some crosschecks
histoNohistogram number (within a run). histoNo[0]: forward histogram number, histNo[1]: backward histogram number

return:

  • true if everthing went smooth
  • false, otherwise.

Definition at line 1625 of file PRunAsymmetryRRF.cpp.

References fBackward, fForward, fGoodBins, PRunBase::fMsrInfo, PRunBase::fRunInfo, PRunBase::fT0s, PRunBase::fTimeResolution, and PRawRunData::GetDataBin().

Referenced by PrepareData().

◆ GetProperFitRange()

void PRunAsymmetryRRF::GetProperFitRange ( PMsrGlobalBlock * globalBlock)
privatevirtual

Determines the proper fit range from global block.

Extracts fit range settings from the GLOBAL block if not specified in the RUN block. The fit range defines the time window used for χ² minimization.

Parameters
globalBlockPointer to global MSR block containing default fit range

Get the proper fit range. There are two possible fit range commands: fit <start> <end> given in (usec), or fit fgb+offset_0 lgb-offset_1 given in (bins), therefore it works the following way:

  1. get fit range assuming given in time from RUN block
  2. if fit range in RUN block is given in bins, replace start/end
  3. if fit range is NOT given yet, try fit range assuming given in time from GLOBAL block
  4. if fit range in GLOBAL block is given in bins, replace start/end
  5. if still no fit range is given, use fgb/lgb.
Parameters
globalBlockpointer to the GLOBAL block information form the msr-file.

Definition at line 1769 of file PRunAsymmetryRRF.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().

◆ GetProperT0()

Bool_t PRunAsymmetryRRF::GetProperT0 ( PRawRunData * runData,
PMsrGlobalBlock * globalBlock,
PUIntVector & forwardHistoNo,
PUIntVector & backwardHistoNo )
privatevirtual

Retrieves proper t0 values for all histograms.

Determines t0 (time zero) values for forward and backward histograms from RUN block, GLOBAL block, or data file (in priority order).

Parameters
runDataPointer to raw run data containing histogram information
globalBlockPointer to global MSR block with default t0 values
forwardHistoVector of forward histogram indices
backwardHistoNoVector of backward histogram indices
Returns
True on success, false if t0 values cannot be determined

Get the proper t0 for the single histogram run.

  1. the t0 vector size = number of detectors (grouping) for forward.
  2. initialize t0's with -1
  3. fill t0's from RUN block
  4. if t0's are missing (i.e. t0 == -1), try to fill from the GLOBAL block.
  5. if t0's are missing, try t0's from the data file
  6. if t0's are missing, try to estimate them
Parameters
runDatapointer to the current RUN block entry from the msr-file
globalBlockpointer to the GLOBLA block entry from the msr-file
forwardHistoNohistogram number vector of forward; forwardHistoNo = msr-file forward + redGreen_offset - 1
backwardHistoNohistogram number vector of backwardward; backwardHistoNo = msr-file backward + redGreen_offset - 1

return:

  • true if everthing went smooth
  • false, otherwise.

Definition at line 1450 of file PRunAsymmetryRRF.cpp.

References PRunBase::fAddT0s, PRunBase::fRawData, PRunBase::fRunInfo, PRunBase::fT0s, PRawRunData::GetDataBin(), PMsrGlobalBlock::GetT0Bin(), PRawRunData::GetT0Bin(), PRawRunData::GetT0BinEstimated(), and PMsrGlobalBlock::GetT0BinSize().

Referenced by PrepareData().

◆ GetStartTimeBin()

virtual Int_t PRunAsymmetryRRF::GetStartTimeBin ( )
inlinevirtual

Returns the first bin used in the fit.

Returns
Start time bin index

Definition at line 129 of file PRunAsymmetryRRF.h.

References fStartTimeBin.

◆ PrepareData()

Bool_t PRunAsymmetryRRF::PrepareData ( )
protectedvirtual

Prepares all data for RRF fitting or viewing.

Main data preparation routine for RRF asymmetry fitting and viewing.

Returns
True on success, false on error

Main data preparation routine that handles background subtraction, RRF packing, and asymmetry calculation from forward/backward histograms.

Performs comprehensive data preparation specifically for rotating reference frame analysis:

  • Loading forward/backward histograms from data files
  • Extracting metadata (field, energy, temperature)
  • Determining time resolution from data file
  • Validating and retrieving t0 values for all histograms
  • Adding multiple runs together (if addruns are specified)
  • Grouping multiple histograms (if grouping is specified)
  • Subtracting background (fixed or estimated)
  • Calculating standard asymmetry and error bars
  • NOTE: RRF transformation is NOT applied here (it's done in PrepareFitData/PrepareViewData)

The standard asymmetry is calculated as:

\[ A_i = \frac{f_i^{\rm c} - b_i^{\rm c}}{f_i^{\rm c} + b_i^{\rm c}} \]

Error propagation (assuming Poisson statistics):

\[ \Delta A_i = \pm\frac{2}{(f_i^{\rm c}+b_i^{\rm c})^2}\sqrt{
    (b_i^{\rm c})^2 (\Delta f_i^{\rm c})^2 +
    (f_i^{\rm c})^2 (\Delta b_i^{\rm c})^2} \]

where $ f_i^{\rm c} $ and $ b_i^{\rm c} $ are background-corrected forward and backward histograms, respectively.

The RRF transformation and packing are applied later in PrepareFitData() or PrepareViewData().

Returns
True if data preparation succeeds, false on any error

Implements PRunBase.

Definition at line 644 of file PRunAsymmetryRRF.cpp.

References PRunBase::DeadTimeCorrection(), PRunBase::fAddT0s, fBackward, 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, PMUSR_UNDEFINED, PrepareFitData(), PrepareViewData(), status, SubtractEstimatedBkg(), and SubtractFixBkg().

◆ PrepareFitData()

Bool_t PRunAsymmetryRRF::PrepareFitData ( )
protectedvirtual

Prepares RRF data specifically for fitting.

Processes pre-grouped data and calculates RRF asymmetry for fitting.

Returns
True on success, false on error

Processes data for fitting, including RRF transformation, packing, and asymmetry calculation with proper error propagation.

Takes forward/backward histograms (after grouping, addrun, and background correction) and performs the RRF transformation for fitting:

  1. Aligns forward/backward histograms (ensures 'first good bin - t0' is identical)
  2. Calculates standard asymmetry: $ A_i = (f_i^{\rm c}-b_i^{\rm c})/(f_i^{\rm c}+b_i^{\rm c}) $
  3. Applies RRF transformation: $ A_{\rm RRF}(t) = A(t) \cdot 2\cos(\omega_{\rm RRF} t + \phi_{\rm RRF}) $
  4. Applies RRF packing (rebinning) to reduce noise after mixing
  5. Propagates errors through both transformations

Error propagation for asymmetry:

\[ \delta A_i = \frac{2}{(f_i^{\rm c}+b_i^{\rm c})^2}\sqrt{(b_i^{\rm c})^2 (\delta f_i^{\rm c})^2 + (f_i^{\rm c})^2 (\delta b_i^{\rm c})^2} \]

RRF packing averages multiple bins to improve statistics after frequency mixing:

  • Packed value: sum of bins / packing factor
  • Error: $ \sigma_{\rm packed} = \sqrt{\sum \sigma_i^2}/N_{\rm pack} $
Returns
True on success, false if data preparation fails

Definition at line 1060 of file PRunAsymmetryRRF.cpp.

References CalcNoOfFitBins(), fBackward, fBackwardErr, PRunBase::fData, fForward, fForwardErr, fGoodBins, PRunBase::fMsrInfo, fRRFPacking, PRunBase::fT0s, PRunBase::fTimeResolution, PMsrGlobalBlock::GetRRFFreq(), and PMsrGlobalBlock::GetRRFPhase().

Referenced by PrepareData().

◆ PrepareViewData()

Bool_t PRunAsymmetryRRF::PrepareViewData ( PRawRunData * runData,
UInt_t histoNo[2] )
protectedvirtual

Prepares RRF data for viewing/plotting.

Prepares RRF asymmetry data for plotting and visualization.

Parameters
runDataPointer to raw run data
histoNoArray of histogram numbers [0]=forward, [1]=backward
Returns
True on success, false on error

Similar to PrepareFitData but includes theory calculation and Kaiser FIR filtering for smooth visualization of RRF curves.

Processes pre-grouped data for display in plots with RRF transformation and special handling for visualization. Similar to PrepareFitData but includes theory calculation with Kaiser FIR filtering for smooth RRF curves.

Processing steps:

  1. Validates and estimates data range if needed
  2. Aligns forward/backward histogram start bins relative to t0
  3. Ensures equal bin counts between forward/backward
  4. Calculates standard asymmetry: $ A_i = (\alpha f_i^{\rm c} - b_i^{\rm c})/(\alpha \beta f_i^{\rm c} + b_i^{\rm c}) $
  5. Applies RRF transformation: $ A_{\rm RRF}(t) = A(t) \cdot 2\cos(\omega_{\rm RRF} t + \phi_{\rm RRF}) $
  6. Applies RRF packing for visualization
  7. Propagates errors: $ \delta A_i = \frac{2}{(f_i^{\rm c}+b_i^{\rm c})^2}\sqrt{(b_i^{\rm c})^2 (\delta f_i^{\rm c})^2 + (f_i^{\rm c})^2 (\delta b_i^{\rm c})^2} $
  8. Calculates theory curve at high resolution
  9. Applies RRF transformation to theory
  10. Applies Kaiser FIR filter to smooth theory curve

The RRF frequency and phase are read from the PLOT block settings.

Parameters
runDataPointer to raw run data for validation and cross-checks
histoNoArray of histogram indices: [0]=forward, [1]=backward
Returns
True on success, false on error

Definition at line 1197 of file PRunAsymmetryRRF.cpp.

References CalcNoOfFitBins(), fAlphaBetaTag, fBackward, fBackwardErr, PRunBase::fData, fForward, fForwardErr, PRunBase::fFuncValues, fGoodBins, PRunBase::fMetaData, PRunBase::fMsrInfo, fRRFPacking, PRunBase::fRunInfo, PRunBase::fT0s, fTheoAsData, PRunBase::fTheory, PRunBase::fTimeResolution, PRawRunData::GetDataBin(), PMsrGlobalBlock::GetRRFFreq(), PMsrGlobalBlock::GetRRFPhase(), and MSR_PARAM_FUN_OFFSET.

Referenced by PrepareData().

◆ SetFitRangeBin()

void PRunAsymmetryRRF::SetFitRangeBin ( const TString fitRange)
virtual

Sets the fit range in bins (can be changed dynamically via COMMAND block).

Dynamically changes the fit range in bin units for RRF data.

Parameters
fitRangeFit range string specification

Allows modification of the fit range at runtime, typically called from the COMMAND block. Supports bin-based fit ranges with optional offsets for fine-tuning.

Syntax formats:

  • Single range: FIT_RANGE fgb[+n0] lgb[-n1]
    • Applied to all RUN blocks
  • Multiple ranges: FIT_RANGE fgb[+n00] lgb[-n01] fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]
    • One pair per RUN block (N must equal number of RUN blocks)

Parameters:

  • fgb: First good bin (start of fit range)
  • lgb: Last good bin (end of fit range)
  • +n: Positive offset to shift start forward
  • -n: Negative offset to shift end backward

Example: "FIT_RANGE 10+5 200-10" uses bins [15, 190] for fitting

Note: The bins refer to the RRF-packed data, not the original histograms.

Parameters
fitRangeString containing fit range specification

Definition at line 415 of file PRunAsymmetryRRF.cpp.

References PRunBase::fFitEndTime, PRunBase::fFitStartTime, fGoodBins, PRunBase::fRunNo, PRunBase::fT0s, PRunBase::fTimeResolution, and PStringUtils::Split().

◆ SubtractEstimatedBkg()

Bool_t PRunAsymmetryRRF::SubtractEstimatedBkg ( )
private

Estimates and subtracts background from histograms.

Calculates background from a specified bin range (typically before t0) and subtracts it. The background range is adjusted to align with accelerator beam cycles when applicable.

Returns
True on success, false if background range is out of bounds

Subtracts the background which is estimated from a given interval (typically before t0).

The background corrected histogramms are: $ f_i^{\rm c} = f_i - \mathrm{bkg} $, where $ f_i $ is the raw data histogram, $ \mathrm{bkg} $ the background estimate, and $ f_i^{\rm c} $ background corrected histogram. The error on $ f_i^{\rm c} $ is

\[ \Delta f_i^{\rm c} = \pm \sqrt{ (\Delta f_i)^2 + (\Delta \mathrm{bkg})^2 } =
   \pm \sqrt{f_i + (\Delta \mathrm{bkg})^2} \]

The background error $ \Delta \mathrm{bkg} $ is

\[ \Delta \mathrm{bkg} = \pm\frac{1}{N}\left[\sum_{i=0}^N (\Delta f_i)^2\right]^{1/2} =
\pm\frac{1}{N}\left[\sum_{i=0}^N f_i \right]^{1/2},\]

where $N$ is the number of bins over which the background is formed.

return:

  • true

Definition at line 936 of file PRunAsymmetryRRF.cpp.

References ACCEL_PERIOD_PSI, ACCEL_PERIOD_RAL, ACCEL_PERIOD_TRIUMF, fBackward, fBackwardErr, fForward, fForwardErr, PRunBase::fRunInfo, and PRunBase::fTimeResolution.

Referenced by PrepareData().

◆ SubtractFixBkg()

Bool_t PRunAsymmetryRRF::SubtractFixBkg ( )
private

Subtracts fixed background from histograms.

Subtracts user-specified fixed background values from forward and backward histograms. Background values are read from the MSR file (e.g., "backgr.fix 2 3" for forward/backward).

Error propagation:

\[ \Delta f_i^{\rm c} = \pm\sqrt{(\Delta f_i)^2 + (\Delta \mathrm{bkg})^2} = \pm\sqrt{f_i + \mathrm{bkg}} \]

Returns
True on success, false if background values are missing

Subtracts a fixed background from the raw data. The background is given in units of (1/bin); for the Asymmetry representation (1/ns) doesn't make too much sense. The error propagation is done the following way: it is assumed that the error of the background is Poisson like, i.e. $\Delta\mathrm{bkg} = \sqrt{\mathrm{bkg}}$.

Error propagation:

\[ \Delta f_i^{\rm c} = \pm\left[ (\Delta f_i)^2 + (\Delta \mathrm{bkg})^2 \right]^{1/2} =
     \pm\left[ f_i + \mathrm{bkg} \right]^{1/2}, \]

where $ f_i^{\rm c} $ is the background corrected histogram, $ f_i $ the raw histogram and $ \mathrm{bkg} $ the fix given background.

return:

  • true

Definition at line 892 of file PRunAsymmetryRRF.cpp.

References fBackward, fBackwardErr, fForward, fForwardErr, and PRunBase::fRunInfo.

Referenced by PrepareData().

Member Data Documentation

◆ fAlphaBetaTag

UInt_t PRunAsymmetryRRF::fAlphaBetaTag
private

Tag indicating α/β configuration: 1=both unity, 2=α free/β unity, 3=α unity/β free, 4=both free.

Definition at line 175 of file PRunAsymmetryRRF.h.

Referenced by CalcChiSquare(), CalcTheory(), and PrepareViewData().

◆ fBackward

PDoubleVector PRunAsymmetryRRF::fBackward
private

Backward detector histogram data.

Definition at line 182 of file PRunAsymmetryRRF.h.

Referenced by GetProperDataRange(), PrepareData(), PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryRRF().

◆ fBackwardErr

PDoubleVector PRunAsymmetryRRF::fBackwardErr
private

Backward detector histogram errors.

Definition at line 183 of file PRunAsymmetryRRF.h.

Referenced by PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryRRF().

◆ fEndTimeBin

Int_t PRunAsymmetryRRF::fEndTimeBin
private

Last bin index for fitting (after RRF transformation)

Definition at line 188 of file PRunAsymmetryRRF.h.

Referenced by CalcChiSquare(), CalcNoOfFitBins(), and GetEndTimeBin().

◆ fForward

PDoubleVector PRunAsymmetryRRF::fForward
private

Forward detector histogram data.

Definition at line 180 of file PRunAsymmetryRRF.h.

Referenced by GetProperDataRange(), PrepareData(), PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryRRF().

◆ fForwardErr

PDoubleVector PRunAsymmetryRRF::fForwardErr
private

Forward detector histogram errors.

Definition at line 181 of file PRunAsymmetryRRF.h.

Referenced by PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryRRF().

◆ fGoodBins

Int_t PRunAsymmetryRRF::fGoodBins[4]
private

Good bin boundaries: [0]=forward first, [1]=forward last, [2]=backward first, [3]=backward last.

Definition at line 185 of file PRunAsymmetryRRF.h.

Referenced by GetProperDataRange(), GetProperFitRange(), PrepareFitData(), PrepareViewData(), PRunAsymmetryRRF(), PRunAsymmetryRRF(), and SetFitRangeBin().

◆ fNoOfFitBins

UInt_t PRunAsymmetryRRF::fNoOfFitBins
private

Number of bins included in the fit after RRF packing.

Definition at line 176 of file PRunAsymmetryRRF.h.

Referenced by CalcNoOfFitBins(), GetNoOfFitBins(), and PRunAsymmetryRRF().

◆ fRRFPacking

Int_t PRunAsymmetryRRF::fRRFPacking
private

RRF packing factor from GLOBAL block (required for RRF analysis)

Definition at line 177 of file PRunAsymmetryRRF.h.

Referenced by PrepareFitData(), PrepareViewData(), PRunAsymmetryRRF(), and PRunAsymmetryRRF().

◆ fStartTimeBin

Int_t PRunAsymmetryRRF::fStartTimeBin
private

First bin index for fitting (after RRF transformation)

Definition at line 187 of file PRunAsymmetryRRF.h.

Referenced by CalcChiSquare(), CalcNoOfFitBins(), and GetStartTimeBin().

◆ fTheoAsData

Bool_t PRunAsymmetryRRF::fTheoAsData
private

If true, theory calculated only at data points; if false, extra points for nicer Fourier transforms.

Definition at line 178 of file PRunAsymmetryRRF.h.

Referenced by PrepareViewData(), PRunAsymmetryRRF(), and PRunAsymmetryRRF().


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