Fit Families¶
A fit changes knobs until a model reproduces a measurement. This page lists what can be measured, which fitter reads it, what is fitted and which solver runs.
What every fit does¶
Load the machine (sequence, beam, energy) and create one knob per fitted magnet attribute.
Split the measurement across worker processes. Each worker owns one MAD-NG instance.
Send the current knobs to every worker. Each worker returns the model prediction at the BPMs and its derivative with respect to every knob.
Sum the weighted squared residuals into a loss and a gradient.
Update the knobs with the optimiser. Repeat from step 3.
Return the best knobs, their 1-sigma uncertainties and why the fit stopped (
FitResult).
Two engines¶
Tracking ( |
POCO ( |
|
|---|---|---|
Measurement |
Turn-by-turn BPM data: |
Closed orbit, or closed twiss (orbit, beta, phase, dispersion), at one or more momenta |
Model side |
MAD-NG |
MAD-NG closed-orbit solve and parametric |
Solver |
Adam, L-BFGS or Levenberg-Marquardt ( |
Levenberg-Marquardt |
Split of the data |
Batches of turns, one particle per turn; held-out validation turns |
One worker per series of measurements |
Result |
|
|
The engines share the worker protocol, the worker pool, the weights, the uncertainty
estimate and the run log (accelmo.fitting). They do not import each other.
Tracking fitters¶
All tracking fitters are subclasses of TrackingFitter.
They differ in where the particles start, which direction they are tracked, and which BPM
readings are compared.
Fitter |
Start coordinates |
Tracking |
Readings compared |
|---|---|---|---|
Measured, at the first BPM of each range |
One turn, forward and backward over every |
BPMs inside each range |
|
|
Same |
Same. A range that contains the AC dipole is tracked the other way round the ring |
BPMs inside each range |
Measured, at the AC-dipole |
One turn, forward from |
All BPMs |
|
Measured, at the kicker marker rows |
|
All BPMs |
|
Measured, at the before-marker every |
Back-to-back |
All BPMs, every turn |
Each fitter builds a tracking plan (tracking/config/tracking.py) that fixes the ranges
and the markers. The step-by-step run of one fit is in Tracking Fit Tour.
Measurement files¶
One parquet file per measurement, with the columns
name, turn, bunch_number, x, px, y, py, var_x, var_y, var_px, var_py.
MeasurementConfig maps each file to a
MeasurementDetails (MAD interface options,
momentum offset machine_deltap, first_bpm). Columns, units and the machine state are
described in Measurement Data.
ACDMarkerFitterandACDSinusoidFitterneed<acd>_beforeand<acd>_afterrows.KickerFitterneedsx,px,y,pyat the kicker marker.
Tracking fit options¶
These TrackingParameters fields (FitterOptions.parameters) change
what a tracking fit parameterises. All but bpm_gain_sigma need a Levenberg-Marquardt fit
(solver=tracking_lm_config(n), tracking_lm_config()).
The last two rows are TrackingDataConfig fields.
Field |
Effect |
|---|---|
|
Every particle’s start |
|
One gain per BPM and plane, reading = (1 + g) x position, with a Gaussian prior of this width |
|
Starts are functions of the BPM gains; the gradient includes that path
( |
|
Holds the mean gain of the listed planes at zero |
|
Zero-centred Gaussian prior on named knobs |
|
Includes |
|
Held-out and used fractions of the turns of each file |
POCO fitters¶
All POCO fitters are subclasses of LMFitter and use
Levenberg-Marquardt.
Fitter |
Measurement |
Fitted in addition to the knobs |
|---|---|---|
|
Nothing; |
|
Same |
BPM gains and corrector kick gains, with Gaussian priors |
machine_state is a set of fixed MAD globals (quadrupole strengths, corrector kicks, tune
knobs). Planes listed in absolute_planes are fitted as absolute orbits; the other planes
are fitted as the change from the fitter’s own machine_state, using each measurement’s
reference orbit.
Knob families¶
Accelerator(errors=..., misalignments=...) chooses what is fitted. Both are dictionaries
from a family name to a set of attributes. Each family is a group of magnets selected by a
name pattern. Elements whose nonzero attribute is zero get no knob.
Machine |
Family |
Element pattern |
|
|
|---|---|---|---|---|
LHC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
||
PSB |
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
SPS |
|
|
|
|
|
|
|
||
FCC |
|
|
|
|
|
|
|
Other fitted parameters:
optimise_energy=TrueFits the beam momentum offset
pt.custom_knobs_to_optimiseExtra global MAD variables, by name.
Knob names follow the element name, for example MQ.12R3.B1.dk1l (integrated gradient
error) and <element>.tilt. A tilt knob starts at 1e-9 rad. Values the fitter reports are
in optimisation space.
Solvers¶
|
Behaviour |
|---|---|
|
Mini-batch gradient descent: one step per batch, learning rate warmup then decay |
|
Quasi-Newton step with a normalised gradient, history |
|
Gauss-Newton step with damping, over every batch. Required by the options above that add parameters |
stage_epochs runs the fit in stages that restart the learning-rate schedule. The POCO
fitters always use Levenberg-Marquardt, configured by
LevenbergMarquardtConfig.