musrfit 1.10.0
nxH5::PNeXusDeadTime Class Reference

Dead time correction calculator for muon detector data. More...

#include <PNeXus.h>

Inheritance diagram for nxH5::PNeXusDeadTime:
Collaboration diagram for nxH5::PNeXusDeadTime:

Public Member Functions

 PNeXusDeadTime (const PNeXus *nxs, bool debug=false)
 Constructor - initializes dead time calculator from NeXus data.
 
bool IsValid ()
 Check if the dead time calculator was initialized successfully.
 
double Up () const
 Get the error definition for the minimizer (FCNBase requirement)
 
double operator() (const std::vector< double > &par) const
 Function call operator - calculates chi-square for given parameters.
 
void Minimize (const int i)
 Minimize dead time for a specific detector spectrum.
 
const std::vector< hsize_t > & GetDimensions () const
 Get the dimensions of the count dataset.
 
std::vector< float > GetDeadTimeEstimated ()
 Get the estimated dead time values from minimization.
 

Private Attributes

bool fDebug {false}
 Debug flag - if true, print additional diagnostic information.
 
bool fValid
 Validity flag - true if required data was loaded successfully.
 
int fGoodFrames {-1}
 Number of good time frames for analysis.
 
float fTimeResolution {0.0}
 Time resolution in picoseconds.
 
std::vector< hsize_t > fDims = {0, 0, 0}
 Dimensions of count data [periods, spectra, bins].
 
int fT0Bin {-1}
 T0 bin number (time zero reference)
 
int fFgbBin {-1}
 First good bin for analysis.
 
int fLgbBin {-1}
 Last good bin for analysis.
 
std::vector< float > fDeadTime
 Dead time values per detector (microseconds) from the file.
 
std::vector< float > fDeadTimeEstimated
 Dead time values per detector (microseconds) as estimated from the data.
 
std::vector< int > fCounts
 Count data for minimization.
 
double fUp {0.5}
 UP parameter for Minuit2 (0.5 for chi-square)
 
unsigned int fIdx {0}
 Current spectrum index being minimized.
 

Detailed Description

Dead time correction calculator for muon detector data.

The PNeXusDeadTime class calculates dead time corrections for muon detector count data using ROOT Minuit2 minimization. It inherits from ROOT::Minuit2::FCNBase to implement a chi-square minimization function.

Dead time is the period after detecting an event during which the detector cannot register another event. This class estimates the dead time parameter for each detector spectrum by minimizing the deviation from expected count rates.

Typical Usage:

nxH5::PNeXus nexus("file.nxs");
nxH5::PNeXusDeadTime ndt(&nexus, false); // false = no debug output
if (ndt.IsValid()) {
auto dims = ndt.GetDimensions();
// Minimize for each spectrum
for (unsigned int i = 0; i < dims[1]; i++) {
ndt.minimize(i);
}
}
Dead time correction calculator for muon detector data.
Definition PNeXus.h:1199
NeXus HDF5 file reader with case-insensitive path lookup.
Definition PNeXus.h:1463
Note
Requires a valid PNeXus object with count data
Uses ROOT Minuit2 for minimization
See also
ROOT::Minuit2::FCNBase
nxH5::PNeXus
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 1198 of file PNeXus.h.

Constructor & Destructor Documentation

◆ PNeXusDeadTime()

nxH5::PNeXusDeadTime::PNeXusDeadTime ( const PNeXus * nxs,
bool debug = false )

Constructor - initializes dead time calculator from NeXus data.

  • Reads count data, time resolution, and bin information from the NeXus file to set up the dead time calculation.
  • Parameters
    nxsPointer to PNeXus object containing the detector data
    debugIf true, print additional debug information during calculations
  • Note
    After construction, check IsValid() to ensure data was loaded successfully
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.cpp, and /workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 2793 of file PNeXus.cpp.

References fCounts, fDeadTime, fDeadTimeEstimated, fDebug, fDims, fFgbBin, fGoodFrames, fLgbBin, fT0Bin, fTimeResolution, and fValid.

Member Function Documentation

◆ GetDeadTimeEstimated()

std::vector< float > nxH5::PNeXusDeadTime::GetDeadTimeEstimated ( )
inline

Get the estimated dead time values from minimization.

Returns the dead time values calculated by the minimize() function for each spectrum. These values represent the dead time parameter that best fits the observed count data when accounting for dead time losses.

Returns
Vector of estimated dead time values (in microseconds) per spectrum
Note
Call minimize() for each spectrum before calling this method to populate the estimated values
See also
minimize() for the calculation method
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 1268 of file PNeXus.h.

References fDeadTimeEstimated.

◆ GetDimensions()

const std::vector< hsize_t > & nxH5::PNeXusDeadTime::GetDimensions ( ) const
inline

Get the dimensions of the count dataset.

  • Returns the dimensions [periods, spectra, bins] of the count data being used for dead time calculation.
  • Returns
    Vector of dimension sizes (typically 3D: [periods, spectra, bins])
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 1251 of file PNeXus.h.

References fDims.

◆ IsValid()

bool nxH5::PNeXusDeadTime::IsValid ( )
inline

Check if the dead time calculator was initialized successfully.

  • Returns
    true if required datasets were found and loaded, false otherwise
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 1215 of file PNeXus.h.

References fValid.

◆ Minimize()

void nxH5::PNeXusDeadTime::Minimize ( const int i)

Minimize dead time for a specific detector spectrum.

  • Performs Minuit2 minimization to find the optimal dead time parameter for the specified spectrum index. Results are printed to stdout.
  • Parameters
    iSpectrum index to minimize (0-based index into second dimension)
  • Note
    Prints minimization results including dead time estimate and errors
    The index i must be less than dims[1] (number of spectra)
    Performs ROOT Minuit2 minimization to find the optimal dead time parameter and count rate model parameters for the specified spectrum index. Uses MnMinimize with strategy 2 (high precision) and stores the result.

Minimization Parameters:

  • dtc: Dead time correction (initial: 0.01, step: 0.01)
  • N0: Initial count rate (initial: estimated from data)
  • N_bkg: Background rate (initial: 0.1)
Parameters
iSpectrum index to minimize (0-based, must be < dims[1])
Note
Results are stored in fDeadTimeEstimated[i] and optionally printed to stdout if debug mode is enabled
See also
GetDeadTimeEstimated() to retrieve results after minimization

< Minuit2 function minimum result

Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.cpp, and /workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 2960 of file PNeXus.cpp.

References fCounts, fDeadTime, fDeadTimeEstimated, fDebug, fDims, fFgbBin, and fIdx.

◆ operator()()

double nxH5::PNeXusDeadTime::operator() ( const std::vector< double > & par) const

Function call operator - calculates chi-square for given parameters.

Calculate the negative log-likelihood for dead time correction.

  • This is the objective function that ROOT::Minuit2 minimizes. It calculates the chi-square deviation between observed counts and expected counts corrected for dead time.
  • Parameters
    parVector of parameters (dead time values in microseconds)
    Returns
    Chi-square value for the given parameters
    This function implements the objective function for ROOT Minuit2 minimization. It calculates the negative log-likelihood comparing observed counts to the expected count rate model with dead time correction.

Model: The expected count rate includes:

  • Exponential muon decay: N(t) = N0 * exp(-t/tau_mu) + N_bkg
  • Dead time correction: N_corrected = N(t) / (1 + N(t) * dtc)

Parameters:

  • par[0] (dtc): Dead time correction parameter
  • par[1] (N0): Initial count rate amplitude
  • par[2] (N_bkg): Background count rate
Parameters
parVector of parameters [dtc, N0, N_bkg]
Returns
Negative log-likelihood value to be minimized
Note
Uses the muon lifetime tau_mu = 2.1969811 microseconds
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.cpp, and /workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 2920 of file PNeXus.cpp.

References fCounts, fDims, fFgbBin, fGoodFrames, fIdx, fLgbBin, fT0Bin, and fTimeResolution.

◆ Up()

double nxH5::PNeXusDeadTime::Up ( ) const
inline

Get the error definition for the minimizer (FCNBase requirement)

  • Returns the UP parameter which defines how the minimizer estimates errors. For chi-square minimization, UP = 0.5 corresponds to 1-sigma errors.
  • Returns
    Error definition parameter (0.5 for chi-square)
Examples
/workspace/LMU/musrfit/src/external/nexus/PNeXus.h.

Definition at line 1223 of file PNeXus.h.

References fUp.

Member Data Documentation

◆ fCounts

std::vector<int> nxH5::PNeXusDeadTime::fCounts
private

Count data for minimization.

Definition at line 1281 of file PNeXus.h.

Referenced by Minimize(), operator()(), and PNeXusDeadTime().

◆ fDeadTime

std::vector<float> nxH5::PNeXusDeadTime::fDeadTime
private

Dead time values per detector (microseconds) from the file.

Definition at line 1279 of file PNeXus.h.

Referenced by Minimize(), and PNeXusDeadTime().

◆ fDeadTimeEstimated

std::vector<float> nxH5::PNeXusDeadTime::fDeadTimeEstimated
private

Dead time values per detector (microseconds) as estimated from the data.

Definition at line 1280 of file PNeXus.h.

Referenced by GetDeadTimeEstimated(), Minimize(), and PNeXusDeadTime().

◆ fDebug

bool nxH5::PNeXusDeadTime::fDebug {false}
private

Debug flag - if true, print additional diagnostic information.

Definition at line 1271 of file PNeXus.h.

Referenced by Minimize(), and PNeXusDeadTime().

◆ fDims

std::vector<hsize_t> nxH5::PNeXusDeadTime::fDims = {0, 0, 0}
private

Dimensions of count data [periods, spectra, bins].

Definition at line 1275 of file PNeXus.h.

Referenced by GetDimensions(), Minimize(), operator()(), and PNeXusDeadTime().

◆ fFgbBin

int nxH5::PNeXusDeadTime::fFgbBin {-1}
private

First good bin for analysis.

Definition at line 1277 of file PNeXus.h.

Referenced by Minimize(), operator()(), and PNeXusDeadTime().

◆ fGoodFrames

int nxH5::PNeXusDeadTime::fGoodFrames {-1}
private

Number of good time frames for analysis.

Definition at line 1273 of file PNeXus.h.

Referenced by operator()(), and PNeXusDeadTime().

◆ fIdx

unsigned int nxH5::PNeXusDeadTime::fIdx {0}
private

Current spectrum index being minimized.

Definition at line 1283 of file PNeXus.h.

Referenced by Minimize(), and operator()().

◆ fLgbBin

int nxH5::PNeXusDeadTime::fLgbBin {-1}
private

Last good bin for analysis.

Definition at line 1278 of file PNeXus.h.

Referenced by operator()(), and PNeXusDeadTime().

◆ fT0Bin

int nxH5::PNeXusDeadTime::fT0Bin {-1}
private

T0 bin number (time zero reference)

Definition at line 1276 of file PNeXus.h.

Referenced by operator()(), and PNeXusDeadTime().

◆ fTimeResolution

float nxH5::PNeXusDeadTime::fTimeResolution {0.0}
private

Time resolution in picoseconds.

Definition at line 1274 of file PNeXus.h.

Referenced by operator()(), and PNeXusDeadTime().

◆ fUp

double nxH5::PNeXusDeadTime::fUp {0.5}
private

UP parameter for Minuit2 (0.5 for chi-square)

Definition at line 1282 of file PNeXus.h.

Referenced by Up().

◆ fValid

bool nxH5::PNeXusDeadTime::fValid
private

Validity flag - true if required data was loaded successfully.

Definition at line 1272 of file PNeXus.h.

Referenced by IsValid(), and PNeXusDeadTime().


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