Introduction
LCLS2 DAQ supports three types of scans:
- epics PV step-scans using bluesky.
- "on-the-fly" scans of epics PVs
- detector configuration scans
On-The-Fly Scans
These are the simplest scans to run where the DAQ is free-running and a PV is changed while taking data. It's advantages are that it is simpler to run and sometimes quicker (since one does not pause the DAQ to move a motor, for example). A disadvantage is that on a per-shot basis one does not know the precise value of the PV, since the PV is typically only recorded at 1Hz in epicsArch. An example script to move a PV while the DAQ is taking data:
from epics import caget, caput, cainfo val = 790000 delta = 7000 import time while 1: val += delta caput('IM3K4:PPM:CAM:EVR:TRIG4:TDES',val) print(caget('IM3K4:PPM:CAM:EVR:TRIG4:TDES')) time.sleep(5)
EPICS PV Step-Scans
EPICS PV step scans use the BlueSky software from BNL (https://nsls-ii.github.io/bluesky/). In this mode one or more PV's are modified while the DAQ is paused, then data is acquired (either for a fixed number of shots or a fixed time) then the DAQ is paused again and the PV is modified again for the next "step". BlueSky supports complex coordinated motion of multiple PV's.
An example python script has been created to demonstrate support for PV scans with the RIX instrument.
The source code is here: https://github.com/slac-lcls/lcls2/blob/master/psdaq/psdaq/control/rix_bluesky_scan.py
This script scans a simulated motor at 15 equally spaced points from -10 to 10, recording 120 events at each point. The number of events per step can be adjusted using a command line argument. A user with knowledge of the direct motor should update the script to replace the simulated motor.
The parameters of the scan should be updated to match the requirements of the experiment. To do so, update this section of bluesky_rix.py:
# Scan motor1 from -10 to 10, stopping # at 15 equally-spaced points along the way and reading dets. RE(scan(dets, motor1, -10, 10, 15))
Here is the script running with default settings (see below for optional arguments):
$ python bluesky_rix.py Transient Scan ID: 1 Time: 2020-12-10 18:24:53 Persistent Unique Scan ID: '2092a9ca-160c-4b52-8683-256f699e1e01' New stream: 'primary' +-----------+------------+------------+ | seq_num | time | motor1 | +-----------+------------+------------+ | 1 | 18:24:58.5 | -10.000 | | 2 | 18:24:59.6 | -8.571 | | 3 | 18:25:00.6 | -7.143 | | 4 | 18:25:01.6 | -5.714 | | 5 | 18:25:02.7 | -4.286 | | 6 | 18:25:03.7 | -2.857 | | 7 | 18:25:04.8 | -1.429 | | 8 | 18:25:05.8 | 0.000 | | 9 | 18:25:06.8 | 1.429 | | 10 | 18:25:07.9 | 2.857 | | 11 | 18:25:08.9 | 4.286 | | 12 | 18:25:10.0 | 5.714 | | 13 | 18:25:11.0 | 7.143 | | 14 | 18:25:12.0 | 8.571 | | 15 | 18:25:13.1 | 10.000 | +-----------+------------+------------+ generator scan ['2092a9ca'] (scan num: 1)
$ python bluesky_lab3.py Transient Scan ID: 1 Time: 2021-02-21 16:33:15 Persistent Unique Scan ID: 'fb4d16b7-2844-431e-bb77-cc90cd1f2fe0' New stream: 'primary' +-----------+------------+------------+------------+ | seq_num | time | motor1 | step_value | +-----------+------------+------------+------------+ | 1 | 16:33:19.7 | -10.000 | 0 | | 2 | 16:33:19.8 | -8.571 | 1 | | 3 | 16:33:19.9 | -7.143 | 2 | | 4 | 16:33:20.0 | -5.714 | 3 | | 5 | 16:33:20.1 | -4.286 | 4 | | 6 | 16:33:20.3 | -2.857 | 5 | | 7 | 16:33:20.4 | -1.429 | 6 | | 8 | 16:33:20.5 | 0.000 | 7 | | 9 | 16:33:20.6 | 1.429 | 8 | | 10 | 16:33:20.7 | 2.857 | 9 | | 11 | 16:33:20.8 | 4.286 | 10 | | 12 | 16:33:20.9 | 5.714 | 11 | | 13 | 16:33:21.0 | 7.143 | 12 | | 14 | 16:33:21.1 | 8.571 | 13 | | 15 | 16:33:21.2 | 10.000 | 14 | +-----------+------------+------------+------------+ generator list_scan ['fb4d16b7'] (scan num: 1)
Preparing for a PV Scan
As a general rule, one should always verify that the DAQ is running well in "normal" mode before attempting to run a scan.
Some specific tips:
- Make sure all the detectors to be used are configured properly.
- Make sure the timing system is configured properly. As of this writing, RIX uses readout groups 2 and 5.
- When you're ready to record a scan, don't forget to enable recording before running bluesky_rix.py! In the control GUI, the disk icon has a diagonal line over it when not recording.
- Use the "normal" DAQ interface to select the detectors of interest as "active" and assign their readout groups.
- Put the DAQ in ALLOCATED or CONNECTED state. Now, you are ready to run bluesky_rix.py.
The bluesky_rix.py script accepts several command line arguments. If you are relying on the default settings, make sure they are correct for your experiment now, not just way back in 2020 when the script was first written.
$ python bluesky_rix.py -h usage: bluesky_rix.py [-h] [-B PVBASE] [-p {0,1,2,3,4,5,6,7}] [-x XPM] [-C COLLECT_HOST] [-t TIMEOUT] [-c READOUT_COUNT] [-g GROUP_MASK] [--config ALIAS] [-v] optional arguments: -h, --help show this help message and exit -B PVBASE PV base (default DAQ:NEH) -p {0,1,2,3,4,5,6,7} platform (default 2) -x XPM master XPM (default 0) -C COLLECT_HOST collection host (default drp-neh-ctl001) -t TIMEOUT timeout msec (default 10000) -c READOUT_COUNT # of events to aquire at each step (default 120) -g GROUP_MASK bit mask of readout groups (default 36) --config ALIAS configuration alias (default BEAM) -v be verbose
Detector Configuration Scans
These scans use the same "step" idea described above for EPICS PV step-scans, but instead alter a detector configuration object on each step. Currently this has been done for the EPIX area detector to take data in the various gain ranges.
Script Control of Run Stop/Start
One can control the DAQ (e.g. to stop and start runs on a timer) with scripts like this:
#!/bin/bash while [ 1 ] do echo going to configured daqstate -p 0 -P tmo -C drp-neh-ctl001 --state configured sleep 5 echo going to running daqstate -p 0 -P tmo -C drp-neh-ctl001 --state running sleep 600 done
Running Scans with Hutch Python
An example hutch-python scan session in RIX:
rix-daq:~> rix3 Loading local disk python env pcds-4.1.4 _ _____ _ _ (_) | __ \ | | | | _ __ ___ _| |__) | _| |_| |__ ___ _ __ | '__| \ \/ / ___/ | | | __| '_ \ / _ \| '_ \ | | | |> <| | | |_| | |_| | | | (_) | | | | |_| |_/_/\_\_| \__, |\__|_| |_|\___/|_| |_| __/ | |___/ INFO Selected default hutch-python daq platform: 0 INFO Loading debug tools... (lines removed for brevity) In [1]: daq=get_daq() In [2]: dets = [daq] In [3]: daq.configure(motors=[sim.fast_motor1, sim.fast_motor2, step_value]) INFO configure: 3 motors Out[3]: ({}, {}) In [4]: RE(bp.scan(dets, sim.fast_motor1, 1, 10, sim.fast_motor2, 1, 10, step_va ...: lue, 1, 10, 10)) Transient Scan ID: 1 Time: 2021-05-14 21:49:10 Persistent Unique Scan ID: '84de9d9f-24a4-4065-bb07-669069fe59a4' New stream: 'primary' +-----------+------------+-------------+-------------+------------+ | seq_num | time | fast_motor1 | fast_motor2 | step_value | +-----------+------------+-------------+-------------+------------+ | 1 | 21:49:22.9 | 1 | 1 | 1 | | 2 | 21:49:24.0 | 2 | 2 | 2 | | 3 | 21:49:25.1 | 3 | 3 | 3 | | 4 | 21:49:26.2 | 4 | 4 | 4 | | 5 | 21:49:27.3 | 5 | 5 | 5 | | 6 | 21:49:28.4 | 6 | 6 | 6 | | 7 | 21:49:29.5 | 7 | 7 | 7 | | 8 | 21:49:30.6 | 8 | 8 | 8 | | 9 | 21:49:31.7 | 9 | 9 | 9 | | 10 | 21:49:32.8 | 10 | 10 | 10 | +-----------+------------+-------------+-------------+------------+ generator scan ['84de9d9f'] (scan num: 1) Out[4]: ('84de9d9f-24a4-4065-bb07-669069fe59a4',) In [5]: daq.push_socket.send_string('shutdown') In [6]: mydaq.comm_thread.join() In [7]: quit
If the "shutdown" and "join" commands are not issued then the "quit" command will hang, and you will have to control-C to end the program.