Skip to main content

fit_counts

Function fit_counts 

Source
pub fn fit_counts(
    measurement: &Measurement,
    calibration: &Calibration,
) -> Result<CountsFit, PipelineError>
Expand description

Fit the areal densities, temperature, normalization and background terms of measurement that are not known to the raw counts of both runs. On a uniform grid of flight times u_i, energies E_i and step w, the counts in bin k are

O_k  = ℓ^O_k · w Σ_i φ_i P_ki
S_k  = ℓ^S_k · c_q · a · w Σ_i φ_i [T_i + b(E_i)] P_ki
T_i  = exp(−Σ_m n_m σ_m(E_i))
b(E) = b0 + b1/√E + b2·√E

with φ_i the beam per µs, P_ki the chance of a neutron at u_i arriving in bin k, n_m and σ_m each isotope’s density and Doppler-broadened total cross section, c_q the charge ratio, a the normalization and ℓ^O_k, ℓ^S_k each run’s live fraction. The background is beam neutrons that reach the detector another way, so it passes through the pulse and scales with the normalization; SAMMY’s BackA, BackB, BackC (cro/mnrm1.f90) are a·b0, a·b1, a·b2, to within the background’s change over the pulse’s delay. SAMMY’s BackD·exp(−BackF/√E) term, and counts that bypass the pulse, such as gammas, are not modelled. The beam φ has the intervals fit_open_beam chooses and is fitted with the rest to both runs, starting from the open-beam fit.

The grid’s first step is at most half the narrowest Doppler full width at half maximum, in flight time, of any resonance inside its energy span, at the starting temperature; it is then halved until the counts of both runs meet BOUND. When the coarser grid of that accepted pair is wider than the rule at the fitted temperature, the fit is repeated from its answer on a first grid built at the fitted temperature. The step is uniform, so a wide window whose span holds a narrow resonance at high energy, or a low fitted temperature, can exceed the grid’s point cap; a temperature the counts barely determine can run to 1 K and refuse the fit that way.

The fitter finds a local minimum. A thin sample hotter than about 1,500 K fitted from room temperature can end in a false one, reported converged with an overdispersion far above 1. Where a black resonance empties bins and the background is near zero, a fitted background with no lower bound can drive a black bin’s prediction to zero, and the fit ends unconverged; with b1 and b2 known, b0 bounded below by 0 ends on that bound, converged.

The overdispersion scales the covariance; it assumes both runs share it and their bins are independent.

§Errors

PipelineError::ShapeMismatch unless each run has one count, and one live fraction when given, per bin; PipelineError::InvalidParameter if a count is not a whole non-negative number, a run has no counts, a live fraction is not in (0, 1], the charge ratio is not finite and positive, a known or starting value is not finite and in its quantity’s range, bounds are not lower < upper in that range with the start between them, there are no isotopes, an isotope is listed twice, an isotope’s resonance data are not finite, or the energies its broadened cross section reads, at the known temperature or at the upper bound of a fitted one, down to zero for a window within the thermal spread of zero energy, are not inside a single one of its evaluated (SLBW, MLBW or Reich–Moore) resolved ranges; PipelineError::UnmodelledCounts if at the fit, converged or not, a bin is predicted negative or non-finite counts, or holds counts predicted below NEGLIGIBLE_PREDICTION: starting or known values the fitter cannot leave; everything fit_open_beam refuses; PipelineError::FlightTimeGrid for the grid’s refusals, including more points than it allows; PipelineError::Fitting if the fitter fails, or the cross sections fail at the start; a failure at a trial temperature is a rejected step.