††thanks: Present address: PSI, CH-5232 Villigen, Switzerland

# Signatures of misalignment in x-ray cavities of cavity-based x-ray free-
electron lasers

Peng Qi  Advanced Photon Source, Argonne National Laboratory, Lemont, Illinois
60439, USA  University of Saskatchewan, Saskatoon, SK S7N5E5, Canada  Yuri
Shvyd’ko<EMAIL_ADDRESS>Advanced Photon Source, Argonne National Laboratory,
Lemont, Illinois 60439, USA

###### Abstract

Cavity-based x-ray free-electron lasers (CBXFEL) will allow use of optical
cavity feedback to support generation of fully coherent x-rays of high
brilliance and stability by electrons in undulators. CBXFEL optical cavities
comprise Bragg-reflecting flat crystal mirrors, which ensure x-rays
circulation on a closed orbit, and x-ray refractive lenses, which stabilize
the orbit and refocus the x-rays back on the electrons in the undulator.
Depending on the cavity design, there are tens of degrees of freedom of the
optical elements, which can never be perfectly aligned. Here, we study
signatures of misalignment of the optical components and of the undulator
source with the purposes of understanding the effects of misalignment on x-ray
beam dynamics, understanding misalignment tolerances, and developing cavity
alignment procedures. Betatron oscillations of the x-ray beam trajectory (both
symmetric and asymmetric) are one of the characteristic signatures of cavity
misalignment. The oscillation period is in the general case a non-integer
number of round-trip passes of x-rays in the cavity. This period (unlike the
amplitude and offset of the oscillations) is independent of the type of
misalignment and is defined by cavity parameters. The studies are performed on
an example of a four-crystal rectangular cavity using analytical and numerical
wave optics as well as ray-tracing techniques. Both confocal and generic
stable cavity types are studied.

###### pacs:

41.50.+h,41.60.Cr, 61.05.cp, 42.55.Vc

##  I Introduction

The next generation of hard x-ray free-electron lasers (XFELs) operating in a
high-repetition-rate ($\simeq$ MHz) pulse sequence mode Decking et al. (2020);
Raubenheimer (2018) will allow for optical cavity–based feedback, like in
classical lasers Siegman (1986). Unlike self-amplified spontaneous emission
(SASE) XFELs Kondratenko and Saldin (1980); Bonifacio et al. (1984); Emma et
al. (2010), the new cavity-based XFELs (CBXFEL) Huang and Ruth (2006); Kim et
al. (2008) are capable of generating fully coherent x-ray beams of high
brilliance and stability. Two major CBXFEL schemes are presently considered:
low gain and high gain.

An x-ray free-electron laser oscillator (XFELO) Kim et al. (2008); Kim and
Shvyd’ko (2009); Lindberg et al. (2011); Kim et al. (2012); Dai et al. (2012)
is a low-gain CBXFEL, which requires a low-loss (high-Q) x-ray cavity. XFELOs
are promising to generate radiation of unprecedented spectral purity with a
meV bandwidth.

Another possible realization of the CBXFEL is a high-gain regenerative
amplifier free-electron laser (XRAFEL) Huang and Ruth (2006); Marcus et al.
(2017); Freund et al. (2019); Marcus et al. (2020), which can reach saturation
after a few round-trip passes. It can therefore allow for a high (close to
100%) extraction efficiency. It can use a similar or identical cavity as an
XFELO; but, with substantially relaxed tolerances on the efficiency and
stability.

Classical laser oscillator cavities in the optical domain are typically
composed of two curved high-reflectance backscattering mirrors, each ensuring
laser beam circulation, refocusing, and stabilization Siegman (1986). In the
hard x-ray domain, these functions have to be assigned to two different types
of optical elements Kim et al. (2008); Kim and Shvyd’ko (2009): high-
reflectance flat Bragg-reflecting diamond crystal mirrors Shvyd’ko et al.
(2010, 2011) and x-ray–transparent beryllium refractive paraboloidal lenses
Lengeler et al. (1999); Kolodziej et al. (2018). Different cavity designs have
been considered: fixed-photon-energy two-crystal cavity Shvyd’ko et al.
(2003); Kim et al. (2008); Kim and Shvyd’ko (2009), tunable-photon-energy
four-crystal cavity Cotterill (1968); Kim and Shvyd’ko (2009), and tunable
compact non-planar six-crystal cavity Shvyd’ko (2013).

Figure 1: Schematic of a cavity-based XFEL with an undulator x-ray source
together with a four-crystal (C${}_{{}_{1}}$-C${}_{{}_{4}}$), two-lens
(L${}_{{}_{1}}$-L${}_{{}_{2}}$) rectangular x-ray cavity and x-ray diagnostics
Marcus et al. (2019). Cavity round-trip length $2(L+W)\simeq 65$ m. X-ray
diagnostics tools include x-ray beam intensity monitors (XBIMs) and an x-ray
beam position, profile, and intensity monitor (XBPM).

Here, we are considering as an example a fixed-photon-energy four-crystal
rectangular cavity proposed for a joint Argonne National Laboratory (ANL) and
SLAC National Laboratory (SLAC) CBXFEL R&D project Marcus et al. (2019). A
CBXFEL with a rectangular cavity is presented in Fig. 1. It is composed of an
undulator x-ray source and a cavity comprising four Bragg-reflecting flat-
crystal mirrors C${}_{{}_{1}}$, C${}_{{}_{2}}$, C${}_{{}_{3}}$, and
C${}_{{}_{4}}$, along with two refractive lenses (L${}_{{}_{1}}$ and
L${}_{{}_{2}}$) as focusing elements. The limited space in the Linac Coherent
Light Source (LCLS) undulator tunnel Raubenheimer (2018) determines the choice
of the fixed-photon-energy rectangular cavity versus a tunable bow tie–type
four-crystal cavity Kim and Shvyd’ko (2009). In the future, the rectangular
cavity could be upgraded to a tunable non-planar six-crystal cavity Shvyd’ko
(2013) taking the same footprint.

There are tens of degrees of freedom of the optical elements (depending on the
cavity design)—many more than in a classical laser oscillator. All of them
have to be aligned with a precision ensuring that the to-be-amplified x-ray
beam returning into the undulator (after traveling tens to hundreds of meters
in the cavity and being refocused to a spot of a few tens of microns) meets a
fresh electron bunch of a similar size and a few tens of microns in length.
Cavity alignment is one of the major challenges in the realization of CBXFELs.
To this end, several essential questions have to be addressed, in particular:
(i) What are the typical misalignment patterns? (ii) Can they be identified
with x-ray beam monitors? (iii) Can different degrees of freedom be
disentangled and the number of mutually dependent degrees of freedom reduced?
(iv) What are the misalignment tolerances? (v) How can the cavity be aligned?

In the first step of our analysis to address these questions, we are studying
the spatial, angular, and temporal behavior of x-rays in the rectangular x-ray
cavity using analytical tools developed for classical laser oscillator
cavities Siegman (1986); Kogelnik and Li (1966). These methods have also been
applied to study statistical misalignment tolerances in CBXFEL cavities
Lindberg et al. (2011); Marcus et al. (2019); Kim (2020). We are using matrix
ray tracing, paraxial resonator theory, and Gaussian mode theory to derive
stable, self-consistent solutions for the Gaussian beams in the cavity; to
determine cavity parameters; and to analyze beam instabilities in both a
perfectly aligned cavity and a cavity with misaligned optical components.

Although in general this analytical approach is quite powerful, it has
limitation, because the Bragg-reflecting crystal mirrors are treated as
100%-reflecting mirrors with unrestricted spectral and angular reflection
widths. In the second step of our analysis, we address this limitation by
using numerical simulation tools, which involve calculations based on the
dynamical theory of Bragg diffraction of x-rays in crystals Authier (2001).
With these tools, we are able to take the actual properties of the optical
elements into account.

The short-term goal of these studies is to understand the spatial, angular,
and temporal behavior of x-rays and the response of the cavity x-ray monitors
to typical misalignment patterns of x-ray optical components and of the x-ray
source, with a view to developing human-controlled cavity alignment
procedures. The long-term goal is to develop computer-assisted algorithms
(e.g., utilizing machine learning) to guide cavity alignment.

We note, that our studies are limited to empty cavity conditions. XFEL gain
effects, in particular, gain guiding effects typical for XRAFEL are not
considered here.

The paper is organized as follows. Section II covers the function and optical
design of the rectangular cavity and its parameters. Results of analytical
studies of the x-ray cavity are presented in Section III, and results of
numerical simulation studies are given in Section IV. A strategy for cavity
alignment is presented in Section V. Conclusions and outlook are discussed in
Section VI.

##  II Four-crystal rectangular cavity optical design and parameters

Table 1: Parameters of the rectangular cavity, x-ray source, and optical components Marcus et al. (2019) used in the calculations presented in the paper. Parameters marked with asterisk are derived from other parameters of the table. | Parameters | Values
---|---|---
Cavity | Type | rectangular
| Length $L$ | 32 m
| Width $W$ | 0.65 m
| Round-trip length∗ $\ell=2(L+W)$ | 65.3 m
| Round-trip time∗ $\tau=\ell/c$ | 218 ns
Source | Type | Gaussian beam
| Rayleigh length∗ $Z_{{}_{o}}$ | 25.67 m
| Transverse size∗ $\sigma_{{}_{x,y}}$ (rms) | 15.9 $\mu$m
| $\sigma_{{}_{x,y}}=\sqrt{(\lambda/4\pi)Z_{{}_{o}}}$ |
| Angular size∗ $\sigma_{{}_{x,y}}^{\prime}$ (rms) | 0.62 $\mu$rad
| $\sigma_{{}_{x,y}}^{\prime}=\sqrt{(\lambda/4\pi)/Z_{{}_{o}}}$ |
| Central photon energy∗ $E(\theta)$ | 9.83102 keV
| Spectral bandwidth | 100 meV
| (as used in numeric simulations) |
Crystals | Material | Diamond
C${}_{{}_{1}}$-C${}_{{}_{4}}$ | Bragg reflection | (400)
| Central angle of incidence $\theta$ | 45∘
| Thickness | C${}_{{}_{1}}$: 20 $\mu$m;
|  | C${}_{{}_{2}}$-C${}_{{}_{4}}$: 500 $\mu$m
| Temperature | 300 K
| Spectral reflection width $\Delta E$ | 90 meV
| Angular reflection width $\Delta\theta$ | 9 $\mu$rad
Lenses | Material | Beryllium
L${}_{{}_{1}}$-L${}_{{}_{2}}$ | Lens type | Paraboloidal 2D
| Focal length $f^{(1)}={\ell}/{4}$ | 16.3 m
|  $f^{(2)}={\ell}/{8}+{2Z_{{}_{o}}}^{2}/{\ell}$ | 28.3 m
| Radius of curvature $R^{(1)}$ | 115 $\mu$m
|  $R^{(2)}$ | 200 $\mu$m

Figure 1 shows the schematic of the CBXFEL Marcus et al. (2019) with the
rectangular x-ray cavity studied here. Parameters of the x-ray cavity, x-ray
source, and optical components are listed in Table 1 and explained below.

X-rays from an undulator source propagate through the x-ray cavity composed of
four Bragg-reflecting crystal mirrors C${}_{{}_{1}}$-C${}_{{}_{4}}$ and two
focusing lenses L${}_{{}_{1}}$-L${}_{{}_{2}}$. In the perfectly aligned
cavity, the optical axis is a rectangle having sides $L$ and $W$ ($L\gg W$),
with crystals placed in its corners, while the lenses are placed in the
symmetry points at distances $\ell/4$ from the source, where $\ell=2(L+W)$ is
the round-trip length. Different locations of the lenses could be considered
as well, but only this symmetric configuration is studied here.

The crystal mirrors compose two backscattering units, which bracket the
undulator, with two crystals C${}_{{}_{1}}$ and C${}_{{}_{2}}$ on one end of
the undulator and two crystals C${}_{{}_{3}}$ and C${}_{{}_{4}}$ on the other
end. In each unit, two successive Bragg reflections reverse the direction of
the beam, which fixes the incidence and reflection angles to exactly 45∘. This
geometry requires an x-ray source generating photons with a
$\sigma$-polarization component (electric field vector perpendicular to the
cavity plane). Diamond crystals are chosen as Bragg reflecting crystal mirrors
because of their high reflectivity, x-ray transparency, and resilience
Shvyd’ko et al. (2011). In particular, the 400 Bragg reflection from diamond
crystal is used, a choice dictated by the practical consideration that it is
easier to obtain high-quality diamond crystal plates in the 100 orientation
than in other orientations Shvyd’ko et al. (2017). The 400 Bragg reflection
with 45∘ incidence angle predefines a 9.83102-keV central photon energy of the
cavity and of the x-ray source, assuming all crystals operate at the same
temperature of 300 K. Crystals C${}_{{}_{2}}$-C${}_{{}_{4}}$ are assumed to be
500 $\mu$m thick for high reflectivity and mechanical stiffness. Crystal
C${}_{{}_{1}}$ is assumed to be 20 $\mu$m thick for output coupling of $\simeq
3$ % of the interactivity power Kim et al. (2008); Kim and Shvyd’ko (2009);
Shvyd’ko (2019).

The x-ray source is assumed to generate a Gaussian beam with a Rayleigh length
$Z_{{}_{o}}$ matched to the electron beam beta function at the undulator
center Marcus et al. (2019), which is considered to be the cavity origin with
$z=0$. The Rayleigh length and photon wavelength $\lambda=hc/E$ define the
root mean square (rms) x-ray source (Gaussian beam waist) transverse size
$\sigma_{{}_{x,y}}=\sqrt{(\lambda/4\pi)Z_{{}_{o}}}$ and the rms angular source
divergence $\sigma_{{}_{x,y}}^{\prime}=\sqrt{(\lambda/4\pi)/Z_{{}_{o}}}$. The
spectral bandwidth of the source is limited artificially in these calculations
to 100 meV to reduce computation time and to match the spectral width of the
Bragg reflections $\Delta E=90$ meV.

The focal length $f$ of the focusing elements L${}_{{}_{1}}$-L${}_{{}_{2}}$
has to be properly chosen in order for the Gaussian beam with Rayleigh length
$Z_{{}_{o}}$ to be a stable and self-consistent (self-reproducing after each
round trip) cavity mode, as discussed in Section III, Eq. (7). The focal
length values – $f^{(1)}$ and $f^{(2)}$ for confocal and generic cavities,
respectively (Table 1) – were chosen based on this consideration but also for
the following practical reason.

We chose beryllium paraboloidal lenses Lengeler et al. (1999) as x-ray
focusing elements in the cavity. They are manufactured with discrete values of
the radius of curvature $R$ RXOPTICS (2021). For the photon energy in
question, the lens with $R=200~{}\mu$m has a focal length of $f^{(2)}=28.3$ m,
close to (but not exactly) the value required to maintain a cavity mode with
the desired properties. In the following calculations, we use this value for
$f^{(2)}$ in the generic cavity and adjust appropriately the values of
$Z_{{}_{o}}$, $\sigma_{{}_{x,y}}$, and $\sigma_{{}_{x,y}}^{\prime}$, as listed
in Table 1. The same $Z_{{}_{o}}$, $\sigma_{{}_{x,y}}$, and
$\sigma_{{}_{x,y}}^{\prime}$ values are used for the confocal cavity with
$f^{(1)}=\ell/4=16.3$ m.

In our studies, x-ray beam size, position, angle, and intensity are calculated
and “monitored” every round-trip pass in the undulator center and in the
midpoint between crystals C${}_{{}_{2}}$ and C${}_{{}_{3}}$. In an experiment,
non-invasive x-ray beam position, profile, and intensity monitors (XBPMs)
installed in these locations can provide all these values except the beam
angle. To monitor x-ray beam angles at different locations in the cavity,
x-ray beam intensity monitors (XBIM) D${}_{{}_{1}}$-D${}_{{}_{4}}$ can be used
to measure the intensity of x-rays penetrating through the diamond crystals on
each round-trip pass (see Fig. 1). A high level of transmitted intensity would
signal that the angle of incidence of x-rays to the (400) reflecting crystal
planes is far off the peak reflectivity angle of the relevant crystal, while a
low intensity would indicate proximity to the peak reflectivity angle. For
this reason, we calculate in our studies the intensity of the x-rays
transmitted through crystals C${}_{{}_{1}}$-C${}_{{}_{4}}$.

The optical axis of the cavity is defined along the trajectory of x-rays in
the perfectly aligned cavity. We use local right-handed reference coordinate
systems, which propagate with the $z$-axis always along the optical axis, the
$y$-axis perpendicular to the cavity plane, and
$\mbox{\boldmath$x$}\times\mbox{\boldmath$y$}=\mbox{\boldmath$z$}$, as
indicated in Fig. 1. The optical elements inherit the same coordinate system
as the incident rays. For angular variation of the ray slope in the $(x,z)$
plane and for rotation of the optical elements, the counterclockwise sense is
defined as positive.

##  III Analytical studies

Here, we are using the paraxial ray-transfer matrix technique and paraxial
wave optics to propagate x-rays and Gaussian beams through the optical
elements of the cavity shown in Fig. 1, to determine parameters of the stable
cavity and the self-consistent Gaussian beam modes and to analyze cavity
instabilities due to the x-ray source and misalignment of optical elements in
the cavity plane.

###  III.1 Stable and self-consistent solution for a perfect cavity

A paraxial ray in any reference plane perpendicular to the optical axis is
given by its distance $x$ from the optical axis and by its angle
$x^{\prime}\ll 1$ with respect to the axis. A ray vector
$\mbox{\boldmath$r$}_{{}_{0}}=\left[\begin{array}[]{c}\\!{x}_{{}_{0}}\\\
{x}_{{}_{0}}^{\prime}\end{array}\\!\right]$ at the source (or input) plane is
transformed to
$\mbox{\boldmath$r$}_{{}_{1}}=\hat{O}\mbox{\boldmath$r$}_{{}_{0}}$ at the
image (or output) plane, where $\hat{O}=\\{AB;CD\\}$ is a $2\times 2$ ray-
transfer matrix of an optical element placed between the planes.

The ray-transfer matrix of the cavity is a sequential product of three
discrete ray-transfer matrices: propagation in free space $\hat{P}(l)$ over
distance $l$, reflection from a crystal mirror $\hat{C}$, and focusing by lens
$\hat{L}(f)$ with focal length $f$, which are given by

$\hat{P}(l)=\left[\begin{array}[]{cc}1&l\\\ 0&1\end{array}\right]\\!\\!,\hskip
2.84526pt\hat{C}=\left[\\!\begin{array}[]{cc}-1&0\\\
0&-1\end{array}\\!\right]\\!\\!,\hskip
2.84526pt\hat{L}(f)=\left[\\!\begin{array}[]{cc}1&0\\\
-{1}/{f}&1\end{array}\\!\right]\\!\\!,$ (1)

respectively Kogelnik and Li (1966); Siegman (1986); Saleh and Teich (2007).
The only impact of the crystal mirror is the inversion of the ray vector space
and angular coordinates Shvyd’ko (2015). The finite angular and spectral
acceptance of the Bragg-reflecting crystal mirrors are not taken into account
within this approach but will be included in the numerical simulations
approach in Section IV.

Figure 2: Equivalent optical scheme of the unfolded symmetric cavity with two
lenses.

The ray-transfer matrix of the cavity in Fig. 1 with four crystals and two
lenses is calculated as a product
$\hat{R}=\hat{P}(\frac{L}{2})\hat{C}\hat{P}(\frac{W}{2})\hat{L}(f)\hat{P}(\frac{W}{2})\hat{C}\hat{P}(L)\hat{C}\hat{P}(\frac{W}{2})\hat{L}(f)\hat{P}(\frac{W}{2})\hat{C}\hat{P}(\frac{L}{2})$.
The source ray vector $\mbox{\boldmath$r$}_{{}_{0}}$ at the undulator center
(considered to be the cavity origin, with $z=0$) is transformed by this matrix
to the image ray vector $\mbox{\boldmath$r$}_{{}_{1}}$ at the same location
after the round trip. Because $\hat{C}=-\hat{I}$, where $\hat{I}=\\{10;01\\}$
is the unit matrix, the ray-transfer matrix of the cavity simplifies to
$\hat{R}=\hat{P}({\ell}/{4})\hat{L}(f)\hat{P}({\ell}/{2})\hat{L}(f)\hat{P}({\ell}/{4})$
and becomes

$\displaystyle\hat{R}\,=\,\left[\begin{array}[]{cc}\frac{8f(f-\ell)+\ell^{2}}{8f^{2}}&\frac{\ell\
(32f^{2}-12f\ell+\ell^{2})}{32f^{2}}\\\
\frac{\ell-4f}{2f^{2}}&\frac{8f(f-\ell)+\ell^{2}}{8f^{2}}\end{array}\right],$
(4)

using Eq. (1). The equivalent scheme of the unfolded symmetric cavity is shown
in Fig. 2.

The cavity is stable (meaning a paraxial ray within the cavity does not escape
after numerous passes) when the matrix trace $(A+D)$ obeys the inequality
$-1\leq(A+D)/2\leq 1$ Siegman (1986); Kogelnik and Li (1966). In our
particular case, stability requires $f\geq\ell/8$, which is a relaxed
condition.

We now use the calculated cavity ray-transfer matrix (4) to determine self-
consistent Gaussian beam modes in the cavity, i.e., the modes self-reproducing
after each round trip. Knowledge of the ray-transfer matrix of an optical
system is particularly useful as it also describes the propagation of the
Gaussian beams through the system Siegman (1986); Kogelnik and Li (1966).
Gaussian beams are eigenstates of paraxial wavefields in free space, and they
can be eigenstates of the linear optical systems presented by ABCD ray-tracing
matrices.

The self-consistent solutions can be found by applying the ABCD propagation
law: a Gaussian beam with the complex beam parameter
$q_{{}_{0}}(z)=z+{\mathrm{i}}Z_{{}_{o}}$ in the source reference plane 0 (here
$Z_{{}_{o}}$ is the Rayleigh range) is transformed to a Gaussian beam with the
beam parameter

$q_{{}_{1}}\,=\,\frac{A\,q_{{}_{0}}\,+\,B}{C\,q_{{}_{0}}\,+D}$ (5)

in reference plane 1 (image plane). We assume here that the waist of the
Gaussian beam source is at the undulator center with $z=0$ and therefore
$q_{{}_{0}}={\mathrm{i}}Z_{{}_{o}}$.

A mode with the complex beam parameter $q_{{}_{0}}$ is a self-consistent
cavity mode if after the complete round trip of the beam it returns to its
initial value, i.e.,

$q_{{}_{1}}=q_{{}_{0}}={\mathrm{i}}Z_{{}_{o}}.$ (6)

Combining Eqs. (4)-(6), we arrive at a second-order equation in
$Z_{{}_{o}}^{2}$ for the self-consistent Gaussian mode containing the focal
length $f$ of the lenses and the cavity round-trip length $\ell$ as
parameters. Alternatively, the equation can be solved for the focal length $f$
required for a specific self-consistent value of $Z_{{}_{o}}^{2}$. There are
two possible solutions:

$f^{(1)}\,=\,\frac{\ell}{4},\hskip
28.45274ptf^{(2)}\,=\,\frac{\ell}{8}\,+\,\frac{2Z_{{}_{o}}^{2}}{\ell}.$ (7)

In both cases $f\geq\ell/8$, and therefore both represent stable solutions. We
note that $f^{(2)}=f^{(1)}$, provided $Z_{{}_{o}}=\ell/4$. We next analyze the
beam dynamics for each solution.

####  III.1.1 Self-consistent confocal cavity solution

A Gaussian beam with any Rayleigh range $Z_{{}_{o}}$ is a self-consistent
solution if the relationship $f^{(1)}={\ell}/{4}$ of Eq. (7) is fulfilled.
This relationship corresponds to a confocal symmetric stable laser cavity
Kogelnik and Li (1966); Siegman (1986), in which the focal points of both
lenses coincide with each other, with the cavity origin (at the undulator
center), and with the midpoint on the return path.

Any Gaussian beam of Rayleigh range $Z_{{}_{o}}$ and beam waist of rms width
$\sigma_{{}_{0}}=\sqrt{\lambda Z_{{}_{o}}/4\pi}$ located at the cavity origin
(which is also a focal point of lens L${}_{{}_{1}}$) is refocused by lens
L${}_{{}_{1}}$ into a Gaussian beam of Rayleigh length
$Z_{{}_{1}}=Z_{{}_{o}}M^{2}$ with beam waist of rms width
$\sigma_{{}_{1}}=M\sigma_{{}_{0}}$ located at the second focal point of lens
L${}_{{}_{1}}$ (which is also midpoint of the return path). Here

$M=f^{(1)}/Z_{{}_{o}}=\ell/4Z_{{}_{o}}$ (8)

is the absolute value of the magnification factor (see Section 3.2 of Saleh
and Teich (2007)). The location of the second Gaussian beam waist is in the
focal point of the second lens L${}_{{}_{2}}$. As a result, this Gaussian beam
is refocused with magnification $1/M$ by the second lens L${}_{{}_{2}}$ to a
Gaussian beam with the waist located at the cavity origin (the second focal
point of lens L${}_{{}_{2}}$), and with exactly the same Rayleigh length and
rms width as the original beam. In the particular case of
$Z_{{}_{o}}=f_{{}_{0}}=\ell/4$, magnification $M=1$ results in the same
Rayleigh length $Z_{{}_{1}}=Z_{{}_{o}}$ and beam width
$\sigma_{{}_{1}}=\sigma_{{}_{0}}$ at the cavity midpoint as well as at the
cavity origin. Figure 3 shows appropriate beam profiles with different
magnification $M$.

Figure 3: Gaussian beam profiles for self-consistent solutions in the
symmetric confocal cavity, shown for different initial Rayleigh range values
$Z_{{}_{o}}=f^{(1)}/M$. The second Gaussian beam waist is in the midpoint of
the round-trip path, with the size of the beam waist (relative to the original
waist size) scaling with the magnification factor $M$.

The ABCD cavity matrix given by Eq. (4) reduces in the confocal cavity case to
a very simple

$\displaystyle\hat{R}^{(1)}\,=\,\left[\begin{array}[]{cc}-1&0\\\
0&-1\end{array}\right]\,=\,-\hat{I}.$ (11)

The $n$-pass confocal cavity matrix can be immediately calculated as
$[\hat{R}^{(1)}]^{n}=(-1)^{n}\hat{I}$, which in turn allows us to calculate
the transformation of an arbitrary initial source ray
$\mbox{\boldmath$r$}_{{}_{0}}$ at the cavity origin after $n$ passes:

$\mbox{\boldmath$r$}_{{}_{n}}\,=\,[\hat{R}^{(1)}]^{n}\mbox{\boldmath$r$}_{{}_{0}}\,=\,(-1)^{n}\mbox{\boldmath$r$}_{{}_{0}}.$
(12)

For an x-ray beam with a distribution of source rays characterized by an
initial average ray vector $\bar{\mbox{\boldmath$r$}}_{{}_{0}}$ that
represents the offset of the beam from the optical axis, Eq. (12) also
describes the pass-to-pass variation of the beam position
$\bar{\mbox{\boldmath$r$}}_{{}_{n}}=\,(-1)^{n}\bar{\mbox{\boldmath$r$}}_{{}_{0}}$
at the source location. The beam position changes periodically but is
reproduced every second pass. If there is no initial beam offset, i.e.,
$\bar{\mbox{\boldmath$r$}}_{{}_{n}}=0$, the beam position is reproduced (is
self-consistent) every pass. In contrast, the beam size

$\sigma_{{}_{n}}=\sqrt{\overline{\left(x_{{}_{n}}-\bar{x}_{{}_{n}}\right)^{2}}}=\sqrt{\overline{x_{{}_{0}}^{2}}-(\bar{x}_{{}_{0}})^{2}}=\sigma_{{}_{0}}$
(13)

never changes at the source origin in the confocal cavity.

####  III.1.2 Self-consistent generic cavity solution

The second solution to Eq. (7) represents a generic cavity configuration. A
Gaussian beam with any Rayleigh length $Z_{{}_{o}}$ is a valid self-consistent
stable solution if focal length $f^{(2)}$ obeys Eq. (7). For this case, the
magnification factor is always $M=1$ for any $Z_{{}_{o}}$ (see Section 3.2 of
Saleh and Teich (2007)). The second waist is located at the midpoint of the
return path and has the same beam waist size as the original Gaussian beam, as
shown schematically in Fig. 3 for $M=1$.

The cavity ray-transfer matrix Eq. (4) in this case is

$\displaystyle\hat{R}^{(2)}\,=\,\left[\begin{array}[]{cc}\frac{1-96r^{2}+256r^{4}}{(16r^{2}+1)^{2}}&\frac{\ell\
(256r^{4}-16r^{2})}{(16r^{2}+1)^{2}}\\\ \frac{16-256r^{2}}{\ell\
(16r^{2}+1)^{2}}&\frac{1-96r^{2}+256r^{4}}{(16r^{2}+1)^{2}}\end{array}\right],\hskip
4.26773ptr=Z_{{}_{o}}/\ell,$ (16)

which transforms to

$\displaystyle\hat{R}^{(2)}\,=\,\left[\begin{array}[]{cc}\cos\phi&Z_{{}_{o}}\sin\phi\\\
-(1/Z_{{}_{o}})\sin\phi&\cos\phi\end{array}\right],$ (19)

using a new parameter $\phi$ defined as

$\displaystyle\cos\phi=A=\frac{1-96r^{2}+256r^{4}}{(16r^{2}+1)^{2}},$ (20)
$\displaystyle\sin\phi=B/Z_{{}_{o}}=-CZ_{{}_{o}}=\frac{16(16r^{2}-1)}{(16r^{2}+1)^{2}},$
(21) $\displaystyle\phi=4\arctan(1/4r).$ (22)

Phase $\phi$ is the accumulated within one round trip Gouy phase
$\arctan(z/Z_{{}_{o}})$ of the Gaussian beams Liu (2021). With the cavity
parameters provided in Table 1,

$\phi=2\pi/2.76.$ (23)

Using Eq. (19), a ray-transfer matrix of a multi-pass cavity can be calculated
as

$\displaystyle[\hat{R}^{(2)}(\phi)]^{n}\,=\,\left[\begin{array}[]{cc}\cos\phi
n&Z_{{}_{o}}\sin\phi n\\\ -(1/Z_{{}_{o}})\sin\phi n&\cos\phi
n\end{array}\right],$ (26)

where $n$ is a number of passes. This expression in turn allows us to
calculate how an arbitrary initial source ray $\mbox{\boldmath$r$}_{{}_{0}}$
at the cavity origin changes after $n$ passes:

$\displaystyle\mbox{\boldmath$r$}_{{}_{n}}\\!=\\![\hat{R}^{(2)}(\phi)]^{n}\mbox{\boldmath$r$}_{{}_{0}}\\!=\\!\left[\begin{array}[]{c}{x}_{{}_{0}}\cos\phi
n+{x}_{{}_{0}}^{\prime}Z_{{}_{o}}\sin\phi n\\\ {x}_{{}_{0}}^{\prime}\cos\phi
n-({x}_{{}_{0}}/Z_{{}_{o}})\sin\phi n\end{array}\right].$ (29)

We now consider a beam of rays with non-zero average distribution of the
initial spatial $\bar{x}_{{}_{0}}$ and initial angular
$\bar{x}_{{}_{0}}^{\prime}$ offset from the optical axis. From Eq. (29) it
follows that the average spatial and angular beam positions at the cavity
origin oscillate after each round-trip pass as

$\bar{\mbox{\boldmath$r$}}_{{}_{n}}\\!=\\!\left[\begin{array}[]{c}\bar{x}_{{}_{n}}\\\
\bar{x}_{{}_{n}}^{\prime}\end{array}\right]=\left[\begin{array}[]{c}\bar{x}_{{}_{0}}\cos\phi
n+\bar{x}_{{}_{0}}^{\prime}Z_{{}_{o}}\sin\phi n\\\
\bar{x}_{{}_{0}}^{\prime}\cos\phi n-(\bar{x}_{{}_{0}}/Z_{{}_{o}})\sin\phi
n\end{array}\right],$ (30)

with a period $2\pi/\phi$, which is a non-integer number of round trips in the
general case. We will refer to this effect as betatron oscillations of x-rays
in a cavity, by analogy to similar effects in periodic accelerator structures
Edwards and Syphers (1992). This effect is of course typical of laser cavities
as well Siegman (1986). The importance of the betatron oscillations for a
closed optical cavity was pointed out recently Kim (2020). The phase $\phi$
corresponds to the phase advance of the betatron oscillations with each round-
trip pass.

Note that, from Eq. (30), betatron oscillations are absent if the initial beam
(source) is perfectly aligned with the optical axis (i.e.,
$\bar{x}_{{}_{0}}=0$ and $\bar{x}_{{}_{0}}^{\prime}=0$). The presence of the
betatron oscillations thus indicates a misaligned source. Table 2 shows an
example of non-zero betatron oscillation for particular source alignment
errors in the cavity whose parameters are provided in Table 1. As shown in the
following sections, the presence of betatron oscillations with a period of
$2\pi/\phi$ is a signature of misalignment (of any kind) in the cavity.

Betatron oscillations are also characteristic of the confocal cavity case, but
there the period of the oscillations is always two cycles; compare Eq. (12)
and Eq. (30).

Table 2: Initial x-ray beam (source) alignment errors and subsequent spatial and angular beam betatron oscillation amplitudes calculated with Eq. (30). Initial alignment errors |  $\bar{x}_{n}$ amplitude |  $\bar{x}_{n}^{\prime}$ amplitude
---|---|---
$\bar{x}_{0}=0$ |  $\bar{x}^{\prime}_{0}Z_{{}_{o}}=5\mu$m |  $\bar{x}^{\prime}_{0}=200$ nrad
$\bar{x}^{\prime}_{0}=200$ nrad |  |
$\bar{x}_{0}=5\mu$m |  $\bar{x}^{\prime}_{0}=5\mu$m |  $\bar{x}_{0}/Z_{{}_{o}}=200$ nrad
$\bar{x}^{\prime}_{0}=0$ |  |

Similarly, Eqs. (29)-(30) can be used to calculate the variation of the rms
spatial and angular spread of the x-ray beam (beam size) after each round
trip:

$\displaystyle\sigma_{{}_{x_{n}}}^{2}=\overline{\left(x_{{}_{n}}-\bar{x}_{{}_{n}}\right)^{2}}=\sigma_{{}_{x_{0}}}^{2}\left(\cos^{2}\phi
n+S^{2}\sin^{2}\phi n\right),$ (31)
$\displaystyle\sigma_{{}_{x_{n}^{\prime}}}^{2}=\overline{\left(x_{{}_{n}}^{\prime}-\bar{x}_{{}_{n}}^{\prime}\right)^{2}}=\sigma_{{}_{x_{0}^{\prime}}}^{2}\left(\cos^{2}\phi
n+S^{-2}\sin^{2}\phi n\right),$ (32)
$\displaystyle{\mathrm{where}~{}~{}}S=\sigma_{{}_{x_{0}^{\prime}}}Z_{{}_{o}}/\sigma_{{}_{x_{0}}},$
(33)

and
$\sigma_{{}_{x_{0}}}=\sqrt{\overline{\left(x_{{}_{0}}-\bar{x}_{{}_{0}}\right)^{2}}}$
and
$\sigma_{{}_{x_{0}^{\prime}}}=\sqrt{\overline{\left(x_{{}_{0}}^{\prime}-\bar{x}_{{}_{0}}^{\prime}\right)^{2}}}$
are initial rms beam size parameters. Here we assume that the spatial and
angular distributions are statistically independent:
$\left<(x_{{}_{0}}-\bar{x}_{{}_{0}})(x_{{}_{0}}^{\prime}-\bar{x}_{{}_{0}}^{\prime})\right>=0$.

If $S=1$, or equivalently

$\sigma_{{}_{x_{0}}}=\sigma_{{}_{x_{0}^{\prime}}}Z_{{}_{o}},$ (34)

we arrive at a stable, self-reproducible beam solution

$\sigma_{{}_{x_{n}}}=\sigma_{{}_{x_{0}}},\hskip
28.45274pt\sigma_{{}_{x_{n}^{\prime}}}=\sigma_{{}_{x_{0}^{\prime}}},$ (35)

valid also for a misaligned source. It is similar to the case of the self-
consistent solution for Gaussian beams given by Eq. (6).

Remarkably, according to Eq. (34), this stable solution is valid only if the
x-ray spatial and angular source sizes $\sigma_{{}_{x_{0}}}$ and
$\sigma_{{}_{x_{0}^{\prime}}}$, respectively, obey the same relationship as
those of the Gaussian beam with Rayleigh range $Z_{{}_{o}}$ at its waist
location.

In all other cases, when $S\not=1$, the beam size and angular spread oscillate
periodically from pass to pass with a twice smaller period around average
values that can be smaller or larger than the initial beam size values,
depending on the $|S|^{2}$ value.

This result implies that the ABCD ray-transfer matrix propagates a collection
of rays with a Gaussian distribution of position and angles given by Eq. (34),
exactly in the same way as it propagates the Gaussian beam with Rayleigh range
$Z_{{}_{o}}$. The equivalence of the paraxial Gaussian ray and Gaussian wave
optics, which is well established Kogelnik and Li (1966); Siegman (1986); Kim
(2020), justifies using ray-transfer techniques to study other aspects of
cavity performance, in particular for a cavity with misaligned optical
components (Section IV).

###  III.2 Ray optics with misaligned elements

The ray-transfer matrix approach can also be used to propagate rays through
optical systems with misaligned optical elements Siegman (1986). Here, we
calculate how the rays are transformed in such cases. These results will be
applied in Section IV to calculate x-ray trajectories in a cavity with
misaligned elements. Those trajectories will be compared with results obtained
with a more advanced numerical simulations approach, which uses the x-ray
optics modeling package Shadow3 Sanchez del Rio et al. (2011).

Figure 4 illustrates the relationships used in calculating misalignment.
Suppose an optical element (a crystal or a lens) is displaced from the perfect
configuration by a distance $\xi$ and an angle $\delta$. The distorted
propagation of the x-rays can be calculated by (i) displacing the incident
x-rays by the same amount as the optical element but in the opposite direction
($-\xi$ and $-\delta$), (ii) transferring the ray with a standard matrix
[$\hat{C}$ or $\hat{L}(f)$], and (iii) moving the transferred ray back by the
adjusted amount. As a result, the coordinates of the distorted ray are given
by

$\displaystyle\begin{bmatrix}x_{n}\\\
x^{\prime}_{n}\end{bmatrix}=M\left(\begin{bmatrix}x_{n-1}\\\
x^{\prime}_{n-1}\end{bmatrix}-\begin{bmatrix}\xi\\\
\delta\end{bmatrix}\right)+\begin{bmatrix}\xi\cos\gamma\\\
\delta\end{bmatrix},$ (36)

where $M$ is the standard ray-transfer matrix corresponding to the optical
element [$\hat{C}$ or $\hat{L}(f)$] and $\gamma$ is the angle between the exit
ray and the incident ray at the location of the optical element, as shown in
Fig. 4. Note that the first adjustment of the ray position ($-\xi$) is
relative to the incident ray. To restore the the exit ray to its correct
position, it needs to be moved by the amount $\xi\cos\gamma$. For a crystal,
the exit ray angle $\gamma=2\theta$ after crystal reflection with Bragg angle
$\theta$. For a lens, $\gamma=0$.

Figure 4: Schematic of incident and adjusted rays clarifying calculation of
the x-ray trajectory distorted by a misaligned optical element.

Thus, the coordinates of the ray vector reflected by a misaligned crystal with
a Bragg angle $\theta=45^{\circ}$ (corresponding to the case of our cavity)
are

$\displaystyle\begin{bmatrix}x_{n}\\\ x^{\prime}_{n}\end{bmatrix}$
$\displaystyle=\hat{C}\begin{bmatrix}x_{n-1}\\\
x_{n-1}^{\prime}\end{bmatrix}+\begin{bmatrix}\xi\\\ 2\delta\end{bmatrix},$
(37)

and the coordinates after a misaligned lens are

$\displaystyle\begin{bmatrix}x_{n}\\\ x_{n}^{\prime}\end{bmatrix}$
$\displaystyle=L(f)\begin{bmatrix}x_{n-1}\\\
x_{n-1}^{\prime}\end{bmatrix}+\begin{bmatrix}0\\\ \xi/f\end{bmatrix}.$ (38)

Eq. (37) shows that crystal misalignment displaces the ray by an amount equal
to the crystal’s positional displacement and deflects the ray by twice the
crystal’s angular misalignment. Eq. (38) indicates that the ray propagation is
not sensitive to angular misalignment of the lens and the angular deflection
of the ray is proportional to positional displacement of the lens. Given the
initial status of a ray and the misalignment status of the optical elements,
the ray position and angle at locations of interest in the cavity can be
traced, as will discussed in the next section.

##  IV Numerical studies

The paraxial ray-transfer matrix and wave-optics Gaussian beam approaches used
in the previous section are limited because the cavity optical components—the
crystals and lenses—are treated in simplified way. The Bragg-reflecting
crystals are considered as 100%-reflecting flat mirrors with unrestricted
spectral and angular reflection widths. Dynamical diffraction effects Authier
(2001) are not taken into account. X-ray absorption in lenses, which limits
their effective aperture Lengeler et al. (1999), is also not considered. As a
result, the round-trip losses in the cavity cannot be studied accurately.

We are using numerical simulation tools to provide for a more realistic
account of the actual properties of the optical elements and to acquire more
detailed insight into the spatial, angular, and temporal behavior of x-rays
(x-ray beam dynamics) and the response of x-ray beam monitors to typical
alignment errors.

The numerical simulations are performed in three dimensions, unlike the two-
dimensional analytical studies performed in Section III.

In most cases, we consider the generic cavity, but we do examine the confocal
cavity case in Section IV.8 for comparison.

Figure 5: A diagram of the simulation work flow. (OE stands for optical
elements.)

###  IV.1 Method

Numerical simulations in this work are performed using the x-ray optics
modeling package Shadow3 Sanchez del Rio et al. (2011) in the Oasys
environment Rebuffi and Sánchez del Río (2016); Rebuffi and del Rio (2017) and
custom Python scripts.

As shown in Fig. 5, the simulation program starts with defining the x-ray
source and all optical elements (crystals and refractive lenses) that exist in
the cavity. The source generates x-rays with randomized positions, angles, and
energies with a given Gaussian distribution. The rays propagate and interact
with each optical element (OE) in the cavity and return to the source. When
multiple-cycle simulation is desired, the x-ray beam keeps propagating and
repeats similar simulations as in the first cycle. The status of all x-rays
after each OE is recorded for the analysis.

In cases that are not affected by the limited reflection width of the crystals
or by photoabsorption in lenses (e.g., for small spatial and angular beam
deflections from the optical axes), the x-ray beam dynamics are also
calculated, using the ray-tracing matrix approach (Section III.2), and
compared with the numerical simulation results obtained with the Shadow3
package.

The x-ray source and optical elements parameters of the simulated CBXFEL
system are listed in Table 1.

###  IV.2 Perfectly aligned system

We commence with a perfectly aligned system and a generic cavity in which the
optical elements and the x-rays source are in the spatial and angular
positions shown in Fig. 1.

Figure 6: Numerical simulations of x-ray beam dynamics in the perfectly
aligned generic four-crystal rectangular cavity shown in Fig. 1. Values are
presented simulated at cavity midpoint (top, left column), source center (top,
right column), and beam intensity monitor positions (bottom row). The cavity
and source parameters are provided in Table 1. Two resolutions are shown:
$2\times 10^{5}$ rays (red) and $2\times 10^{6}$ rays (blue). The positional
and angular oscillations are due to numerical simulation artifacts, as
discussed in the text. See text for details.

Figure 6 presents results of the numerical simulations, which will serve as a
baseline to identify signatures of misalignment in subsequent studies. The
graphs in the top four rows show variations after each round-trip cycle of the
x-ray beam spatial position (a)-(b), angle (c)-(d), transverse beam size
(e)-(f), and beam intensity (g)-(h) calculated either at the midpoint of the
return path (left column) or at the x-ray source location (right column). The
beam positions and angles are measured as a relative deviation of the average
ray distribution from the optical axis. The beam size is calculated as the rms
of the ray distribution.

Graphs (i)-(l) in the bottom row of Fig. 6 show the intensities (calculated
for each cycle) of x-rays transmitted through crystals
C${}_{{}_{1}}$-C${}_{{}_{4}}$, respectively. In an experiment, these
intensities would be measured by the corresponding XBIMs
D${}_{{}_{1}}$-D${}_{{}_{4}}$ shown in Fig. 1.

The analytical studies performed in Section III (for a perfectly aligned
cavity with an x-ray source generating a self-consistent Gaussian beam)
predict a perfectly reproducible beam after each round trip. In contrast, the
numerical simulations show pass-to-pass periodic non-zero variation of the
x-ray beam position, angle, and size in the perfectly aligned cavity at both
source and midpoint. The x-ray beam trajectory oscillates with a period of
2.77 cavity cycles. This value corresponds exactly to the period of the
betatron oscillations derived for a system with the same parameters featuring
a perfectly aligned cavity but a misaligned source [see Eqs. (23), (29), and
(30)].

As we noted in Section III, betatron oscillations are a signature of
misalignment, in particular, of the x-ray source. We do in fact have a
misaligned source in this case, but here the “misalignment” is an artifact
arising from the use of a finite number of rays. Such a “beam” consisting of
discrete rays is never perfectly aligned with the optical axis. Figure 6
provides a baseline for the scale of beam variations due to this artifact. In
fact, the spatial and angular variations in Figs. 6(a)-(f) are very small,
about 1/1000 of the beam size and angular beam divergence, and therefore can
be neglected in this case. To explore the scale of this artifact, we use
simulations at two resolutions: $2\times 10^{5}$ rays (red) and $2\times
10^{6}$ rays (blue). Increasing the number of rays decreases the amplitudes of
the oscillations, albeit at a cost of increased computation time, but they
never reach zero (that would occur only with an infinite number of rays). The
simulations of a misaligned cavity presented in the following sections use the
lower resolution of $2\times 10^{5}$ rays.

The beam size in Figs. 6(e)-(f) oscillates with a twice smaller period and an
amplitude of $\simeq 0.3~{}\mu$m around an average value of $\simeq
15.2~{}\mu$m. The oscillations are independent of the number of rays and
therefore this effect is not the artifact discussed in the previous paragraph.
The average beam size is smaller than the source size value of $15.9~{}\mu$m
[See Table 1]. According to Eqs. (31)-(33), this indicated that the numerical
value of parameter $|S|^{2}\not=1$ [See Eq. (33)], i.e. x-ray source
parameters are chosen slightly off those of a Gaussian beam with Rayleigh
length $Z_{{}_{o}}$ at its waist.

Figure 6 also shows the evolution of the beam intensity. The intra-cavity
intensity of x-rays decays exponentially, with a half lifetime of
$t_{{}_{1/2}}=10.8(1)$ cycles [see Figs. 6(g)-(h)]. We note that the faster
decay during the first cycles occurs because the x-ray source bandwidth used
in the calculations ($\simeq 100$ meV) is slightly larger than the $\simeq 90$
meV bandwidth of the 400 Bragg reflection of the diamond crystals. The round-
trip intensity losses are about 6.4%. Of this, $\simeq 3$ % is coupled out
through 20-$\mu$m-thick crystal C${}_{{}_{1}}$. Figure 6(i) shows the relevant
out-coupling time dependence, with a decay constant of 9.3 cycles. The
remaining losses are due to photoabsorption in the lenses and crystals.

Figures 6(j)-(l) show the time dependence of leakage through crystals
C${}_{{}_{2}}$-C${}_{{}_{4}}$, respectively, of x-rays belonging to the tails
of the intra-cavity spectral distribution. The magnitudes of the signals are
small, and they vanish rapidly as the tails become sharper after each Bragg
reflection. If the crystal C${}_{{}_{1}}$ thickness is increased to match that
of crystals C${}_{{}_{2}}$-C${}_{{}_{4}}$, the decay constant in Fig. 6(i)
becomes as fast as those in Fig. 6(j)-(l).

Figure 7: Schematics of crystal misalignment scenarios. One-crystal
misalignment: (a) yaw angle $\delta$, (b) roll angle $\rho$, and (c) position
$\xi$ for crystal C${}_{{}_{4}}$. Systematic multi-crystal misalignment: (d)
yaw angles $\delta$, $3\delta$, $5\delta$, and $7\delta$ for crystals
C${}_{{}_{1}}$-C${}_{{}_{4}}$, respectively.

###  IV.3 Alignment errors

Having established the baseline performance for a perfectly aligned cavity, we
now model the effects of typical angular and spatial alignment errors on the
x-ray beam trajectory in the cavity and how these in turn are reflected in the
temporal response of the beam monitors. In most cases, we consider alignment
error of a single degree of freedom of a single optical component or of the
x-ray source.

Figure 8: Additional misalignment scenarios. (a) Lens L${}_{{}_{1}}$ with yaw
angle error $\delta$ or (b) spatial error $\xi$; (c) undulator source with yaw
angle $\delta$ or (d) position misalignment $\xi$.

For example, one crystal in the cavity can be misaligned by yaw angle $\delta$
[crystal C${}_{{}_{4}}$ in Fig. 7(a)], which corresponds to the rotation
around the $\hat{y}$-axis perpendicular to the crystal cavity, while the other
crystals are aligned perfectly at the designed
$45\text{\,}\mathrm{\SIUnitSymbolDegree}$ to the optical axis and
perpendicular to the cavity plane. Alternatively, the roll angle $\rho$ of one
crystal can be misaligned [crystal C${}_{{}_{4}}$ in Fig. 7(b)], corresponding
to rotation around the axis formed by the intersection of the crystal surface
and the cavity plane. A typical spatial alignment error $\xi$ of crystal
C${}_{{}_{4}}$ along the $\hat{x}$-axis is shown in Figure 7(c). The arrows on
the schematics show in all cases the positive direction of the alignment
error.

Figure 9: Simulation results of the beam dynamics in the rectangular four-
crystal cavity without lenses with systematically misaligned crystal yaw
angles.

Figure 10: Similar to Fig. 12, but with yaw angle error $\delta$ in crystal
C${}_{{}_{4}}$.

Figure 11: Similar to Fig. 12, but with roll angle error $\rho$ in crystal
C${}_{{}_{4}}$. The dashed lines show out-of-cavity-plane deflections.

Figure 12: Similar to Fig. 12, but with spatial error $\xi$ in crystal
C${}_{{}_{4}}$.

Along with single-element alignment errors, we also consider a special multi-
crystal error case, which we refer to as systematic angular misalignment. This
kind of error is typical for fixed-photon-energy cavities, such as the four-
crystal cavity we are considering here, which require the yaw angles (Bragg
angles) of all crystals to be fixed. Such multi-crystal error occurs naturally
as a result of the cavity alignment procedure. Cavity alignment starts with
installation of crystal C${}_{{}_{1}}$ as close as possible to
$45\text{\,}\mathrm{\SIUnitSymbolDegree}$to the incident beam; however, this
placement can never be exactly $45\text{\,}\mathrm{\SIUnitSymbolDegree}$. If
the first crystal is misaligned by yaw angle $\delta$, then the reflected beam
is $2\delta$ off the optical axis. To achieve the highest reflectivity at
every next crystal, the second, third, and fourth crystals have to be
misaligned by angles $3\delta$, $5\delta$, and $7\delta$, respectively, as
shown in Fig. 7(d). The beams reflected from these crystals are $4\delta$,
$6\delta$, and $8\delta$ off the optical axis, respectively. In this scenario,
we assume that no lenses are installed.

In later sections, we study the effects of such crystal alignment errors on
x-ray beam dynamics in the cavity; however, we first consider a pure crystal
cavity without lenses, in which the effect of the angular and spatial errors
can be disentangled.

Other possible misalignment errors discussed later are presented in Fig. 8.

###  IV.4 Lensless cavity with crystal alignment errors

Figure 12 shows simulation results of x-ray beam dynamics in the four-crystal
cavity without lenses with systematically misaligned crystal yaw angles,
corresponding to Fig. 7(d). Figures 12, 12, and 12 show numerical simulation
results when crystal C${}_{{}_{4}}$ has yaw angle alignment error $\delta$,
roll angle error $\rho$, or spatial alignment error $\xi$, respectively,
corresponding to Fig. 7(a)-(c). In all these figures, the results are
organized like those for the perfectly aligned cavity in Fig. 6, with one
exception: in Figs. 12(i)-(l) and 12(i)-(l), the time response in XBIMs
D${}_{{}_{1}}$-D${}_{{}_{4}}$ is shown on a linear scale. Each figure includes
data for a perfectly aligned lensless cavity.

The intra-cavity intensity half lifetime increases from 10.6 cycles for a
perfect cavity with lenses (Fig. 6) to 12.7 cycles for a perfect lensless
cavity, because the lenses and their associated losses are absent.

For all instances of the lensless cavity (including perfectly aligned) the
beam size rapidly increases by $\simeq 40~{}\mu$m/cycle (rms), because there
is no refocusing.

For cavities with yaw angle errors, each cycle increases both the angular and
spatial deviation of the beam from the optical axis at both source and
midpoint. The angular deviation increases linearly, and the spatial deviation
increases quadratically. The systematic multi-crystal yaw error produces an
effect 4 to 5 times larger than the one-crystal yaw angle error. Already after
a few cycles, the angular deviations become larger than the half width (4.5
$\mu$rad) of the angular width of the 400 Bragg reflection from diamond. As a
result, leakage through the crystals increases, causing increased signals at
XBIMs D${}_{{}_{1}}$-D${}_{{}_{4}}$ compared to the perfectly aligned lensless
cavity [see Figs. 12(i)-(l) and Figs. 12(i)-(l)]. The intra-cavity intensity
also decreases rapidly with yaw angle error $\delta$ [see Fig. 12(g)-(h) and
Fig. 12(g)-(h)].

In contrast, the effect of the roll angle error $\rho$ of crystal
C${}_{{}_{4}}$ is much smaller, both on the in-cavity-plane beam position and
on the in-cavity-plane angular deviation from the optical axis, as shown by
solid lines in Figs 12(a)-(d). The effect is small because there is only a
weak coupling between variation in roll angle and variation in the angle of
incidence of x-rays to the reflecting atomic planes in the crystals. As a
result, the intra-cavity decay curves in Figs. 12(g)-(h) and the signal
variations in XBIMs D${}_{{}_{1}}$-D${}_{{}_{4}}$ in Figs. 12(i)-(l) do not
differ from those for the perfectly aligned lensless cavity. The main effect
of the roll angle error is in the out-of-plane deviation of the beam position
and angle at both source and midpoint, as shown by the dashed lines in Figs
12(a)-(d). The roll angle misalignment can be corrected in the lensless
crystal cavity by observing the beam profile at the midpoint location.

For all types of crystal angular errors, a positive angular error results in
negative angular and negative spatial deviation of the x-ray beam from the
optical axis.

The spatial alignment error $\xi$ of crystal C${}_{{}_{4}}$ results only in a
rapid linear increase of the beam position deviation from the optical axis
(positive for positive error) at both source and midpoint, while the beam
angle does not change. As a result, the decay curves in Figs. 12(g)-(l) are
the same as for the perfectly aligned lensless cavity.

In the lensless cavity, the spatial crystal error does not affect the angular
beam deviations. This property can be used for cavity alignment, as discussed
in Section V.

###  IV.5 Complete generic cavity with crystal alignment errors

Figure 13: Numerical simulation results of x-ray beam dynamics in the
rectangular four-crystal generic cavity with systematically misaligned crystal
yaw angles.

Figure 14: Similar to Fig. 16, but with yaw angle error $\delta$ in crystal
C${}_{{}_{4}}$.

Figure 15: Similar to Fig. 16, but with roll angle error $\rho$ in
C${}_{{}_{4}}$.
The dashed lines represent out-of-cavity-plane deviations.

Figure 16: Similar to Fig. 16, but with position error $\xi$ in crystal
C${}_{{}_{4}}$.

We now consider a complete four-crystal rectangular cavity with lenses, as in
Fig. 1, featuring various crystal alignment errors. Figures 16-16 show
numerical simulation results of the x-ray beam dynamics for the following
cases: systematically misaligned yaw angles of crystals
C${}_{{}_{1}}$-C${}_{{}_{4}}$ (Fig. 16), one-crystal yaw angle error in
C${}_{{}_{4}}$ (Fig. 16), roll angle error in crystal C${}_{{}_{4}}$ (Fig.
16), or position error in crystal C${}_{{}_{4}}$ (Fig. 16). The simulation
results in Figs. 16-16 are arranged in the same way as those for the perfect
cavity in Fig. 6, with one exception. In panels (a)-(d) of Figs. 16, 16, and
16, we show with thick pink lines the results of calculations using ray-
transfer matrices (see Section III.2), for comparison with the results
obtained with the Shadow3 simulation package Sanchez del Rio et al. (2011).
Remarkably, they are practically identical, as long as the angular deviations
are much smaller than the angular width of the Bragg reflections.

####  IV.5.1 Betatron oscillations

Adding the focusing lenses dramatically changes the x-ray beam dynamics in the
cavity. For the same crystal alignment errors, the beam size, beam trajectory,
and beam monitor response are completely different in the complete cavity.

Unlike the lensless cavity case, any alignment error produces both spatial and
angular deflections of the beam from the optical axis.

In all presented cases, the pass-to-pass variations of the spatial or angular
deviations from the optical axis as well as of the beam size are much smaller,
compared to the lensless cavity analogs shown in Figs. 12-12. The beam size
variation and the beam position deflection from the optical axis per cycle are
now about 100 times smaller, while the angular deflection per cycle is 10
times smaller, compared to the analogous conditions for the lensless cavity.
These changes are clear evidence that the beam size and beam trajectory are
stabilized by the lenses. This stabilization takes place only if the
parameters and locations of the lenses are chosen properly, as discussed in
Section III.1. We note that we are considering here the generic cavity case;
the confocal cavity case is considered later, in Section IV.8.

Table 3: Comparison of the beam characteristics at the source location and at the midpoint of the return path for the cavity with the systematically misaligned crystal yaw angles ($\delta$ = $0.10\text{\,}\mathrm{\SIUnitSymbolMicro rad}$). |  Beam position ($\mathrm{\SIUnitSymbolMicro m}$) |  Beam angle ($\mathrm{nrad}$) |  Beam size ($\mathrm{\SIUnitSymbolMicro m}$) |  Half lifetime (cycles) |  Oscillation period (cycles)
---|---|---|---|---|---
Source | 10.82 | 8.67 | 15.17 | 10.8 | 2.77
Midpoint | 11.10 | 8.91 | 15.17 | 10.9 | 2.77
Table 4: X-ray beam characteristics at the source position calculated for
various crystal misalignment types from the data in Figs. 16-16. A second sign
for offset values is provided if the sign differs between the source and the
midpoint. Offset values for both locations are given for the crystal position
error case.

[t]  c c c c c c c c c c c c c c  c c c c c c c c c c c c c c c c  Alignmentc
errorc c c c c c Betatron oscillation type and parameters Half lifetime
(cycles) Position ($\mathrm{\SIUnitSymbolMicro m}$) Angle (nrad) Size
($\mathrm{\SIUnitSymbolMicro m}$) Type Value Offset Amplitude (rms) Offset
Amplitude (rms) Average Amplitude (rms) None 0 0 0.02 0 0 15.47 0.26 10.8
C${}_{{}_{1}}$-C${}_{{}_{4}}$ systematic yaw angle $\delta$ (nrad) 50 5.41
4.03 4 151 15.24 0.45 10.7 100 10.82 8.03 9 303 15.17 0.27 10.6 C${}_{{}_{4}}$
yaw angle $\delta$ (nrad) 200 5.49 4.69 $\pm$ 134 188 15.25 0.33 10.6 400
10.99 9.34 $\pm$ 268 375 15.24 0.39 10.4 C${}_{{}_{4}}$ roll angle $\rho$1
(nrad) 200 3.88 3.29 $\pm$ 95 132 15.33 0.33 10.8 400 7.77 6.57 $\pm$ 189 264
15.31 0.32 10.8 C${}_{{}_{4}}$ position $\xi$ ($\mu$m) 10 4.81 (-0.09) 4.03
-0.09 (-0.21) 0.15 15.15 0.42 10.8 20 9.63 (-0.17) 8.04 -0.18 (-0.42) 0.29
15.34 0.41 10.7

  * 1

The roll-angle alignment errors result primarily in off-cavity-plane x-ray
beam deflections, with the corresponding values shown in the table. The effect
on the in-cavity-plane beam deflections is minor and not shown.

Unlike the steadily increasing beam size and increasing spatial and angular
beam deviations from the optical axis in the lensless cavity, the beam size
and beam deviations in the complete cavity experience periodic variations
having a constant amplitude and constant offset from the optical axis. This
effect is found at both source and midpoint for all simulated cases, as shown
in Figs. 16-16. Remarkably, the oscillation period of the beam deviations is
always 2.77 cycles, independent of the type of misalignment, while the beam
size oscillation period is half that value. These values correspond exactly to
the period of the betatron oscillations in a perfectly aligned generic cavity
with a misaligned source, as derived analytically in Section III.1.2 [see Eqs.
(23), (30), and (31)-(32)] for a CBXFEL system with the same cavity and source
parameters. These betatron oscillations are not specific to this particular
cavity. Rather, they are a generic signature of misalignments in periodic
focusing systems composed of lenses or mirrors, whether these are laser
cavities Siegman (1986) or accelerators Edwards and Syphers (1992).

The amplitudes and offsets of the betatron oscillation increase in proportion
to the alignment error values111We note that the amplitudes of the betatron
oscillation in Figs. 16-16 are much larger than those in Fig. 6, which are due
to the artifact arising from use of a finite number of discrete rays in the
beam, as discussed in Section IV.2. This difference means that the
oscillations in Figs. 16-16 are real effects.. Only in a few cases, which we
will term symmetric, are the oscillation offsets zero. One such case is
systematic angular misalignment, for which the offset of the angular
oscillations is zero at both source and midpoint and is independent of the
alignment error value [see Fig. 16(c)-(d)], while simultaneously the offset of
the spatial oscillations is non-zero [see Fig. 16(a)-(b)]. A second case is a
cavity with position error $\xi$ in crystal C${}_{{}_{4}}$ [see Fig. 16(a)],
for which the offset of the spatial oscillations does reach zero, but only at
the midpoint of the return pass. In all other cases, the oscillation offsets
are non-zero, and we will refer to such cases as asymmetric betatron
oscillations.

Asymmetric betatron oscillations take place only on one side of the optical
axis, with the beam touching or barely crossing the axis. The side on which
oscillations occur depends on the sign of the alignment error or on which
crystal is misaligned. In the first approximation, the offset of the betatron
oscillations is equal to their amplitude. The smallest deflection from the
optical axis for any error value or type is near zero (the beam is almost on
the optical axis), while the largest deviation equals two amplitudes.

Another common signature can be observed in the beam dynamics in the cavities
with angular crystal alignment errors. In all such cases (see Figs. 16-16),
the beam characteristics (size and deflections) are very similar, both at the
source center and at the midpoint. See, for example, the values in Table 3 for
the case of systematically misaligned yaw angles. Stated another way, the beam
monitors at the midpoint reflect the beam status at the source.

This similarity of beam characteristics between source and midpoint is
observed in most of the simulations, with one exception. In the case of
spatial error in crystal C${}_{{}_{4}}$, the offset values of the betatron
oscillations at the two locations are different, as shown in Fig. 16. However,
the beam size and the amplitudes of the betatron oscillations are still the
same at both locations.

Table 4 presents x-ray beam characteristics at the source location calculated
for various crystal misalignment types from the data in Figs. 16-16. Shown are
offsets and amplitudes of the betatron oscillations for the beam position,
angle, and size. If the offsets have different signs at the two locations,
both signs are provided, with the upper sign corresponding to the source
center and lower sign to the midpoint location. For the case of position error
in crystal C${}_{{}_{4}}$, we provide offset values for both locations.

The smallest crystal alignment errors shown in the table are chosen such that
the rms amplitude of the betatron oscillations for the beam position is less
than 5 $\mu$m, i.e., smaller than one third of the 16-$\mu$m rms source size
(see Table 1). These smallest alignment errors could be considered as
alignment error tolerances.

There are several issues to be noted regarding the signs of the offsets. For
all positive crystal alignment errors (angular and spatial), the offset of the
spatial betatron oscillations is positive at all monitored positions, with one
exception, namely, for spatial error at crystal C${}_{{}_{4}}$. For that case,
the spatial betatron oscillations are symmetric with zero offset at the
midpoint location. For the angular betatron oscillations, the offset is zero
for the systematic misalignment case, negative at both source and midpoint for
the case of spatial error in crystal C${}_{{}_{4}}$, and opposite in sign for
the cases of yaw and roll error at crystal C${}_{{}_{4}}$ (positive offset at
the source, negative offset at the midpoint). Note that if a different crystal
is faulty, the signs may change relative to those noted in Table 4 for errors
at crystal C${}_{{}_{4}}$. For example, a faulty crystal C${}_{{}_{3}}$
changes the sign of both position and angular oscillation. For a faulty
crystal C${}_{{}_{2}}$, the sign of angular oscillation changes but that of
position does not. The reverse is true for a faulty crystal C${}_{{}_{1}}$,
where the position sign changes but the angular sign does not.

The deviations of the beam from the optical axis in the cavity plane are
observed to be more sensitive to systematic yaw angle misalignment than to the
one-crystal yaw angle misalignment, and least sensitive to roll angle
misalignment.

Figure 17: Simulation results of x-ray beam dynamics in the four-crystal
generic cavity with yaw angle error $\delta$ at lens L${}_{{}_{1}}$.

Figure 18: Similar to Fig. 18, but with position error $\xi$ at lens
L${}_{{}_{1}}$.

Table 5: X-ray beam characteristics at the source position simulated for the
cavity with yaw angle error $\delta$ or lateral spatial error $\xi$ of one
lens derived from the data in Figs. 18-18. A second sign for offset values is
provided if the sign differs between the source and the midpoint.

[t]  Alignment error Betatron oscillation type and parameters Half lifetime
(cycles) Position ($\mathrm{\SIUnitSymbolMicro m}$) Angle (nrad) Size
($\mathrm{\SIUnitSymbolMicro m}$) Type Value Offset Amplitude (rms) Offset
Amplitude (rms) Average Amplitude (rms) None 0 0.00 0.02 0.00 0.00 15.47 0.26
10.8 L${}_{{}_{1}}$ yaw angle $\delta$ (mrad) 10 0.00 0.04 0.00 0.00 15.24
0.39 10.8 100 0.00 0.04 0.00 0.00 15.25 0.40 10.8 L${}_{{}_{1}}$ position
$\xi$ ($\mu$m) 10 -4.80 4.31 $\pm$123 158 15.26 0.34 10.6 20 -9.60 8.63
$\pm$246 316 15.21 0.39 10.4

Figure 19: Simulation results of x-ray beam dynamics in the rectangular four-
crystal generic cavity with angle error $\delta$ at source.

Figure 20: Similar to Fig. 20, but with position error $\xi$ at source.

Table 6: X-ray beam characteristics at the source position simulated for a
cavity with yaw angle alignment error $\delta$ or lateral spatial error $\xi$
at the source as derived from the data in Figs. 20-20.

[t]  Alignment error Betatron oscillation type and parameters Half lifetime
(cycles) Position ($\mathrm{\SIUnitSymbolMicro m}$) Angle (nrad) Size
($\mathrm{\SIUnitSymbolMicro m}$) Type Value Offset Amplitude (rms) Offset
Amplitude (rms) Average Amplitude (rms) None 0 0.00 0.02 0.00 0.00 15.47 0.60
10.7 Source angle $\delta$ (nrad) 250 -0.10 4.41 7 178 15.30 0.51 10.7 500
-0.20 8.87 15 358 15.15 0.41 10.7 Source position $\xi$ ($\mu$m) 5 0.15 3.58 3
134 15.27 0.42 10.7 10 0.3 7.17 6 269 15.16 0.38 10.7

Transverse beam size oscillations observed in panels (e)-(f) of Figs. 16-16 do
not change either with the type or magnitude of the alignment errors and have
the same origin as those in the perfectly aligned cavity, see Figs. 6(e)-(f)
and discussion in Section. IV.2.

####  IV.5.2 Cavity ringdown curves

In contrast to the lensless cavity, the angular beam variations due to the
crystal alignment errors are much smaller than the width of the Bragg
reflections. As a result, the intra-cavity ringdown curves in panels (g)-(h)
of Figs. 16, 16, and 16, together with their half lifetimes, do not change
substantially and are close to those of the perfectly aligned cavity case. For
the roll angle misalignment case, the ringdown curves practically do not
change at all; see Figs. 16(g)-(h). This lack of change is due to weak
coupling between the variation of the crystal roll angle and the variation of
the angle of incidence of x-rays to the Bragg reflecting atomic planes in the
crystals. Similar behavior is observed in the analogous lensless cavity case
presented in Fig. 12.

The ringdown curves in panels (j)-(l) of Figs. 16, 16, and 16, reflecting
leakage of x-rays through crystals C${}_{{}_{2}}$-C${}_{{}_{4}}$, reveal
higher sensitivity to crystal errors. The betatron oscillations can be
detected by XBIMs D${}_{{}_{2}}$-D${}_{{}_{4}}$, as calculations in panels
(j)-(l) show. They are practically invisible at XBIM D${}_{{}_{1}}$ [panel (i)
in each figure], reflecting output coupling of x-rays through crystal
C${}_{{}_{1}}$. Additional simulations (not presented here) show that the
visibility of the betatron oscillations at XBIM D${}_{{}_{1}}$ increases with
the thickness of crystal C${}_{{}_{1}}$.

Although crystals C${}_{{}_{2}}$-C${}_{{}_{4}}$ have identical thicknesses,
the ringdown curves in panels (j)-(l) of Figs. 16, 16, and 16 are different.
Additional simulations show that this difference has two causes: first, the
asymmetric shape of the Bragg reflection angular dependence, and second, the
presence of a dispersive crystal setting. As a result, angular deflection from
the Bragg peak always has a different sign from the preceding reflection and,
therefore, a slightly different reflectivity.

###  IV.6 Complete generic cavity with misaligned lenses

In the next step, we consider the complete four-crystal rectangular cavity as
in Fig. 1, now including x-ray lenses with angular and spatial alignment
errors. Figure 18 shows numerical simulation results of the x-ray beam
dynamics in the cavity with lens L${}_{{}_{1}}$ having yaw angle error
$\delta$, while Fig. 18 shows results for lens L${}_{{}_{1}}$ having lateral
position error $\xi$. The simulation results in Figs. 18-18 are organized in
the same way as those for the cavity with crystal alignment errors (Figs.
16-16). Table 5 presents relevant x-ray beam characteristics, organized
analogously to Table 4 for the crystal error cases.

The x-ray beam dynamics are very insensitive to angular errors at the lens.
This behavior is expected because the x-ray beam (a few tens of micrometers in
cross-section) is at almost normal incidence to the nearly flat apex of the
parabolic surface of the lens (radius of curvature 200 $\mu$m). The angular
errors must be in a radian range to produce any significant distortion of
x-ray beam trajectory.

In contrast, the lateral spatial errors at the lens are as critical for x-ray
beam dynamics as spatial errors at the crystals. The lateral spatial error
tolerance is $|\xi|\lesssim 10~{}\mu$m, very similar to the crystal spatial
error case (compare Tables 4 and 5). The ringdown curves also have similar
behavior for both crystals and lenses.

###  IV.7 Perfect generic cavity with misaligned x-ray source

Betatron oscillations of the x-ray beam can be induced even in a perfectly
aligned cavity, provided the x-ray source is misaligned, as shown in our first
analysis of betatron oscillations using analytical methods, in Section
III.1.2.

The numerical simulations of the beam dynamics for this case are shown in
Figs. 20-20, and the beam characteristics are presented in Table 6.

Both the angular and spatial source misalignment types result in symmetric
betatron oscillations of the x-ray beam position and angle (see Figs. 20-20,
respectively), in agreement with analytical calculations represented by Eq.
(30). Both approaches—analytical and numerical—also agree quantitatively. The
thick pink lines in Figs. 20-20 show results calculated with the ray-transfer
matrix approach; they are almost identical to the red lines for the results
calculated numerically with the Shadow3 package Sanchez del Rio et al. (2011)
for the same magnitudes of the alignment errors.

The sensitivity to the source alignment errors is comparable to the
sensitivity to alignment errors of the optical elements. The smallest
alignment errors in Table 6 can be considered as source alignment tolerance.

Figure 21: Numerical simulation results of x-ray beam dynamics in the confocal
rectangular four-crystal cavity with systematically misaligned crystal yaw
angles.

Figure 22: Similar to Fig. 24, but with yaw angle error $\delta$ at crystal
C${}_{{}_{4}}$.

Figure 23: Similar to Fig. 24, but with position error $\xi$ at lens
L${}_{{}_{1}}$.

Figure 24: Similar to Fig. 24, but with position error $\xi$ at crystal
C${}_{{}_{4}}$.

###  IV.8 Misaligned confocal cavity

So far in this section we have used numerical methods to study x-ray beam
dynamics in a generic four-crystal rectangular x-ray cavity. Here we address
x-ray beam dynamics in a confocal cavity, which we studied partially using
analytical methods in Section III.1.1. The only difference to the generic
cavity case is a different choice of the focal length of both lenses, which is
now $f^{(1)}=\ell/4=16.3$ m (see Table 1). In the confocal cavity case,
Gaussian beams with any Rayleigh length $Z_{{}_{o}}$ are stable and self-
consistent solutions. In our calculations, we will use the same parameters for
the Gaussian x-ray source as in the generic cavity case.

Figures 24-24 show numerical simulation results of the x-ray beam dynamics in
the confocal cavity with different alignment errors: systematically misaligned
yaw angles at crystals C${}_{{}_{1}}$-C${}_{{}_{4}}$ (Fig. 24), one-crystal
yaw angle error $\delta$ at C${}_{{}_{4}}$ (Fig. 24), position error $\xi$ at
crystal C${}_{{}_{4}}$ (Fig. 24), and position error $\xi$ at lens
L${}_{{}_{1}}$ (Fig. 24). The simulation results in Figs. 24-24 are arranged
in the same way as those for the generic cavity in Figs. 16-16.

Just as in the generic cavity, alignment errors in the confocal cavity result
in betatron oscillations (both symmetric and asymmetric) of the x-ray beam
position and angle. Unlike the generic cavity case, however, the beam size at
the monitored locations is stable; there are no beam size oscillations, in
agreement with Eq. (13). Also unlike the generic cavity, the beam sizes at the
source and the midpoint are different. At the midpoint, the beam size is
demagnified to $\simeq 9.8~{}\mu$m from $\simeq 15.8~{}\mu$m at the source
location due to a demagnification factor of $M=0.62$, in agreement with
$M=f^{(1)}/Z_{{}_{o}}$ of Eq. (8).

For the same magnitudes of the alignment errors, the magnitudes of the spatial
and angular beam displacements from the optical axis are close to those
observed in the generic cavity discussed earlier.

However, there are some substantial differences. The period of the betatron
oscillation in the confocal cavity is exactly 2 cycles (compare to 2.77 cycles
in the generic cavity), in agreement with analytical simulations in Section
III.1.1 [see Eq. (12)].

Due to this two-cycle period, for all types of alignment errors of the optical
elements in a confocal cavity, the x-ray beam returns to the initial position
on the optical axis every second pass. The angular beam deviations show
similar behavior, but in some cases the angular deviations are always zero,
i.e., completely insensitive to some types of alignment errors, such as
systematic angular misalignment and spatial error at crystal C${}_{{}_{4}}$.

This property, however, does not extend to the source alignment errors. From
Eq. (12) and results of numerical simulations that are not shown here, the
x-ray source error is reproduced every second cycle. The beam size, however,
either does not change at the source origin, provided the source errors are
involved, or varies insignificantly by 0.15 $\mu$m (rms) because of the
optical elements errors..

These very interesting properties of the confocal cavity can be used to
mitigate tolerances on CBXFEL cavity alignment errors (albeit not on the
source errors). For this approach to work, however, the electron bunches
should arrive with a periodicity matching the betatron oscillations, i.e.,
with a period equal to two round-trip times of x-rays in the optical cavity.
This approach also halves the cavity size for the given electron beam
repetition rate, but at a cost of increased cavity losses, as every second
round trip is idle.

Ringdown curves in the confocal cavity are of course not identical to those in
the generic cavity, showing instead some nuanced differences. However, the
decay times are similar.

##  V Cavity alignment

There are tens of degrees of freedom of the optical elements in CBXFEL
cavities (close to 30 in the rectangular four-crystal cavity considered in
this paper)—many more than in a classical laser oscillator cavity. All these
degrees of freedom have to be aligned with a precision ensuring that the to-
be-amplified x-ray beam a few tens of microns in cross-section returning into
the undulator meets a fresh electron bunch of a similar size.

The effects of different alignment errors are (in most cases) entangled. Where
should cavity alignment start, and how should it be performed? The results of
the numerical simulation presented in Section IV can be used to propose a
strategy for cavity alignment.

First, we recall that in the lensless cavity the spatial crystal error does
not affect the angular beam deviations (see Fig. 12). Similarly, the roll
angle crystal errors in the lensless cavity produce very small effects on the
in-cavity-plane angular beam deviations (see Fig. 12).

As a result, the angular and spatial errors can be decoupled by first aligning
crystals in the absence of lenses and then moving in and aligning the lenses.
The full procedure would be as follows:
(1) With lenses removed, align crystal angles (yaw and roll).
(2) Align crystal positions.
(3) Move in and align lenses.
(4) Adjust the round-trip time to the periodicity of the electron bunches by
changing simultaneously the longitudinal positions of two crystals (e.g.,
C${}_{{}_{2}}$ and C${}_{{}_{3}}$) and optimizing the CBXFEL gain.

Time-resolved signals from XBIMs D1, D2, D3, and D4 and from the XBPM at the
midpoint are essential for all steps in the alignment.

As noted earlier, the results of our studies show that the XBPM at the
midpoint reflects the beam status at the source. This fact is very useful, as
in practice it is much easier to monitor the beam at the midpoint than in the
undulator.

##  VI Discussion, conclusions and outlook

We are studying spatial, angular, and temporal behavior of x-ray beams
generated by a Gaussian source and stored in a stable x-ray cavity (i.e.,
x-ray beam dynamics) using analytical methods (paraxial ray-transfer matrix,
wave-optics Gaussian beam methods) and numerical ray-tracing computer codes.
An example of a rectangular cavity with a 65-m round-trip length is
considered, which is designed for a test cavity-based XFEL Marcus et al.
(2019). The cavity is composed of four Bragg-reflecting flat crystal mirrors
located in the corners of the rectangular cavity and two lenses in two
symmetry points (see Fig. 1). The focal length of the lenses is chosen to
ensure a stable, self-consistent solution for the Gaussian beam in the cavity.

The analytical approaches allow us to determine two stable self-consistent
solutions, which we here term the confocal and generic cases. Both cases are
studied here.

The analytical approaches are powerful, but they are limited in some respects
because the cavity optical components—the crystals and lenses—are treated in a
simplified fashion that neglects photoabsorption and the strongly restricted
angular and spectral ranges of Bragg reflections. Because of these
limitations, the analytical approach does not provide information about beam
intensity that is essential for cavity diagnostics, namely, the intensity of
the x-ray beams stored in the cavity, output-coupled from the cavity, or
leaked through cavity crystals. The numerical approach removes these
limitations. Both approaches, however, provide similar results for the beam
position and angle, if the alignment errors are small.

Our studies are focused on the impact on x-ray beam dynamics of spatial and
angular alignment errors of the optical components and of the x-ray source.

Most of the alignment errors result in reduced lifetime of x-rays stored in
the cavity. But, any misalignment of an optical component or the x-ray source
results in periodic betatron-like oscillations of the x-ray orbit in the
cavity. The period of the betatron oscillations is a non-integer number (in a
general case) of the passes of the stored x-ray beams in the cavity. The
period is independent of the type of misalignment and is defined by the
parameters of the cavity and x-ray source. The betatron oscillation period is
different for the confocal and generic cavities.

The amplitude and offset of the betatron oscillations are signatures of the
misalignment type. The betatron oscillations are either symmetric, with zero
offset, or asymmetric, with the offset magnitude equal to the amplitude of the
oscillations. The amplitude and offset of the betatron oscillations are
proportional to the magnitude of the alignment error. The offset sign depends
on the sign of the alignment error, on the location of the faulty optical
element, and on the monitored location. In general, the presence of betatron
oscillations is a signature of cavity misalignment.

In all misalignment cases, the amplitude of the betatron oscillations are
practically identical at the source and midpoint locations. The x-ray beam
sizes at these locations can differ by a magnification factor. These facts are
of practical importance for cavity diagnostics and alignment, as monitoring at
the midpoint is easier than in the undulator. However, the offset signs of the
betatron oscillations can be different at the source and midpoint locations.
In one case considered in the paper, even the magnitude of the offset can
differ at the source and midpoint locations. This happens due to the crystal
position error (see Fig. 16).

Transverse beam size at the source and midpoint locations is stable
independent of the type and magnitude of the alignment errors. Beam size
oscillations may appear even in a perfectly aligned cavity if the spatial and
angular source parameters are not equal to those of a Gaussian beam with
Rayleigh length $Z_{{}_{o}}$ at its waist [See Eq. (34) and Table 1].

Tolerances of $\simeq 5-10$ $\mu$m in positional alignment and $\simeq 50-200$
nrad in yaw angle alignment of the crystal mirrors are required to achieve
close to the perfect half lifetime of 10.5 passes of the stored in the cavity
x-ray beam power and a betatron oscillation amplitude close to zero. Similar
tolerances are required for the lens position errors and for the source angle
and position errors.

The angular and spatial x-ray beam dynamics results [see panels (a)-(d) of
Figs. 16-20] obtained with numerical simulations are practically identical to
those obtained with the ray-transfer matrix approach, as long as the angular
deviations are much smaller than the angular width of the Bragg reflections.

For any misalignment type of the optical elements in the confocal cavity, the
x-ray beam position returns on the optical axis every second pass. This
property may be used to mitigate alignment tolerances for the CBXFEL cavity,
provided electron bunches are arriving every second pass of x-rays in the
cavity. This approach may also halve the cavity size for the given electron
repetition rate, but at a cost of increased cavity losses, because the x-ray
pulse is amplified only each second round trip.

Caution is required in using a confocal cavity, as small variations of the
cavity parameters may result in beam instabilities. For example, slightly
changing the focal length $f^{(1)}=\ell/4$ to $f^{(1)}(1+\epsilon)$
($|\epsilon|\ll 1$) may slightly change the period of the betatron
oscillations from exactly 2 to 2+$\delta$ passes, without causing beam
instabilities. However, breaking the cavity symmetry by displacing lenses
along the optical axis from the symmetry points may result in beam
instabilities.

Betatron oscillations and reduced lifetime of x-rays stored in the cavity are
also expected to be the typical signatures of misalignments for x-ray cavities
of other types. More studies are required, including wavefront propagation
simulations, to scrutinize the obtained results and apply them to computer-
assisted cavity alignment procedures, including strategies based on machine
learning.

##  VII Acknowledgments

Kwang-Je Kim and Ryan Lindberg (ANL) are acknowledged for pointing out the
importance of the equivalence of the ray optics and the paraxial wave optics
as well as of the betatron oscillation for a closed optical cavity. Luca
Refuffi, Xianbo Shi (ANL) and Manuel Sanches del Rio (European Synchrotron,
ESRF) are acknowledged for helping to set up x-ray optics modeling with
package Shadow3 in the Oasys environment. P.Q. acknowledges L. Dean Chapman
(University of Saskatchewan) for support and useful discussions. Peifan Liu
(ANL) is acknowledged for reading the manuscript, valuable amendments and
observations. Deming Shu, Marion White (ANL), Zhirong Huang, Gabriel Marcus,
Diling Zhu, and Tien Tan (SLAC) are acknowledged for useful discussions. Work
at Argonne National Laboratory was supported by the U.S. Department of Energy,
Office of Science, Office of Basic Energy Sciences, under contract DE-AC02-
06CH11357.

## References

  * Decking et al. (2020) W. Decking, S. Abeghyan, P. Abramian, and et al., Nature Photonics 14, 391 (2020).
  * Raubenheimer (2018) T. Raubenheimer, in _Proc. 60th ICFA Advanced Beam Dynamics Workshop (FLS’18), Shanghai, China, 5-9 March 2018_ (JACoW Publishing, Geneva, Switzerland, 2018), no. 60 in ICFA Advanced Beam Dynamics Workshop, pp. 6–11, ISBN 978-3-95450-206-6, https://doi.org/10.18429/JACoW-FLS2018-MOP1WA02, URL http://jacow.org/fls2018/papers/mop1wa02.pdf.
  * Siegman (1986) A. E. Siegman, _Lasers_ (University Science Books, Sausalito, California, 1986).
  * Kondratenko and Saldin (1980) A. M. Kondratenko and E. L. Saldin, Part. Accel. 10, 207 (1980).
  * Bonifacio et al. (1984) R. Bonifacio, C. Pellegrini, and L. Narducci, Optics Communications 50, 373 (1984), ISSN 0030-4018.
  * Emma et al. (2010) P. Emma, R. Akre, J. Arthur, R. Bionta, C. Bostedt, J. Bozek, A. Brachmann, P. Bucksbaum, R. Coffee, F.-J. Decker, et al., Nature Photonics 4, 641 (2010).
  * Huang and Ruth (2006) Z. Huang and R. D. Ruth, Phys. Rev. Lett. 96, 144801 (2006).
  * Kim et al. (2008) K.-J. Kim, Yu. Shvyd’ko, and S. Reiche, Phys. Rev. Lett. 100, 244802 (2008).
  * Kim and Shvyd’ko (2009) K.-J. Kim and Yu. V. Shvyd’ko, Phys. Rev. ST Accel. Beams 12, 030703 (2009).
  * Lindberg et al. (2011) R. R. Lindberg, K.-J. Kim, Yu. Shvyd’ko, and W. M. Fawley, Phys. Rev. ST Accel. Beams 14, 010701 (2011).
  * Kim et al. (2012) K.-J. Kim, Yu. Shvyd’ko, and R. R. Lindberg, Synchrotron Radiation News 25, 25 (2012).
  * Dai et al. (2012) J. Dai, H. Deng, and Z. Dai, Phys. Rev. Lett. 108, 034802 (2012).
  * Marcus et al. (2017) G. Marcus, Y. Ding, J. Duris, Y. Feng, Z. Huang, J. Krzywinski, T. R. T. Maxwell, K.-J. Kim, R. Lindberg, Yu. Shvyd’ko, et al., in _Proceedings of 38th International Free Electron Laser Conference_ (Santa Fe, NM, USA, 2017).
  * Freund et al. (2019) H. P. Freund, P. J. M. van der Slot, and Yu. Shvyd’ko, New Journal of Physics 21, 093028 (2019).
  * Marcus et al. (2020) G. Marcus, A. Halavanau, Z. Huang, J. Krzywinski, J. MacArthur, R. Margraf, T. Raubenheimer, and D. Zhu, Phys. Rev. Lett. 125, 254801 (2020).
  * Shvyd’ko et al. (2010) Yu. V. Shvyd’ko, S. Stoupin, A. Cunsolo, A. Said, and X. Huang, Nature Physics 6, 196 (2010).
  * Shvyd’ko et al. (2011) Yu. V. Shvyd’ko, S. Stoupin, V. Blank, and S. Terentyev, Nature Photonics 5, 539 (2011).
  * Lengeler et al. (1999) B. Lengeler, C. Schroer, J. Tümmler, B. Benner, M. Richwin, A. Snigirev, I. Snigireva, and M. Drakopoulos, J. Synchrotron Radiation 6, 1153 (1999).
  * Kolodziej et al. (2018) T. Kolodziej, S. Stoupin, W. Grizolli, J. Krzywinski, X. Shi, K.-J. Kim, J. Qian, L. Assoufid, and Yu. Shvyd’ko, Journal of Synchrotron Radiation 25, 354 (2018).
  * Shvyd’ko et al. (2003) Yu. V. Shvyd’ko, M. Lerche, H.-C. Wille, E. Gerdau, E. E. Alp, M. Lucht, H. D. Rüter, and R. Khachatryan, Phys. Rev. Lett. 90, 013904 (2003).
  * Cotterill (1968) R. M. J. Cotterill, Appl. Phys. Lett. 12, 403 (1968).
  * Shvyd’ko (2013) Yu. Shvyd’ko, Beam Dynamics Newsletter 60, 68 (2013), International Committee for Future Accelerators., URL https://icfa-usa.jlab.org/archive/newsletter/icfa_bd_nl_60.pdf.
  * Marcus et al. (2019) G. Marcus, J. Anton, L. Assoufid, F.-J. Decker, G. Gassner, K. Goetze, A. Halavanau, J. Hastings, Z. Huang, W. Jansma, et al., in _Proc. FEL’19_ (JACoW Publishing, Geneva, Switzerland, 2019), no. 39 in Free Electron Laser Conference, pp. 282–287, ISBN 978-3-95450-210-3, https://doi.org/10.18429/JACoW-FEL2019-TUD04, URL http://jacow.org/fel2019/papers/tud04.pdf.
  * Kogelnik and Li (1966) H. Kogelnik and T. Li, Appl. Opt. 5, 1550 (1966).
  * Kim (2020) K. Kim, Tech. Rep. Preprint AOP-TN-2020-106, Argonne National Laboratory (2020).
  * Authier (2001) A. Authier, _Dynamical Theory of X-Ray Diffraction_ , vol. 11 of _IUCr Monographs on Crystallography_ (Oxford University Press, Oxford, New York, 2001).
  * Shvyd’ko et al. (2017) Yu. Shvyd’ko, V. Blank, and S. Terentyev, MRS Bulletin 62, 437 (2017).
  * Shvyd’ko (2019) Yu. Shvyd’ko, Phys. Rev. Accel. Beams 22, 100703 (2019).
  * RXOPTICS (2021) RXOPTICS (2021), http://www.rxoptics.de.
  * Saleh and Teich (2007) B. E. A. Saleh and M. C. Teich, _Fundamentals of photonics; 2nd ed._ (Wiley, New York, NY, 2007).
  * Shvyd’ko (2015) Yu. Shvyd’ko, Phys. Rev. A 91, 053817 (2015).
  * Liu (2021) P. Liu (2021), Peifan Liu is acknowledged for this observation, while reading the manuscript.
  * Edwards and Syphers (1992) D. A. Edwards and M. J. Syphers, _An Introduction to the Physics of High-Energy Accelerators_ , Wiley Series in Beam Physics and Accelerator Technology (Wiley, New York, 1992), ISBN 978-0-471-55163-8.
  * Sanchez del Rio et al. (2011) M. Sanchez del Rio, N. Canestrari, F. Jiang, and F. Cerrina, Journal of Synchrotron Radiation 18, 708 (2011).
  * Rebuffi and Sánchez del Río (2016) L. Rebuffi and M. Sánchez del Río, Journal of Synchrotron Radiation 23, 1357 (2016).
  * Rebuffi and del Rio (2017) L. Rebuffi and M. S. del Rio, in _Advances in Computational Methods for X-Ray Optics IV_ , edited by O. Chubar and K. Sawhney (SPIE, 2017), vol. 10388, p. 28.