The Neil Gehrels Swift Observatory

Making BAT Spectra and Response Matrices

1. Overview:

This thread describes how to make a spectrum from BAT event data using the task 'batbinevt'. It also shows the appropriate corrections that need to be applied, and how to make a response matrix.

Read this thread if you want to: Make a spectrum and response matrix from BAT data for use in XSPEC.

Last update: 2007-09-04

2. Introduction

Making a spectrum involves selecting the time of interest, and the desired energy binning.

Let's assume we are interested in the burst GRB 050713A, in particular a flare from time 142921843 (MET) to 142921868 (MET).

3. Prerequisites

We will use the original event list of GRB 050713A as an example (obsid 00145675 000). The event data should have been ray-traced by the SDC using the position of the GRB. Energy calibrations should also have been applied. See the Mask-Weighting and Energy Correction threads for more information.

If the auxilliary raytracing file is not available (it was not archived by the SDC until late 2005), then it must be recreated using the Mask-Weighting thread.

4. Change into Event Directory

Change directories to the location of the event data.

cd 00145675000/bat/event

5. Make the spectrum

BAT spectra are made with the 'batbinevt' task. Here is an example for the flare discussed above:

  batbinevt infile=sw00145675000bevshsp_uf.evt.gz outfile=flare.pha outtype=PHA \
    timedel=0.0 timebinalg=u tstart=142921843 tstop=142921868 \
    energybins=CALDB:80 outunits=RATE \
    detmask=../hk/sw00145675000bcbdq.hk.gz clobber=YES 

6. Apply Corrections to the Spectrum

There are several corrections that need to be applied to a spectrum before it can be fit by XSPEC. The first correction involves inserting the proper ray-tracing keywords into the file.

Several geometric parameters are required to make an accurate response matrix, such as the position of the burst in instrument coordinates. Because the spacecraft is often slewing during the burst, it is not possible to know for sure what those geometric parameters should be until the desired spectrum has been created. The 'batupdatephakw' task does this for you, using the auxiliary ray-tracing file described above. If the auxiliary raytracing file does not exist in your observation, then you will have to create it using the Mask-Weighting thread. If you do not apply this correction, then fluxes may be in error by up to 50%, and power law indices may be off by up to 0.5.

  batupdatephakw flare.pha sw00145675000bevtr.fits.gz

Next, you should apply the BAT-recommended systematic error to your spectrum. The 'batphasyserr' task is used to do this, and the error vector is stored in the calibration database.

  batphasyserr flare.pha CALDB

7. Generate a Response Matrix

A response matrix should be created for each spectrum where the GRB is at a different position in the BAT field of view. For example, one response matrix should be made for data taken before any slew, and one after any slew. Any spectra made during the slew should have their own response matrix.

  batdrmgen flare.pha flare.rsp NONE

8. Important: Spectrum of a Source During a Slew

It is often the case that a gamma-ray burst source is moving in the BAT field of view. This is because the spacecraft often slews to the position of the GRB before the burst emission is has ended. The BAT spectral response changes with position, so you should not use one response matrix for the entire burst. For a source with a power law spectrum, a position error of 25 degrees introduces an error of about 0.1 in the photon index, and about 10% in total flux. The spectral distortion effect will be more pronounced if the slew is a longer distance, or if the GRB has strong emission peaks separated by a large time and/or distance. The distortion will be less if the GRB emission occurs mostly during a pointing, and of course there will be no distortion if the burst emission is completely confined to a pointing.

You should break long bursts which overlap slews into smaller segments corresponding to whether the spacecraft is moving or not. Generally speaking, you should make a response matrix whenever the position of the source changes by more than 15 degrees (or smaller increments if you wish). One straightforward way to do this is to use the position columns in the auxiliary ray tracing file. Look for the columns named IMX and IMY, which contain the source position in the BAT field of view, relative to the spacecraft pointing direction. The values are tangent plane coordinates, so tan(15 deg) ~ 0.27. Thus, you should break a spectrum into segments where the source moves no more than 0.25 in the IMX or IMY coordinate.

The SDC should make "pre-slew" and "post-slew" response matrices. These generally should correspond to the pointings during the BAT trigger, and the following pointing after the slew, respectively. These matrices will be useful if the burst primarily overlaps either the pre-slew or post-slew pointings.

9. Analyze Spectrum in XSPEC

You can now load this spectrum within the spectral fitting program XSPEC. Please be aware that you should ignore data below 14 keV and above 195 keV. Since the BAT mask becomes transparent around 150 keV, the BAT team recommends fitting spectra in the 15-150 keV range.

9.1. Common Spectral Models

The following models are commonly used in fitting of BAT spectra.

powerlaw/pegpwrlw

The simplest model. Powerlaw is normalized by its differential spectrum, and pegpwrlw is normalized by total flux. NOTE: since the powerlaw model is normalized at 1 keV, it can lead to spurious statistical correlations between parameters in the BAT 15-150 keV band; pegpwrlw is preferred.

cutoffpl

Power law with an exponential cut-off at high energies. As with the simple power law model, cutoffpl is normalized at 1 keV.

grbm

"Band" gamma-ray burst model. Typically BAT spectra do not cover a large enough energy range to uniquely determine all Band model parameters. NOTE: "tem" parameter in "grbm" model is a cutoff energy instead of Epeak. Epeak is calculated with the following way; Epeak = (2+alpha)*tem.

The BAT team uses the following custom cut-off power law model in XSPEC:

  mdefine cutep50 (E/50.0)**(-a)*exp(-E*(2.0-a)/b)

where the parameters are:

a

photon index

b

Epeak [keV]

the advantages to this model are that the photon index is normalized at 50 keV, in the middle of the BAT energy band, and the Epeak parameter is the well known quantity associated with gamma-ray bursts, which can also be derived from the Band model (see above).

In comparison to the standard cut-off power law model (cutoffpl), the photon index is identical, and the relation between Epeak and HighECut is,

  Epeak = (2-PhoIndex)*HighECut

where HighECut is the exponential cut-off energy of XSPEC.

Typically, the BAT team prefers the custom cut-off power law fit if the chi-squared value improves by more than 6 over the pure power law fit.

10. Choosing Different Energy Binning

You are free to choose different energy binning than the default 80-bin spectrum (the default is selected with energybins=CALDB:80).

The batbinevt task accepts either a file with an EBOUNDS extension containing bin edges, or a comma-separate list of energy bin edges.

11. Do Not Use GRPPHA

Do not group spectral bins of BAT spectra with programs like GRPPHA. The purpose of doing so for photon counting instruments is to collect enough photons in each bin so that gaussian statistics apply. However, BAT is not a photon counting instrument. By virtue of the mask weighting technique, BAT spectra already have gaussian statistics. Thus, there is no need to performing grouping. Spectral fits with non-grouped spectra should be correct, even if the count rate in a given bin is consistent with zero.

For low-statistics data, it may appropriate to use XSPEC's setplot group command to make a more pleasing plot, but be aware that this command makes some statistical assumptions about "counts" in a spectrum which are not necessarily applicable to BAT spectra. It is more correct to make a new spectrum with coarser energy binning.

12. Making Multiple Spectra

By default, batbinevt makes a single (type I) pulse height spectrum. You can choose other energy binning strategies. Please see then time-selection section of the Light Curve thread for more ideas on how to do this.

13. Low Chi-square Values

When fitting the spectra of very bright sources, you may find that the reduced chi-square value of the best-fitting model is less than 1.0. When this situation occurs, it is an indication that systematic errors in the response matrix dominate over the Poisson statistical errors of the spectrum. (The systematic errors are appended by the "batphasyserr" task.)

In most cases, users should simply proceed with the normal error analysis, and should not attempt to rescale the error bars of their spectrum to produce a reduced chi-square of 1.0. The small chi-square value should cause most fitting packages like XSPEC to increase the uncertainties of parameter values, compared to the parameter uncertainties derived from Poisson statistics alone. This is the appropriate behavior, i.e. it allows the estimated systematic errors to be reflected in the parameter uncertainties.

14. Modifications