musrfit 1.10.0
PPrepFourier Class Reference

Prepares time-domain μSR data for Fourier transformation. More...

#include <PPrepFourier.h>

Public Member Functions

 PPrepFourier ()
 Default constructor (requires separate configuration)
 
 PPrepFourier (const Int_t packing, const Int_t *bkgRange, PDoubleVector bkg)
 Full constructor with all configuration parameters.
 
virtual ~PPrepFourier ()
 Destructor.
 
virtual void SetBkgRange (const Int_t *bkgRange)
 Sets background range for automatic background calculation.
 
virtual void SetBkg (PDoubleVector bkg)
 Sets explicit background values for each data set.
 
virtual void SetPacking (const Int_t packing)
 Sets rebinning/packing factor for data reduction.
 
virtual void AddData (musrFT_data &data)
 Adds a time-domain data set for processing.
 
virtual void DoBkgCorrection ()
 Applies background correction to all data sets.
 
virtual void DoPacking ()
 Applies rebinning/packing to reduce data points.
 
virtual void DoLifeTimeCorrection (Double_t fudge)
 Applies muon lifetime correction for theory-free analysis.
 
TString GetInfo (const UInt_t idx)
 Returns metadata string for a specific data set.
 
Int_t GetDataSetTag (const UInt_t idx)
 Returns data set tag identifier.
 
UInt_t GetNoOfData ()
 Returns number of stored data sets.
 
std::vector< TH1F * > GetData ()
 Creates ROOT histograms for all processed data sets.
 
TH1F * GetData (const UInt_t idx)
 Creates ROOT histogram for a specific processed data set.
 

Private Member Functions

virtual void InitData ()
 Initializes processed data from raw data.
 

Private Attributes

std::vector< musrFT_datafRawData
 Raw input data sets with metadata.
 
std::vector< PDoubleVectorfData
 Processed data (after t0, corrections, packing)
 
Int_t fBkgRange [2]
 Background range: [0]=start bin, [1]=end bin (-1=unused)
 
PDoubleVector fBkg
 Explicit background values (one per data set)
 
Int_t fPacking
 Rebinning factor (1=no rebinning, N=combine N bins)
 

Detailed Description

Prepares time-domain μSR data for Fourier transformation.

PPrepFourier is a utility class that processes raw time-domain μSR data before Fourier transformation. It performs essential preprocessing steps:

  • Background correction (using range or explicit values)
  • Data rebinning/packing for improved statistics
  • Muon lifetime correction for theory-free analysis
  • Time range selection

The class handles multiple data sets simultaneously and prepares them for subsequent Fourier analysis without requiring theoretical fit functions.

Usage Example:
PPrepFourier prep(packing, bkgRange, bkgValues);
prep.AddData(dataSet1);
prep.AddData(dataSet2);
prep.DoBkgCorrection();
prep.DoPacking();
prep.DoLifeTimeCorrection(1.0);
std::vector<TH1F*> histos = prep.GetData();
PPrepFourier()
Default constructor (requires separate configuration)
See also
musrFT_data for the input data structure

Definition at line 87 of file PPrepFourier.h.

Constructor & Destructor Documentation

◆ PPrepFourier() [1/2]

PPrepFourier::PPrepFourier ( )

Default constructor (requires separate configuration)

Default constructor that initializes to default values.

Sets background range to unused (-1, -1) and packing to 1 (no rebinning). Background values and data must be set separately using setter methods.

Definition at line 43 of file PPrepFourier.cpp.

References fBkgRange, and fPacking.

◆ PPrepFourier() [2/2]

PPrepFourier::PPrepFourier ( const Int_t packing,
const Int_t * bkgRange,
PDoubleVector bkg )

Full constructor with all configuration parameters.

Full constructor that initializes all configuration parameters.

Parameters
packingRebinning factor (1=no rebinning, 2=combine 2 bins, etc.)
bkgRangeBackground range [start, end] in bins (-1 if not used)
bkgVector of explicit background values (one per data set)

Creates a PPrepFourier instance with complete configuration. Background can be specified either via range (for automatic calculation) or via explicit values (one per data set to be added later).

Parameters
packingRebinning factor (1=no rebinning, N=combine N bins)
bkgRangeBackground range [start, end] in bins (-1 if not used)
bkgVector of explicit background values (one per data set)

Definition at line 64 of file PPrepFourier.cpp.

References fPacking, SetBkg(), and SetBkgRange().

◆ ~PPrepFourier()

PPrepFourier::~PPrepFourier ( )
virtual

Destructor.

Destructor that cleans up internal data structures.

Clears both raw data and processed data vectors. Note that TH1F objects returned by GetData() are owned by the caller and not cleaned up here.

Definition at line 80 of file PPrepFourier.cpp.

References fData, and fRawData.

Member Function Documentation

◆ AddData()

void PPrepFourier::AddData ( musrFT_data & data)
virtual

Adds a time-domain data set for processing.

Adds a time-domain data set to the internal collection.

Parameters
datamusrFT_data structure containing raw data and metadata

Stores the raw data and metadata for later processing. Multiple data sets can be added and will be processed together by DoBkgCorrection(), DoPacking(), and DoLifeTimeCorrection().

Parameters
datamusrFT_data structure containing raw histogram data and metadata

Definition at line 188 of file PPrepFourier.cpp.

References fRawData.

Referenced by main().

◆ DoBkgCorrection()

void PPrepFourier::DoBkgCorrection ( )
virtual

Applies background correction to all data sets.

Uses either the background range (averaged over range) or explicit background values. Background is subtracted from all data points.

Subtracts background from each data point. The background can be specified in two ways:

  1. Background range: Calculates average over the specified bin range
  2. Explicit values: Uses the background values set via SetBkg()

If fData is not yet initialized, calls InitData() first. If neither background range nor explicit values are provided, no correction is applied. Validates that background range is within data bounds and that the number of explicit background values matches the number of data sets.

Definition at line 209 of file PPrepFourier.cpp.

References fBkg, fBkgRange, fData, fRawData, and InitData().

Referenced by main().

◆ DoLifeTimeCorrection()

void PPrepFourier::DoLifeTimeCorrection ( Double_t fudge)
virtual

Applies muon lifetime correction for theory-free analysis.

Applies muon lifetime correction for theory-free Fourier analysis.

Parameters
fudgeRescaling factor for estimated N0 (typically ~1.0)

Multiplies data by exp(t/τ) to remove muon decay, estimates N0 from the average, and normalizes to create asymmetry-like data. Works best for high fields (>few kGauss) where depolarization is minimal.

Performs a theory-free lifetime correction by:

  1. Multiplying data by exp(t/τ_μ) to remove muon decay
  2. Estimating N0 as the average of the corrected data
  3. Subtracting N0 and normalizing by N0 to get asymmetry-like data

This approach works well for high fields (>few kGauss) where depolarization is minimal, but may be less accurate for low fields where significant relaxation occurs during the muon lifetime.

If fData is not yet initialized, calls InitData() first. Background correction should typically be applied before lifetime correction.

Parameters
fudgeRescaling factor for estimated N0 (typically ~1.0, allows fine-tuning)

Definition at line 322 of file PPrepFourier.cpp.

References fData, fRawData, InitData(), and PMUON_LIFETIME.

Referenced by main().

◆ DoPacking()

void PPrepFourier::DoPacking ( )
virtual

Applies rebinning/packing to reduce data points.

Applies rebinning/packing to reduce the number of data points.

Combines adjacent bins according to the packing factor to improve statistics and reduce the number of data points.

Combines adjacent bins according to the packing factor to improve statistics and reduce data size. Bins are summed in groups of fPacking size. If fPacking=1, no rebinning is performed.

If fData is not yet initialized, calls InitData() first. The time resolution should be adjusted accordingly (multiplied by fPacking) when creating histograms.

Definition at line 273 of file PPrepFourier.cpp.

References fData, fPacking, fRawData, and InitData().

Referenced by main().

◆ GetData() [1/2]

std::vector< TH1F * > PPrepFourier::GetData ( )

Creates ROOT histograms for all processed data sets.

Returns
Vector of TH1F pointers (caller owns the histograms)

Creates histograms with proper time binning, respecting time ranges and packing. The caller is responsible for deleting the histograms.

Converts the processed data into TH1F histograms with proper time binning. The time range, bin width, and histogram titles are taken from the musrFT_data metadata. The packing factor is applied to the time resolution.

Returns
Vector of TH1F pointers (caller owns and must delete)
Note
The caller is responsible for deleting the returned histograms.
Returns empty vector if no data is present.

Definition at line 411 of file PPrepFourier.cpp.

References fData, fPacking, and fRawData.

Referenced by main().

◆ GetData() [2/2]

TH1F * PPrepFourier::GetData ( const UInt_t idx)

Creates ROOT histogram for a specific processed data set.

Creates a ROOT histogram for a specific processed data set.

Parameters
idxData set index
Returns
TH1F pointer (caller owns), or nullptr if idx out of range

Creates a histogram with proper time binning for the specified data set. The caller is responsible for deleting the histogram.

Converts a single processed data set into a TH1F histogram with proper time binning. The time range, bin width, and histogram title are taken from the musrFT_data metadata. The packing factor is applied to the time resolution.

Parameters
idxData set index
Returns
TH1F pointer (caller owns and must delete), or nullptr if idx out of range
Note
The caller is responsible for deleting the returned histogram.
Returns nullptr if no data is present or idx is out of range.

Definition at line 488 of file PPrepFourier.cpp.

References fData, fPacking, and fRawData.

◆ GetDataSetTag()

Int_t PPrepFourier::GetDataSetTag ( const UInt_t idx)

Returns data set tag identifier.

Returns the data set tag identifier.

Parameters
idxData set index
Returns
Data set tag, or -1 if idx out of range

The data set tag is used to label and group related data sets, particularly for average-per-data-set operations in Fourier analysis.

Parameters
idxData set index
Returns
Data set tag value, or -1 if idx out of range

Definition at line 386 of file PPrepFourier.cpp.

References fRawData.

Referenced by main().

◆ GetInfo()

TString PPrepFourier::GetInfo ( const UInt_t idx)

Returns metadata string for a specific data set.

Returns the metadata string for a specific data set.

Parameters
idxData set index
Returns
Metadata string, or empty string if idx out of range
Parameters
idxData set index
Returns
Metadata string from musrFT_data.info, or empty string if idx out of range

Definition at line 364 of file PPrepFourier.cpp.

References fRawData.

◆ GetNoOfData()

UInt_t PPrepFourier::GetNoOfData ( )
inline

Returns number of stored data sets.

Returns
Number of data sets added via AddData()

Definition at line 171 of file PPrepFourier.h.

References fRawData.

Referenced by main().

◆ InitData()

void PPrepFourier::InitData ( )
privatevirtual

Initializes processed data from raw data.

Initializes processed data by copying from raw data starting at t0.

Copies raw data to fData starting from t0 bin. This is called automatically by processing methods if needed.

Creates the fData vectors from fRawData, starting from the t0 bin for each data set. This effectively removes pre-t0 bins and creates a working copy for subsequent processing (background correction, packing, lifetime correction).

If t0 is negative or not set, data is copied from bin 0. This method is called automatically by processing methods if fData is not yet initialized.

Definition at line 548 of file PPrepFourier.cpp.

References fData, and fRawData.

Referenced by DoBkgCorrection(), DoLifeTimeCorrection(), and DoPacking().

◆ SetBkg()

void PPrepFourier::SetBkg ( PDoubleVector bkg)
virtual

Sets explicit background values for each data set.

Sets explicit background values for all data sets.

Parameters
bkgVector of background values (one per histogram)

Provides pre-calculated background values (one per data set) instead of calculating them from a background range. This allows different background values for each histogram.

Parameters
bkgVector of background values (should match number of data sets)

Definition at line 149 of file PPrepFourier.cpp.

References fBkg.

Referenced by PPrepFourier().

◆ SetBkgRange()

void PPrepFourier::SetBkgRange ( const Int_t * bkgRange)
virtual

Sets background range for automatic background calculation.

Sets the background range for automatic background calculation.

Parameters
bkgRangeArray [start, end] specifying background bins (both ≥-1)

Specifies the bin range [start, end] for calculating background by averaging. Values of -1 indicate that background range is not used (explicit background values should be provided instead). Validates that both values are ≥-1 and prints warnings if invalid values are encountered.

Parameters
bkgRangeArray [start, end] with background bin range (both must be ≥-1)

Definition at line 99 of file PPrepFourier.cpp.

References fBkgRange.

Referenced by main(), and PPrepFourier().

◆ SetPacking()

void PPrepFourier::SetPacking ( const Int_t packing)
virtual

Sets rebinning/packing factor for data reduction.

Sets the rebinning/packing factor for data reduction.

Parameters
packingNumber of bins to combine (must be > 0)

Specifies how many adjacent bins to combine during DoPacking(). A value of 1 means no rebinning, 2 combines pairs of bins, etc. Invalid values (≤0) are rejected with a warning.

Parameters
packingNumber of bins to combine (must be > 0)

Definition at line 167 of file PPrepFourier.cpp.

References fPacking.

Referenced by main().

Member Data Documentation

◆ fBkg

PDoubleVector PPrepFourier::fBkg
private

Explicit background values (one per data set)

Definition at line 196 of file PPrepFourier.h.

Referenced by DoBkgCorrection(), and SetBkg().

◆ fBkgRange

Int_t PPrepFourier::fBkgRange[2]
private

Background range: [0]=start bin, [1]=end bin (-1=unused)

Definition at line 195 of file PPrepFourier.h.

Referenced by DoBkgCorrection(), PPrepFourier(), and SetBkgRange().

◆ fData

std::vector<PDoubleVector> PPrepFourier::fData
private

Processed data (after t0, corrections, packing)

Definition at line 194 of file PPrepFourier.h.

Referenced by DoBkgCorrection(), DoLifeTimeCorrection(), DoPacking(), GetData(), GetData(), InitData(), and ~PPrepFourier().

◆ fPacking

Int_t PPrepFourier::fPacking
private

Rebinning factor (1=no rebinning, N=combine N bins)

Definition at line 197 of file PPrepFourier.h.

Referenced by DoPacking(), GetData(), GetData(), PPrepFourier(), PPrepFourier(), and SetPacking().

◆ fRawData

std::vector<musrFT_data> PPrepFourier::fRawData
private

Raw input data sets with metadata.

Definition at line 193 of file PPrepFourier.h.

Referenced by AddData(), DoBkgCorrection(), DoLifeTimeCorrection(), DoPacking(), GetData(), GetData(), GetDataSetTag(), GetInfo(), GetNoOfData(), InitData(), and ~PPrepFourier().


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