Monte Carlo simulations of the runaway breakdown of air are used to calculate the spectra of terrestrial gamma-ray flashes (TGFs), which are then compared with RHESSI and CGRO/BATSE observations. It is found that the recent RHESSI spectrum is not consistent with a source altitude above 24 km but can be well fit by a source in the range of 15–21 km, depending upon the electric field geometry of the source. Because 15 km is not unusual for the tops of thunderstorms, especially at low latitudes, and is lower than typical minimum sprite altitudes, the RHESSI data imply that thunderstorms and not sprites may be the source of these TGFs. On the other hand, the soft energy spectrum seen in some BATSE TGFs is inconsistent with such large atmospheric depths, indicating that there may exist two distinct sources of TGFs, with altitudes below 21 km and above 30 km.
 The discovery of high altitude discharges such as red-sprites in 1990 [Franz et al., 1990] was followed two years later by the introduction of the relativistic runaway electron avalanche (RREA) model [Gurevich et al., 1992]. Because the RREA model requires electric field strengths only about 1/10th as large as that needed for conventional air breakdown, it seemed natural to consider runaway breakdown for explaining sprites. This approach appeared to be validated by the surprising discovery by CGRO/BATSE, two years later, of large bursts of gamma-rays propagating up from the earth's atmosphere [Fishman et al., 1994]. These terrestrial gamma-ray flashes (TGFs) were immediately assumed to originate from high altitudes, above 30 km (<13 g/cm2), due to the large attenuation of gamma-rays in the atmosphere. The association of TGFs and sprites was apparently strengthened when two years later a TGF was clearly associated with a positive cloud–to-ground lightning discharge, the kind that were known to produce sprites [Inan et al., 1996].
 In addition to spacecraft observations of TGFs, X-ray and gamma-ray emission has been measured from thunderstorms and from natural and triggered lightning [Eack et al., 1996; Moore et al., 2001; Dwyer et al., 2004a; Dwyer et al., 2005] Although the thunderstorm and lightning X-ray emission almost certainly involves runaway breakdown, it has usually been assumed that this emission is unrelated to the TGFs.
 In 2003, as part of a triggered lightning experiment at the University of Florida/Florida Tech International Center for Lightning Research and Testing, a large burst of gamma-rays was observed on the ground at sea level in association with the initial stage of rocket-triggered lightning [Dwyer et al., 2004b]. Because the burst occurred at the time the upward propagating leader should have reached the cloud charge several km above the ground, Dwyer et al. argued the source was probably located inside the thunderstorm and that the gamma-rays had propagated through several km of air to reach the detectors on the ground. Dwyer et al. further suggested that if such a burst of gamma-rays were directed upward, perhaps from near the tops of the thunderstorms, then a similar event could possibly have been observed from space.
 Recently, Smith et al.  reported new observations of TGFs by the Reuven Ramaty High Energy Solar Spectroscopic Imager (RHESSI). They measured 10–20 TGFs per month since the February 2002 launch, with much improved measurements of the TGF energy spectrum than were available with BATSE. In this paper, results of a Monte Carlo simulation of the runaway breakdown of air are presented, and the energy spectra predicted by the model are compared with both the RHESSI and BATSE spectra, allowing an estimation of the source altitudes of the TGFs.
2. Runaway Breakdown Simulation
 TGFs likely involve the production of runaway electrons in strong electric fields and the subsequent production of high–energy bremsstrahlung x-rays as the energetic electrons collide with air [Lehtinen et al., 1996]. To model these processes, a 3-D Monte Carlo simulation of the runaway breakdown of air was used. The simulation includes, in an accurate form, all the relevant physics for describing the interactions of photons and energetic electrons with air [Dwyer, 2003]. The electron interactions include energy losses through ionization and atomic excitation, Møller scattering for secondary electron production and elastic scattering. Bremsstrahlung production of x-rays and gamma-rays and the photon propagation is fully modeled, including photoelectric absorption, coherent and Compton scattering and pair production. Furthermore, bremsstrahlung production from all secondary electrons and positrons and positron annihilation gamma-rays are included. As part of this work, the bremsstrahlung and atmospheric Comptonization and absorption processes were verified by independent simulations with GEANT, a standard high-energy particle and radiation transport code used in particle physics and astrophysics.
 The Monte Carlo simulation was used to model the TGF spectra for various electric field strengths, source altitudes and source geometries. In the simulation, the runaway avalanche was allowed to develop in a region with a uniform electric field. Outside this avalanche region the field was set equal to zero. The runaway electrons were propagated until all electrons exited the avalanche region and subsequently came to a stop.
 The 4 solid curves at the bottom of Figure 1 were calculated by the Monte Carlo simulation. They are the X-ray spectra (plotted with arbitrary normalizations) produced by runaway breakdown for five values of the electric field, E/n = 300, 400, 1000, and 2500 kV/m, where n is the density of air with respect to the value at STP. The amplitudes of the curves are arbitrary and are arranged on the plot for clarity. Because most of the x-rays originate from within one avalanche length before the end of the avalanche region, with the emission extending slightly past the avalanche region as the electrons slow down and stop, the source altitude is defined to be the upper end of the avalanche region. In Figure 1, the X-ray spectra were found at a plane 13 g/cm2 away from the end of the avalanche region, the amount of atmosphere needed for most of the runaway electrons to loss their energy and stop. In the upper atmosphere, 13 g/cm2 corresponds to an altitude of about 30 km. At medium energies (0.1 to 1 MeV) the model spectra are slightly steeper than the E−1 spectrum, which can be used to approximate bremsstrahlung emission. This is due to the contribution of the low-energy electrons, both runaway and non-runaway and the details of the bremsstrahlung cross-section. The fall off at higher energies is due to the energy spectrum of the runaway electrons, which have an average energy of about 7.2 MeV.
 As can be seen in Figure 1, the X-ray spectral shapes are not very sensitive to the value of the electric field strength. Only the 300 kV/m spectrum falls off slightly faster at high energies then the spectra of other field values, resulting from the fact that E/n = 300 kV/m is right above the runaway breakdown threshold Eth/n = 284 kV/m [Dwyer, 2003]. For the following simulations presented in this paper the electric field strength 400 kV/m was used, a value consistent with the upper range measured inside thunderstorms [Marshall et al., 2005]. However, the conclusions reached in this paper are not dependent upon this specific choice. In the simulations, the magnetic field was set equal to zero, since for altitudes below 30 km the earth's magnetic field does not have a significant impact upon the results.
3. Comparing the Model With the Data
 Measured gamma-ray spectra are usually interpreted by convolving model spectra with the instrument response matrix. The data can be presented in count space (what is measured), along with the convolved model spectra, or in photon space (the true spectrum), with the data points quasi-deconvolved by multiplying them by the ratio of the unconvolved to convolved model. If most of the counts at low energies are due to downscattering in the instrument and not low-energy incident photons, then the quasi-deconvolution will be “obliging”, with the data points adjusting to agree with the model. This is true of the RHESSI data below 60 keV. Figure 1 shows the quasi-deconvolved, background-subtracted, RHESSI spectrum summing 289 TGFs, constructed both assuming an E−1 power law (lower plot) and the spectrum from the runaway breakdown model with the source at an atmospheric depth of 50 g/cm2, corresponding to a source altitude of 21 km (upper plot). The high energy data are fairly independent of the assumed spectrum and cannot be made to agree with the power law, while the low energy data tend to validate whatever spectrum is assumed.
 Also shown in Figure 1 is the average of the four quasi-deconvolved photon spectra presented by Nemiroff et al. , who assumed a power law. It has been normalized to match the RHESSI spectrum created under the same assumption. BATSE has a better response at low-energies (30–60 keV) than RHESSI, so the lack of a turnover at low energies in this case probably cannot be explained entirely by obligingness in the inversion. This is important because the lack of turn over in the BATSE data below 50 keV indicates that the source of these BATSE TGFs must be above 30 km (<13 g/cm2), since atmospheric absorption due to the photoelectric effect is large below 50 keV.
 Consider the RHESSI spectrum shown in Figure 1 above 0.5 MeV, where the data are less sensitive to assumptions about the spectrum. The excess above the E−1 line, seen in both photon spectra, implies that the photons passed through a considerable amount of material, i.e. there must have been a substantial layer of atmosphere between the top of the avalanche region and the spacecraft. If significant atmospheric absorption is not present, then the bremsstrahlung spectrum can never be flatter than the E−1 spectrum regardless of the angular distributions measured or the source spectrum of the electrons. The case for a substantial layer of atmosphere between the top of the avalanche region and the spacecraft is strengthened when the runaway breakdown model spectra, shown in the figure, are used, since they are even steeper than E−1.
 In calculating the TGF model spectra, an important issue is the intensity threshold for detecting the events. For a beam of runaway electrons, the emitted x-rays will also be beamed. As the x-rays propagate up through the atmosphere, they Compton scatter, sometimes to large angles. These Compton scattered photons will have lower energies and hence a softer spectrum than the x-rays left in the beam. Because they are scattered into a large solid angle, the odds that the spacecraft will be in a location to measure the softer spectrum is greater than the odds that it will measure the harder spectrum in the beam. However, the fluence of the x-rays measured outside of the beam will be considerably less. Therefore, the better the sensitivity of the instrument to low fluence events, the more of the low energy x-rays will be included in the accumulated spectrum. Because the fluence ratio of a RHESSI flash at the 90th percentile to a flash at the 10th percentile is about a factor of 2, the model spectra only include emission into angles at which the flash would appear at least half as bright to the satellite as a flash directly below it.
Figure 2 shows the combined RHESSI counts spectrum. Because of the sensitivity of the deconvolution process to assumptions about the spectrum, unlike Figure 1, the data have not been corrected for the instrumental response but still include a background subtraction. Because most of the RHESSI TGFs occur just above the threshold of detection, many probably remain undetected, and those which are detected are more likely to have occurred during a positive fluctuation of the background. Therefore, the background spectra, which are accumulated in 1-second intervals on either side of each flash, are systematically underestimated. The magnitude of this effect is related to the unknown number of undetected flashes. Simulations show that the background could be underestimated by as much as a factor of two if ∼98% of TGFs are undetected. The error bars in Figure 2 extend downward to include the systematic effect of doubling the background estimate; the effect is significant only below 0.1 MeV.
 The model spectra shown in Figure 2 were calculated by the simulation for four atmospheric depths, 13 g/cm2 (30 km), 30 g/cm2 (24 km), 50 g/cm2 (21 km) and 130 g/cm2 (15 km). For five of the spectra, the electric field inside the runaway electron avalanche region was assumed to be uniform and directed vertically downward, resulting in an upward beam of runaway electrons. These spectra were propagated through the instrument, transforming them into counts spectra, with a detailed Monte Carlo simulation of the RHESSI spacecraft, using GEANT [Smith et al., 2002].
 As can be seen, the runaway breakdown spectrum is clearly not consistent with the RHESSI TGF data for 30 g/cm2 and less (i.e. for altitudes above 24 km) but a source region at 21 km (50 g/cm2) results in a spectrum that more closely matches the RHESSI data. The spectrum for 130 g/cm2 (15 km) for the beamed geometry is also not consistent with RHESSI data.
 Because the source of the runaway breakdown is not known, the assumption that the electric field is uniform and directed vertically downward may not be correct. If the runaway electrons are emitted isotropically into the upper cone with a half angle of 45°, then the effects of the intensity threshold are reduced. For this case, it is found that the altitude that gives a good fit to the RHESSI data is lowered considerably. The black curve in Figure 2 shows the calculated spectrum for a source region at 15 km (130 g/cm2) for the non-beamed geometry just described.
 The RHESSI spectrum strongly suggests that the observed gamma-rays must have passed through at least 50 g/cm2 of atmosphere, corresponding to a source altitude of 21 km. This source altitude is below the lower limit of 25 km placed on the TGF altitude by Smith et al. . However, the 25 km limit was based on the consideration of atmospheric attenuation only and did not include the repopulation of the lower photon energies by Comptonization as is done here.
 The comparison between the runaway breakdown Monte Carlo simulation and the RHESSI energy spectra implies that the source of these TGFs is not sprites (E. Williams et al., Lightning flashes conducive to the production and escape of gamma radiation to space, submitted to Journal of Geophysical Research, 2005). Using sferics observations Cummer et al.  found that 13 of the RHESSI TGFs were associated with positive polarity lightning discharges, but the charge moment changes of these events were too small to be associated with sprites and were about two orders of magnitude smaller than required by high-altitude runaway breakdown theory. Furthermore, Cummer et al. concluded that the most likely scenario was that runaway breakdown was occurring at altitudes below 30 km, which agrees with the results presented here.
 On the other hand, a 15 km source region is within the range of thunderstorms, especially at low geographic latitudes where the tropopause is often at that height. If the TGFs are produced in the space above thunderstorms (≤21 km) then some other high-altitude discharge phenomenon such as blue jets [Wescott et al., 1995], which are observed to emanate from the tops of thunderstorms, may be involved.
 These results appear to contradict the subset of the BATSE spectra shown by Nemiroff et al. , which continues to rise down to 25 keV, but the raw BATSE light curves (http://www.batse.msfc.nasa.gov/batse/tgf/) show a broad range of spectral variation, and many of the harder events may be similar to those that are found in the RHESSI data by the current analysis. As discussed by Smith et al. , the selection criteria for the BATSE TGFs and RHESSI TGFs were different. Therefore, it is possible that there are two kinds of TGFs, corresponding to low and high altitude sources. It is also possible that during an individual flash, there are two distinct source regions, the lower region (<21 km) producing the extended spectrum out to many MeV and the higher region (>30 km) producing a much softer spectrum. Indeed, Nemiroff et al.  reported substantial softening of the spectra as the TGF progressed (over a timescale of msec), indicating a possible upward shift in the source altitude. Another possibility is that two mechanisms for producing the runaway electrons are at work. The spectra presented in this paper, based upon the RREA model, include the X-ray emission from all the lower energy electrons. Therefore, to enhance the <50 keV X-ray fluence, an additional source of <50 keV electrons, beyond that predicted by the RREA model, is required. However, because most of the photons that make it out of the atmosphere started off as higher energy gamma-rays, and Compton scattered down in energy, large changes to the source spectrum at low energies would be needed to solve the discrepancy.
 In order to match the measured fluences of gamma-rays at 600 km, the simulation shows that 1 × 1016 runaway electrons with energies greater than 1 MeV were created by the runaway breakdown avalanche for a source at 21 km (50 g/cm2), and 2 × 1017 runaway electrons were created if the avalanche was located at 15 km (130 g/cm2). At 15 km, this number of runaway electrons would produce about 1023 low-energy secondary electrons through ionization of the air. If thunderstorms are the source of the TGFs then the large amount of ionization created by the runaway breakdown could drastically alter the conductivity of the cloud.
 For an ambient atmospheric cosmic-ray flux of 1000 s−1 m−2, a source with an area of 1 km2 would require an avalanche multiplication factor of 2 × 1011 to produce 2 × 1017 runaway electrons in 1 msec, and a 10000 km2 source would require an avalanche multiplication factor of 2 × 107. These multiplication factors would require 600 MV and 400 MV potential drops, respectively, within the high field region for a 400 kV/m sea-level equivalent electric field. Interestingly, positron and photon feedback effects should become important before such large multiplication factors are obtained [Dwyer, 2003].
 We wish to thank Steven Cummer for very useful conversations. This work was supported by the NSF grant ATM 0133773.