Dealing with background in XSPEC

When the background requires a different response to the source

Suppose we have a model for the background spectrum which requires a different response to that for the source spectrum. Read in the source and background spectra as separate files :

XSPEC12>data 1:1 source.pha 2:2 back.pha

The source and background files have their own response matrices :

XSPEC12>response 1 source.rsp 2 back.rsp

Set up the model for the source. Here we will take the simple case of an absorbed power-law :

XSPEC12>model phabs(pow)

Input parameter value, delta, min, bot, top, and max values for ...
              1      0.001          0          0     100000      1e+06
1:data group 1::phabs:nH>
              1       0.01         -3         -2          9         10
2:data group 1::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
3:data group 1::powerlaw:norm>

Input parameter value, delta, min, bot, top, and max values for ...
              1      0.001          0          0     100000      1e+06
4:data group 2::phabs:nH>
              1       0.01         -3         -2          9         10
5:data group 2::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
6:data group 2::powerlaw:norm>0 0

Note that we have fixed the normalization of the source model for the background dataset at zero so it doesn't contribute. Now we need to set up the background model for both datasets with its own response matrix.

XSPEC12>response 2:1 back.rsp 2:2 back.rsp

This tells xspec that both these datasets have a second model which must be multiplied by the back.rsp response matrix. We now define the background model to be used. In this case take the simple example of a single power-law

XSPEC12>model 2:myback pow

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01         -3         -2          9         10
1:myback:data group 1::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
2:myback:data group 1::powerlaw:norm>

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01         -3         -2          9         10
3:myback:data group 2::powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
4:myback:data group 2::powerlaw:norm>

We have now set up xspec so that the source data is modeled by a source model multiplied by the source response plus a background model multiplied by the background response and the background data is modeled by the background model multiplied by the background response. The background models fitted to the source and background data are constrained to be the same.

XSPEC12>show model

Current model list:

========================================================================
Model phabs<1>*powerlaw<2> Source No.: 1   Active/On
Model Model Component  Parameter  Unit     Value
 par  comp
                           Data group: 1
   1    1   phabs      nH         10^22    1.0000000      +/-  0.0            
   2    2   powerlaw   PhoIndex            1.0000000      +/-  0.0            
   3    2   powerlaw   norm                1.0000000      +/-  0.0            
                           Data group: 2
   4    1   phabs      nH         10^22    1.0000000      = 1:phabs[1]:nH
   5    2   powerlaw   PhoIndex            1.0000000      = 1:powerlaw[2]:PhoIndex
   6    2   powerlaw   norm                0.0            frozen
________________________________________________________________________


========================================================================
Model myback:powerlaw<1> Source No.: 2   Active/On
Model Model Component  Parameter  Unit     Value
 par  comp
                           Data group: 1
   1    1   powerlaw   PhoIndex            1.0000000      +/-  0.0            
   2    1   powerlaw   norm                1.0000000      +/-  0.0            
                           Data group: 2
   3    1   powerlaw   PhoIndex            1.0000000      = 1:myback:powerlaw[1]:PhoIndex
   4    1   powerlaw   norm                1.0000000      = 1:myback:powerlaw[1]:norm
________________________________________________________________________

Including particle background

A particular case of background requiring a different response is particle background. This is assumed to depend on the instrumental response but not on the telescope effective areas. In xspec v11 and earlier a particle background model could be included by appending /b to additive components at the end of the model definition. These components were multiplied by the response file but not the arf. To do the equivalent in the current version of xspec suppose that our source.rsp in the example above can be split into source.rmf, the instrument response, and source.arf, the telescope effective area. To read the data in this case we do the following :

XSPEC12>data 1:1 source.pha 2:2 back.pha
XSPEC12>response 1 source.rmf 2 source.rmf
XSPEC12>arf 1 source.arf
XSPEC12>response 2:1 source.rmf 2:2 source.rmf

We can then define the source and background models in the same way as the previous example.

Simulating a spectrum with particle background

Suppose we don't yet have a background spectrum but want to simulate a dataset which includes the particle background. We need a spectrum file - it doesn't matter what is in it - and the rmf and arf files.

XSPEC12>data test.pha
XSPEC12>response source.rmf
XSPEC12>arf source.arf
XSPEC12>response 2:1 source.rmf

Now define the source and background models and run fakeit eg :

XSPEC12>model phabs(pow)

Input parameter value, delta, min, bot, top, and max values for ...
              1      0.001          0          0     100000      1e+06
1:phabs:nH>
              1       0.01         -3         -2          9         10
2:powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
3:powerlaw:norm>

XSPEC12>model 2:myback pow

Input parameter value, delta, min, bot, top, and max values for ...
              1       0.01         -3         -2          9         10
1:myback:powerlaw:PhoIndex>
              1       0.01          0          0      1e+24      1e+24
2:myback:powerlaw:norm>

XSPEC12>fakeit