Tracking Fit Tour¶
A tour of ArcByArcFitter and
ACDMarkerFitter: what each part of the code does, in the
order it runs. The other fitters differ only in where the particles start and which
readings are compared (Fit Families). Other model backends are described in
Model backends. Underlined words are defined in the Glossary at the bottom
of the page.
The idea¶
Package map¶
accelmo.configOptimiserConfig,WorkerRuntime,TrackingDataConfigandTrackingParameters.accelmo.trackingThe tracking fitters.
accelmo.fittingParts shared with the closed-orbit fitters.
setup.py: model, BPM list, starting knobsworker.py: base workerprotocol.py: messages between processesreduction.py: sums the worker results
accelmo.machineAccelerator models.
accelerators/: LHC, SPS, PSB, FCCmad/: MAD-NG setup and tracking scripts
accelmo.optimisersUpdate rules:
adam.py,lbfgs.py.
Not used by the tracking fitters: poco, analysis, runlog, monitor.
tracking ──▶ fitting ──▶ machine
│
└─▶ optimisers
Fitter input¶
The fitter reads one parquet file per measurement with the columns
name, turn, bunch_number, x, px, y, py, var_x, var_y, var_px, var_py.
Arc-by-arc vs ACD marker¶
Both fitters run the same code. They differ in which parts of the ring are tracked.
Left, ArcByArcFitter: tracks every start BPM to every end BPM, forward (teal) and
backward (orange), for one turn. With acd_excited=True, a range containing the
AC dipole is tracked round the other side of the ring (dashed).
Right, ACDMarkerFitter: two tracks round the whole ring: forward from
<acd>_after, backward from <acd>_before.
ArcByArcFitter |
ACDMarkerFitter |
|
|---|---|---|
Plan class |
|
|
Tracks per batch |
starts × ends × 2 |
2 |
Start point |
first BPM of the range |
ACD marker |
BPMs compared |
BPMs inside the range |
all BPMs |
Both setup functions live in tracking/config/tracking.py.
Trace one fit¶
From fitter = ArcByArcFitter(...) to fitter.run(). Paths are relative to
src/accelmo/.
1. Construction (main process)¶
Step |
Code |
What it does |
|---|---|---|
Pick the plan |
|
The fitter calls its setup function, which returns the plan. |
Load the model |
|
|
Filter BPMs |
|
Removes bad BPMs from the start and end lists. |
Load the data |
|
|
Create the loop |
|
|
2. Start the workers (main process)¶
Step |
Code |
What it does |
|---|---|---|
|
|
Calls |
Build payloads |
|
For each tracking range and each batch, collects the BPMs, the measured data and the weights into one payload. |
Spawn |
|
Starts one |
3. Worker startup (worker process, MAD-NG)¶
Step |
Code |
What it does |
|---|---|---|
Wait for messages |
|
Receives |
Load MAD-NG |
|
Loads its own copy of the machine and rotates the sequence to start at its first BPM or marker. |
Make knobs differentiable |
|
Adds each knob as a TPSA parameter. |
Load particles |
|
Creates one particle per measured turn, at the measured start coordinates. |
4. Optimisation loop (all processes)¶
Step |
Code |
What it does |
|---|---|---|
Send knobs |
|
Sends |
Track |
|
MAD-NG tracks the batch and stores x, y and their knob derivatives at each BPM. |
Loss and gradient |
|
loss = Σ w·(model − measured)². Sends back the loss and gradient as a
|
Step |
|
Sums the gradients from all workers and updates the knobs with Adam or
L-BFGS. With a |
End of epoch |
|
Computes the validation loss, saves the best knobs, checks whether to stop, and prints one log line. |
5. Finish (main process, workers)¶
Step |
Code |
What it does |
|---|---|---|
Uncertainties |
|
Each worker sends its part of the uncertainty matrices, then stops. |
Return the result |
|
Returns a |
Messages between processes¶
Defined in fitting/protocol.py. The main process talks to every
worker with three messages: Start, Evaluate and Stop.
Batch step¶
Runs once per batch.
Glossary¶
- AC dipole¶
A magnet that drives the beam to oscillate. Short form: ACD.
- batch¶
A group of measured turns. Each turn is one particle in a worker.
- BPM¶
Beam position monitor. Measures the beam’s x and y position each turn.
- bunch¶
A group of particles in the beam. Each bunch is processed separately.
- epoch¶
One pass over all batches.
- kick¶
The moment the beam is excited. Turns before it are dropped.
- knob¶
A fitted parameter, usually a magnet strength.
- MAD-NG¶
The accelerator simulation code. Each worker runs its own copy.
- parquet¶
The file format of the measurement data.
- payload¶
Everything one worker needs to start: its BPMs, measured data and weights.
- plan¶
The class that sets the tracking ranges for a mode.
- TPSA¶
A number that carries its derivatives with it. Tracking with TPSA gives derivatives without extra runs.
- turn¶
One trip of the beam around the ring.
- validation worker¶
A worker that tracks held-out turns and reports only a loss.
- worker¶
A separate process that tracks part of the data.