Skip Ribbon Commands
Skip to main content
Navigate Up
Sign In

An Office of Science User Facility

Matter in Extreme Conditions (MEC)


X-ray Diffraction at MEC Endstation

​​​​​​​Z. Xing​*, E. Galtier, H.J. Lee, E. Granados, B. Arnold, S. Mullane, C. Bolme, A. Fry, P. Hart and B. Nagler

* Contact author:


  • ​​​​​Z. Xing, “X-ray diffraction at Matter in Extreme Conditions endstation”, 57th Annual Meeting of the APS Division of Plasma Physics, Savannah, US, November 16-20, 2015 


Here we describe a standard platform dedicated for the X-ray diffraction studies at MEC endstation, which can be used to reconstruct a complete diffraction pattern from multiple detectors at different positions or orientations, optimize the detector positions in a timely manner (less than few seconds of CPU time) using calibration materials, extract the lattice spacing profiles and determine texture features. This platform as well as the analysis software package, named as ExtremeXRD, is available to the MEC user community for efficient diffraction measurements and real-time data analysis. We will build this platform into a standardized instrument to ease the setup and tear-down procedure in the near future.


Experimental setup

As an illustration of how the experiment and data analysis are performed, here we describe a typical experimental setup used in one of our user's experiment, R. Smith et. al., for the LD7014 beam time. We normally provide ​several Cornell SLAC pixel array detectors (CSPAD) for the diffraction measurements with some of them having smaller active sensor sizes of 400x400 pixels (CSPAD 140k), and some larger of 825x830 pixels (CSPAD 550k or CSPAD Quad). The nominal pixel size is 110 um with the exception that there are two rows of pixels in the middle of the 2x1 tile (CSPAD 140k contains two 2x1 tiles while CSPAD 550k contains eight) that are wider by a factor of 2.5. The pixels near the edge of each tile usually read out more noises. The detectors are orientated around the primary interaction point in a Debye-Scherrer transmission geometry, with an example of the setup illustrated in Fig.1. Here four CSPAD 140k, labeled as A, B, C and D, and one CSPAD 550k, labeled as Quad, are used to record the diffractions, and the optical laser beam path is not shown specifically as it can have different geometrical configurations with respect to the X-ray depending on the goal of the experiment. 

Fig.1 Standard LCLS coordinate system is shown here with the positive x direction pointing north, positive y direction pointing up and positive z direction pointing downstream of the FEL beam. Five detectors, CSPAD Quad and four CSPAD 140k, are shown for a typical experimental setup, where some of them are titled with an angle in order to maximize the solid angle coverage.

Reconstruction​ of the diffraction pattern

We use two methods to reconstruct the Debye-Scherrer diffraction rings integrating images from multiple detectors. The first method, shown as (a) in Fig2, is simply a direct mapping from the real CSPAD pixels to any projection plane, which is faster in terms of computation time but has sampling artifacts due to the limited detector acceptance, pixel size, etc. The second method we use is called reverse mapping, shown as (b) in Fig2,where we back trace from the projection plane or virtual plane to the real CSPAD detector. Numerical interpolation and extrapolation methods are used to obtain the photon counts in the regimes where there is no CSPAD detector acceptance. This method is slower in terms of time complexity and generates a more uniform diffraction image using the fitting or interpolation technique.

Fig.2 The direct and reverse mapping method used to reconstruct the Debye-Scherrer diffraction rings.

Optimization of the detector geometry

Instead of using the very time consuming grid-search-based optimization approach, we have developed a fitting method based on the gradient descent search. This is a quasi-Newton method that approximates the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm, where some user interactive input is needed to select a few reference points on the raw diffraction rings within the actual detector. To be more specific, the multivariate objective function that needs to be minimized is formulated as:

where the x and y coordinates with a subscript "L" indicate the interactively selected reference points on the raw diffraction rings. By giving these reference points, we can analytically solve this optimization problem for the gradient, derivatives, etc., thus improves the time complexity of the minimization procedure significantly.

Tutorial for the analysis tool

1. ​​​​The XRD analysis tool is written purely in Python, it can be either run on a standalone user laptop or under the framework of mecana master analysis GUI. The instructions to use mecana analysis package is shown below. 


2. Once the mecana GUI is up running, you can check the box "XRD analysis" providing an "experiment" name and "run" number, clicking the "RUN" button will then launch the XRD analysis GUI in a separate window as shown below.

3. In the XRD analysis GUI, first configure the detectors that you are interested by clicking "Detector config" button: the detector names "QUAD", "A", "B", etc., should each match to a DAQ name in the data system. Setting DAQ name to '-1' will disable the particular detector from the integrated diffraction profile. Rotation flags allow you to rotate the detectors in units of 90 degrees (+/- 2 = +/- 180 deg).

4. Range and bin size (resolution) of various kinematic variables can be examined and defined by clicking on "Load config file" button. You can set the ranges and bin sizes for Bragg angle, azimuthal angle, x and y coordinates for the projection of Debye-Scherrer rings, and z coordinate of the virtual detector plane by clicking the "Save config file" button.

5. Provide an initial "guess" of the detector positions and orientations, such as the x-y-z coordinates of the bottom left corner of the CSPAD detector and the three Euler rotation angles of the detectors. The exact definition of these positioning parameters are described in the MEC XRD paper. Click the "Initial detector position" button to examine and modify the initial detector positions, from which the subsequent optimization procedure will start. These intial guesses don't need to be very precise, it just provides some guidance for the fitter to find the optimal detector position.

6. Examine the projected Debye-Scherrer rings, based on the initial guess of the detector geometries, of some calibration sample such as LaB6 or CeO2. Type what material is used, in this case "LaB6", for calibration in the field "Sample material", and click the "Method I" button of "Plot the diffraction patterns" to make the projections onto x-y and theta-phi plane. You can see the diffraction patterns are mis-aligned compared to the expected or calculated ones for LaB6, which are indicated by the green dashed lines.

7. Next we will start to use the calibration sample to optimize the detector geometry. First, we choose the detector that we intend to optimize the positioning: type the detector name, "QUAD", under the item "Optimization of detector geometry". Since we more or less know which ones of the Bragg angles for LaB6 are within the detector acceptance of QUAD and will be used as reference in the fit from the figure shown above, we just need to type in these Bragg angles by clicking "Config ref." button. We will use the 100, 110, 111, 200, 210, 211 and 220 lines of LaB6 as references, where the 2-theta angles are 21.4449, 30.5101, 37.5982,43.6908, 49.1676, 54.2240, and 63.5026 degrees, respectively. We will interactively select 5 points ("# of ref. per ring") along each of these 7 diffraction rings as reference points.

By clicking the "Select ref." button, we will start to interactively select the reference points along the various diffraction rings. Try to select the 5 ref points along the whole ring, covering a maximum azimuthal angle range. An example of the selected reference points for detector "QUAD" is shown below.

The final step is to just start the fitter, by clicking "Fit" button. The optimized detector geometry will displayed on the terminal and also saved into a configuration file ("configurations.dat").

8. Finally, we can now check the diffraction profiles again with the optimized detector geometry:

(a) method I, direct mapping method.

(b) method II, reverse mapping method, where the numerical interpolation and extrapolations are utilized to smooth out the sampling artifacts.

9. You have the option to write the 2theta profile and theta-phi map into some text-based files or tiff images (tab "Write the diffraction patterns to ASCII or tiff files"), which can then be coupled into subsequent applications such as refinement programs. Quit the XRD analysis tool by clicking the "Quit" button.

10. Parallel computing using openMPI tools: you can process mutiple runs or events by using the several thousand cores or CPU's available at the LCLS computing farm. An example is shown below:

  Here I want to process run number 364, run 365 of experiment mecg8415, event number 1 to 10, thus 20 jobs will be submitted to queue named "psfehprioq". For policies and basic instructions of how to use the computing queues, see the link provided by the LCLS date analysis group: 

Batch jobs at LCLS​

I just use the direct mapping method (Method I) to generate the 2-theta line-out (ASCII file) as well as the theta-phi or X-Y map (tiff images). You can check the batch job status following the instructions given at the link above such as "bjobs -a -w", "bqueues | grep ps | grep feh; bqueues | head -n 1", etc. A log file for the submitted batch job will be written to scratch folder, "/reg/d/psdm/mec/mecg8415/scratch/" in this case, where you can see more details of the jobs.



SLAC SLAC National Accelerator Laboratory, Menlo Park, CA
Operated by Stanford University for the U.S. Dept. of Energy