Heasim and skyback simulation tools and their application to the Hitomi mission

We present an introduction to the heasim multimission observation and skyback background, highenergy pseudo Monte Carlo astrophysical simulation tools. Heasim may be used to accurately and efficiently construct flexible image transport system (FITS) event files for simple or composite sources with a wide range of standard and user-defined spatial, spectral, and temporal characteristics. Skyback is designed to enable users to assess the impact of background discrete and diffuse emission on prospective observations, and skyback output may be directly input into heasim. We present a brief overview of heasim and skyback input, algorithms, usage, and output. We also introduce the sxsbranch tool that computes Hitomi soft X-ray spectrometer resolution grade branching ratios, emphasizing its application to simulations. We include several examples of particular relevance to the Hitomi mission. © The Authors. Published by SPIE under a Creative Commons Attribution 3.0 Unported License. Distribution or reproduction of this work in whole or in part requires full attribution of the original publication, including its DOI. [DOI: 10.1117/1.JATIS.4.4.048003]


Introduction
Simulation in X-ray astrophysics is a basic ingredient in mission design and plays a fundamental role in feasibility assessment, planning, and interpretation of observations. Many data centers provide mission-specific simulation tools, e.g., MARX for Chandra, 1 SciSim for XMM-Newton, 2 and xissim for Suzaku. 3 Heasim is designed to be a multimission observation simulator that adopts a simplified, computationally efficient, probabilistic approach. A flux of incoming photons is randomly assigned times, positions on the sky, and energies based on the intrinsic temporal, spatial, and spectral properties of the source. This is then transformed into a list of events with their associated "detected" arrival times, positions, and energy channels based on the mission and instrument, and other observation parameters (exposure time, pointing, and spacecraft orientation). The capabilities of the telescope-plus-detector system are encapsulated into point-spread (or enclosed-energy), vignetting, effective area, and energy redistribution functions, plus an internal background. The design of heasim allows for input of single or multiple sources with physical characteristics determined by several standard and user-defined options.
The skyback tool simulates the discrete and diffuse highenergy astrophysical background over a large energy range and produces a catalog of background point sources with their associated spectra and redshifts. It also creates a background spectrum composed of intrinsically diffuse emission and that from unresolved sources. Skyback produces output files that may be directly input to heasim and, in addition, a table model suitable for the XSPEC 4 spectral fitting package.
Heasim and skyback are, in part, based on the simulation procedures that are available within XIMAGE 5 and the quicksim simulator for XMM-Newton. 6 Heasim and skyback are included in the standard HEASoft distribution 7 and use parameter files similar to other FTOOLS. They are written in the C language and utilize the XSPEC and HEASP 8 libraries. Features of their predecessors that proved accurate and effective were largely maintained in the development of these tools, and priority placed on expanding or revising features needed to enhance efficiency and expand the types of sources that might be simulated (as a result, very bright sources, sources based on an input image, some classes of time-varying sources are more easily accommodated), in anticipation of the sorts of simulations required to interpret Hitomi data and support feasibility studies for proposals for observations. The remainder of this paper presents a brief overview of the input, algorithms, usage, and output of heasim (Sec. 2) and skyback (Sec. 3) with a few worked examples of particular relevance for Hitomi 9 as well as the upcoming X-ray Astronomy X-ray imaging spectroscopy mission (XRISM) (Sec. 5). We also introduce the sxsbranch tool that computes Hitomi soft X-ray spectrometer (SXS) resolution grade branching ratios (Sec. 4), with an emphasis on its application in simulations (Sec. 5). An in-depth Hitomi simulation user manual that includes additional details, as well as Hitomi prelaunch supporting files (Sec. 8) and example scripts, are publicly available from the HEASARC anonymous ftp area. 10,11 Revisions and additions to these tools that might improve their performance and expand the scope of their application are touched on in Sec. 6.

Heasim Approach to Simulation
Heasim transforms a description of an astronomical source (or list of sources) into a flexible image transport system (FITS) file composed of a bintable with a list of "detected" X-ray events according to the characteristics of a particular instrument and details of the observation. The source is described by its location and distribution on the sky, the energy distribution and flux of its X-ray emission, and its variation in time. These properties are encapsulated in a source definition file (sdf) that may refer to auxiliary files provided by the user. Properties of the focal plane configuration [such as the detector field-of-view (FoV) and pixel size] are determined by the choice of X-ray mission and instrument and contained in a mission database file, whereas those having to do with the performance of the X-ray optics, detector response, and internal background are contained in supporting "calibration" files that are specified by heasim input parameter settings. The pointing direction in the sky and exposure time of the observation are selected using input parameter settings as well.
The steps that heasim takes in creating a set of simulated events for each input source, and for the background, are as follows. (1) The absorbed input spectrum (in photons cm −2 s −1 as a function of energy in keV) derived from one of several available spectral models, or from a user-defined spectrum file, is calculated in each input energy bin on a grid taken from the input ancillary response file (arf) that tabulates the instrument effective collecting area as a function of energy. (2) This is then converted to counts/bin by multiplying by the exposure time and by the effective area read from the arf. (3) For each source, the code loops over each input energy bin and over the counts in each bin, (4) probabilistically assigning a sky position to each event according to the source spatial distribution determined either by one of the available models or by a user-defined input image. (5) If a vignetting function, which quantifies the energy-dependent effective reduction of the X-ray telescope collecting area as a function of angle with respect to the telescope axis, is specified, events are discarded with a probability equal to one minus the vignetting function at the relevant energy and focal plane position. (6) Events are displaced from their incident locations according to a probability distribution determined by an input point-spread function (psf) or enclosed-energy function (eef), (7) discarded if located outside the FoVof the instrument, and (8) assigned final discrete sky coordinates that are resampled within detector pixels unless resampling is switched off. (9) Events in each energy bin not discarded due to vignetting or falling outside the FoV are redistributed into discrete output detector energy channels (referred to as PI or pulse-height invariant channels that account for detector gain and are related in a one-to-one manner with a range of photon energies) according to the input response matrix function (rmf) that defines the spectral redistribution from input energy to PI channel and the PI-to-energy mapping. These events are then (10) randomly assigned times according to the source temporal characteristics (constant, sinusoidal, or burst). The time assignment proceeds by mapping the light curve onto a uniform distribution using the integral of the light curve, employing a look-up table if necessary. For the sinusoidal option, this is conducted within a single cycle following selection of a random cycle within the exposure. For the burst, the look-up table spacing is adapted to resolve the steeply rising portion of the light curve. Sky background sources, i.e., from the output of skyback, are processed in the same manner. Internal background events from an input spectrum, following rescaling to the detector area and observation exposure time, are assigned random detector locations and times within the exposure. Events from all sources and from the internal background are merged and sorted on time, with an option to identify pileup based on a simple time interval criteria for events adjacent in time.

Input
The heasim simulation input includes a number of required and optional parameters and supporting files that set the details of the simulated observation and simulation mode of operation, characterize the performance and properties of the instrument, and specify the source properties. We provide a brief description of these here; for more details, readers should consult the user guide. 10,11 The mission and instrument are specified in the heasim parameter file, as are the exposure time and pointing, and names of various optional and required files that contain the description of the source(s) (including any skyback output files describing background sources), and performance of the X-ray optics and detector (see below). Several operational options may set here as well, such as those needed for validation or observation splitting into subexposures (Sec. 2.3).
Heasim has two continuous, internal coordinate systemsone aligned with the plane of projection to celestial coordinates and centered on the pointing direction, and one rotated according to the roll angle to align with the instrument system. These are converted to discrete sky and focal plane coordinates according to the entries in the mission database file, heasim.mdb-an ASCII file that describes the detector orientation with respect to the telescope axis, and the criteria that determine how heasim resamples photons into pixels and discards those that end up outside the FoVor fall into gaps in the detector, for the supported instruments. The default heasim.mdb file is included in the refdata area of the HEASoft distribution.
Heasim users specify the spatial, spectral, and temporal characteristics of the sources to be simulated using the sdf, an ASCII file designed to represent a simple, compact, yet flexible, means of defining the spatial, temporal, and spectral properties of a source or ensemble of sources. Each source is described in the sdf by a single row that includes the source position, foreground hydrogen column density, flux (and bandpass over which that flux is defined), and describes the spectrum by one of five one-parameter models, or by a table provided by the user. Optionally, the user may also specify either one of the four possible extended-source functions and the corresponding set of parameters, or provide an image that heasim interprets as the true source distribution on the sky (otherwise the source is assumed to be point-like). Finally, sinusoidal or burst-like time variability may be specified. Currently, sources that are both time-variable and spatially extended are not supported. A fuller description of these source definition options may be found in Sec. 7.
Multiple-source simulations are realized simply by adding lines to the sdf. More complex sources with spatially varying spectra or multiple components with different temporal and/or spectral characteristics (such as a source with extended constant and point-like periodic components) are built up in a similar manner. For example, an extended source with a temperature gradient (in projection) is represented by an sdf with one row for each of a set of nonoverlapping, contiguous annuli. Support for the input of user-defined image files and tabulated spectra enables the simulation of sources with arbitrary spatial and spectral characteristics; however, only a limited number of types of temporal variability are currently supported. The simx 12 (which shares some development heritage with heasim) and sixte 13 simulation tools are designed to utilize simput files intended as a standard simulation data input format for X-ray telescopes; 14 however, heasim currently is designed to be fully self-contained within HEASoft and does not support simput file input.
Supporting calibration files that describe the spectral response (effective area and energy redistribution) of the detector, the spatial response of the optics (redistribution of X-rays in the focal plane, vignetting function), and the internal background are specified by optional or required filenames in the heasim parameter file. These files are described in more detail in Sec. 8. A collection of standard prelaunch Hitomi calibration files, representing all of the standard formats, are included in a separate supporting files tarffile, ahsimfiles.tar.gz (Sec. 1).

Operation and Output
As with any FTOOL, heasim may be run with parameters either prompted for, set on the command line, or preset using the pset command. Utilization of scripts streamlines the operation of repeated simulations for the same source using different detectors, and a set of example scripts are available for download (ahsimscripts.tar.gz; Sec. 1).
The simulation may be split into multiple subexposures by setting the heasim subexposure flag and duration parameters. In this case, continuity in phase or time offset from a burst is imposed, and the above steps are conducted for each subexposure, with the time-sorting, pileup calculation, and writing to output completed within each interval to reduce memory usage. If the subexposure duration parameter exceeds the total exposure time, the subexposure duration is "optimized" to include <500;000 counts per subexposure based on the flux and bandpass in the sdf and the effective area. Time is assigned in blocks for each energy bin and events sorted in time, within each subexposure.
The output of heasim is a FITS event file 15 with the following columns: TIME, the time of the event in seconds; X and Y, the sky coordinates related to celestial coordinates by keywords written in the event file header; PI, the energy channel; and PILEUP, a flag set to 1 if the event is piled up (and 0 otherwise). Data products may be extracted from the simulated event file and analyzed using standard tools such as those in HEASoft. When XSELECT is used for extraction, the XSELECT environmental variable XSELECT_MDB should be set to xselect.mdb.heasim (included as part of the supporting files distribution). For extraction of spectra in particular, the coordinate used for the weighted map ("wmapname") should be set to SKY coordinates ðx; yÞ, and any region filtering must be applied using SKY or WCS coordinates.

Skyback
Skyback is designed to enable users to assess the impact of background discrete and diffuse emission on prospective observations, and the skyback output may be directly input into heasim. Skyback currently includes the three basic background components described briefly below and in more detail in Sec. 9, any or all of which may be included. Additional or alternative background components may be simulated by including them in the heasim sdf. Skyback input parameters and output files are independent of any mission (although the energy grid specified by the input parameters should sample the energy grid corresponding to the mission in any subsequent simulation).
(1) The steady X-ray background at energies below 1 keV is generally dominated by hot gas in the halo of the Milky Way and that filling the local supernova-blown bubble that encompasses the solar system. The combined spectrum and flux of these galactic halo (Halo) and local hot bubble (LHB) components for a particular region in the sky are derived from ROSAT all-sky survey (RASS) surface brightness maps in several bands following the procedures used in quicksim.
(2) Solar wind charge exchange (SWCX) emission in the soft X-ray band is variable and caused by the interaction of ions in the solar wind with neutral atoms in the exosphere of the Earth and interplanetary space. 16 An assessment of the importance of the SWCX contribution to a simulated observation may be estimated using the following two simple models: a pure emission-line spectrum, or a continuous spectrum based on DXL sounding rocket measurements of the local galaxy diffuse X-ray emission. 17 The magnitude of this component is determined by specifying the flux in the brightest 0.57 keV OVII line, or the total flux for the continuous representation via skyback parameter settings. In the former case, additional O emission lines with ratios fixed at typical SWCX values are included.
(3) Following procedures included in the XIMAGE simulator, the point source background component is modeled as a two-subcomponent "Nð> SÞ distribution" that expresses the number of observed source counts above a certain flux per unit solid angle. The first subcomponent is a broken power law Nð> SÞ designed to allow the inclusion of an extragalactic point-source component; and, the second Nð> SÞ subcomponent a single power law that may be used to augment the background with a Galactic or an additional extragalactic point source background. Parameter settings determine the slopes (and flux where the distribution changes slope for the first subcomponent) and normalizations of these subcomponents, as well as a threshold used to split this background contribution into two parts: an ensemble of discrete sources plus extended emission due to unresolved sources.
Spectra for the background point sources may be set to one of the heasim-supported spectral models (Sec. 2.2) or based on standard torus models 18

Input, Operation, and Output
No input is required other than setting the values in the parameter file. Skyback may be run with parameters either prompted for, set on the command line, or preset using the pset command. Utilization of scripts streamlines the operation of repeated simulations apropos to different detectors, and example scripts are available for download (ahsimscripts.tar.gz; Sec. 1). Skyback output generally includes the following files: (1) a catalog of resolved point sources with source positions and spectra specifications for each source, in a format following that of heasim point sdfs; (2) a file that supplements the point source catalog with values of the redshift and intrinsic absorption; (3) a "catalog" with a single line representing the diffuse emission, in the heasim format for a flat extended source distribution; (4) the total diffuse (included unresolved point sources) background spectrum calculated on a user-specified energy grid in the form of a heasim user input spectrum ASCII file; and, (5) an XSPEC table model (FITS) file.
Because of the simplified treatment of the point source background, it is recommended to run skyback with different sets of parameters for different bandpasses. The selections in Table 1, where fabs0-5 represents the fraction of sources in each bin of intrinsic N H , and fpar0-4 represents the fraction in each bin of source spectral index or opening angle (Sec. 9), roughly produce average values of the shape and normalization of the 0.5-to 2.0-keV and 2-to 10-keV astrophysical backgrounds, respectively. In combination with the Halo and LHB components, these are used to approximate the Hitomi SXI/SXS and HXI astrophysical backgrounds in the example in Sec. 5.2 below (though they are equally appropriate for any missions with similar bandpasses). The input spectra including all resolved, unresolved, and intrinsic diffuse components are shown in Fig. 1.

Sxsbranch and Its Use in Simulation
The energy resolution of events detected by the SXS (and similar microcalorimeter detectors) may be degraded from its baseline value of ∼5 eV 21 depending on the proximity in time of preceding and following pulses. Events were, accordingly, assigned resolution grades by on-board Hitomi SXS processing 22 into five resolution grades, determined by the combination of time interval to the nearest event (high, mid, and low), and the time interval to the event that it immediately follows (primary and secondary). Since a grade criterion may be used in selection of events for data product extraction, and detector response is both grade-and pixel-dependent, knowledge of the grade distribution per pixel and over the entire array for real and simulated event files is needed for observation planning and data analysis.
From an input real or simulated Hitomi SXS event file, or an SXS count rate, the sxsbranch FTOOL computes and records in an output file, rates, and branching ratios (the fraction of total events in each grade) for each event resolution grade within each SXS pixel. 10,11 Sxsbranch also statistically estimates these quantities using the total rates from the input (file or count rate) using Poisson statistics and includes these in a separate extension to the output file as a reference in cases where non-Poissonian effects may be present (e.g, a burst light curve). Applied to real SXS event files, it may be used to compare branching ratios with their expected values. For purposes of observation planning, since grade filtering is generally applied prior to SXS spectral extraction, expected branching ratios are needed for estimating the rate of events that would be useful in a particular context (e.g., only those with the highest spectral resolution). In addition, if the input file is a heasim simulated SXS event output file, sxsbranch produces a more realistic version of the event file   Fig. 1 Composite input background spectra (all sources) used for the Hitomi SXI/SXS (black) and HXI (red) as described in Table 1.
Journal of Astronomical Telescopes, Instruments, and Systems 048003-4 Oct-Dec 2018 • Vol. 4 (4) such that a similar filtering as that to be applied to an actual event file may be applied. This is realized by adding and filling two columns: PIXEL with the pixel number and ITYPE with the grade (ITYPE ¼ 0, 1, 2, 3, and 4 for high-resolution primary (HP), mid-resolution primary (MP), mid-resolution secondary (MS), low-resolution primary (LP), low-resolution secondary (LS), respectively. Grades that approximate those imposed by real SXS event processing are assigned for simulated events by comparing the time intervals between events with the time interval values set by the three sxsbranch time interval input parameters needed to distinguish the five resolution grades. Sxsbranch operates in three modes: (1) no input file, (2) input simulated file, and (3) input file from observations. (1) If there is no input file, sxsbranch internally simulates events using an input exposure time and count rate, with counts distributed in the array according to a specified file containing the relative counts per pixel (or assumed uniform if no such file is input). Times are randomly assigned, with an option for a burst-like light curve parameterized as described above for heasim. Branching ratios are then calculated using these internally simulated events. (2) If the input file is an SXS event file created by heasim, sxsbranch calculates branching ratios after assigning pixels and grades as described above, to each event in the file. Electrical crosstalk 22 , whereby a signal in one pixel may induce a reduced signal in another, between pixels that are nearest or next-nearest (by electrical bonding identified using a calibration pixel map) may be estimated based on their PI values (used as a proxy for PHA) and several parameter settings. Applications of sxsbranch in this mode are presented in Secs. 5.1 and 5.3. (3) If the input SXS event file is from an observation (or ground calibration), sxsbranch calculates the branching ratios of the events using the grades already present in the file.
Additional sxsbranch capabilities allow for the masking of specific pixels in calculating the full-array branching ratios, and for the merging of "piled-up" (for simulated input) events defined as separated in time by intervals smaller than that set by one input parameter up to a total time interval set by another parameter. 10,11 The energy of the merged event is set equal to the sum of energies of the individual events that were merged, and the merged event is discarded if the value exceeds that given by a parameter for the maximum energy that can be processed. Crosstalk (if included) events are added, and events are graded based on the event list, after merging.

Bright Point Source
A Hitomi SXS simulation of a bright point source provides a simple illustration of a joint heasim/sxsbranch application. The source is assumed to have a (constant) Crab Nebula-like flux (2 × 10 −8 erg cm −2 s −1 in the 2-to 10-keV bandpass) and a spectrum characterized by an absorbed (N H ¼ 3 × 10 21 cm −2 ) power law (index 2.1). The source is assumed to be on-axis, i.e., the pointing is set to be the same as the source position, with roll angle (267.7 deg) and exposure time (9735 s) the same as the nominal roll angle and cleaned exposure time of the actual Hitomi SXS Crab Nebula observation. Two simulations are conducted: one using prelaunch estimates of the relevant rmf, arf, eef, and nxb; and one using postlaunch versions of these constructed as explained below. Both are compared to the results of standard SXS analysis of the actual Hitomi Crab Nebula observation. 23,24 The postlaunch rmf is calculated using the sxsmkrmf FTOOL 25,26 applied to the cleaned Crab Nebula SXS event file for HP and MP grades, and then renormalized. The postlaunch on-axis arf for the entire SXS detector array is calculated using the aharfgen FTOOL 26 and then rescaled using the psf fraction that is part of the xrtraytrace screen/log output (the rescaling is needed since heasim requires an effective area that corresponds to all incident events-whether or not they land on the detector and are ultimately included in the final simulated event file). The postlaunch energy-dependent onaxis eef is calculated using the eeftable FTOOL 27 by inputting the ray-tracing event file created in the course of constructing the arf. The postlaunch nxb is calculated using the sxsnxb FTOOL. 25 The prelaunch simulation is internally subdivided into 86 subexposures and the postlaunch simulation into 5 subexposures. The simulated event files are input into sxsbranch (Sec. 4), and the resulting event file along with the additional ITYPE (grade) column is used to extract spectra for (1) all pixels and (2) for HP and MP grades only (the recommended selection for bright sources). Various count rates and computed branching ratios are compared in Table 2 for the cleaned observed and simulated event files, as are the Poisson statistical estimates based on the count rates and expected distribution over pixels for a point source (Sec. 4), which are in excellent agreement with the simulated values. Observed and postlaunch simulated spectra are compared in Fig. 2. For the spectral comparison, the appropriate files are applied to the grade-filtered simulated spectrum, i.e., nxb and rmf scaled by the HP + MP branching ratio and the original (not rescaled) arf that relates count rates in the region defined by the SXS array into intrinsic source flux. The large reduction in total count rate from pre-to postlaunch estimates is due to the effect of the SXS gatevalve 26,28 in the latter. Some of the discrepancies between real and simulated postlaunch event files, and between estimated and calculated branching ratios (note also that the former are based on a prelaunch estimate of the eef and the corresponding assumed pixel distribution of counts), may be partly attributed to the idealized treatment for the simulations that assigns grades based solely on the relative timing of cleaned events. However, the excess measure in the observed spectrum with respect to that for the simulated fiducial Crab Nebula flux and high-energy steepening of the spectrum are not understood and under active investigation. 28 In the examples that follow, we apply prelaunch calibration files that are also more suitable for XRISM simulations, unless stated otherwise.

Including Astrophysical Background
In this example, the output from skyback with parameters as described in Table 1 is input into heasim with the point source flux set to a negligible value and the exposure time to 500 ks in order to emphasize the background component. The Hitomi SXI, HXI1, and HXI2 images and spectra extracted from the entire FoVare shown in Figs. 3 and 4, respectively. The spectra are compared (not fit) with a composite XSPEC model that includes one component for each contribution as follows: absorbed and unabsorbed thermal (Raymond-Smith) plasma models representing the Halo and LHB, and the cutoff power law model fit to the 3-to 60-keV spectrum from the High-Energy Astronomical Observatory 1 derived by Gruber et al. 29 representing the extragalactic background. The thermal component parameters are based on a joint SXI/SXS fit with an added power law representing the extragalactic background; the Gruber et al. model 29 (originally normalized per steradian) is scaled to the particular FoV of each instrument. Figure 5 shows the FeK-region of the spectrum extracted from a simulation of a 200-ks SXS observation of a cluster of galaxies based on the Perseus cluster. The X-ray emitting components in the core include an active galactic nucleus (AGN) with an absorbed power law component and narrow 6.4-keV FeKαemission feature, and an intracluster medium component (ICM) with spatial distribution modeled as a β-model with β ¼ 0.53 and core radius 1.26 arcmin. 30 The input ICM spectral model is constructed by fitting the actual Hitomi Perseus cluster SXS data with a model that includes a single temperature, variable abundance plasma with turbulent broadening, 31 with the text output of the best-fit model specified in the sdf along with the β-model   Fig. 3 SXI, HXI1, and HXI2 images of the simulated X-ray background derived using skyback with the parameters displayed in Table 1.  parameters. The sdf also includes two additional lines with power law and monoenergetic spectra representing the AGN continuum and redshifted Fe resonance line with fluxes based on the fit. The spectra from the previous example could have also been produced from simple spectral-only simulations. An illustrative scientifically related application of heasim (in conjunction with sxsbranch) would be to assess the feasibility of constraining the extent of the nuclear FeKα emission by comparing simulations with various exposure times, and assuming various spatial distributions for this component. For example, one may apply sxsbranch to heasim output events from a series of Perseus cluster-like simulations as described in Sec. 5.3, with the same FeKα line flux but with different spatial distributions, selecting the high-energy resolution events in a narrow band, and then comparing the distributions of counts over pixels in the array. Figure 6 shows the results from two such simulations: one with a point-like FeKα distribution, the other an identical simulation where the FeKα emission is assumed to be extended in a constant surface brightness disk 1 arcmin in radius (∼20 kpc at the redshift of the Perseus cluster). HP, MP, and MS grade events are selected in a 7-eV wideband centered on the redshifted centroid of the emission line. Figures 7 and 8 show these same distributions as heat maps. An F-test comparison of the two distributions yields p-values of ∼0.068 for the full array and ∼0.021 for the innermost 16 pixels; a Monte Carlo approach may be used for a more complete assessment as each simulation runs to completion in <1 min on a MacBook Pro with 2.5 GHz quad-core Intel Core i7 processor and 16 GB 1600 MHz DDR3 of memory. A full spectral decomposition in each pixel to better isolate the line component may also be conducted, as was done in the analysis of the actual Hitomi analysis. 32

Summary and Outlook
The heasim multimission observation simulator by itself or in combination with skyback, and/or sxsbranch in the case of Hitomi, may be used to accurately and efficiently construct FITS event files for sources with a wide range of standard   Fig. 7 Heat map for the pixel distribution shown as the blue histogram in Fig. 6, with the narrow band HP + MP + MS counts indicated in each pixel.  spatial, spectral, and temporal distributions. Additional capabilities allow the user to extend these to any spatial distribution, in which the user has an FITS image and any spectral distribution that can be provided in tabular form. Even more complex sources may be modeled by representing separate components as individual entries in the sdf. Planned future improvements to heasim include the support of additional missions via an expanded mission database file, and the capability to match the flexibility in the spatial and spectral domains with similar capabilities in the temporal domain by enabling the user to input files specifying the source light curve (full light curve for aperiodic, or folded light curve for periodic, sources). Direct or indirect interfaces that support simput files (for heasim input or skyback output) may be considered.
The fidelity of all of background components in skyback ought to be improved. A more realistic, less phenomenological SWCX model 33 is urgently needed, and the Halo and LHB components ought to utilize updated plasma models and N H maps. The discrete background may also be made less phenomenological and instead incorporate the principles of a simple AGN population synthesis model. 19,20 7 Appendix A: Source Definition Files As discussed in Sec. 2.2, the sources to be simulated by heasim are described by the sdf. Each source is described in the sdf by a single row of the form E Q -T A R G E T ; t e m p : i n t r a l i n k -; s e c 7 ; 6 3 ; 4 6 5 ra; dec; NH; spec_mod; spec_par; flux; bandpass; filename; format; units; source_specs; where ra and dec specify the celestial coordinates of the source, and NH is the foreground column density. The spectral characteristics may be specified either (a) as a single-component spectral model (spec_mod) with one spectral parameter (spec_par) and flux in some bandpass; or, as a user-defined spectrum input using the parameters filename, format, and units. In the former case, a minimal set of models that may be described by a single parameter-index (power law), temperature (blackbody, thermal bremsstrahlung, and solar abundance thermal plasma), or energy (monoenergetic)-is supported. We expect that, for most applications, users would utilize these options for preliminary simulations to be followed up using more complex user-input spectra. In the latter case, spec_mod is set to "user," and filename corresponds to the user-defined input spectral model file that may be created using XSPEC and can utilize several format and unit options. The final parameter in the sdf, source_specs, is optional and defines temporal or spatial source characteristics-if omitted, the source is assumed to be point-like and steady in time. The format of source_specs is such as to specify a mode with qualifiers in the form of a list of parameters delimited by parentheses, e.g., pulse (0.1, 0.5). Heasim currently supports four modes: pulse, burst, extmod, and image. The pulse mode generates sinusoidal light curves and has two parameters: the period in seconds and the pulse fraction. Burst light curves are created by setting burst mode parameters tburst, risetime, decaytime, and burstratio, where tburst is the time in seconds when the burst starts with respect to the start of the observation, risetime is the (linear) rise time in seconds, decaytime is the exponential decay time in seconds, and burstratio is the ratio of the peak-to-quiescent flux. The flux in the sdf always refers to the average flux over the exposure time for these time-varying sources.
The extmod and image source_specs modes are used for sources with extended spatial distributions characterized by an extended source model or a FITS standard input image, respectively. The possible spatial source_specs settings are extmod (beta, core_radius, ellipticity, pos_angle, Rmin, and Rmax), extmod (ellipse, ellipticity, pos_angle, Rmin, and Rmax), extmod (power, slope, Rmin, and Rmax), extmod (flat, Rmin, and Rmax), and image (filename, xmin, xmax, ymin, and ymax). The corresponding models are the two-dimensional β-model 34 with core radius in arcmin, circular flat (constant surface brightness) model, two-dimensional annulus model, two-dimensional Gaussian model with distinct fullwidth half-maxima given in arcmin, and power law surface brightness model, respectively. For the annulus and β models, ellipticity is defined as the ratio between major and minor axes of the constant surface brightness contours. All models have minimum and maximum radii (defined along the major axis if two-dimensional) given in arcmin, and a position angle measured counterclockwise from the sky to major axis for two-dimensional models. For the image option, the sour-ce_specs parameters specify the input fits image filename and coordinate boundaries in units of pixels that define a subimage (if set to 0 the entire image in that direction is included).

Appendix B: Support (Calibration) Files
The essential spectral support files for heasim are the input response matrix (rmf), ancillary response (arf), and internal background spectrum (nxb) files. The arf contains the telescope effective area as a function of energy for the instrument of interest, whereas the rmf contains a matrix representing the line spread function that expresses the probability that an incoming X-ray at each energy is detected in some discrete energy channel for the instrument of interest. The detector quantum efficiency (QE) may be included in the arf, in which case the rmf is normalized (the sum of LSF values over output energy channel is unity for each input energy), or in the rmf, in which case the rmf is not normalized except for energies where the QE ¼ 1. The nxb (non-X-ray background) file, as defined here, expresses the spectrum observed over the entire detector in the absence of an astronomical source due to particles interacting with the detector, optics, and other structures.
These files must follow standard fit format standards. 35 The energy scales in the arf effective area extension must be compatible with that in the rmf matrix extension to a relative level given by the heasim arfrmftol input parameter; and, the internal background energy channels should match those in the rmf EBOUNDS extension. The arf should be simply defined to convert flux from a source into count rate on the focal plane (independent of the FoV or spectral extraction region). The internal background spectrum BACKSCAL keyword must be defined as the ratio of detector area from which the spectrum is extracted to the total detector area.
The psf information may be input in one of several tabular forms as an enclosed-energy as a function of radius (eef) for a range of X-ray energies and off-axis angles with respect to the optical axis. Alternatively, it may take the form of a FITS file with one bintable extension identifying triplets of off-axis angle (in arcmin), azimuthal angle (in deg), and energy (in keV)each corresponding to one of a series of subsequent psf Journal of Astronomical Telescopes, Instruments, and Systems 048003-8 Oct-Dec 2018 • Vol. 4 (4) image extensions-as well as specifying the image coordinate system keywords. The vignetting function information may also be input in one of the several tabular forms specifying its variation as a function of off-axis angle for a range of X-ray energies. Alternatively, it may take the form of a FITS file with one bintable extension identifying the energy (in keV) corresponding to each of a series of subsequent vignetting map image extensions, as well as specifying the image coordinate system keywords of the maps.
Instrument maps define the FoV of the detector and are referenced in the heasim mission database file. The instrument map is an FITS image, where the image is in focal plane coordinates as defined by the mission database file and has value 1 within the detector and 0 outside the detector.

Appendix C: Skyback Model Details
Additional details on the three X-ray background components implemented as part of skyback follows: (1) Halo and LHB components utilize RASS surface brightness maps 36 to create a model background spectrum appropriate for the part of the sky being observed. The model consists of an absorbed thermal (Raymond-Smith) plasma at T halo ∼ 10 6.6 K representing the excess over the extragalactic component seen in the RASS hard bands, plus an unabsorbed thermal plasma at T halo ∼ 10 6 K representing the additional excess in the soft band. (3) The first of the two X-ray background subcomponents due to point sources follows a broken power law Nð> SÞ distribution specified by parameters for the bright-and faint-end slopes, flux where the slope changes value, normalization per unit sky area, and minimum and maximum fluxes. The fluxes are defined over a user-specified energy bandpass, and a flux threshold is determined such that sources fainter than this are treated as undetected and their emission subsumed into the diffuse background. This threshold may be directly set or defined by separately setting a signal-to-noise threshold along with an exposure time and count-rate-to-flux conversion for the instrument of interest. The second Nð> SÞ subcomponent is a single power law with slope and normalization per unit sky area set by the user that may be defined over the same bandpass as the first component, spans the same flux range, and has the same detection threshold.
Spectra for the point sources drawn from the broken power law Nð> SÞ background may be set to any of the heasimsupported spectral models described in Sec. 7, with user-defined spectral parameter and foreground column density. Alternatively, the spectra of the background sources may be based, at least in part, on standard torus models 18 following the formalism of either (1) Ref. 19 or (2) Ref. 20. For these options, intrinsic redshifts for each point source to be applied to their spectra are drawn from a distribution assumed to be a simple linear ramp up to z ¼ 1 and an exponential decline at larger redshifts (∝ ze −z ) as a rough approximation of the observed distribution of luminous, optically thin AGN. 19 For option (1), the spectrum for each source is determined by one of the torus models with a distinct intrinsic column density and opening angle drawn from discrete distributions and with a randomly selected inclination angle. The opening angle (θ) distribution is determined by user-selected fractions in five bins (parameters fpar0-4): θ ≤ 30, 30 < θ ≤ 45, 45 < θ ≤ 60, 60 < θ ≤ 75, and θ > 75; the log of the intrinsic column density by user-selected fractions in six bins (parameters fabs0- For option (2), each point source is an absorbed power law with logðN H Þ determined as just described, and power law index (Γ) drawn from a discrete distribution with user-selected fractions in five bins (dual-purpose parameters fpar0-4): 1.5 < Γ ≤ 1.7, 1.7 < Γ ≤ 1.9, 1.9 < Γ ≤ 2.1, 2.1 < Γ ≤ 2.3, and 2.3 < Γ ≤ 2.5. In the highest logðN H Þ bin, the power law is replaced by a torus model with the largest available opening angle and inclination of 0 deg, the assigned power law, and the assigned logðN H Þ-with the power law subtracted off. This should be a good approximation to a pure-reflection model. In the next-to-highest logðN H Þ bin, the absorbed power law is supplemented with this same reflection model scaled down by 0.37. 20 The user may choose to either assign spectra for the point sources drawn from the single power law Nð> SÞ component in an identical manner to those drawn from the broken power law Nð> SÞ or separately set these to any of the heasim-supported spectral models with user-defined spectral parameter described above.