gtlike Help File

The gtlike tool performs unbinned and binned likelihood analysis of the LAT data.

Usage: gtlike irfs expcube srcmdl statistic optimizer evfile
scfile expmap cmap bexpmap

The application of the likelihood method to photon-counting experiments was described by Cash 1979 (Cash W. 1979, ApJ 228, 939). Maximum likelihood method was applied in the analysis of EGRET data as parameter estimation (Mattox J. R. et al 1996, ApJ 461, 396), and it will be applied in the analysis of GLAST data as well.

The likelihood statistic L is the probability of obtaining observational data given an input model. In our case, the input model is the distribution of gamma-ray sources on the sky, and includes their intensity and spectra. We use this likelihood to find the best fit model parameters. These parameters include the description of a source's spectrum, its position, and intensity.

During its lifetime, Fermi LAT will observe hundreds of millions of photons (counts), but for most analyses we will be interested in a subset of only a few hundred or a few thousand. The data will be too sparse to allow the use of CHI2 as test statistic. In that case, a full Poisson likelihood is needed for model parameter estimation.

For a small number of counts, the unbinned likelihood can be calculated rapidly; but as the number of counts increases the time to calculate the likelihood becomes prohibitive, and the binned likelihood must be used.

For an overview of the mathematical and statistical reason to apply the likelihood analysis in the analysis of the GLAST data, it is highly recommended that you read the Likelihood Overview (adapted from the FSSC's Cicerone).

In the next section, the definition of source region on region of interest are given. The explanation of how to generate the source model for the likelihood analysis is described after that. The different optimizers to produce the fitting in the likelihood analysis are given in the Model Fitting section. Finally, an overview of the steps of how to perform an unbinned and binned likelihood analysis is described.

SOURCE REGION AND REGION OF INTEREST

Due to the large LAT point spread function at low energies (e.g., 68% of the counts will be within 3.5 degrees at 100 MeV (see GLAST LAT Performance for a review of LAT performance); to analyze a single source, the counts within a region around the source have to be included. We call that region the "region of interest" (ROI). The ROI is selected from the original event file using the gtselect tool. (See gtselect and gtselect Help.)

The ROI should be several times the characteristic PSF size in order to satisfy the restrictions of the Likelihood package. Nearby sources will contribute counts to that region, so they have to be included in the model as well. The region that includes those sources is called "Source Region". All these sources will be in the source model file that has to be input in gtlike. (See the "Source Model section.)

The "Source Region" is centered on the ROI, with a radius that is larger than the ROI radius by several PSF length scales. For example, when fitting a single point source, an ROI with a radius of 10 degrees and a Source Region radius of 20 degrees would be appropriate. Since the size of the LAT PSF goes roughly as (PSF_100MeV) x (E/100)^{-0.8} (with E in MeV), if you are considering only higher energy photons (e.g., > 1 GeV) smaller ROI and Source Region radii of just a few degrees may be used.

THE SOURCE MODEL

The gtlike tool reads the source model from an XML file. SAE has a GUI-tool called the Model Editor (modeleditor) that can be used to create this file without any knowledge of xml.

For information about the type of source that you are able to create, the spatial models and the spectral functions, see the Likelihood Tutorial: Unbinned --> Create a Source Model XML File.

MODEL FITTING

Optimizers. In the Fermi ScienceTools there are five optimizers to maximize the log likelihood function: DRMNGB, DRMNFB, NEWMINUIT, MINUIT and LBFGS.

The optimizers determine the best-fit spectral parameters, but not the location; the source coordinates are fixed. However, a tool is provided that performs a grid-search, mapping out the maximum likelihood value over a grid of locations: gtfindsrc. (See gtfindsrc and gtfindsrc Help; also see gttsmap and gttsmap Help.)

DRMNGB finds the local minima of a continuously differentiable function subject to simple upper and lower bound constrains. It uses a variant of Newton's method with quasi-Newton Hessian updating method, and model/trust-region technique to aid convergence from poor starting values. The original code obtained from Netlib is in Fortran, but it was converted to C++ and has some converge problems.

DRMNFB interfaces with many of the same subroutines as DRMNGB, but handles the derivative information differently and does not seem to suffer from some of the convergence problems encountered with DRMNGB.

MINUIT interfaces with the original FORTRAN Minuit processed by f2c (FORTRAN to C translator) and then adapted to compile as C++. In the Fermi Science Tools, only a few of MINUIT's possibilities are used. For example, all variables are treated as bounded. No user interaction is allowed, and only the MIGRAD algorithm is implemented. For more information about MINUIT, see the MINUIT Function Minimization and Error Analysis Reference Manual, available from the documentation section of the Minuit website.

NEWMINUIT interfaces with an entirely **NEW** code of 'true' C++ designed in an object-oriented way. It is based on the original MINUIT for algorithms and functionality and uses only a few of MINUIT's features: the MIGRAD and HESSE algorithms. All variables are treated as bounded. No user interaction is allowed and, while it has no limits on the number of free parameters, there is certainly a practical limit, beyond which any fit is suspect. The MINUIT manual suggests a maximum number of around 15.

LBFGS was originally obtained from Netlib. The original code is in Fortran, but as with the others, it was translated to C++. The "L'' in the name means "limited memory''. That means that the full approximate Hessian is not available.

Note: Generally speaking, the fastest way to find the parameters estimation in the likelihood Fermi ScienceTool is to use the DRMNGB (or DRMNFB) approach to find initial values and then use MINUIT (or NEWMINUIT) to find more accurate results.

PROCEDURE FOR LIKELIHOOD ANALYSIS

There are two possible ways to perform a likelihood analysis in the LAT data: Unbinned and binned likelihood. A summary for each case is given in the following subsections; a further explanation can be obtained from the Workbook's LAT Science Tools section (click on the Source Analysis button).

1-UNBINNED LIKELIHOOD ANALYSIS

The event data file provided by the GSSC website and the spacecraft data file are needed to perform a likelihood analysis. For simulated data, the spacecraft data file could be produced by gtorbsim (see the gtorbsim Help File), but real data can be obtained from the GSSC website. You can also perform a likelihood analysis for simulated LAT data. (See the gtobssim Help File, to know how to generate simulated data.)

To perform an unbinned likelihood, several Fermi ScienceTools have to be run before running gtlike. The following paragraphs describe the steps to obtain the significance of a given detection:

  1. Select the ROI (see the Source Region and Region of Interest section in this document) using gtselect. (See gtselect Help.)

You may also need to use gtmktime to select the Good Time Intervals (GTI) that define a time range when the data can be considered valid. (See gtmktime Help.)

  1. Create the exposure map needed for gtlike in the unbinned likelihood analysis.

This requires two steps:

  1. First, create the livetime cube map. (See gtltcube and gtltcube Help.)
  1. Then create the exposure map: The exposure map needed for unbinned likelihood analysis can be generated using gtexpmap. (See gtexpmap and gtexpmap Help).

Note: The event file input to gtexpmap is in general a filtered event file from an original event file obtained from SLAC's Data Portal or produced by Monte Carlo simulations. This original event file should be filtered using the gtselect tool. (See gtselect and gtselect Help.)

  1. Run gtdiffrsp. (See gtdiffrsp and gtdiffrsp Help.)
  1. Run gtlike.

The gtlike tool will give you the TS value for each source in the source model, as well as the values obtained in the fitting process of the parameters in the source model file.

Inputs to gtlike:

  • The source model file. (Refer to the Source Model section, above.)
  • The exposure cube and the exposure (created in previous steps).

Note: In this step, you are also allowed to chose from different optimizers in the fitting process. (See the Model Fitting, below.)

2) BINNED LIKELIHOOD ANALYSIS

To perform a binned likelihood analysis the event data file and the spacecraft data file are needed. Both files could be obtained from the GSSC website. There are several steps to perform a binned likelihood analysis; the full description of all of them is in the workbook. The summary is given below:

  1. Create a 3D Counts Map. The first step is to create a count map of the ROI. (See the Source Region and Region of Interest section, above).

Note: In the binned analysis, the ROI is defined as the boundaries of the count map, so it is not appropriate to apply acceptance cone cuts. (See gtselect and gtselect Help.)

  1. Identify Candidate Sources and Define the Model. The second step is to create the source model file. (See The Source Model section, above.)
  1. Compute Livetimes. To speed up the exposure calculations performed by Likelihood, it is helpful to precompute the livetime as a function of sky position and off-axis angle. The gtltcube application does this for the whole sky. (See gtltcube and gtltcube Help.)
  1. Compute 3D Exposure Map. Use gtexpcube2 to create exposure maps corresponding to the counts maps generated above. The maps cover the same region of the sky as the counts maps and have separate planes for different energies spanning the energy range of the counts maps. (See gtexpcube2 and gtexpcube Help.)
  1. Compute Source Maps. These are model count maps of each source, i.e., multiplied by exposure and convolved with the effective PSF. The gtsrcmaps application performs this task. (See gtsrcmaps and gtsrcmaps Help.)
  1. Run gtlike. Select the "binned" option of the "statistic" parameter, and then select the optimizer. (See the Model Fitting section, above.)

As output, gtlike will give you the TS and the predicted number of counts. It will also give you the parameters of the spectra (e.g., the spectral index, in the case of a power law spectra) for each source you have in your source model file.

  1. Simulate based on your model. For comparison to the counts map data, you can create a model map of the region based on the fit parameters. This map is essentially an infinite-statistics counts map of the ROI based on your model fit. The gtmodel application reads in the fitted model, applies the proper scaling to the source maps, and adds them together to get the final map. (See gtmodel and gtmodel Help.)

Examples: gtlike

Parameters are passed following the FTOOLs model (i.e., they can be passed interactively by: answering a prompt; as a list in a command line; or by editing the parameter file).

To run gtlike, enter (at the command line): gtlike

You will be prompted for parameter values.

Note: "Hidden" parameters are not prompted. If you want to override one of the "hidden" parameters, specify the values in the command line. For example, if you want to change the relative fit tolerance, enter (at the command line): gtlike ftol=1e-3

gtlike has specific parameters for each of the statistics selected; for example, the parameter cmap only works if you chose the binned likelihood.

Example 1: unbinned likelihood analysis

An example of how to run the tool for unbinned likelihood analysis is given below:

> gtlike
Statistic to use <BINNED|UNBINNED> [UNBINNED] :
Spacecraft file [] : FT2.fits
Event file [] : 3C279_3C273_back_filtered.fits
Unbinned exposure map [] : expMap.fits
Exposure hypercube file [] : expCube.fits
Source model file [] : src_model.xml
Response functions to use [HANDOFF] : P6_V3_DIFFUSE
Optimizer <DRMNFB|NEWMINUIT|MINUIT|DRMNGB|LBFGS> [DRMNFB] : NEWMINUIT

In the example above the event file is called 3C279_3C273_back_filtered.fits. It is a file that contains simulated data for 3C279, 3C273 and the Galactic and Extragalactic background. The source model with the spectral and spatial information includes the sources 3C279, 3C273 and the Galactic and Extragalactic background, and it is called src_model.xml. The exposure cube and exposure map were produced previously with gtltcube and gtexpmap, respectively. NEWMINUIT was chosen as optimizer. The Spacecraft data file selected was: FT2.fits and the response function P6_V3_DIFFUSE was selected. The results of the likelihood analysis are printed in the Standard Output and also saved in an ASCII file (results.dat) and in a FITS file with information of the number of counts and fluxes for each energy bin and for each source.

The above example can also be run from the command line as follows:

gtlike irfs=P6_V3_DIFFUSE expcube=expCube_3C279_3C273_back.fits
srcmdl=src_model.xml statistic=UNBINNED optimizer=NEWMINUIT
evfile=_3C279_3C273_back_filtered.fits scfile=FT2.fits
expmap=expMap.fits

Example 2: Binned likelihood analysis

An example of how to run the tool for a binned likelihood analysis is given below:

> gtlike
Statistic to use <BINNED|UNBINNED> [BINNED] :
Counts map file [srcMaps_v1.fits] : srcMaps.fits
Binned exposure map [] :
bexpmap_phi4.fits
Exposure hypercube file [] :
3C279_binned_ltcube_phi4.fits
Source model file [] : src_model.xml
Response functions to use [HANDOFF] : P6_V3_DIFFUSE
Optimizer <DRMNFB|NEWMINUIT|MINUIT|DRMNGB|LBFGS> [DRMNFB] : NEWMINUIT

In the example the livetime cube was previously generated by gtltcube, the source maps was generated by gtsrcmaps, NEWMINUIT was chosen as optimizer and the response function P6_V3_DIFFUSE was selected.

The above example can also be run from the command line as follows:

>gtlike irfs=P6_V3_DIFFUSE expcube=3C279_binned_ltcube_phi4.fits
srcmdl=src_model.xml statistic=BINNED optimizer=NEWMINUIT
cmap=srcMaps.fits bexpmap=
bexpmap_phi4.fits


Owned by: J. Chiang

 

Last updated by: Chuck Patterson 02/10/2011