Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

 

XTCAV The XTCAV (X-band Transverse deflecting mode CAVity) is a detector that is used to determine the laserx-ray power vs. time of each LCLS shot. Some detailed documentation from Tim Maxwell on this device is Here. Alvaro Sanchez-Gonzalez authored the original psana-python code to do the rather complex analysis of images from the XTCAV camera to determine these quantities. This current version has been updated to run more quickly and to fix some analysis errors.

These scripts use some XTCAV data that was made public so they should be runnable by all users. The scripts can be found in <TJ HELP PLEASE> in the files xtcavDark.py, xtcavLasingOff.py, xtcavLasingOn.py.

Quickstart

XTCAV analysis is a three step process involving "dark", "lasing off", and "lasing on" runs. First, we process dark runs, which are runs without any electron bunches. We take the average of a series of dark run images to get the general pixel values of the camera background. We can then subtract this "average image" from the lasing on and off runs to get a closer approximation of the actual energy of the electron bunches. We then process the lasing off runs, which are images of electron bunches without any lasing. We take a series of these images, subtract the average background (from previous step), and zero-out all noise around the region of interest. From this cleaned up image, we can calculate the electron current, the energy dispersion and center of mass, and other physical properties of the electron bunch. We then cluster together these lasing off images into an (optimally or manually chosen) number of groups based of of the electron current. The properties of these profiles are then averaged to create an aggregate lasing off profile. This is done to help reduce noise in the image as well as to speed up the process of choosing a lasing off reference in the lasing on analysis (discussed next). For the lasing on runs, we process each image individually in a similar manner to the lasing off images. Once we calculate the physical properties, we choose an aggregated lasing off profile with the most similar electron current. Then, using either the energy loss or energy spread methods, we can calculate the power of the electron bunch.  

Here are some examples of command line tools and output using the scripts located in xtcav/bin:

Dark

Code Block
languagepython
xtcavDark amox23616 104 --max_shots 400

Output

Code Block
languagepython
dark background reference
  Experiment: amox23616
  Run: 104
  Valid shots to process: 400
100.0 % done, 400 / 400
Maximum number of images processed

...

Code Block
languagepython
xtcavLasingOff amox23616 131 --max_shots 200

...

Code Block
languagepython
Lasing off reference
	 Experiment: amox23616
	 Runs: 131
	 Number of bunches: 1
	 Valid shots to process: 200
	 Dark reference run: None
100.0 % done, 200 / 200
Averaging lasing off profiles into  12  groups.

 

Lasing On

Code Block
languagepython
xtcavLasingOn amox23616 137 --max_shots 5

...

languagepython

...

It can also be used to give information about the relative energies and arrival times of x-ray pulses that are closely spaced in time (fs delays). Unfortunately, some data analysis is necessary to extract this "power profile" from the raw detector signal. This documentation will go through how to do this.

For most experiments, the analysis should be basically turn-key using the code we provide at LCLS. The "Quickstart" section should be enough if you just want to do that as fast as possible. Many experiments that rely heavily on the XTCAV, however, operate in unique electron-beam modes (multibunch, etc) that require more manual fine-tuning of the analysis. To support those cases, we go through a little of the theory behind the XTCAV & analysis routines used to extract the information of interest.

Some knowledge of the physical setup is necessary to understand any data processing results. The XTCAV works by sending the electron beam at the end of the LCLS (after the undulators, so after x-rays have been generated) through a transverse accelerator that "kicks" the electrons, causing the front (early) part of the beam to head one direction, and the back (late) to head the other way. Then, the beam is sent through a magnetic field, which bends it; electrons with high kinetic energy bend a little less than those with low KE. Here is a little schematic:

Image Added

In this way, the electrons get sorted by both time and energy. The beam hits a fluorescent screen that is imaged by a camera – this image is the raw data we process. A typical XTCAV images looks like this, with "time" on the x-axis and "energy" on the y-axis:

Image Added

You may notice there are vertical streaks in this image. Those streaks reflect the energy some electrons lost when they generated x-rays in the XFEL undulator! If we compare this image to a comparable image that did not generate x-rays ("lasing off" run, more on that later) then we can "reconstruct" the x-ray power as a function of time.

 

Table of Contents

Quickstart

All XTCAV analysis is a three step process involving "dark", "lasing off", and "lasing on" runs. The first two are references; the last is how we commonly refer to runs that contain data of interest. Simple scripts are provided as part of the psana python environment for processing each.

The XTCAV data consists of the elecontr

Dark Runs

Dark runs are These runs without any electrons going through the accelerator. We take the average of a series of dark run images to get the general pixel values of the camera background. We can then subtract this "average image" from the lasing on and off runs to get a closer approximation of the actual energy of the electron bunches.

Code Block
languagepython
xtcavDark amox23616 104 --max_shots 400

Output

Code Block
languagepython
dark background reference
  Experiment: amox23616
  Run: 104
  Valid shots to process: 400
100.0 % done, 400 / 400
Maximum number of images processed


Lasing Off Runs

We then process the lasing off runs, which are images of electron bunches without any lasing. We take a series of these images, subtract the average background (from previous step), and zero-out all noise around the region of interest. From this cleaned up image, we can calculate the electron current, the energy dispersion and center of mass, and other physical properties of the electron bunch. We then cluster together these lasing off images into an (optimally or manually chosen) number of groups based of of the electron current. The properties of these profiles are then averaged to create an aggregate lasing off profile.

Code Block
languagepython
xtcavLasingOff amox23616 131 --max_shots 200


Output

Code Block
languagepython
Lasing off reference
	 Experiment: amox23616
	 Runs: 131
	 Number of bunches: 1
	 Valid shots to process: 200
	 Dark reference run: None
100.0 % done, 200 / 200
Averaging lasing off profiles into  12  groups.

 

Lasing On Runs

For the lasing on runs, we process each image individually in a similar manner to the lasing off images. Once we calculate the physical properties, we choose an aggregated lasing off profile with the most similar electron current. Then, using either the energy loss or energy spread methods, we can calculate the power of the electron bunch. 

Code Block
languagepython
xtcavLasingOn amox23616 137 --max_shots 5


Output

Code Block
languagepython
Using file 104-end.data for dark reference
Using file 131-end.data for lasing off reference
Agreement: 91.4276%; Maximum power: 6.64857; GW Pulse Delay: 18.512 
Agreement: 91.1052%; Maximum power: 5.82139; GW Pulse Delay: 20.6758 
Agreement: 93.136%; Maximum power: 4.88641; GW Pulse Delay: 18.0389 
Agreement: 94.1173%; Maximum power: 6.76523; GW Pulse Delay: 16.2321 
Agreement: 92.9344%; Maximum power: 7.14828; GW Pulse Delay: 11.2065 


Theory


The LCLS X-band Transverse deflecting mode CAVity (XTCAV) diagnostic system is shown in Fig. 1. There are two key elements to the system: the XTCAV and the final dipole magnet.

As shown in Fig. 1, immediately after the undulator is the XTCAV. This generates an effective RF (11.424 GHz) electromag- netic force pointing in the horizontal direction with an amplitude varying sinusoidally in time. Then, as illustrated in Fig. 2a, the electron bunch travels through the cavity with this RF wave at roughly the speed of light. The bunch time of arrival is set so its center coincides with when the amplitude of the RF field is zero. Then the net deflection of the bunch will also be zero.

However, the bunch has a finite length, some-thousand times shorter than the wavelength of the RF. As shown in Fig. 2a, the head sees a small, positive electric field while trailing electrons see a small, negative transverse electric field. The effect is a linearly-varying force for different slices of the bunch. The head (tail) gets a transverse momentum kick to the left (right), shearing the bunch into a horizontal streak.

Analysis Setup

Two things must be done before XTCAV analysis will function: a "dark run" must be analyzed to get the pedestal values for cameras, and a "no lasing" run must be analyzed to generate sets of "no lasing" images (the latter is quite a complex process). Note that for demonstration these first two scripts write constants to a "local" calibration directory called "calib". For a real-experiment you won't need these lines because you will have permission to write to your official experiment calibration-constants directory.

...