Cctbx.xfel GUI/Energy tab: Difference between revisions

From cctbx_xfel
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:cctbx.xfel GUI/Energy tab}} The '''Energy tab''' calibrates the per-shot photon energy at LCLS. It is shown only when the facility is LCLS and the GUI is not in monitoring mode. The tab runs its calculations in the ''Calib Worker'' thread, whose light turns yellow while a calibration is running and green when it is idle. Back to cctbx.xfel GUI. == Background == At LCLS each shot's photon energy can be measured two ways: from the electron beam energy...")
 
No edit summary
 
Line 1: Line 1:
{{DISPLAYTITLE:cctbx.xfel GUI/Energy tab}}
{{DISPLAYTITLE:cctbx.xfel GUI/Energy tab}}
The '''Energy tab''' calibrates the per-shot photon energy at LCLS. It is shown only when the facility is LCLS and the GUI is not in monitoring mode. The tab runs its calculations in the ''Calib Worker'' thread, whose light turns yellow while a calibration is running and green when it is idle.
The '''Energy tab''' calibrates the per-shot photon energy at LCLS. It is present only when the facility is LCLS and the GUI is not in monitoring mode; otherwise both the tab and the ''Calib Worker'' light are absent. The ''Calib Worker'' light turns yellow while a calibration is running, green when it is idle, and red when a calibration failed; the reason is printed in the terminal, and the next calibration can be started straight away.


Back to [[cctbx.xfel GUI]].
Back to [[cctbx.xfel GUI]].
Line 10: Line 10:
# '''Ebeam calibration''': with the spectrometer calibrated, its per-shot energies are compared with the ebeam energies over a set of ordinary runs to find the constant '''ebeam offset''' (and the equivalent wavelength offset), so that the ebeam value can be corrected on shots where the spectrometer is unusable.
# '''Ebeam calibration''': with the spectrometer calibrated, its per-shot energies are compared with the ebeam energies over a set of ordinary runs to find the constant '''ebeam offset''' (and the equivalent wavelength offset), so that the ebeam value can be corrected on shots where the spectrometer is unusable.


The results are entered into [[cctbx.xfel GUI/Trials tab#Run block settings|run block settings]] (<code>spectrum_eV_per_pixel</code>, <code>spectrum_eV_offset</code>, <code>wavelength_offset</code>) so that processing jobs use the calibrated energies.
The results are entered into [[cctbx.xfel GUI/Trials tab#Run block settings|run block settings]] (the ''Spectrum'' and ''Wavelength'' rows) so that processing jobs use the calibrated energies. The run block dialog can take them straight from this tab, or from a file it saved.


== FEE Energy Scan Description ==
== FEE Energy Scan Description ==
* '''Experiment''': the LCLS experiment the scan runs belong to. Defaults to the experiment in Settings; change it if the scan was collected under a different experiment.
* '''Experiment''': the LCLS experiment the scan runs belong to. Defaults to the experiment in Settings; change it if the scan was collected under a different experiment.
* '''Max events''': how many shots of each run to average (200 by default). More shots give a cleaner spectrum but take longer.
* '''Max events''': how many shots of each run to average (200 by default). Must be a positive integer. More shots give a cleaner spectrum but take longer.
* '''Run / Notch Energy (eV)''' table: one row per calibration run. Click a cell to edit it. '''Add Row''' appends a row and '''Clear All''' empties the table.
* '''Run / Notch Energy (eV)''' table: one row per calibration run. Click a cell to edit it. '''Add Row''' appends a row and '''Clear All''' empties the table.
* '''Run Calibration''': checks that each run exists and each energy is a number, then runs the calibration in the background. Two plots fill in when it finishes: the '''trendline''' (notch position against energy, with the fitted line) and the '''spectra''' (each run's averaged spectrum with its detected notch). Each plot has a matplotlib toolbar for zooming and saving.
* '''Run Calibration''': checks that each run exists and each energy is a number (a dialog reports the offending entry otherwise), clears the previous results, then runs the calibration in the background. Two plots fill in when it finishes: the '''trendline''' (notch position against energy, with the fitted line) and the '''spectra''' (each run's averaged spectrum, with the detected notches labelled on the plot and a draggable legend listing the runs). Each plot has a matplotlib toolbar for zooming and saving.
 
Starting a new FEE calibration also discards the ebeam result, since that was measured against the previous spectrometer calibration; run the ebeam comparison again afterwards.


== Runs for Ebeam Calibration ==
== Runs for Ebeam Calibration ==
* The checklist shows every run in the database; '''Refresh''' picks up runs that arrived since the tab was opened and '''Clear''' unticks everything and clears the plot.
* The checklist shows every run in the database; '''Refresh''' picks up runs that arrived since the tab was opened and '''Clear''' unticks everything and clears the plot.
* Tick the runs to compare and press '''Run Calibration'''. The FEE calibration must have been run first, and each run must belong to a run block (the detector address is taken from it). Runs that are in no run block are skipped with a message in the terminal.
* Tick the runs to compare and press '''Run Calibration'''. The FEE calibration must have been run first (the button refuses with a dialog otherwise), and each run must belong to a run block (the detector address is taken from it). Runs that are in no run block, or that have no events with both a spectrometer and an ebeam reading, are skipped: the former with a message in the terminal, the latter with a note in the plot legend.
* The plot overlays the ebeam energies with the calibrated spectrometer energies for the selected runs. The worker writes a small locator file per run to an <code>energy</code> folder next to the output folder.
* The plot overlays the ebeam energies with the calibrated spectrometer energies for the selected runs.
* '''Clear''' unticks the runs and discards the ebeam result and its plot.


== Calibration Results ==
== Calibration Results ==
The box shows '''FEE eV per pixel''', '''FEE eV offset''' and '''Ebeam offset''' (in eV, with the equivalent wavelength offset in Å). '''Save calibration''' writes them as a PHIL file (default <code>fee/fee_calib.phil</code> next to the output folder):
The box shows '''FEE eV per pixel''', '''FEE eV offset''' and '''Ebeam offset''' (in eV, with the equivalent wavelength offset in Å). '''Save calibration''' is enabled once there is a result to save; it writes the results as a PHIL file (default <code>fee/fee_calib.phil</code> next to the output folder) and confirms the file name in the box:


<pre>spectrum_eV_per_pixel=...
<pre>spectrum_eV_per_pixel=...
Line 31: Line 34:
wavelength_offset=...</pre>
wavelength_offset=...</pre>


The first two go into the ''spectrum_eV_per_pixel'' and ''spectrum_eV_offset'' fields of a run block and the wavelength offset into its ''wavelength_offset'' field. Since changing those fields creates a new run block, do the calibration before starting the main processing where possible, or create a new trial with the calibrated run block afterwards.
The [[cctbx.xfel GUI/Trials tab#Run block settings|run block dialog]] has two buttons under its ''Spectrum'' row: '''Use Energy tab calibration''' copies the current results from this tab (enabled once the FEE calibration has run), and '''Load calibration file...''' reads a file saved here. Both fill the ''eV per pixel'' and ''eV offset'' fields, and the ''Wavelength offset'' when the ebeam comparison has been run. Since changing those fields creates a new run block, do the calibration before starting the main processing where possible, or create a new trial with the calibrated run block afterwards.

Latest revision as of 19:22, 2 November 2026

The Energy tab calibrates the per-shot photon energy at LCLS. It is present only when the facility is LCLS and the GUI is not in monitoring mode; otherwise both the tab and the Calib Worker light are absent. The Calib Worker light turns yellow while a calibration is running, green when it is idle, and red when a calibration failed; the reason is printed in the terminal, and the next calibration can be started straight away.

Back to cctbx.xfel GUI.

Background

At LCLS each shot's photon energy can be measured two ways: from the electron beam energy reported by the accelerator (the ebeam), and from the FEE spectrometer, which records the spectrum of every pulse on a one-dimensional detector. The spectrometer gives the better value, but its pixel axis must be calibrated into eV. This tab does that in two steps:

  1. FEE calibration: several short runs are collected with the beam energy stepped through a notch of known energy. Fitting the notch position in each run's average spectrum against the known energies gives the spectrometer's eV per pixel and eV offset.
  2. Ebeam calibration: with the spectrometer calibrated, its per-shot energies are compared with the ebeam energies over a set of ordinary runs to find the constant ebeam offset (and the equivalent wavelength offset), so that the ebeam value can be corrected on shots where the spectrometer is unusable.

The results are entered into run block settings (the Spectrum and Wavelength rows) so that processing jobs use the calibrated energies. The run block dialog can take them straight from this tab, or from a file it saved.

FEE Energy Scan Description

  • Experiment: the LCLS experiment the scan runs belong to. Defaults to the experiment in Settings; change it if the scan was collected under a different experiment.
  • Max events: how many shots of each run to average (200 by default). Must be a positive integer. More shots give a cleaner spectrum but take longer.
  • Run / Notch Energy (eV) table: one row per calibration run. Click a cell to edit it. Add Row appends a row and Clear All empties the table.
  • Run Calibration: checks that each run exists and each energy is a number (a dialog reports the offending entry otherwise), clears the previous results, then runs the calibration in the background. Two plots fill in when it finishes: the trendline (notch position against energy, with the fitted line) and the spectra (each run's averaged spectrum, with the detected notches labelled on the plot and a draggable legend listing the runs). Each plot has a matplotlib toolbar for zooming and saving.

Starting a new FEE calibration also discards the ebeam result, since that was measured against the previous spectrometer calibration; run the ebeam comparison again afterwards.

Runs for Ebeam Calibration

  • The checklist shows every run in the database; Refresh picks up runs that arrived since the tab was opened and Clear unticks everything and clears the plot.
  • Tick the runs to compare and press Run Calibration. The FEE calibration must have been run first (the button refuses with a dialog otherwise), and each run must belong to a run block (the detector address is taken from it). Runs that are in no run block, or that have no events with both a spectrometer and an ebeam reading, are skipped: the former with a message in the terminal, the latter with a note in the plot legend.
  • The plot overlays the ebeam energies with the calibrated spectrometer energies for the selected runs.
  • Clear unticks the runs and discards the ebeam result and its plot.

Calibration Results

The box shows FEE eV per pixel, FEE eV offset and Ebeam offset (in eV, with the equivalent wavelength offset in Å). Save calibration is enabled once there is a result to save; it writes the results as a PHIL file (default fee/fee_calib.phil next to the output folder) and confirms the file name in the box:

spectrum_eV_per_pixel=...
spectrum_eV_offset=...
ebeam_eV_offset=...
wavelength_offset=...

The run block dialog has two buttons under its Spectrum row: Use Energy tab calibration copies the current results from this tab (enabled once the FEE calibration has run), and Load calibration file... reads a file saved here. Both fill the eV per pixel and eV offset fields, and the Wavelength offset when the ebeam comparison has been run. Since changing those fields creates a new run block, do the calibration before starting the main processing where possible, or create a new trial with the calibrated run block afterwards.