Let param models take initial parameters from the input file - #148
Merged
Conversation
The smooth (extended) ABCD models could only start the fit from pre-computed polynomial coefficients via a standalone file passed on the command line, which has to be kept in sync with the datacard by hand. Let the tool that writes the datacard ship them instead, in an auxiliary bundle of the input file itself. - auxiliary: add 'initial_params_name' fixing the bundle naming convention (initial_params_<model>_<process>_<channel>) and 'read_initial_params' to decode a bundle into (params, order) - smooth_extended_abcd_model: factor the 'params:' token parsing into 'resolve_params_token' and add the 'aux:<name>' spec next to the file paths - SmoothExtendedABCDIsoMT: with neither 'params:' nor 'order:' given, look up the canonical bundle name and use it if the input file carries one, so no extra CLI token is needed. An explicit 'order:N' keeps starting from zero. - add tests for all four resolution paths Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4WA7YjkNDZCubSrjaUWjd
davidwalter2
added a commit
to davidwalter2/WRemnants
that referenced
this pull request
Aug 10, 2026
Getting the initial parameters for the SmoothExtendedABCDIsoMT param model required running regen_smoothing_params.py separately and passing the resulting file to rabbit_fit.py via 'params:PATH'. That file has to be kept in sync with the templates by hand. Compute the same coefficients while setting up the fit and store them as an auxiliary bundle in the output file, where rabbit picks them up by itself, so the fit command needs no 'params:' token at all. - rabbit_helpers: add 'compute_smoothing_params', the computation previously inline in regen_smoothing_params.py, which now calls it and writes the same standalone file as before - setupRabbit: build the extended ABCD fake selector for the fake group, derive the coefficients and add them as auxiliary data under the name rabbit looks for. Only when the ABCD relation is actually solved in the fit (--fakeEstimation none with mt and relIso fit axes), disable with --noSmoothingParams - bump rabbit to the branch adding the auxiliary lookup (WMass/rabbit#148) regen_smoothing_params.py is kept for deriving the starting values from a different input file than the one that is fit. Verified that the stored parameters are bit-identical to the ones from regen_smoothing_params.py, and that a fit reading them from the input file converges (edmval 2.6e-13). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4WA7YjkNDZCubSrjaUWjd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The smooth (extended) ABCD models can start the fit from pre-computed polynomial coefficients, but so far only via a standalone file passed on the command line (
params:file.hdf5). That file has to be kept in sync with the datacard by hand — if the templates are regenerated with a different binning or a different input, nothing notices.This lets the tool that writes the datacard ship the starting values instead, in an
auxiliarybundle of the input file itself, where they cannot drift away from the templates they were derived from.Changes
rabbit/auxiliary.pyinitial_params_name(model, process, channel)fixes the bundle naming convention:initial_params_<model>_<process>_<channel>.read_initial_params(indata, name)decodes a bundle into(params, order).rabbit/param_models/smooth_extended_abcd_model.pyparams:token parsing is factored intoresolve_params_token(token, indata), which gains anaux:<name>spec alongside the existing.hdf5/np.loadpaths.rabbit/param_models/abcd_isomtmt_model.pySmoothExtendedABCDIsoMTresolves its starting values in this precedence:params:aux:<name>params:<file.hdf5>order:Ninitial_params_SmoothExtendedABCDIsoMT_<process>_<channel>if present, else zerosSo a datacard that carries the bundle needs no extra CLI token at all.
The generic
SmoothExtendedABCDgetsparams:aux:<name>but no automatic lookup — its six region dicts do not give an unambiguous(process, channel)pair to build a default name from.Notes
params:<file.hdf5>andorder:Nbehave as before, and a datacard without the bundle starts from zero as before.orderfrom the file as a bare ndarray rather than anint.Testing
New
tests/test_param_model_initial_params.pycovers all four resolution paths, plus an unknown bundle name raising. Full suite: 21 passed.Exercised end to end from WRemnants (
setupRabbit.pywriting the bundle,rabbit_fit.pyconsuming it with noparams:token): the model logsUsing initial parameters from auxiliary bundle 'initial_params_SmoothExtendedABCDIsoMT_Fake_ch0' of the input file (order 3), the starting values match the standalone file bit-for-bit, and the fit converges (edmval 2.6e-13).🤖 Generated with Claude Code
https://claude.ai/code/session_01N4WA7YjkNDZCubSrjaUWjd