+++
title = "Offspec integration"
weight = 20
+++

## Option: offspecular detector phi-integration

Offspecular simulation requires phi-integration over 2D detector.
This option defines the exact way how the integration is done.

Various integration methods provide different speed and
accuracy and have their own parameters.

```python
simulation.options().setOffspecIntegratorOptions("IntegrationMethod", 
						{
						par1name : value, 
						par2name : value, 
						...
						})
```

1. The default integrator is ["AdaptiveGaussKronrod"](https://www.gnu.org/software/gsl/doc/html/integration.html#qag-adaptive-integration)

Adaptive, provides good accuracy but may slow down the performance.
```python
simulation.options().setOffspecIntegratorOptions("AdaptiveGaussKronrod",
						{
						"max_subintervals" : 200,
						"abs_tolerance" : 1e-9,
						"rel_tolerance" : 1e-7,
						"GK_rule" : 3
						});
```
`"GK_rule"` is the integer key from 1 to 6, corresponding to
15, 21, 31, 41, 51 or 61-point Gauss-Kronrod rule.


2. ["GaussKronrod"](https://www.gnu.org/software/gsl/doc/html/integration.html#qng-non-adaptive-gauss-kronrod-integration)

Non-adaptive version with integration over <=87 points.
```python
simulation.options().setOffspecIntegratorOptions("GaussKronrod",
						{
						"abs_tolerance" : 1e-9,
						"rel_tolerance" : 1e-7
						});
```

3. ["Romberg"](https://www.gnu.org/software/gsl/doc/html/integration.html#romberg-integration)

Semi-adaptive with iterative subdivisions
```python
simulation.options().setOffspecIntegratorOptions("Romberg",
						{
						"subdivision_depth" : 5,
						"abs_tolerance" : 1e-9,
						"rel_tolerance" : 1e-7
						});
```
