The ahgainfit task calculates time-dependent energy gain corrections by comparing the theoretical and observed energies of a calibration line or line complex. For each run of the task, only one line may be specified to calculate the gain correction (see parameter 'linetocorrect'). The ahgainfit task is a multi-instrument one and is used directly by the scripts sxigainfit and xtdgainfit, hxigainfit, and sgdgainfit for Hitomi SXI and XRISM Xtend, Hitomi HXI, and Hitomi SGD respectively. For Hitomi SXS and XRISM Resolve, the sxsgain and rslgain tasks incorporate the core fitting functionality implemented by ahgainfit.
The task ahgainfit takes, as input, an event file with time and energy columns, and requires that the events are time-ordered. The task accumulates spectra from events that are consecutive in time with energy centered on the calibration feature, and compares each spectrum from the events with a theoretical model of the calibration feature profile. The calibration feature used by ahgainfit is specified by the parameter 'linetocorrect' as a string, and the names and energies of the features are specified in a calibration file ('linefitfile'). The calibration feature may be composed of many atomic or nuclear line components that are listed in the calibration file.
The energy range for the spectra constructed from the event file, as well as from the theoretical profile, may be specified in two different ways. (1) The default energy range for the spectra is determined by the smallest and largest energies of the line components that is then expanded with the 'extraspread' parameter, i.e. the energy range is [E_min - extraspread : E_max + extraspread]. The parameter 'extraspread' should be set to a sufficiently large value to accommodate the expected energy shift, as well as the width of the calibration feature. This width is larger than the natural width of the feature, as it includes convolution with a Gaussian of FWHM specified by the 'broadening' parameter. (2) Alternatively, the energy range may be specified by setting the 'startenergy' and 'stopenergy' parameters. If these parameters are non-negative, the ahgainfit task uses their values to accumulate the spectra instead of the range derived using the 'extraspread' setting.
The energy column used to accumulate the spectra is specified by the 'energycol' parameter. The units for the energy column is channel, where the eV per channel is set by the 'evchannel' parameter. The spectra are binned according to the 'binwidth' parameter, where 'binwidth' is in units of 'energycol' channels. The theoretical profile is constructed on a mesh defined by this energy range and 'binwidth', where each calibration line is assumed to be Lorentzian. The profile may be convolved with a Gaussian, where the FWHM is given by the 'broadening' parameter.
The number of events in each spectrum is defined by the 'numevent' and 'minevent' parameters. The task accumulates spectra with a number of events between 'minevent' and 'numevent'. However, if a spectrum has fewer than 'minevent' events, then it is combined with the previous spectrum if possible. Therefore, all spectra include a number of events between 'minevent' and 'numevent+minevent-1'. To avoid having spectra accumulated over large intervals of time, the group of points in the spectrum is truncated when the time interval between consecutive events is greater than the 'gapdt' parameter. Spectra that are adjacent in time may share a percentage of their points based on the 'grpoverlap' parameter, which may vary between 0 and 100. If 'grpoverlap' is set to 0, the consecutive spectra share no points in common; if set to 100 they share all points in common but one.
The spectral events may be conditionally collected based on the value of a column present in the event file, given by the 'splitcol' parameter. This option may be used, for example, to find the gain correction for each layer of the HXI detector ('splitcol=LAYER').
If a GTI file is specified by the 'gtifile' parameter, events outside of these GTI intervals are excluded. Spectra are not accumulated across GTI intervals unless the 'spangti' parameter is set to yes.
For each accumulated spectrum, the ahgainfit task fits the theoretical profile to the data and also derives binned and unbinned averages; a least-squares method is used in the fitting. The fitted parameters are energy shift, scaling factor, background (unless the 'background' parameter is set to NONE), and optionally, convolution width if 'fitwidth=yes'. The background is fitted with a constant value if 'background' is set to CONST, and a power-law if set to SLOPE. The unbinned average energy (as specified by 'energycol') is the sum of the energies in the spectrum divided by the number of events in the spectrum. The binned average energy is the weighted average, derived by summing over bins in the spectrum, taking the product of the energy and number of events per bin, and dividing by the total number of events in the spectrum. The fitted gain correction is computed from the fitted shift with respect to the theoretical line profile. The binned average gain correction is computed from the difference between the profile and spectrum averages.
The default values for the parameters used in the fitting method ('minwidth0', 'maxitcycle', 'r2tol', 'searchstepshift', 'maxdshift', 'bisectolshift', 'searchstepwidth', 'maxdwidth', 'bisectolwidth', and 'minwidth') need not be changed since these parameters have already been optimized.
The output file has two extensions. One extension, named GRID_PROFILE, contains the energies and amplitudes of the theoretical profile used in the fitting procedure, including any convolution from the 'broadening' parameter. The other extension, DRIFT_ENERGY, reports the fitting results for each spectrum in the following columns: TIME (midpoint of the time interval over which the spectrum is collected), SPLITCOL (value of splitcol for spectrum as given by the 'splitcol' parameter; this column is absent if 'splitcol=NONE'), COR_FIT (energy correction factor from spectrum fit), COR_AVE (energy correction factor from spectrum average), CHISQ (reduced chi-squared of the fit), AVGUNBIN (average energy of events in spectrum prior to binning), AVGBIN (weighted spectrum average energy), AVGFIT (average energy from fit), SHIFT (fitted energy shift), SCALE (fitted vertical scaling factor), BGRND (fitted background), WIDTH (if 'fitwidth=no', same as broadening parameter; if 'fitwidth=yes', fitted width), TELAPSE (difference between times of first and last event in spectrum), EXPOSURE (calculated using the GTI), NEVENT (total number of events collected for this spectrum), BINMESH (array containing the count spectrum energy bins), SPECTRUM (array containing the observed binned count spectrum), and FITPROF (array containing theoretical profile with fitted parameters applied). If the 'calcerr' parameter is set to yes, one-sigma errors for the SHIFT and WIDTH are calculated. The errors are calculated with chi-squared and maximum-likelihood methods, and output in the columns SIGSHCHI2, SIGWDCHI2, SIGSHLIKE, and SIGWDLIKE, respectively. If the 'writeerrfunc' parameter is set, the chi-squared and likelihood calculated values are output in the arrays SHCHI2, SHLIKE, WDCHI2, and WDLIKE. The number of output values in these shift and width arrays are specified in the 'nerrshift' and 'nerrwidth' parameters, respectively. The extrema of these error arrays are specified by the parameters 'shifterrfac' and 'widtherrfac'. The shift error arrays extend between SHIFT +/- (shifterrfac*W), and the width error arrays extend between [WIDTH - (W/widtherrfac)] and [WIDTH + (W*widtherrfac)], where W is the quadrature of the fitted width and the natural width.
Compute the gain correction for a Hitomi SXI event file (OBSID 100050010) using the Mn Kalpha line as the theoretical profile. The theoretical profile is convolved with a Gaussian with a FWHM of 12 eV, and gains are computed separately for each CCD_ID.
ahgainfit infile=ah100050010sxi_p0100004b0_uf.evt.gz outfile=ah100050010sxi_p0100004b0_drift_out.fits linetocorrect=Mnka \ energycol=PI splitcol=CCD_ID extraspread=20. evchannel=6.0 broadening=12.0 fitwidth=yes
Compute the gain correction for a Hitomi HXI event file (OBSID 100050010) using the Mn Kalpha line as the theoretical profile. The theoretical profile is convolved with a Gaussian with 200 eV FWHM, and gains are computed separately for each unique value in a column called EVTCAT.
ahgainfit infile=ah100050010hx1_p0camrec_ufa.evt.gz outfile=ah100050010hx1_p0camrec_drift_out.fits linetocorrect=Mnka \ energycol=PI splitcol=EVTCAT extraspread=400. evchannel=100. broadening=200. fitwidth=yes
Compute the gain correction for a Hitomi SGD event file (OBSID 100050030) using the 103mRh line as the theoretical profile. The theoretical profile is convolved with a Gaussian with 1500 eV FWHM, and gains are computed separately for each unique value in a called called MATTYPE.
ahgainfit infile=ah100050030sg1_p0cc2rec_ufa.evt.gz outfile=ah100050030sg1_p0cc2rec_drift_out.fits linetocorrect=103mRh \ energycol=PI splitcol=MATTYPE extraspread=2500. evchannel=1000. broadening=1500. fitwidth=yes
Compute the gain correction for a XRISM Resolve event file (OBSID 100050020) using the Mn Kalpha line as the theoretical profile. The theoretical profile is convolved with a Gaussian with 200 eV FWHM, and gains are computed separately for each unique value in a column called PSP_ID.
ahgainfit infile=xa100050020rsl_p0px1010_uf.evt outfile=xa100050020rsl_p0px1010_drift_out.fits linetocorrect=Mnka \ energycol=PI splitcol=PSP_ID extraspread=400. evchannel=100. broadening=200. fitwidth=yes
Compute the gain correction for a XRISM Xtend event file (OBSID 100050020) using the Mn Kalpha line as the theoretical profile. The theoretical profile is convolved with a Gaussian with a FWHM of 12 eV, and gains are computed separately for each CCD_ID.
ahgainfit infile=xa100050020xtd_p0100004b0_uf.evt outfile=xa100050020xtd_p0100004b0_drift_out.fits linetocorrect=Mnka \ energycol=PI splitcol=CCD_ID extraspread=20. evchannel=6.0 broadening=12.0 fitwidth=yes
February 21, 2024