{'fraction_non_alphanumeric': 0.04720246106517977, 'fraction_numerical': 0.008892520669102096, 'mean_word_length': 4.131968426245683, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
X-ray beam-shaping via deformable mirrors: analytical computation of the required mirror profile

X-ray mirrors with high focusing performances are in use in both mirror modules for X-ray telescopes and in synchrotron and FEL (Free Electron Laser) beamlines. A degradation of the focus sharpness arises in general from geometrical deformations and surface roughness, the former usually described by geometrical optics and the latter by physical optics. In general, technological developments are aimed at a very tight focusing, which requires the mirror profile to comply with the nominal shape as much as possible and to keep the roughness at a negligible level. However, a deliberate deformation of the mirror can be made to endow the focus with a desired size and distribution, via piezo actuators as done at the EIS-TIMEX beamline of FERMI@Elettra. The resulting profile can be characterized with a Long Trace Profilometer and correlated with the expected optical quality via a wavefront propagation code. However, if the roughness contribution can be neglected, the computation can be performed via a ray-tracing routine, and, under opportune assumptions, the focal spot profile (the Point Spread Function, PSF) can even be predicted analytically. The advantage of this approach is that the analytical relation can be reversed; i.e, from the desired PSF the required mirror profile can be computed easily, thereby avoiding the use of complex and time-consuming numerical codes. The method can also be suited in the case of spatially inhomogeneous beam intensities, as commonly experienced at Synchrotrons and FELs. In this work we expose the analytical method and the application to the beam shaping problem.


Introduction
An important problem in X-ray optics is the prediction of the image quality from surface imperfections of a focusing, grazing-incidence mirror. This task is traditionally achieved via ray-tracing routines in the long spatial wavelengths spectral range, in which geometric optics is believed to be valid, and applying the known X-ray scattering theory in the high frequencies realm. Detailed information on the profile, and statistical information on the roughness of a grazing incidence mirror, enable the computation of the Point Spread Function (PSF) of the mirror [1] or system of mirrors [2] at any X-ray wavelength.
However, the inverse problem, i.e., the analysis of the PSF to derive the mirror profiles, has received less attention. While in the first-order scattering regime the theory allows an immediate inversion of the formalism, i.e., from the scattering distribution to the Power Spectral Density (PSD) of the surface roughness [3], in geometrical optics we still lack a direct, analytical method to connect the profile error to the shape of the PSF. Such a method could have application especially in beam shaping techniques that turn the radiation intensity distribution provided by a source like a FEL (Free Electron Laser) into another one on the focal plane, via a deformable mirror. Beam shaping techniques are being adopted at the EIS-TIMEX beamline of FERMI@Elettra [4].
In this paper we establish an analytical relation between the simplest profile of a single-reflection mirror characterized by a real longitudinal profile z m (x) and its PSF in the nominal focal plane. We suppose the focal plane to be located at a distance f from the mid-plane of the mirror (Fig. 1), assumed as origin of the reference frame, and we denote the nominal profile of the mirror with z n (x), of length L over the x-axis. The negative x semi-axis points toward the focal plane. For on-ground X-ray sources like Synchrotrons or FELs, which are located at a large, but finite distance, the focusing profile is usually an ellipsoid. For astronomical sources, in practice at infinity, imaging is obtained via mirror systems including a paraboloid, usually followed by a second reflection on a hyperboloid [5]. In most cases, the nominal profile is designed to concentrate the beam to a single point on the focal plane, at (0, −f ); the resulting PSF is a Dirac delta function. Sometimes, the mirror geometry deliberately allows some tolerable aberration on-axis, to improve the focus off-axis and so increase the mirror useful field [6].
Indeed, real mirrors are characterized by profile defects that can be measured, e.g., using a Long Trace Profilometer [7]. While the specific nominal shape affects the existence, the location, and the intrinsic aberrations of an ideal mirror focus, the PSF of a real mirror focus mostly depends on the mirror profile error, The resulting slope distribution spreads the PSF over the focal plane. The PSF also depends on the distribution of the intensity over the mirror length: astronomical sources illuminate uniformly the mirrors owing to their practically infinite distance. Conversely, FEL sources are characterized by a markedly anisotropic brilliance, usually Gaussian. Therefore, the deformations of near the mirror center usually affect the PSF much more than those near the edges. A ray-tracing routine is the most widespread method adopted to compute the PSF from the X-ray mirror shape and illumination, in geometrical optics approximation, even if the results are difficult to express analytically. For simplicity, we heretofore suppose these 3 conditions to be fulfilled: • the geometrical optics approximation is applicable, i.e., the effects of surface roughness and aperture diffraction are negligible; • the roundness (sagittal) errors have a negligible impact on the PSF; • the X-ray source can be assumed to be point-like.
The first condition is not always easy to verify a priori, because the spectral range of spatial frequencies where the geometrical optics can be applied varies with the X-ray energy, the incidence angle α, and even the amplitude of defects [1,2,8].
The second condition is usually fulfilled in grazing incidence, because the roundness errors effect is suppressed by a factor of 1 2 tan 2α with respect to the axial errors. This allows us to reduce the relation profile-PSF to only one dimension, considering the sole, dominating effect of the axial profile errors, z e (x). Also the PSF dependence is reduced to a single variable, the θ angle (Fig. 1).
The applicability of the third condition depends on the specific application and the accuracy requested in shaping the focused beam. In practice, it is met whenever the source, as imaged and demagnified on the focal plane, is much smaller than the desired beam size.
Although a PSF can be computed univocally via a ray-tracing routine, there is in general more than one z e (x) to return a single PSF (Fig. 2). The PSF results from angular deviations of rays on the surface, so it depends more on the slope distribution than on the mirror profile itself. Among all the possible mirror profiles, we thereby select the only one that fulfills the additional condition: • the derivative of the profile error, z ′ e , shall increase monotonically over the profile, i.e., the concavity of z e must always be upwards.
This condition is not related to intrinsic curvature of the mirror, whose nominal profile z n (x) must be concave upwards in order to have focusing properties, but simply operates a selection among all the infinite possible profile errors, which in principle can have any concavity. For example, all the sinusoidal errors in Fig. 2a return the same PSF, but only the solid line fulfills the z ′ e monotonicity condition. In the Sect. 2 of this paper we see that this  Figure 2: An example of PSF degeneracy: (a) sinusoidal profile errors z e of different period, 2L, and amplitude, A, but the same A/L ratio, (b) return the same PSF (Eq. 17). Only the solid line, however, does not exhibit curvature inversions and is suitable for the calculation in Sect. 2. The beam intensity that impinges on the mirror is assumed to be uniform.
selection establishes a one-to-one correspondence between locations on the mirror and on the focal plane: this in turn allows us to set an analytical relation between a profile error with these properties and a PSF. Some examples of computation are shown in Sect. 3.

From profile to PSF
We define g(x) to be the beam intensity distribution over the mirror length, in the x direction: we require that g(x) ≥ 0 for all − L 2 < x < + L 2 and that g is normalized to 1 over the mirror length, if the beam distribution is uniform, g(x) = 1/L. Rays impinging on the mirror at the coordinates (x, z m ) are deviated from the focus according to the local slope. The angular deviation of the ray, owing to the small angle approximation, is twice the slope error, After traveling a distance f + x ( Fig. 1), they intersect the focal plane with a lateral displacement as the deformations are usually below the micron and f is of several metres, the 2 nd term is overwhelmingly dominant. Hence, the angle seen from the centre of the optic (Fig. 1 By hypothesis, the derivative z ′ e (x) is an increasing function of x, so θ is also an increasing function of x. Therefore, we have a one-to-one correspondence x ↔ θ. In most cases, the mirror length is negligible with respect to the focal length, and Eq. 4 reduces to θ(x) ≈ 2z ′ e (x). We now divide the mirror profile into segments of variable length, ∆x k , with k = 0, 1, · · · aiming at constant derivative changes, ∆z ′ e (Fig. 3). In this way, the derivative of the segments takes on discrete, equally-spaced values z ′ e,k , increasing from its minimum z ′ e,m at x = −L/2, to its maximum z ′ e,M Figure 3: Profile errors with discrete steps in the derivative. Each step results in a delta-like peak in the PSF: the integral of each peak is proportional to the width of the respective step in the profile and to the beam intensity at that position. As the steps are reduced, the peaks become lower and closer, and tend to a continuous PSF. at x = +L/2. Likewise, θ increases as per Eq. 4 over the focal plane from its minimum, θ m , to its maximum, θ M . Rays striking on the mirror between x k and x k + ∆x k reach the focal plane at angles between θ k and θ k + ∆θ k , with an intensity ∆I(θ k ) proportional to the length of the k th segment and to g(x k ), The ∆θ k 's are obtained by differentiating Eq. 4, owing to the large focal length, the second term of Eq. 6 is negligible. Clearly, ∆θ k > 0. The PSF is the intensity in the nominal focal plane per angle unit, ∆I(θ k )/∆θ k : Passing to the actual profile in the limit ∆z ′ e → 0, Eq. 7 turns into for all values of θ that correspond to some x via Eq. 4 -that can be inverted because of the supposed z ′ e (x) monotonicity -and zero elsewhere. To simplify the notation, in Eq. 8 we have introduced the asymmetric intensity distribution, In the limit of a regular profile, Eq. 6 becomes therefore Eq. 8, as expected, is normalized to 1 over the focal plane: As z ′ e (x) is an increasing function of x, z ′′ e (x) ≥ 0. Hence, Eq. 8 returns a positive and finite PSF wherever z ′′ e (x) > 0. If z ′′ e (x) = 0 at some x, however, some attention should be paid when applying Eq. 8: • If z ′′ e (x) = 0 at some isolated x =x, i.e., the profile error tend to be straight asx is approached, then the PSF diverges to infinity at θ(x) but Eq. 8 can be applied at all the nearby locations. In practice, this produces a sharp peak, but not a Dirac delta, in the PSF. Anyway, the integral of the PSF remains finite (Eq. 11).
• If z ′′ e (x) = 0 in one or more intervals of the kind [x j , x j + ∆x j ], with j = 1, 2, . . . , N, then z e (x) exhibits N straight segments and θ(x) has N "plateaux", i.e., θ = θ(x j ) in correspondence of those positions. Hence, the relation θ = θ(x) cannot be reversed anymore. Physically, all the intensity impinging on the linear segments is focused at θ(x j ), resulting in Dirac deltas at those locations. To extend the computation to this case, we have two possibilities: 1. g(x) = 0 wherever z ′′ e (x) = 0. Therefore, the straight segments do not give contribution to the PSF and Eq. 8 can be used: fortunately, profile deformations obtained from the inverse formula (Eq. 15) fall precisely in this case. 2. g(x) > 0 in some interval where z ′′ e (x) = 0. In this case, the straight segments shall be firstly removed from the profile before applying Eq. 8. The contribution of the straight segments, P SF str , should be subsequently included by adding N Dirac deltas to the PSF, each of them normalized to the total intensity impinging on the j-th segment: • If z ′ e (x) is discontinuous at some x =x (a "kink" in the profile) like in Fig. 4b, then z ′′ e (x) is infinite atx, so P SF (θ) = 0 for all values of θ in the interval corresponding via Eq. 4 to the z ′ e (x) leap atx.

From PSF to profile
We now derive the reverse form of Eq. 8, which can be directly applied to the problem of beam shaping (Sect. 3.2). For any P SF (θ) ≥ 0 at the focal plane defined at angles [θ m , θ M ], and for any g(x) ≥ 0 over the mirror length [−L/2, +L/2], a profile error can be computed under the conditions listed in Sect. 1. The substitution of Eq. 9 and 10 reduces Eq. 8 to This simple differential equation is solved if z ′ e (x) is known at one value of x. This choice affects the average tilt of the profile, hence it will change the position, but not the shape of the PSF: for instance, a natural choice for a symmetric PSF could be z ′ e (0) = 0. However, since both distributions are normalized to 1, it is convenient to set z ′ e − L 2 = θ m . This choice preserves also the position of an asymmetric PSF on the angular scale.   The profile deformation imparted to the mirror is computed from the requested PSF, via Eq. 15, assuming an isotropic X-ray source, and f ≫ L. The profile exhibits two discontinuities in z ′ e ("kinks") corresponding to the two gaps in the PSF. Applying a ray-tracing routine to the computed profile yields back the initial PSF shown in Fig. 4a (dashed line).
Hence, integrating both sides of Eq. 14, we have and, if the integrations can be performed, the equation can be solved for z ′ e (x) for any x in the interval [−L/2, +L/2]. Finally, a further integration returns z e (x). For Eq. 15 to be applied, the PSF must be normalized to 1 over the focal plane, and g(x) must be normalized to 1 over the mirror length (Eq. 2), not over the entire x-axis, otherwise the profile error will return only the core of the PSF: i.e., the part of the PSF that is normalized to the integral of g(x) over the mirror length.
As long as both P SF (θ) > 0 for all θ and g(x) > 0 for all x, the integrals in Eq. 15 are increasing functions of the upper integration limits. Therefore, solving for z ′ e will automatically return an increasing function of x, i.e., an upwards concave profile error as required (Sect. 1). Likewise the direct computation (Sect. 2.1), a few special cases deserve some attention: • g(x) = 0 for some x: this occurs, e.g., if the beam extension over x is smaller than the mirror length. In this case, solving Eq. 15, z ′ e (x) will be a constant where g(x) = 0, resulting in straight segments of z e . This appears reasonable, because there is nothing to shape where the intensity is zero. As we anticipated in the previous section, in the straight segments z ′′ e (x) = 0, but also g(x) = 0, so the re-application of Eq. 8 to the generated profile does not pose a problem.
• P SF (θ) = 0 at some θ, like in the example shown in Fig. 4a: this situation leads to inversion problems, because the left-hand of Eq. 15 becomes a constant in an interval of z ′ e for a singlex. A way to extend the computation to this case is to adopt for z ′ e (x) the limit value at the closest edge of the intervals where left-hand of Eq. 15 is constant. In most cases, these intervals are in the PSF wings and do not pose a problem. Otherwise, they result in a z ′ e discontinuity atx, i.e. a kink in z e (Fig. 4b).

A direct computation
We hereafter consider some application of Eq. 15, assuming for simplicity f ≫ L, i.e., which implies the asymmetry factor (Eq. 9) to be completely negligible. For example, if the profile error is a half-sinusoid and the beam is initially uniform, Eq. 8 returns a typical, diverging PSF: with |θ| < 2πA/L, and zero elsewhere. A PSF of this kind was shown in Fig. 2b. The HEW (Half Energy Width, i.e. the angular diameter including half integral of the PSF) can be directly computed from Eq. 17:

Some inverse computations
Inverse computations are more interesting, because they can be directly applied to beam-shaping problems. For instance, if a uniform beam impinges on a focusing mirror, which deformation yields a Lorentzian-shaped PSF, with w -the HEW parameter -arbitrary? For simplicity, we have assumed the focal plane to be infinitely extended, so Eq. 19 is normalized to 1. The substitution of g(x) = 1/L and Eq. 19 into Eq. 15 yields, neglecting the asymmetry factor (Eq. 9) and assuming z ′ e (0) = 0 because of the PSF symmetry, Then, Eq. 20 can be solved for z ′ e : which returns by integration the desired profile  Figure 6: (a) A top-hat distribution of 4 µrad full width (Eq. 23) and (b) the profile deformations (Eq. 26) to turn a Lorentzian g(x) of variable width δ into that PSF. We note that the profiles tend to become straight as g(x) → 0 toward the edges of the mirror profile.
with γ π to avoid the profile divergence at the mirror edges. The exact choice of γ really affects only the very edges of the mirror profile: a suitable value can be e.g., γ = 3.12. In Fig. 5a we display some Lorentzian PSFs for different values of w, and the respective profile errors are reported in Fig. 5b.
We now consider an initially anisotropic source (like a FEL) that has to be turned into, e.g., a top-hat PSF of full width w (Fig. 6a): For simplicity, g(x) is supposed to be a Lorentzian function over the mirror length, .
where δ is the HEW parameter. If δ ≪ L, g(x) is nearly normalized to 1 over the mirror length. Substituting Eqs. 23 and 24 into Eq. 15, we derive, neglecting the asymmetry factor (Eq. 9), where we have set, owing to the PSF symmetry, z ′ e (0) = 0. Eq. 25 can be easily integrated by parts, yielding some profiles of this kind are shown in Fig. 6b. The beam-shaping problem under study at the EIS-TIMEX beamline of FERMI [4] requires the same computation, even if the initial intensity matches more a Gaussian than a Lorentz function. Since a Gaussian function cannot be integrated analytically, the profile computation has to be performed by solving Eq. 15 numerically.
In Fig. 7 we show the same exercise aiming at a PSF with King profile, i.e., a generalization of Eq. 24: where w is a width parameter, β > 0 is a slope parameter and N is a normalization factor over the focal plane. We suppose g(x) to still be a Lorentzian: the integration of a King function cannot be performed analytically, so the computation of the mirror deformation has to be obtained numerically. The PSFs and the corresponding mirror profiles are shown in Fig. 7. We note that the mirror profiles tend to resemble the ones of Fig. 6 as the PSF converges to a top-hat shape, i.e., for increasing values of β.

Conclusions
In this work we have shown how the well-known problem of computing a focusing mirror PSF from the profile errors can be solved analytically for the special class of upwards-concave profiles. Although this seems less useful than a ray-tracing, a great advantage is the possibility to invert the formalism and derive a mirror profile deformation from a desired PSF. This can be done analytically in a number of cases, and numerically in any case. The resulting profile is the simplest possible one, as it does not exhibit undulations, therefore it should be possible to reproduce, e.g., via piezo actuators. Only if a PSF exhibits gaps, the profile will present kinks that can pose more difficulties to the shaping. It should be kept in mind that the results may differ from predictions if the initial hypotheses are not fulfilled: • If the geometrical optics is not completely applicable, a self-consistent treatment that includes the effect of aperture, mid-frequency defects, and roughness [1,2] has to be considered, but the formalism becomes very difficult to reverse.
• If the sagittal errors are not negligible, the PSF has to be computed via a complete ray-tracing routine, which is also difficult to reverse.
• If the source size is not negligible, the demagnified source has to be convolved with the ideal PSF. Therefore, to compute the correct profile deformation from a requested PSF, the demagnified source profile has to be preliminarily de-convolved, which is not always possible.
The extension of the formalism hitherto presented to the mentioned situations, and the computation for the case of EIS-TIMEX, will be the subject of a subsequent paper.