Centre and close an L3-style slit aperture
Four-phase L3-style slit procedure: (1) drive the virtual-motor
Hcenter / Vcenter so the beam image lands at the centre
of the detector frame; (2) incrementally close Hsize /
Vsize to a target size (typically 0 = fully closed); (3)
rezero the virtual motors – redefine the current physical
pose as the new origin so the four virtual motors read 0 at the
closed + centred position; (4) reopen the slits to the
original aperture (snapshot’s Hsize / Vsize, e.g. 1 mm)
so the operator ends with a usable beam through a centred slit.
Phases 3 and 4 are both default-enabled but gated per axis;
--no-rezero / --no-reopen skip the respective phase.
The procedure is parameterised over which slit station to target:
A (front-end L3 Slits at z = 25225 mm) or B (2-BM-B
entrance L3-style slits at z = 50500 mm, default). The four
virtual-motor PVs for each station follow the same template
<PREFIX>Hcenter, <PREFIX>Vcenter, <PREFIX>Hsize,
<PREFIX>Vsize; see Beamline components for the per-
station prefix.
Name
centre_and_close_slits
Source
Implementation: procedures/centre_and_close_slits.py
Release notes: 2bm-procedures CHANGELOG
Devices
Beamline components: A-station L3 Slits OR B-station L3-style Slits – selected via the
--slit-stationflag. The procedure drives the fouraovirtual-motor PVs (Hsize,Hcenter,Vsize,Vcenter) and polls the four underlying blade motors’.DMOVto detect motion completion.Beamline components: MCTOptics – read only. Camera + lens are auto-detected from
2bm:MCTOptics:CameraSelect / LensSelectas in Detector Z-rail alignment to the beam.Beamline components: Detector microscope (whichever Camera/Lens is currently selected) – used to image the beam spot for centroid measurement.
Preconditions
Same upstream preconditions as Detector Z-rail alignment to the beam (see its Preconditions table for the full machine-readable list, including PSS hutches secure, ACIS permit, FES + B-shutter open, energy configured, sample out of beam). The procedure-specific preconditions:
State |
Predicate |
Satisfied by |
|---|---|---|
|
The chosen slit has Hsize > 0 and Vsize > 0 (i.e. some beam reaches the detector). Procedure aborts at calibration if no centroid signal. |
operator (slit must be open enough to see a beam spot) |
|
The current camera+lens combination produces a centroid above threshold for the current beam state. Tested implicitly: calibration’s baseline centroid measurement fails with the upstream-precondition checklist if no signal. |
cascade of all upstream preconditions for Detector Z-rail alignment to the beam |
Operating envelope (v0.0.1)
Per-motion confirmation gate on every slit move (centring perturb / restore / iteration correction, every closing step).
Snapshot + restore for slit Hcenter, Vcenter, Hsize, Vsize plus camera state. On clean completion the new (centred, closed) state is kept; on abort the procedure restores everything to baseline.
Centring divergence guard: aborts if centroid error magnitude grows by >1.5× between consecutive iterations.
Centring sensitivity sanity floor: if the 2x2 matrix M has
|det| < min(default 1.0 pix²/mm²), the procedure aborts with a clear “calibration step too small” message. Operator remedy:--centring-step-mm 1.0or larger.
Parameters
Name |
Type |
Unit |
Description |
|---|---|---|---|
|
|
— |
Which station’s slits to drive. Default: |
|
> 0 |
mm |
Perturbation applied to Hcenter / Vcenter during sensitivity calibration. Default: 0.5. |
|
> 0 |
pixels |
Centroid must be within N pixels of the frame centre in
both axes to declare centring converged. Default: 15
(at the COM noise floor on 2-BM-B’s multilayer-stripe
images; tightening below ~15 pix requires frame averaging
via |
|
> 1 |
× |
Abort centring if |
|
≥ 1 |
— |
Default: 5. |
|
0 < d ≤ 1 |
— |
Per-iteration correction multiplier. Default: 0.5. |
|
> 0 |
mm |
Clip on per-iteration |
|
> 0 |
mm |
Size reduction per closing step (H and V alternating). Default: 0.1. |
|
≥ 0 |
mm |
Final H aperture. Default: 0 (fully closed). |
|
≥ 0 |
mm |
Final V aperture. Default: 0. |
|
bool |
— |
If True (default), after closing the procedure rezeros the
four virtual motors by setting the per-axis |
|
bool |
— |
If True (default), after rezero (or after closing, if
rezero is disabled) the procedure caputs the snapshot’s
original |
|
> 0 |
s |
Camera exposure. Default: 0.2. |
(Common parameters with Detector Z-rail alignment to the beam — centroid_algorithm,
threshold_fraction, bg_corner_size, bg_sigma_threshold,
frames_per_measurement, camera_pixel_um, --yes,
--confirm-restore, --dry-run, --log-level — are
documented there.)
Steps
# |
Action |
PV / call |
|---|---|---|
1 |
Detect operator-set configuration. Read MCTOptics
CameraSelect / LensSelect; derive |
|
2 |
Snapshot pre-procedure state: slit Hcenter, Vcenter, Hsize, Vsize, full camera state. |
|
3 |
Calibrate centring sensitivity matrix M (2×2):
(b) [gated] Perturb (c) [gated] Same for (d) Sanity-check: Logs SVD singular values and condition number; warns when
|
|
4 |
Iterate centring: for
(b) If both (c) Divergence guard: abort if (d) [gated] Compute correction
|
|
5 |
Close slits: alternating H / V size reduction in
|
|
6 |
Phase 3 (default ON): Rezero. For each axis (H, V), separately gated: (a) (b) (c) IRREVERSIBLE. Once any rezero write is issued, the
snapshot-restore for slits is disabled: the pre-rezero
baseline values are in the old coordinate system, and
writing them back through the new origin would
physically move the slits to arbitrary positions.
Operator can answer Skip the entire phase via the |
4 |
7 |
Phase 4 (default ON): Reopen. Per axis, gated:
caput the snapshot’s original Skip with the |
|
8 |
Restore. Run by
Camera state always restored. Slit restore order: Hcenter → Vcenter → Hsize → Vsize. |
|
Postconditions
On clean completion:
Centroid is within
centring_threshold_pixof the frame centre in both axes (at the time of the final centring measurement).Hsize == target_h_size_mmandVsize == target_v_size_mm(typically both 0) or the beam was no longer above threshold at a size slightly above target.Camera state restored to the operator’s pre-procedure values.
The slit virtual motors’ final state depends on which phases ran:
Default (rezero + reopen both on): virtual motors read
Hcenter = Vcenter = 0andHsize = Vsize = original aperture(e.g. 1 mm). New origin is defined; slits are open at the original aperture centred on the beam axis.``–no-reopen``: virtual motors read
Hsize = Vsize = 0(slits closed). Origin set if rezero ran.``–no-rezero`` (+ default reopen): slits open at the original aperture, centred on the corrected pose; coordinate system unchanged from pre-procedure.
``–no-rezero –no-reopen``: slits closed at the new centred pose, no coordinate change. Useful for verification.
On abort:
All four slit virtual motors restored to snapshot baseline.
Camera state restored.
Failure modes
Symptom |
Recovery |
|---|---|
|
|
Calibration baseline centroid fails (“no signal above threshold”). |
One of the upstream preconditions failed – the error message prints a checklist. Open FES + B-shutter, verify beam, slits open wide enough, etc. |
Sensitivity matrix near-singular. |
The slit-centre perturbation produced negligible
centroid motion. Try larger |
Centring diverges (error grows >1.5× iter-to-iter). |
The sensitivity matrix M has a sign or magnitude error.
Re-run calibration with a larger |
Centring runs out of iterations without converging. |
Restore puts slits back to baseline. Increase
|
Closing step makes the beam disappear earlier than expected (e.g. at H = 0.3 mm rather than 0.1). |
Not a failure – the procedure logs the H/V at which the beam disappeared and exits successfully. The “closed past beam” criterion is intentional: it confirms the slits actually cut off the beam. |
Operator walkthrough
Confirm upstream preconditions (FES, B-shutter, beam, sample out of beam, detector visible on MEDM).
Launch with default flags;
--slit-station Bis the default.The first ~4 prompts confirm centring-sensitivity calibration motions (perturb Hc, restore, perturb Vc, restore). Each is a small move (default 0.5 mm) and should produce a visible centroid shift on the live view.
After M is logged with a reasonable condition number (< 10), iteration begins. Each iter prompts once for the (Hcenter, Vcenter) pair correction. Centroid should drop toward the frame centre.
Once centred (within
centring_threshold_pix), the closing phase starts. Each step is a 0.1 mm reduction; the operator sees the spot shrink on the live view.Procedure exits when both sizes reach 0 or the beam disappears.
The y/N gate at the terminal is the operator’s safety check –
read the plan block before answering y. If anything looks
wrong (PV name, sign, magnitude), answer N and the
procedure restores cleanly.
Notes
The 8.6 µrad-scale precision of Detector Z-rail alignment to the beam is not the goal here: this procedure positions the slits in millimetres, not the rail in microradians.
centring_threshold_pix = 5with bin 2×2 at 1.1× means the centroid is within 5 × 6.27 / 1.1 ≈ 28 µm object-side – fine for slit centring.The closing phase is intentionally sequential (H step, measure, V step, measure, …) rather than simultaneous: each step gives the operator a fresh image to confirm the beam is shrinking as expected, and the centroid measurement detects the “beam disappeared” condition that ends the loop.
The slit virtual motors (
aorecords) drive downstream calc records which in turn drive the underlying blade motors. The procedure usesmove_table_axisfor motion-done because the pattern is the same as the detector optical table: write the soft PV, poll the underlying motors’.DMOV.Open trigger this procedure creates: register a per-station
SlitAsset on the cora side and acentre_and_close_slitsProcedure record incora/docs/deployments/2-bm/procedures.md.