# Attenuation correction for sample shape

In cases of strongly scattering or absorbing samples, the detected scattering intensity is lower than the 'true' scattering. Moreover, for oddly-shaped samples, the extinction of scattering may be anisotropic: some parts of the detector image are more attenuated than others because of the differing path-lengths through the sample.

## Formulation

In the following, we assume a transmission-scattering (TSAXS) experiment.

The measured scattering, $S_m$, at a particular scattering angle $(\Theta_o, \chi_o)$ (where $\Theta_o$ is the full ($2 \theta$) scattering angle between the scattered ray and the incident beam, and $\chi_o$ is the azimuthal angle: $\chi=0^{\circ}$ corresponds to the $q_z$ axis, whereas $\chi=90^{\circ}$ is along the $q_r$ axis) can be computed by summing the scattering contributions for all the elements along the beam path through the sample.

We define a realspace coordinate system $(x,y,z)$ where z points vertically, y points along the beam direction, and x points horizontally with respect to the sample. Let the sample size along the beam direction be L. Defining the point where the beam first enters the sample as $(0,0,0)$ we write:

\begin{alignat}{2} S_m(\Theta_o,\chi_o) = \int \limits_{l=0}^{l=L} S(l) \mathrm{d}l \end{alignat}

The scattering from a particular location within the sample is affected by two attenuation effects:

1. The beam flux within the sample decreases due to absorption/scattering, such that the flux at position $l$ is not the incident flux, $I_0$ but attenuated to:
$I(l) = I_0 e^{- \alpha l }$
where $\alpha$ is (Beer-Lambert like) extinction coefficient. If the 'true' scattering probability is given by $\sigma$ (i.e. $I_0 \sigma$ is the scattering observed in the absence of attenuation), then the scattering at $l$ is:
$S(l) = I(l) \sigma = I_0 e^{-\alpha l} \sigma$
2. The scattered radiation is itself attenuated as it passes through the sample. Let this path-length (from scattering location $(0,l,0)$ until it exits the sample along the direction $(\Theta_o, \chi_o)$) be denoted $p(l)$. In such a case, the scattering that exits the sample is:
\begin{alignat}{2} S(l) & = I(l) \sigma \times \mathrm{attenuation}(l) \\ & = I_0 e^{-\alpha l} \sigma e^{-\alpha p(l)} \\ & = I_0 \sigma e^{-\alpha (l+p(l))}\\ \end{alignat}

The measured scattering is thus:

\begin{alignat}{2} S_m(\Theta_o,\chi_o) & = \int \limits_{l=0}^{L} I_0 \sigma e^{-\alpha (l+p(l))} \mathrm{d}l \\ & = I_0 \sigma \int \limits_{0}^{L} e^{-\alpha (l+p(l))} \mathrm{d}l \\ \end{alignat}

The integral of course depends on the form of $p(l)$ which depends on the sample shape. Note that in the limiting case of weak attenuation ($\alpha\approx0$), we obtain the very simple result:

\begin{alignat}{2} S_m(\Theta_o,\chi_o) & = I_0 \sigma \int \limits_{0}^{L} e^{0} \mathrm{d}l \\ & = I_0 \sigma L \\ \end{alignat}

As expected, scattering intensity scales with the scattering volume.

## Normalization

To normalize-out the effect of attenuation, one can simply divide by the integral:

\begin{alignat}{2} S_{\mathrm{norm}} (\Theta_o,\chi_o) & = \frac{S_m(\Theta_o,\chi_o)}{\int_{0}^{L} e^{-\alpha (l+p(l))} \mathrm{d}l } \\ & = I_0 \sigma \end{alignat}

Of course in the case of weak attenuation the integral is simply L, and we are normalizing by the beam-path through the sample.

## Coordinates

For a vector that starts at $(0,0,0)$ and terminates at $(x,y,z)$, pointing along direction $(\Theta_o,\chi_o)$, the full length is:

$|\mathbf{v}| = v = \sqrt{ x^2 + y^2 + z^2 }$

We can consider triangles in various planes:

1. xz plane (looking along beam):
$\tan(90^{\circ}-\chi_o) = \frac{z}{x}$
$\cos(90^{\circ}-\chi_o) = \frac{x}{\sqrt{x^2+z^2}}$
$\sin(90^{\circ}-\chi_o) = \frac{z}{\sqrt{x^2+z^2}}$
$\tan(\chi_o) = \frac{x}{z}$
$\cos(\chi_o) = \frac{z}{\sqrt{x^2+z^2}}$
$\sin(\chi_o) = \frac{x}{\sqrt{x^2+z^2}}$
2. xy plane (looking from above):
$\tan(\omega_{xy}) = \frac{x}{y}$
$\cos(\omega_{xy}) = \frac{y}{\sqrt{x^2+y^2}}$
$\sin(\omega_{xy}) = \frac{x}{\sqrt{x^2+y^2}}$
3. yz plane (looking from side):
$\tan(\omega_{yz}) = \frac{z}{y}$
$\cos(\omega_{yz}) = \frac{y}{\sqrt{y^2+z^2}}$
$\sin(\omega_{yz}) = \frac{z}{\sqrt{y^2+z^2}}$
4. plane of beam elevation:
$\tan(\omega_{\mathrm{elevation}}) = \frac{z}{\sqrt{x^2+y^2}}$
$\cos(\omega_{\mathrm{elevation}}) = \frac{\sqrt{x^2+y^2}}{\sqrt{x^2+y^2+z^2}}$
$\sin(\omega_{\mathrm{elevation}}) = \frac{z}{\sqrt{x^2+y^2+z^2}}$
5. plane of full scattering angle:
$\tan(\Theta_o) = \frac{\sqrt{x^2+z^2}}{y}$
$\cos(\Theta_o) = \frac{y}{\sqrt{x^2+y^2+z^2}}$
$\sin(\Theta_o) = \frac{\sqrt{x^2+z^2}}{\sqrt{x^2+y^2+z^2}}$

### Height Z

If the vector's final point is at height $z=Z$:

\begin{alignat}{2} v_Z & = \sqrt{ x^2 + y^2 +Z^2 } \\ & = \frac{ \sqrt{x^2+Z^2} }{ \sin(\Theta_o) } \\ & = \frac{ 1 }{ \sin(\Theta_o) } \sqrt{\left( Z \tan(\chi_o) \right)^2 + Z^2} \\ & = \frac{ Z }{ \sin(\Theta_o) } \sqrt{\tan^2(\chi_o) + 1} \\ & = \frac{ Z }{ \sin(\Theta_o) } \sec(\chi_o) \\ & = \frac{ Z }{ \sin(\Theta_o) \cos(\chi_o) } \\ \end{alignat}

This has a minimum of $v_z=Z$ when $(\Theta_o,\chi_o)=(90^{\circ},0^{\circ})$.

### Depth L

If the vector's final position is at depth $y=L$:

\begin{alignat}{2} v_Y & = \sqrt{ x^2 + L^2 +z^2 } \\ & = \frac{ L }{ \cos(\Theta_o) } \\ \end{alignat}

This has a minimum of $v_Y=L$ when $\Theta_o=0^{\circ}$.

### Width X

If the vector's final position is at width $x=X$:

\begin{alignat}{2} v_X & = \sqrt{ X^2 + y^2 +z^2 } \\ & = \frac{ \sqrt{X^2+z^2} }{ \sin(\Theta_o) } \\ & = \frac{ 1 }{ \sin(\Theta_o) } \sqrt{X^2 + \left( \frac{X}{ \tan(\chi_o) } \right)^2} \\ & = \frac{ |X| }{ \sin(\Theta_o) } \sqrt{1 + \frac{1}{ \tan^2(\chi_o) } } \\ & = \frac{ X }{ \sin(\Theta_o) } \sqrt{\frac{\tan^2(\chi_o)+1}{ \tan^2(\chi_o) } } \\ & = \frac{ X }{ \sin(\Theta_o) } \frac{\sqrt{\tan^2(\chi_o)+1}}{ \sqrt{\tan^2(\chi_o) }} \\ & = \frac{ X }{ \sin(\Theta_o) } \frac{ \sec(\chi_o) }{ \tan(\chi_o) } \\ & = \frac{ X \cos(\chi_o) }{ \sin(\Theta_o) \cos(\chi_o) \sin(\chi_o) } \\ & = \frac{ X }{ \sin(\Theta_o) \sin(\chi_o) } \\ \end{alignat}

This has a minimum of $v_X=X$ when $(\Theta_o,\chi_o)=(90^{\circ},90^{\circ})$.

## Rectangular prism

If the sample is a rectangular prism with dimensions $(2X, 2Y, 2Z) = (2X, L, 2Z)$ and the beam falls upon the center of the xz front-face, then the beam travels a distance L through the sample, and the scattered radiation in any quadrant passes through the rectangular prism of size $(X,L,Z)$. The distance from $(0,l,0)$ to the exit-point from the sample is the distance to the closest sample face:

\begin{alignat}{2} p\left(l\right) & = \mathrm{min}( d_{\mathrm{top}}(l) , d_{\mathrm{back}}(l) , d_{\mathrm{side}}(l) ) \\ \end{alignat}

The distances are:

\begin{alignat}{2} d_{\mathrm{top}}(l) & = v_Z \\ & = \frac{ Z }{ \sin(\Theta_o) \cos(\chi_o) } \\ \end{alignat}
\begin{alignat}{2} d_{\mathrm{back}}(l) & = v_{L-l} \\ & = \frac{ L-l }{ \cos(\Theta_o) } \\ \end{alignat}
\begin{alignat}{2} d_{\mathrm{side}}(l) & = v_X \\ & = \frac{ X }{ \sin(\Theta_o) \sin(\chi_o) } \\ \end{alignat}