musrfit 1.10.0
PRunAsymmetryBNMR Class Reference

Class for handling β-NMR asymmetry fits. More...

#include <PRunAsymmetryBNMR.h>

Inheritance diagram for PRunAsymmetryBNMR:
Collaboration diagram for PRunAsymmetryBNMR:

Public Member Functions

 PRunAsymmetryBNMR ()
 Default constructor.
 
 PRunAsymmetryBNMR (PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData)
 Main constructor for β-NMR asymmetry fitting.
 
virtual ~PRunAsymmetryBNMR ()
 Destructor.
 
virtual Double_t CalcChiSquare (const std::vector< Double_t > &par)
 Calculates chi-square for the current parameter set.
 
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 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.
 
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 Int_t GetPacking ()
 Returns the packing factor.
 
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 fitting or viewing.
 
virtual Bool_t PrepareFitData ()
 Prepares data specifically for fitting.
 
virtual Bool_t PrepareViewData (PRawRunData *runData, UInt_t histoNo[2])
 Prepares 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.
 
virtual Double_t EstimateAlpha ()
 Estimates α parameter from data.
 

Private Attributes

UInt_t fAlphaBetaTag
 Tag indicating α/β configuration: 1=both unity, 2=α free/β unity, 3=α unity/β free, 4=both free, 5=α estimated/β unity, 6=α estimated/β free.
 
UInt_t fNoOfFitBins
 Number of bins included in the fit.
 
Int_t fPacking
 Bin packing factor from RUN or GLOBAL block.
 
Bool_t fTheoAsData
 If true, theory calculated only at data points; if false, extra points for nicer Fourier transforms.
 
PDoubleVector fForwardp
 Positive helicity forward histogram data.
 
PDoubleVector fForwardpErr
 Positive helicity forward histogram errors.
 
PDoubleVector fBackwardp
 Positive helicity backward histogram data.
 
PDoubleVector fBackwardpErr
 Positive helicity backward histogram errors.
 
PDoubleVector fForwardm
 Negative helicity forward histogram data.
 
PDoubleVector fForwardmErr
 Negative helicity forward histogram errors.
 
PDoubleVector fBackwardm
 Negative helicity backward histogram data.
 
PDoubleVector fBackwardmErr
 Negative helicity backward 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.
 
Int_t fEndTimeBin
 Last bin index for fitting.
 

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 β-NMR asymmetry fits.

PRunAsymmetryBNMR implements asymmetry fitting for β-NMR (Beta-detected Nuclear Magnetic Resonance) experiments. Unlike conventional μSR asymmetry, β-NMR requires handling of helicity-dependent data with separate positive and negative helicity histograms.

The asymmetry is calculated from four histograms:

  • Forward positive helicity (F+)
  • Backward positive helicity (B+)
  • Forward negative helicity (F-)
  • Backward negative helicity (B-)

The class supports various α and β parameter configurations:

  • Tag 1: α = β = 1 (both fixed to unity)
  • Tag 2: α ≠ 1, β = 1 (free α, fixed β)
  • Tag 3: α = 1, β ≠ 1 (fixed α, free β)
  • Tag 4: α ≠ 1, β ≠ 1 (both free)
  • Tag 5: α auto-estimated, β = 1
  • Tag 6: α auto-estimated, β ≠ 1
See also
PRunBase for the base class providing common functionality
PRunAsymmetry for the standard μSR asymmetry implementation

Definition at line 62 of file PRunAsymmetryBNMR.h.

Constructor & Destructor Documentation

◆ PRunAsymmetryBNMR() [1/2]

PRunAsymmetryBNMR::PRunAsymmetryBNMR ( )

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 PRunAsymmetryBNMR.cpp.

References fEndTimeBin, fGoodBins, fNoOfFitBins, fPacking, fStartTimeBin, fTheoAsData, and PRunBase::PRunBase().

◆ PRunAsymmetryBNMR() [2/2]

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

Main constructor for β-NMR asymmetry fitting.

Main constructor that initializes β-NMR 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:

  1. Validates packing parameter from RUN or GLOBAL block
  2. Determines α/β parameter configuration (tags 1-6)
  3. Validates α and β parameter numbers
  4. Sets fAlphaBetaTag based on whether α/β are fixed to 1, free, or auto-estimated
  5. Calls PrepareData() to load and process histogram data

The α/β tag determines the asymmetry calculation method:

  • Tag 1: Both α=1 and β=1 (simplest case)
  • Tag 2: α free, β=1 (one asymmetry parameter)
  • Tag 3: α=1, β free (alternative single parameter)
  • Tag 4: Both α and β free (most general)
  • Tag 5: α auto-estimated, β=1 (automatic calibration)
  • Tag 6: α auto-estimated, β free
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 103 of file PRunAsymmetryBNMR.cpp.

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

◆ ~PRunAsymmetryBNMR()

PRunAsymmetryBNMR::~PRunAsymmetryBNMR ( )
virtual

Destructor.

Destructor that cleans up helicity histogram data.

Clears all eight histogram vectors (forward/backward × positive/negative helicity × data/errors) to free memory.

Definition at line 213 of file PRunAsymmetryBNMR.cpp.

References fBackwardm, fBackwardmErr, fBackwardp, fBackwardpErr, fForwardm, fForwardmErr, fForwardp, and fForwardpErr.

Member Function Documentation

◆ CalcChiSquare()

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

Calculates chi-square for the current parameter set.

Calculates chi-square for β-NMR asymmetry fit.

Parameters
parParameter vector from MINUIT
Returns
Chi-square value

Computes χ² by comparing the asymmetry function with the theory: χ² = Σ[(A_data - A_theory)²/σ²]

The asymmetry depends on fAlphaBetaTag:

  • Tag 1 (α=β=1): A = (F+ - B+) / (F+ + B+)
  • Tag 2-4: Various combinations with α and/or β corrections
  • Tag 5-6: Auto-estimated α

Supports OpenMP parallelization for faster calculation.

Parameters
parParameter vector from MINUIT minimizer
Returns
Chi-square value

Implements PRunBase.

Definition at line 245 of file PRunAsymmetryBNMR.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 PRunAsymmetryBNMR::CalcChiSquareExpected ( const std::vector< Double_t > & par)
virtual

Calculates expected chi-square (for statistical analysis).

Calculates expected chi-square (not yet implemented).

Parameters
parParameter vector from MINUIT
Returns
Expected chi-square value

This method is intended for statistical analysis of fit quality, but implementation is pending due to complexity of β-NMR asymmetry calculation.

Parameters
parParameter vector from MINUIT (unused)
Returns
Always returns 0.0 (placeholder)

Implements PRunBase.

Definition at line 364 of file PRunAsymmetryBNMR.cpp.

◆ CalcMaxLikelihood()

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

Calculates maximum likelihood estimator.

Calculates maximum likelihood estimator (not yet implemented).

Parameters
parParameter vector from MINUIT
Returns
Maximum likelihood value

Maximum likelihood fitting for β-NMR asymmetry is not yet implemented. Prints warning message when called.

Parameters
parParameter vector from MINUIT (unused)
Returns
Always returns 1.0 (placeholder)

Implements PRunBase.

Definition at line 381 of file PRunAsymmetryBNMR.cpp.

◆ CalcNoOfFitBins()

void PRunAsymmetryBNMR::CalcNoOfFitBins ( )
virtual

Calculates the number of bins to be fitted.

Calculates the number of bins in the fit range.

Determines fNoOfFitBins based on the fit range and data availability.

Converts fit time range (fFitStartTime, fFitEndTime) to bin indices (fStartTimeBin, fEndTimeBin) and calculates fNoOfFitBins. Performs boundary checking to ensure indices stay within valid data range.

Definition at line 501 of file PRunAsymmetryBNMR.cpp.

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

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

◆ CalcTheory()

void PRunAsymmetryBNMR::CalcTheory ( )
virtual

Calculates theoretical asymmetry function.

Calculates theoretical β-NMR asymmetry values.

Computes the theory values for the β-NMR asymmetry based on the current parameters and fit function.

Computes theory points for all data bins using the current parameters. The calculation method depends on fAlphaBetaTag:

  • Tag 1 (α=β=1): A = f(t)
  • Tag 2 (α≠1, β=1): A = [f(α+1)-(α-1)]/[(α+1)-f(α-1)] - [-f(α+1)-(α-1)]/[(α+1)+f(α-1)]
  • Tag 3 (α=1, β≠1): A = f(β+1)/[2-f(β-1)] - f(β+1)/[2+f(β-1)]
  • Tag 4 (α≠1, β≠1): Combined formula with both α and β corrections
  • Tag 5 (α estimated, β=1): Uses auto-estimated α
  • Tag 6 (α estimated, β≠1): Uses auto-estimated α with β correction

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

Implements PRunBase.

Definition at line 535 of file PRunAsymmetryBNMR.cpp.

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

◆ EstimateAlpha()

Double_t PRunAsymmetryBNMR::EstimateAlpha ( )
privatevirtual

Estimates α parameter from data.

Estimates the α parameter from histogram data.

Returns
Estimated α value

Calculates α based on the asymmetry ratio of forward and backward histograms.

Calculates an automatic α value by comparing integrated counts in forward and backward histograms for both helicities. The estimate uses:

α = √[(F+×B+) / (F-×B-)]

where F+, B+, F-, B- are the total counts in the respective histograms. This provides a data-driven calibration when α is not explicitly specified.

Returns
Estimated α value (defaults to 1.0 if calculation fails)

Definition at line 1965 of file PRunAsymmetryBNMR.cpp.

References fBackwardm, fBackwardp, fForwardm, and fForwardp.

Referenced by PrepareViewData(), and SubtractEstimatedBkg().

◆ GetEndTimeBin()

virtual Int_t PRunAsymmetryBNMR::GetEndTimeBin ( )
inlinevirtual

Returns the last bin used in the fit.

Returns
End time bin index

Definition at line 132 of file PRunAsymmetryBNMR.h.

References fEndTimeBin.

◆ GetNoOfFitBins()

UInt_t PRunAsymmetryBNMR::GetNoOfFitBins ( )
virtual

Returns the number of bins used in the fit.

Returns
Number of fit bins

Calls CalcNoOfFitBins() to update fNoOfFitBins before returning the value.

Returns
Number of bins included in the fit range

Definition at line 398 of file PRunAsymmetryBNMR.cpp.

References CalcNoOfFitBins(), and fNoOfFitBins.

◆ GetPacking()

virtual Int_t PRunAsymmetryBNMR::GetPacking ( )
inlinevirtual

Returns the packing factor.

Returns
Number of bins combined (1 = no packing)

Definition at line 138 of file PRunAsymmetryBNMR.h.

References fPacking.

◆ GetProperDataRange()

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

Retrieves proper data range for histograms.

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 1783 of file PRunAsymmetryBNMR.cpp.

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

Referenced by PrepareData().

◆ GetProperFitRange()

void PRunAsymmetryBNMR::GetProperFitRange ( PMsrGlobalBlock * globalBlock)
privatevirtual

Determines the proper fit range from global block.

Determines the proper fit range for the run.

Parameters
globalBlockPointer to global MSR block

Fit ranges can be specified in two ways:

  • Time format: fit <start> <end> in microseconds
  • Bin format: fit fgb+offset_0 lgb-offset_1 in bins

Resolution order:

  1. Check RUN block for fit range (time or bins)
  2. If not found, check GLOBAL block for fit range
  3. If still not found, default to fgb/lgb (first/last good bins)

For bin format, converts to time using: time = (bin - t0) × time_resolution

Parameters
globalBlockPointer to GLOBAL block from MSR file

Definition at line 1915 of file PRunAsymmetryBNMR.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 PRunAsymmetryBNMR::GetProperT0 ( PRawRunData * runData,
PMsrGlobalBlock * globalBlock,
PUIntVector & forwardHistoNo,
PUIntVector & backwardHistoNo )
privatevirtual

Retrieves proper t0 values for all histograms.

Parameters
runDataPointer to raw run data
globalBlockPointer to global MSR block
forwardHistoVector of forward histogram indices
backwardHistoNoVector of backward histogram indices
Returns
True on success, false on error

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 1608 of file PRunAsymmetryBNMR.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 PRunAsymmetryBNMR::GetStartTimeBin ( )
inlinevirtual

Returns the first bin used in the fit.

Returns
Start time bin index

Definition at line 126 of file PRunAsymmetryBNMR.h.

References fStartTimeBin.

◆ PrepareData()

Bool_t PRunAsymmetryBNMR::PrepareData ( )
protectedvirtual

Prepares all data for fitting or viewing.

Prepares β-NMR asymmetry data for fitting or viewing.

Returns
True on success, false on error

Main data preparation routine that handles background subtraction, packing, and asymmetry calculation from the four helicity histograms.

Main data preparation routine that performs the following steps:

  1. Retrieves forward/backward histograms for both helicities
  2. Gets time resolution from data file
  3. Validates t0 values (cross-checks MSR file vs. data file)
  4. Adds runs if addruns are specified
  5. Groups histograms if grouping is specified
  6. Subtracts background (fixed or estimated)
  7. Applies bin packing if specified
  8. Calculates β-NMR asymmetry with proper error propagation

The asymmetry calculation handles four histograms per helicity:

  • Forward+, Backward+, Forward-, Backward-

Error propagation for asymmetry A = (F-B)/(F+B):

\[ \Delta A = \pm\frac{2}{(F+B)^2}\sqrt{B^2(\Delta F)^2 + F^2(\Delta B)^2} \]

Returns
True if successful, false on error

Implements PRunBase.

Definition at line 659 of file PRunAsymmetryBNMR.cpp.

References PRunBase::fAddT0s, fBackwardm, fBackwardp, fForwardm, fForwardp, 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 PRunAsymmetryBNMR::PrepareFitData ( )
protectedvirtual

Prepares data specifically for fitting.

Returns
True on success, false on error

Sets up data structures for the fitting process, including determining fit ranges and calculating the number of fit bins.

Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for fitting. Before forming the asymmetry, the following checks will be performed:

  1. check if data range is given, if not try to estimate one.
  2. check that if a data range is present, that it makes any sense.
  3. check that 'first good bin'-'t0' is the same for forward and backward histogram. If not adjust it.
  4. pack data (rebin).
  5. if packed forward size != backward size, truncate the longer one such that an asymmetry can be formed.
  6. calculate the asymmetry: $ A_i = (f_i^c-b_i^c)/(f_i^c+b_i^c) $
  7. calculate the asymmetry errors: $ \delta A_i = 2 \sqrt{(b_i^c)^2 (\delta f_i^c)^2 + (\delta b_i^c)^2 (f_i^c)^2}/(f_i^c+b_i^c)^2$

Definition at line 1092 of file PRunAsymmetryBNMR.cpp.

References PRunData::AppendErrorValue(), PRunData::AppendValue(), CalcNoOfFitBins(), fBackwardm, fBackwardmErr, fBackwardp, fBackwardpErr, PRunBase::fData, fForwardm, fForwardmErr, fForwardp, fForwardpErr, fGoodBins, fPacking, PRunBase::fT0s, PRunBase::fTimeResolution, PRunData::GetError(), and PRunData::GetValue().

Referenced by PrepareData().

◆ PrepareViewData()

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

Prepares data for viewing/plotting.

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

Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for view representation.

  1. check that data range is present, that it makes any sense.
  2. check that 'first good bin'-'t0' is the same for forward and backward histogram. If not adjust it.
  3. pack data (rebin).
  4. if packed forward size != backward size, truncate the longer one such that an asymmetry can be formed.
  5. calculate the asymmetry: $ A_i = (\alpha f_i^c-b_i^c)/(\alpha \beta f_i^c+b_i^c) $
  6. calculate the asymmetry errors: $ \delta A_i = 2 \sqrt{(b_i^c)^2 (\delta f_i^c)^2 + (\delta b_i^c)^2 (f_i^c)^2}/(f_i^c+b_i^c)^2$
  7. calculate the theory vector.
Parameters
runDataraw run data needed to perform some crosschecks
histoNohistogram number (within a run). histoNo[0]: forward histogram number, histNo[1]: backward histogram number

Definition at line 1254 of file PRunAsymmetryBNMR.cpp.

References PRunData::AppendErrorValue(), PRunData::AppendValue(), CalcNoOfFitBins(), EstimateAlpha(), fAlphaBetaTag, fBackwardm, fBackwardmErr, fBackwardp, fBackwardpErr, PRunBase::fData, fForwardm, fForwardmErr, fForwardp, fForwardpErr, PRunBase::fFuncValues, fGoodBins, PRunBase::fMetaData, PRunBase::fMsrInfo, fPacking, PRunBase::fRunInfo, PRunBase::fT0s, fTheoAsData, PRunBase::fTheory, PRunBase::fTimeResolution, PRawRunData::GetDataBin(), PRunData::GetError(), PRunData::GetValue(), and MSR_PARAM_FUN_OFFSET.

Referenced by PrepareData().

◆ SetFitRangeBin()

void PRunAsymmetryBNMR::SetFitRangeBin ( const TString fitRange)
virtual

Sets the fit range in bins.

Dynamically changes the fit range (used in COMMAND block).

Parameters
fitRangeFit range string (format depends on configuration)

Parses a fit range string to update fit boundaries. The string format is:

  • Single range: FIT_RANGE fgb[+n0] lgb[-n1]
  • Multiple runs: FIT_RANGE fgb[+n00] lgb[-n01] fgb[+n10] lgb[-n11] ...

Where:

  • fgb = first good bin
  • lgb = last good bin
  • +n = positive offset to shift fgb forward
  • -n = negative offset to shift lgb backward

If one pair is given, it applies to all runs. If multiple pairs are given, the number must match the number of RUN blocks.

Parameters
fitRangeString containing fit range specification

Definition at line 426 of file PRunAsymmetryBNMR.cpp.

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

◆ SubtractEstimatedBkg()

Bool_t PRunAsymmetryBNMR::SubtractEstimatedBkg ( )
private

Estimates and subtracts background from histograms.

Returns
True on success, false on error

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 944 of file PRunAsymmetryBNMR.cpp.

References ACCEL_PERIOD_PSI, ACCEL_PERIOD_RAL, ACCEL_PERIOD_TRIUMF, EstimateAlpha(), fBackwardm, fBackwardmErr, fBackwardp, fBackwardpErr, fForwardm, fForwardmErr, fForwardp, fForwardpErr, fPacking, PRunBase::fRunInfo, and PRunBase::fTimeResolution.

Referenced by PrepareData().

◆ SubtractFixBkg()

Bool_t PRunAsymmetryBNMR::SubtractFixBkg ( )
private

Subtracts fixed background from histograms.

Returns
True on success, false on error

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 882 of file PRunAsymmetryBNMR.cpp.

References fBackwardm, fBackwardmErr, fBackwardp, fBackwardpErr, fForwardm, fForwardmErr, fForwardp, fForwardpErr, and PRunBase::fRunInfo.

Referenced by PrepareData().

Member Data Documentation

◆ fAlphaBetaTag

UInt_t PRunAsymmetryBNMR::fAlphaBetaTag
private

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

Definition at line 175 of file PRunAsymmetryBNMR.h.

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

◆ fBackwardm

PDoubleVector PRunAsymmetryBNMR::fBackwardm
private

Negative helicity backward histogram data.

Definition at line 186 of file PRunAsymmetryBNMR.h.

Referenced by EstimateAlpha(), PrepareData(), PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryBNMR().

◆ fBackwardmErr

PDoubleVector PRunAsymmetryBNMR::fBackwardmErr
private

Negative helicity backward histogram errors.

Definition at line 187 of file PRunAsymmetryBNMR.h.

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

◆ fBackwardp

PDoubleVector PRunAsymmetryBNMR::fBackwardp
private

Positive helicity backward histogram data.

Definition at line 182 of file PRunAsymmetryBNMR.h.

Referenced by EstimateAlpha(), PrepareData(), PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryBNMR().

◆ fBackwardpErr

PDoubleVector PRunAsymmetryBNMR::fBackwardpErr
private

Positive helicity backward histogram errors.

Definition at line 183 of file PRunAsymmetryBNMR.h.

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

◆ fEndTimeBin

Int_t PRunAsymmetryBNMR::fEndTimeBin
private

Last bin index for fitting.

Definition at line 192 of file PRunAsymmetryBNMR.h.

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

◆ fForwardm

PDoubleVector PRunAsymmetryBNMR::fForwardm
private

Negative helicity forward histogram data.

Definition at line 184 of file PRunAsymmetryBNMR.h.

Referenced by EstimateAlpha(), PrepareData(), PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryBNMR().

◆ fForwardmErr

PDoubleVector PRunAsymmetryBNMR::fForwardmErr
private

Negative helicity forward histogram errors.

Definition at line 185 of file PRunAsymmetryBNMR.h.

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

◆ fForwardp

PDoubleVector PRunAsymmetryBNMR::fForwardp
private

Positive helicity forward histogram data.

Definition at line 180 of file PRunAsymmetryBNMR.h.

Referenced by EstimateAlpha(), PrepareData(), PrepareFitData(), PrepareViewData(), SubtractEstimatedBkg(), SubtractFixBkg(), and ~PRunAsymmetryBNMR().

◆ fForwardpErr

PDoubleVector PRunAsymmetryBNMR::fForwardpErr
private

Positive helicity forward histogram errors.

Definition at line 181 of file PRunAsymmetryBNMR.h.

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

◆ fGoodBins

Int_t PRunAsymmetryBNMR::fGoodBins[4]
private

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

Definition at line 189 of file PRunAsymmetryBNMR.h.

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

◆ fNoOfFitBins

UInt_t PRunAsymmetryBNMR::fNoOfFitBins
private

Number of bins included in the fit.

Definition at line 176 of file PRunAsymmetryBNMR.h.

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

◆ fPacking

Int_t PRunAsymmetryBNMR::fPacking
private

Bin packing factor from RUN or GLOBAL block.

Definition at line 177 of file PRunAsymmetryBNMR.h.

Referenced by GetPacking(), PrepareFitData(), PrepareViewData(), PRunAsymmetryBNMR(), PRunAsymmetryBNMR(), and SubtractEstimatedBkg().

◆ fStartTimeBin

Int_t PRunAsymmetryBNMR::fStartTimeBin
private

First bin index for fitting.

Definition at line 191 of file PRunAsymmetryBNMR.h.

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

◆ fTheoAsData

Bool_t PRunAsymmetryBNMR::fTheoAsData
private

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

Definition at line 178 of file PRunAsymmetryBNMR.h.

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


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