Files
salman 6308dceb36 Add real-musrfit integration checks for the beta.3 baseline
- tests/integration-musrfit.test.js stages each single-run .generated.msr
  fixture (data path rewired to the fake tree), runs real 'musrfit -e', and
  asserts the fitted STATISTIC block matches the recorded converged value
  (asymmetry 39.776426, bounds 60.869627, t0/background 5.602355, NDF 406).
  It also round-trips every .fitted.msr fixture through parseMSRFitStatistic.
  Gated on the musrfit binary + fake data; prints a skip notice otherwise.
- Wire into the npm test script; document in the reference fixtures README.
- Mark the beta.3 fixture, integration, and title-handling TODO gates done.
2026-08-31 19:41:02 +02:00

64 lines
3.6 KiB
Markdown

# Reference fixtures
Golden MSR files captured from fixed `muSRFlow` GUI configurations. Each
`<name>.generated.msr` is the byte-for-byte output of `buildMSR()` for a
deterministic configuration and is verified hermetic by
`tests/reference-fixtures.test.js` (no `musrfit` required).
The naming records the workflow:
- `asymmetry.generated.msr` — single-run Asymmetry fit with bounds and an FFT
block (the canonical export path).
- `bounds.generated.msr` — Asymmetry fit with tight explicit bounds and the FFT
block disabled.
- `t0background.generated.msr` — Asymmetry fit with fixed forward/backward t0
and fixed background values.
- `singlehist.fitted.msr` — a real SingleHist **fit result** (fittype 0,
`GaussianCos` model, 16 fitted parameters, converged `STATISTIC` block with
`maxLH/NDF 1.04011`, NDF 3644) captured from production. It is the anchor for
the reverse-parsing path: `tests/reference-fixtures.test.js` verifies that
muSRFlow reads it back into GUI state (`parseMSRFitStatistic`,
`parseMSRParameters`, `parseMSRTheoryModel`, `parseMSRGUISettings`).
- `global.generated.msr` — global-asymmetry fit (`AsymmetryGLB`, fittype 2) over
runs 2452-2460 with the `GaussianCos` model and a shared phase `Phi`. The
generator emits a single-RUN template (run 2452) that `msr2data` later expands
to all nine runs; the FITPARAMETER already carries the shared + per-run set.
- `global.fitted.msr` — the real **global fit result** over runs 2452-2460:
37 fitted parameters (one shared `Phi` + 9 runs x `Alpha`/`Asy`/`Sgm`/`Frq`),
converged `chisq/NDF 1.034138` (NDF 8198). Because the run-family THEORY shares
parameters through `mapN`, `parseMSRTheoryModel` deliberately refuses to
reconstruct it (safe guard, editor-owned) — the test asserts that refusal.
- `singlehist.generated.msr` — SingleHist detector-normalization workflow
(fittype 0): four histogram groups each with its own `No`/`NBg` normalization
and a detector-resolved phase, so the RUN blocks carry `norm` + `map`.
- `functions.generated.msr` — global-asymmetry workflow where the frequency is
expressed through a custom field parameter (`fun1 = gamma_mu * Pfield`), so
the generated MSR carries a `FUNCTIONS` block alongside THEORY.
> `missingdata` was on the original pending list but is **not** a `.generated.msr`
> workflow: `buildMSR()` has no "missing data" output. Missing data is a
> run-time concern (`classifyMissingDataOutput` reads musrfit output that says a
> data file was not found) and belongs to the integration/runner side, not the
> hermetic generation goldens.
## Regenerating a fixture
Edit the corresponding `config` in `tests/reference-fixtures.test.js`, write the
new `buildMSR()` output to `<name>.generated.msr`, and re-run the test. Only do
this when the generator change is intentional; otherwise the test guards against
unexpected drift. The real-fitted counterparts (`.fitted.msr`) used by the
later integration checks are produced by running `musrfit` on the generated MSR
against the configured data root.
## Integration checks
`tests/integration-musrfit.test.js` is gated on the presence of the real
`musrfit` binary and the fake data tree. When both are present it stages each
single-run `.generated.msr` fixture (rewiring its data path to the on-disk fake
data), runs `musrfit -e`, and asserts the fitted MSR's `STATISTIC` block matches
the recorded converged value (asymmetry `39.776426`, bounds `60.869627`,
t0/background `5.602355`, all NDF 406). It also round-trips every `.fitted.msr`
fixture through `parseMSRFitStatistic`. Without the tools it prints a skip
notice and exits successfully so the hermetic suite stays runnable on a bare
CI box.