NAME
    gtexphpsun -  Calculates the exposure for different energies as a
	function of distance from the Sun or Moon

USAGE
	gtexphpsun infile outfile irfs emin emax enumbins ebinfile

DESCRIPTION

    gtexphpsun is used to calculate exposure maps binned in energy and distance
    from either the Sun or the Moon.  The exposure maps are calculated in
    HEALPix and are used by gtsuntemp along with an exposure map from
    gtexpcube2 to calculate the average intensity of either the Sun or the Moon.
    As input it takes a livetime cube calculated with gtltcubesun and an
    instrument response function.  It accounts for the phi-modulation of the
    effective area for the irfs that implement this dependence (if the livetime
    cube is binned in phi).

NOTES

    It is possible to have the exposure HEALPix map calculated with a different
    binning than the input from gtltcubesun map but it is not advised.

    The energy binning for gtexpcube2, gtexphpsun, and gtsuntemp must match or
    this tools will fail with an error message saying that some energy bins are
    not found.

PARAMETERS

    infile [filename]
    Livetime from gtltcubesun.

    outfile [filename]
    Exposure map output HEALPix file.

    irfs [string]
    The instrument response (PSF, effective area, energy resolution) is a
    function of energy, inclination angle (the angle between the source and the
    LAT normal), and photon category. Note that an explicit instrument response
    function (IRF) must be given and that it is not possible to give "CALDB" as
    the requested IRF. Instead a specific IRF must be given such as P7REP_SOURCE_V15.

    (evtype) [integer]
    The event type selection for Pass 8 data. The event type is a
    subselection of the event class. Users can select on range of
    events based on conversion type (front/back), angular
    reconstruction quality (PSF values), and energy
    reconstruction quality (EDISP values). The default value is
    INDEF, which will not apply a subselection.

    (binsz = 0) [double]
    Size of the HEALPix map in degrees. A value of 0 (the default) uses the
    binning from the input livetime cube from gtltcubesun.

    (ebinalg = LOG) [string]
    Algorithm for defining energy bins, in logarithmic scale ("LOG") or provided
    by a user (“FILE”).

    emin [double]
    Start energy (MeV) of first bin. It must be larger than the lowest energy
    covered by the instrument response function (IRF) used.

    emax [double]
    Stop energy (MeV) of last bin. It must be less than, or equal to, the highest
    energy covered by the instrument response function (IRF) used.

    enumbins [integer]
    Number of logarithmically spaced energy bins spanning emin to emax.

    ebinfile [filename]
    The name of the energy bin definition file. Only used if ebinalg is FILE.

    (bincalc = EDGE) [string]
    Specifies how energy layers are computed from the count map (cmap
    parameter) energy bounds, e.g., bincalc="CENTER" will force the tool to
    compute the exposures using the energy at the geometric mean of the energy
    bounds for each energy bin. The default is bincalc="EDGE" and should be
    what is used in the binned Likelihood analysis. It must be the same value
    as used in gtexpcube2.

    (ignorephi = no) [boolean]
    Ignore phi information (i.e., phi-averaged effective area) in the livetime cube.
    While the default value is "no", the value "yes" would be preferred.

    (thmax = 180) [double]
    Applies a theta cut on the entries from the livetime cube that are included
    in the exposure integrals. It constrains the angle with respect to the
    instrument. Units are degrees from the LAT's z-axis. The default is "180"
    and should not be changed. It must be the same value as used in gtexpcube2.

    (thmin = 0) [double]
    Applies a theta cut on the entries from the livetime cube that are included
    in the exposure integrals. It constrains the angle with respect to the
    instrument. Units are degrees from the LAT's z-axis. Default is "0".
    It must be the same value as used in gtexpcube2.

    (table = EXPOSURE) [string]
    Exposure cube extension.

    (chatter = 2) [integer]
    This parameter fixes the output verbosity: no screen output (0),
    nominal screen output (2), maximum verbosity (4).

    (clobber = yes) [boolean]
    If true, an existing file of the same name will be overwritten.

    (debug = no) [boolean]
    Activate debugging mode. When debug is "no", all exceptions that are not
    caught and handled by individual tool-specific code are caught by
    a top-level exception handler that displays information about the
    exception and then exits. When debug is "yes", such exceptions are
    not caught by the top level code. Instead the tool produces a
    segmentation violation, which is more useful for debugging. When
    debugging mode is enabled, the tool produces more verbose output
    describing any errors or exceptions that are encountered.

    (mode = ql) [string]
    Mode of automatic parameters: "h" for batch, "ql" for interactive.


EXAMPLE

    Parameters are passed to gtltcubesun following the FTOOLS model. They can
    be passed by responding to a prompt, as a list in a command line, or by
    editing the parameter file. This allows gtltcubesun to be called from a
    script.

    To be prompted for gtltcubesun simply type in the command line:

    > gtexphpsun
    Solar System Tools Livetime cube file[] : expCubeSun.fits
    Output file name[expMapSun.fits]
    Response functions to use[] : P7REP_SOURCE_V15
    Start energy (MeV) of first bin[] : 100
    Stop energy (MeV) of last bin[] : 10000
    Number of logarithmically-spaced energy bins[] : 10

    Note: the start and stop energies and the number of energy bins must match
    those used with gtexpcube2, otherwise gtexphpsun will fail with an error
    message saying that some energy bin is not found.


    That last example could be also run on the command line as follows:

    > gtexphpsun infile=expCubeSun.fits outfile=expMapSun.fits irfs=P7REP_SOURCE_V15 emin=100 emax=10000 enumbins=10

SEE ALSO

            gtltcubesun

            gtltsumsun

            gtsuntemp
