+++
title = "Background"
weight = 80
+++

### Poisson background

To add a Poisson background to a `Simulation` instance, use

```python
bg = ba.PoissonBackground()
simulation.setBackground(bg)
```

In this case, the output intensity is randomly distributed around the exact value with discrete Poisson statistics.

The lower the intensity of the probing beam, the lower the signal-to-noise ratio.

### Constant background

To add a constant background to a `Simulation` instance, use

```python
bg = ba.ConstantBackground(1e3)
simulation.setBackground(bg)
```

#### Special cases

[Specular simulation](/ref/sim/class/specular):

Background is applied before the reflectivity is normalized, so the background value will also be divided by the probe beam intensity. 

[Depth probe simulation](/ref/sim/class/depthprobe):

Background is not supported.

#### Examples

{{% ref-ex "specular/Background.py" %}}
{{% ref-ex "scatter2d/Background.py" %}}

{{< galleryscg >}}
{{< figscg src="/img/auto/scatter2d/Background.png" width="450px" caption="Scattering intensity">}}
{{< /galleryscg >}}

The script below shows how to add different types of background in the context of a GISAXS simulation of cylindrical particles on substrate.

{{< show-ex file="scatter2d/Background.py" >}}
