NAME 

    gtobssim - Simulate photon events from astrophysical sources
               and process those photons according to the specified
               instrument response functions.

USAGE
 
    gtobssim infile srclist scfile evroot simtime startdate use_ac
             ra dec radius irfs seed


DESCRIPTION

    gtobssim allows the user to simulate point and diffuse source Fermi 
    observations using a specific spectral shape for a selected region of 
    the sky in survey or pointed modes. Its intended use includes 
    observation and proposal planning, as well as assessing actual observations.

    The simulated point and diffuse sources can be: (1) non-variable point sources
    with a power-law spectrum or broken power-law spectrum; (2) extended sources
    where the incident photons are distributed as a 2D Gaussian projected
    on the sky; (3) sources where the user-specified energy distribution is 
    entered as a 2 column ASCII file; (4) sources for which the energy 
    distribution is determined by a symbolic expression; (5) isotropic 
    sources,for which the photons are generated uniformly on the sky 
    following a power-law spectrum; (6) sources for which the incident photons
    are generated from a 3D FITS image comprising an energy axis for the 3rd
    dimension and, e.g., RA and Dec as the sky coordinates; (7) sources where the
    photons are generated using a 2D FITS image as a template and a single 
    power-law spectrum is used for the entire map; (8) periodic sources, that 
    is point sources with sinusoidal light curve; (9) transient sources including
    gamma-ray burst.

    It is worth mentioning that not all sources available in gtobssim are 
    available in gtlike (i.e., the source models that are included in gtlike 
    are a subset of the ones available in gtobssim).

    In order to simulate a source, gtobssim requires that the user provides the
    spacecraft pointing and live-time history file (a FITS file). The latter
    can be either an existing one, or created by gtorbsim (see gtorbsim help 
    for further explanation), or computed by gtobssim itself after defining a
    pointing strategy.

    Another requirement is a source model file. This file is an xml file
    with information about the source, such as: integral flux, photon
    spectral index, type of spectrum, energy range, position of the source
    (RA, DEC), etc. This file could be made using templates or using 
    "ModelEditor" (see "ModelEditor" help for further explanation: after typing 
    "modeleditor" at the prompt, a gui appears. Select "HELP" in the main menu). 
    ModelEditor was first designed to generate source model files for gtlike, 
    but it was later updated to accommodate models that are supported in both 
    gtlike and gtobssim. Note that even though the source models for gtlike are 
    in XML format, the files are not exactly the same as the source XML files
    for gtobssim. For the models supported in both gtobssim and in gtlike
    you have the option to save them in either format, which helps in the
    preparation of your analysis. 
    
    The source model file may contain more sources than you want to
    simulate for a given task. The user needs to provide an ASCII file
    with the list of sources that have to be simulated for that
    specific task as an input to gtobssim.


PARAMETERS

    infile [filename]
         File of flux-style source definitions. This is the file that
         defines the source content of the simulation to be performed,
         including names, sky locations, spectral and flux parameters.
	 Default is "none".
  
    srclist [filename]
         ASCII file containing list of source names to be simulated.
	 Default is "source_names.txt"
 
    scfile [filename]
         Spacecraft data file containing information such as the spacecraft
         pointing as a function of time. This file could be generated by
         gtorbsim for simulated observations (see gtorbsim help for further
         explanation) or more commonly it can be obtained from the FSSC
         website. Default is "none".
     
    (sctable) [string]
         Spacecraft data extension. Default is "SC_DATA".
 
    evroot [string]
      Prefix which will be applied to all output files. Default is "test".
  
    (evtable) [string]
         Event table extension name. Default is "EVENTS".
 
    simtime [double]
         This is the total elapsed time over which simulated data are
         generated (in seconds). The total time that gtobssim allows you
         to simulate is limited by "maxtime" (see below). 
 
    (ltfrac) [double]
         Livetime fraction. Fraction of each 30 seconds interval during
         which photon events can be accumulated.  This does not include
         the effect of SAA passages. Default is "0.9".
   
    tstart [double]
         Simulation start time in seconds with respect to MET 0. 
	 Default is "INDEF".

    (nevents) [boolean]
         Use simulation time as number of events.  This parameter allows
         one to specify the number of events to be simulated, rather than
         the simulation time.  If "yes" is specified the integer portion
         of the simulation time is taken to be the number of events. 
	 Default is "no".
  
    (maxtime) [double]
         Maximum simulation time (seconds). Default is "3.155e8" sec, 
	 approximately 10 years. 

    (startdate) [string]
         Mission start date. The spacecraft data file should include 
	 the range of time of your simulation. See gtorbsim help to know 
	 how to create the spacecraft data file. 
	 Default is "2001-01-01 00:00:00".
 
    (offset) [integer]
         Constant offset to be applied to MC_SRC_ID column for
         identifying events from specific sources in the input
         model. Default is "0".

    (rockangle) [double]
         Rocking angle, in degrees. This is the angle Fermi is rocked 
	 to keep the LAT pointing perpendicular to the orbital motion and,
	 consequently, to have uniformity of exposure. 
	 The maximum rocking angle is 60 degrees. Default is "INDEF".
  
    use_ac [boolean]
         Acceptance cone. If the value is "yes", the user is prompted
	 to specify the central coordinates of the cone (RA, Dec) as well 
	 as its radius (see below). Deafult is "no".
 
    ra [double]
         Right ascension of the cone center (degrees), to be specified if use_ac
         parameter was set to "yes". Default is "0".
   
    dec [double]
         Declination of the cone center (degrees), to be specified if use_ac
         parameter was set to "yes". Default is "0".
  
    radius [double]
         Radius of the cone center (degrees), to be specified if use_ac
         parameter was set to "yes". Default is "20".
  
    (emin) [double]
         Minimum event energy (in MeV). Default is "1". 

    (emax) [double]
         Maximum event energy (in MeV). Default is "1e6".

    (edisp) [boolean]
         Energy dispersion. If this flag is set to "yes" (default value) the 
         energy dispersion will be applied to the incoming photons.  If this
         flag is set to "no", a diagonal response is applied and the ENERGY
         column equals the input or simulation value. 
 
    irfs [string]
	 Instrument response functions. The instrument response (PSF, effective
	 area, energy resolution) is currently a function of energy,
	 inclination angle (the angle between the source and the LAT normal)
	 and photon category. Since the LAT will usually survey the sky, a
	 source will be observed at different inclination angles. Each count
	 will therefore be characterized by a different instrument response
	 function (IRF). The default value is to use "SOURCE", FRONT+BACK . i.e. P8R2_SOURCE_V6
 
    (area) [double]
         LAT cross-sectional area (only used if irfs=none). Default is 1.

    (maxrows) [integer]
         Maximum number of rows that each file generated by gtobssim will
         contain. Default is "1000000".
 
    seed [integer]
      Random number seed for the simulation. Default is "293049".

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

    (clobber) [boolean]
         If true, an existing file of the same name will be overwritten. 
         Default is "yes".
    
    (debug) [boolean]
         Activate debugging mode. Default is "no". 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.
    
    (gui) [boolean]
         Graphical User Interface (GUI) mode is activated if set to "yes".
         Default is "no".
    
    (mode) [string]
         Mode of automatic parameters: "h" for batch, "ql" for interactive. 
         Default is "ql".


EXAMPLES

    Parameters are passed following the FTOOLs model: They could be passed
    answering from a prompt, as a list in a command line, or by editing
    the parameter file.
     
    To run gtobssim simply type in the command line: 

> gtobssim
 
    The parameter values have to be provided. Not all parameter are prompted: 
    some of them are "hidden". To change one of the "hidden" parameter, the 
    user should specify the values in the command line or modify its mode 
    by editing the parameter file. For example if you like to change the 
    minimum energy value for the events (100 MeV instead of the default 30 
    MeV), the following command line has to be typed:

> gtobssim emin=100

    Examples of possible sources that could be simulated by gtobssim are
    listed below (Note: This is not a complete sample of all possible 
    sources that gtobssim can generate):

    1) Power Law

    An example of how to generate a source model file to simulate 3C279 
    (Ra=193.98, Dec=-5.82) with a power law spectrum with a photon spectral 
    index of 1.96 and an integrated flux (from 20 MeV to 20 GeV) of 
    3.48e-4 m^-2s^-1 is given below:

<source_library title="example_3C279">
 <source name="_3C279" flux="3.48e-4">
        <spectrum escale="MeV">
           <particle name="gamma">
              <power_law emin="20.0" emax="200000." gamma="1.96"/>
           </particle>
           <celestial_dir ra="193.98" dec="-5.82"/>
        </spectrum>
 </source>
</source_library>

    It is strongly recommended to produce this source model files directly
    using model editor (see model editor help).
    The parameter escale specifies the units of energy used elsewhere in the 
    source specification. It can have values of MeV or GeV, with GeV as 
    default. In the example MeV was chosen.

    For this source model file the ASCII source data file should read: "_3C279"
    (Note: It is not possible to write directly 3C279 as source name in
    the xml source file)

    An example of inputs parameters is given below: 

> gtobssim
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files[test]  3C279
Simulation time (seconds)[86400]  2592000
Simulation start date[2001-01-01 00:00:00]  2008-12-31
Apply acceptance cone?[no]  yes
RA of cone center (degrees) (-360:360)[0]  193.98
Dec of cone center (degrees) (-90:90)[0]  -5.82
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049] 
added source "_3C279"
Generating events for a simulation time of 2.592e+06 seconds....
Done.

    In this case the simulation started on 2008-12-31 and lasted for 1
    month (2592000 seconds). The pointing history file used was 
    spacecraft_data_file.fits. Two files were created
    3C279_events_0000.fits (the fits file with the events) and
    3C279_srcIds.txt (an ASCII file with the summary information). The
    minimum and maximum energy values for the simulation are the default
    values in this case. If you enter emin=30 in the command line as
    input, then the resulted events will have an energy larger that 30
    MeV. But the expected integrated flux between 20 MeV and 200000 MeV
    will be the one that is in the source model file: 3.48e-4 m^-2s^-1.

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=3C279 simtime=2592000 \
 startdate=2008-12-31 use_ac=yes ra=193.98 dec=-5.82 radius=40 \
 irfs=P8R2_SOURCE_V6 seed=29304


    2) Broken Power Law

    An example of an xml source file to simulate a point source with a
    broken power-law spectrum is given below:

<source_library title="example_mysource">
  <source name="mysource" flux="5e-4">
     <spectrum escale="MeV">
        <particle name="gamma">
           <power_law emin="20.0" emax="200000." 
           gamma="1.80" ebreak="1000" gamma2="2.30"/>
         </particle>
         <galactic_dir l="120" b="60"/>
    </spectrum>
  </source>
</source_library>

    The total integrated flux between 20 and 200000 MeV is, in this case,
    5e-4 m^-2s^-1. The photon spectral index is 1.80 between 20 MeV and
    1000 MeV (the break in the spectra) and 2.30 between 1000 MeV and
    200000 MeV.

    This source model file could be obtained using directly model editor
    (see model editor tool).

    The ASCII data file for this source should read: mysource

    An example of input parameters is given below:

> gtobssim 
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files [test]  mysource
Simulation time (seconds) [86400]  2592000
Simulation start date [2001-01-01 00:00:00] 2008-12-31
Apply acceptance cone? [no] yes
RA of cone center (degrees) (-360:360)[0]  195.555759
Dec of cone center (degrees) (-90:90)[0]  57.066813
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049]
added source "mysource"
Generating events for a simulation time of 2.592e+06 seconds....
Done.

    In this case the simulation started on 2008-12-31 and lasted for 1
    month (2592000 seconds). The Pointing history file used was
    spacecraft_data_file.fits. The Response Function used was P8R2_SOURCE_V6.
    The number of events generated was: 24. Two files were created
    mysource_events_0000.fits (the fits file with the events) and
    mysource_srcIds.txt (an ASCII file with the summary information).

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=mysource simtime=2592000 \
 startdate=2008-12-31 use_ac=yes ra=195.555759 dec=57.066813 radius=40 \
 irfs=P8R2_SOURCE_V6 seed=293049


    3) Gaussian source:

    In this case, the incident photons are distributed as a 2D Gaussian projected on the sky.
    An example of source model is given below:

<source_library title="example_gaussian">
  <source name="gaussian_source">
        <spectrum escale="MeV">
           <SpectrumClass name="GaussianSource"
               params="0.1, 2.1, 120., 60., 1.0, 1.0, 0.0, 30., 2e5"/>
           <use_spectrum frame="galaxy"/>
        </spectrum>
     </source> 
</source_library>

    The parameters are:
    - Total flux in units of m^-2 s^-1
    - Photon spectral index such that  dN/dE~E^-/Gamma
    - Source centroid J2000 right ascension in degrees.
    - Source centroid J2000 declination in degrees.
    - Semi-major axis of the 68% CL contour in degrees (default: 1).
    - Semi-minor axis of the 68% CL contour in degrees (default: 1).
    - Position angle of the major axis measured wrt North in degrees (default: 0)
    - Minimum photon energy in MeV (default: 30).
    - Maximum photon energy in MeV (default: 1e5)

    This source model file could be obtained using directly model editor
    (see model editor help).

    The ASCII data file for this source should read:  gaussian_source

    An example of inputs parameters is given below: 

> gtobssim
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files [test]  gaussian
Simulation time (seconds) [86400]  2592000
Simulation start date [2001-01-01 00:00:00] 2008-12-31
Apply acceptance cone? [no] yes
RA of cone center (degrees) (-360:360)[0]  120
Dec of cone center (degrees) (-90:90)[0]  60
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049]
added source "gaussian_source"
Generating events for a simulation time of 2.592e+06 seconds....
Done.

    In this case the simulation started on 2008-12-31 and lasted for 1
    month (2592000 seconds). The Pointing history file used was
    spacecraft_data_file.fits. The number of events generated was: 6053, and two
    files were created gaussian_events_0000.fits (the fits file with the
    events) and gaussian_srcIds.txt (an ASCII file with the summary
    information).

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=gaussian simtime=2592000 \
 startdate=2008-12-31 use_ac=yes ra=120 dec=60 radius=40 irfs=P8R2_SOURCE_V6 \
 seed=293049


    4) Periodic source:

    It is possible to simulate a point source with sinusoidal light
    curve. _The example below corresponds to the simulation of a periodic
    source in the center of the Galaxy:

<source_library title="example_periodic">
    <source name="periodic_source">
        <spectrum escale="MeV">
           <SpectrumClass name="PeriodicSource"
                     params="0.1, 2.1, 1e3, 1, 0.75, 30., 2e5"/>
           <galactic_dir l="0" b="0"/>
        </spectrum>
     </source>
</source_library>

    The parameters are:
    - Average flux in units of  m^-2 s^-1.
    - Photon spectral index such that  dN/dE ~E^-\Gamma
    - Source period in seconds.
    - Amplitude of the sinusoidal modulation (default: 0.5).
    - Phase offset specified on the unit interval (default: 0).
    - Minimum photon energy in MeV (default: 30)
    - Maximum photon energy in MeV (default: 1e5)

    The ASCII data file for this source should read:  periodic_source

    An example of inputs parameters is given below: 

> gtobssim 
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files [test]  periodic
Simulation time (seconds) [86400]  2592000
Simulation start date [2001-01-01 00:00:00] 2008-12-31
Apply acceptance cone? [no] yes
RA of cone center (degrees) (-360:360)[0]  266.404996
Dec of cone center (degrees) (-90:90)[0]  -28.936172
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049]
added source "periodic_source"
Generating events for a simulation time of 2.592e+06 seconds....
Done.

    In this case the simulation started on 2008-12-31 and lasted for 1
    month (2592000 seconds). The Pointing history file used was
    spacecraft_data_file.fits. P8R2_SOURCE_V6 was used as Response Function. Two files
    were created periodic_events_0000.fits (the fits file with the events)
    and periodic_srcIds.txt (an ASCII file with the summary information).

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=periodic simtime=2592000 \
 startdate=2008-12-31 use_ac=yes ra=266.404996 dec=-28.936172 \
 radius=40 irfs=P8R2_SOURCE_V6 seed=293049


    5) Pulsar Source:

    To simulate a pulsar you need to create an ASCII template file
    containing the light curve. The file should consist of two columns:
    phase and intensity. The phase intervals must be uniformly spaced. The
    phase scale and absolute intensities are arbitrary and rescaled using
    the period and flux parameter values.

    The following is an example of the source file for a pulsar. In this
    case the Crab pulsar it is simulated with the template named:
    CrabTemplate.dat. 

<source_library title="example_pulsar">
  <source name="Crab_Pulsar">
    <spectrum escale="MeV">
      <SpectrumClass name="Pulsar"
        params="1e3,2.,0.033,0,0,$(FERMI_DIR)/refdata/fermi/observationSim/CrabTemplate.dat,0,30,1e5"/>
           <celestial_dir ra="83.57" dec="22.01"/>
    </spectrum>
  </source>
</source_library>

    The parameters are:
    - Average flux in units of  m^-2 s^-1.
    - Photon spectral index such that  dN/dE~E-\gamma
    - Pulsar period in seconds.
    - Time derivative of the pulsar period in ss^-1
    - Reference epoch in MET seconds.
    - Filename of the ASCII light curve template. The file should consist of
      two columns, phase and intensity. The phase intervals must be
      uniformly spaced. The phase scale and absolute intensities are
      arbitrary and rescaled using the period and flux parameter values.
    - Phase offset in the unit interval (default: 0).
    - Minimum photon energy in MeV (default: 30).
    - Maximum photon energy in MeV (default: 1e5).

    The ASCII data file for this source should read:  Crab_pulsar

    An example of inputs parameters is given below: 

> gtobssim
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files [test]  crab
Simulation time (seconds) [86400]  2592000
Simulation start date [2001-01-01 00:00:00] 2008-12-31
Apply acceptance cone? [no] yes
RA of cone center (degrees) (-360:360)[0]  83.57
Dec of cone center (degrees) (-90:90)[0]  22.01
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049]
added source "Crab_pulsar"
Generating events for a simulation time of 2.592e+06 seconds....
Done.


    In this case the simulation started on 2008-12-31 and lasted for 1
    month (2592000 seconds). The Pointing history file used was
    spacecraft_data_file.fits. P8R2_SOURCE_V6 was used as Response Function.
    The number of events generated was: 71 and two files were created
    crab_events_0000.fits (the fits file with the events) and
    crab_srcIds.txt (an ASCII file with the summary information).

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=crab simtime=2592000 \
 startdate=2008-12-31 use_ac=yes ra=83.57 dec=22.01 radius=40 \
 irfs=P8R2_SOURCE_V6 seed=293049


    6) SimpleTransient: 

    This allows the user to simulate a point source with a single active
    interval during which it has a constant flux and power-law
    spectrum. An example of source model is given below:

<source_library title="example_simpletransient"> 
    <source name="simple_transient">
        <spectrum escale="MeV">
           <SpectrumClass name="SimpleTransient"
            params="100., 2.,1000,3500, 30., 2e5"/>
           <celestial_dir ra="83." dec="22."/>
        </spectrum>
     </source>
</source_library>

    The parameters are:
    - Flux while in the active state in units of  m^-2 s^-1,
    - Photon spectral index such that dN/dE~E^-Gamma
    - Start time of the active state in MET seconds.
    - Stop time of the active state in MET seconds.
    - Minimum photon energy in MeV (default = 30)
    - Maximum photon energy in MeV (default = 1e5)

    The ASCII data file for this source should read:  simple_transient

    An example of input parameter is given below;

> gtobssim
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files [test]  simpleT
Simulation time (seconds) [86400] 
Simulation start date [2001-01-01 00:00:00] 2008-12-31
Apply acceptance cone? [no] yes
RA of cone center (degrees) (-360:360)[0]  83
Dec of cone center (degrees) (-90:90)[0]  22
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049]
added source "simple_transient"
Generating events for a simulation time of 8.64e+04 seconds....
Done.

    In this case the simulation started on 2008-12-31. The Pointing
    history file used was spacecraft_data_file.fits. P8R2_SOURCE_V6 was 
    used as Response Function.  The number of events generated was: 
    10, and two files were created simpleT_events_0000.fits (the fits 
    file with the events) and simpleT_srcIds.txt (an ASCII file with 
    the summary information).

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=simpleT simtime=86400 \
 startdate=2008-12-31 use_ac=yes ra=83 dec=22 radius=40 irfs=P8R2_SOURCE_V6 \
 seed=293049


    8) SpectralTransient:

    It is possible to simulate a transient source giving the light curve
    data as template. Here you have an example of source model:

<source_library title="example_spectraltransient"> 
   <source name="spectral_transient">
        <spectrum escale="MeV">
            <SpectrumClass name="SpectralTransient"
            params="flux=1e-1, tstart=0., tstop=1e4, 
            templateFile=$(FERMI_DIR)/refdata/fermi/genericSources/testTemplate.dat, 
            emin=20, emax=2e5, lc=0, z=0, useLogParabola=0"/>
            <celestial_dir ra="193.4" dec="-5.82"/>
        </spectrum>
     </source>
</source_library>

    The parameters are:
    - Mean flux during the active state in units of  m^-2s^-1
    - Start time of the active state in MET seconds.
    - Stop time of the active state in MET seconds.
    - Filename of the light curve template. May be ASCII or FITS.
    - Minimum photon energy in MeV (default: 20). 
    - Maximum photon energy in MeV (default: 2e5).
    - Light curve number, if FITS file (default: 0).
    - Redshift used for EBL attenuation calculation (default: 
      useLogParabola (default = 0)

    The ASCII data file for this source should read:  spectral_transient

    An example of inputs parameters is given below: 

> gtobssim
File of flux-style source definitions[none]  src_sim.xml
File containing list of source names[sources_name.txt]  source.dat
Pointing history file[none]  spacecraft_data_file.fits
Prefix for output files [test]  spectraT
Simulation time (seconds) [86400]  2592000
Simulation start date [2001-01-01 00:00:00] 2008-12-31
Apply acceptance cone? [no] yes
RA of cone center (degrees) (-360:360)[0]  193.4
Dec of cone center (degrees) (-90:90)[0]  -5.82
Acceptance cone radius (degrees) (0:180)[20]  40
Response functions [P8R2_SOURCE_V6]
Random number seed [293049]
added source "spectral_transient"
Generating events for a simulation time of 2.592e+06 seconds....
Done.

    In this case the simulation started on 2008-12-31 and lasted for 1
    month (2592000 seconds). The Pointing history file used was
    spacecraft_data_file.fits. P8R2_SOURCE_V6 was used as Response Function.
    The number of events generated was: 61, and two files were created
    spectraT_events_0000.fits (the fits file with the events) and
    spectraT_srcIds.txt (an ASCII file with the summary information).

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

>gtobssim infile=src_sim.xml srclist=sources.dat \
 scfile=spacecraft_data_file.fits evroot=spectraT simtime=2592000 \
 startdate=2008-12-31 use_ac=yes ra=193.4 dec=-5.82 radius=40 \
 irfs=P8R2_SOURCE_V6 seed=293049



    8) Background source:

    To produce a realistic model you should also include the simulation of
    the Galactic and Extragalactic background.

    8a)  Recommended Background Model by the Diffuse group:

    The recommended diffuse model is simulated using the following xml file:

<source name="GalacticDiffuse_v06">
<!-- This is v06 of the diffuse emission model that is recommended by the Diffuse Group.
Total photon flux from the map (#/m^2/s) = 6.508 over the whole
energy range of the MapCube file  -->
   <spectrum escale="MeV">
     <SpectrumClass name="MapCube" params="flux=6.508,fitsFile=$(FERMI_DIR)/refdata/fermi/galdiffuse/gll_iem_v06.fits"/>
     <use_spectrum frame="galaxy"/>
   </spectrum>
</source>
     <!-- This is the isotropic diffuse spectrum that is recommended by the
          the diffuse group for P6V3 FRONT + BACK; integrated
          flux below is 6.508 ph m^-2 s^-1 [Note units]
	  When a flux of 0 is given integral is calculated automatically and used.  
				-->


<source name="IsotropicDiffuse">
   <spectrum escale="MeV">
     <SpectrumClass name="FileSpectrumMap" params="flux=0,fitsFile=$(FERMI_DIR)/refdata/fermi/galdiffuse/isotropic_allsky.fits,specFile=$(FERMI_DIR)/refdata/fermi/galdiffuse/isotropic_iem_v02.txt,emin=39.3884,emax=403761"/>
      <use_spectrum frame="galaxy"/>
   </spectrum>
 </source>


See the example given in the following web page:
http://fermi.gsfc.nasa.gov/ssc/data/analysis/scitools/obssim_tutorial.html.

The model file gll_iem_v06.fits is a MapCube source, suitable for use with
Likelihood and ObsSim XML source models. The MapCube is all-sky in Galactic
coordinates with 0.5 deg pixels. It has 30 planes of energy, logarithmically
spaced from 50 MeV to 500 GeV.
The model is a 'Ring' or 'Hybrid' model developed by Jean-Marc Casandjian
 and Isabelle Grenier using the same gas ring maps that GALPROP uses, 
and the inverse Compton intensity calculated by GALPROP. Most or all of the
 rings have been generated by Guðlaugur Jóhannesson (Gulli), with the CO 
rings based on a specially-filtered composite data set prepared by Tom Dame. 
GALPROP is developed by Gulli, Igor Moskalenko, Troy Porter, and Andy Strong.
gll_iem_v06.fits is defined only up to 500 GeV.



2b)Other Galactic Background Models:

To simulate the diffuse Galactic background you may use MapSource as
spectral class. In Mapsource the photons are generated using a 2D FITS
image as a template.  A single power-law spectrum is used for the
entire map.  A sample xml source file is given below:

<source_library title="galactic_back">
 <source name="Galactic_Diffuse">
  <spectrum escale="MeV">
      <SpectrumClass name="MapSource" params="26.56,2.1,$(FERMI_DIR)/
      refdata/fermi/galdiffuse/EGRET_diffuse_gal.fits,20.,2e5"/>
      <use_spectrum frame="galaxy"/>
  </spectrum>
 </source>
</source_library>

In the example above the total photon flux from the map is (#/m^2/s) =
26.56; the Photon spectral index is 2.1; the minimum photon energy is 30
MeV; and the maximum photon energy is 2x10^5 MeV.  The fits file
EGRET_diffuse_gal.fits is the EGRET interstellar emission model (basically that
of Hunter et al.  ApJ 481 pag 205 1997), which is available in the Science
Tools distribution in "$(FERMI_DIR)/refdata/fermi/galdiffuse" directory. 

Again, you can generate the same source model using directly the model
editor tool (see model editor help).

An example of input parameters to simulate the all-sky diffuse
background is given below for 1-day simulation starting 2008-12-31 and
with P8R2_SOURCE_V6 as response function:

> gtobssim
File of flux-style source definitions [src_sim.xml] : 
File containing list of source names [sources.dat] : 
Pointing history file [spacecraft_data_file.fits] : 
Prefix for output files [galactic_back] : 
Simulation time (seconds) [86400] : 
Simulation start date [2008-12-31] : 
Apply acceptance cone? [no] : 
Response functions [P8R2_SOURCE_V6] : 
Random number seed [29304] : 
added source "Galactic_Diffuse"
Generating events for a simulation time of 86400 seconds...
Done.

Two files were created: galactic_back_events_0000.fits (the fits file
with the events) and galactic_back_srcIds.txt (an ASCII file with the
summary information). This example generated 29827 events.

Another way to simulate the diffuse background is to use the MapCube
source, which is a generalization of MapSource source. MapCube allows
separate maps to be specified for arbitrary energies. This allows for
spectral variations across a diffuse source. MapCube was used to
generate the interstellar gamma rays from the Milky Way using a cube
generated from gamma-ray intensities calculated by the GALPROP
software (http://galprop.stanford.edu/na_home.html). The example below
is for the GP_gamma.fits model of the interstellar emission of the
Milky Way.

<source_library title="galactic_back">
   <source name="Galactic_Diffuse">
      <spectrum escale="MeV">
         <SpectrumClass name="MapCube" params="18.58,$(FERMI_DIR)/
           refdata/fermi/galdiffuse/GP_gamma.fits"/>
         <use_spectrum frame="galaxy"/>
      </spectrum>
   </source>
</source_library>

The MapCube source has only 2 parameters in its specification: Total
photon flux from the map, integrated over the energy range of the cube
(#/m^2/s) and the Fits file of cube. Note that MapCube requires that
the input FITS files contain a binary table extension called
'ENERGIES' that defines the energy of each of the spatial planes in
the cube. The units of the map are differential intensity (e.g.,
photons cm^-2 s^-1 MeV^1 sr^-1), although the integral value is
renormalized by whatever total photon flux is specified in the
specification of the source. Note that GP_gamma.fits does not contain
extragalactic diffuse emission. See next section for an example of how
to simulate the extragalactic background. This file is available in
the Science Tools distribution in "$(FERMI_DIR)/refdata/fermi/galdiffuse" directory.

The input example below is for the GP_gamma.fits model of the
interstellar emission of the Milky Way;

> gtobssim
File of flux-style source definitions [src_sim.xml] : src_sim2.xml
File containing list of source names [sources.dat] : 
Pointing history file [spacecraft_data_file.fits] : 
Prefix for output files [galactic_back] : galactic_back_GP
Simulation time (seconds) [86400] : 
Simulation start date [2008-12-31] : 
Apply acceptance cone? [no] : 
Response functions [P8R2_SOURCE_V6] : 
Random number seed [29304] : 
added source "Galactic_Diffuse"
Generating events for a simulation time of 86400 seconds....
Done.

Two files were created: galactic_back_GP_events_0000.fits (the fits
file with the events) and galactic_back_GP_srcIds.txt (an ASCII file
with the summary information). This input generated 36952 events.

That previous example could be also run in the command line as follows:

>gtobssim infile= src_sim.xml srclist=sources.dat
 scfile=spacecraft_data_file.fits evroot= galactic_back_GP simtime=86400
 startdate=2008-12-31 use_ac=no irfs=P6_V3_DIFFUSE seed=29304



2b) Other Extragalactic Emission Model:

The source model file below implements the extragalactic diffuse
inferred by EGRET (Sreekumar et al. ApJ 494 pag 523 1998). The flux
has units of photons m^-2 s^-1 integrated between Emin and Emax. The
photon spectral index is gamma, i.e., dN/dE = Const*E -gamma .

<source_library title="extragalactic_back">
    <source name="Extragalactic_Diffuse" flux="0.545">
      <spectrum escale="MeV">
         <particle name="gamma">
             <power_law emin="30." emax="100000." gamma="2.1"/>
          </particle>
         <solid_angle mincos="-0.4" maxcos="1."/>
       </spectrum>
    </source>
</source_library>

This source model file could be obtained using directly model editor
(see model editor help).

For this example the ASCII source data file should read:

Extragalactic_Diffuse
 
An example of how to run gtobssim to simulate these sources is given below:

> gtobssim
File of flux-style source definitions [none]  src_sim.xml
File containing list of source names [source_names.txt] : sources.dat
Pointing history file [none] : spacecraft_data_file 
Prefix for output files [test] : extragalactic_back
Simulation time (seconds) [86400] 
Simulation start date [2001-01-01 00:00:00] 2008-12-31 
Apply acceptance cone? [no] : 
Response functions []  P8R2_SOURCE_V6
Random number seed [29304] : 
added source "Extragalactic_Diffuse"
Generating events for a simulation time of 86400 seconds....
Done.

Two files were created: extragalactic_back_events_0000.fits (the fits
file containing the events) and extragalactic_back_srcIds.txt (an
ASCII file with the summary information). This source generated 12136
events in the 1-day observation. The response function used was
P8R2_SOURCE_V6.

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

>gtobssim infile=src_sim.xml srclist=sources.dat
 scfile=spacecraft_data_file.fits evroot= extragalactic_back simtime=86400
 startdate=2008-12-31 use_ac=no irfs= P8R2_SOURCE_V6 seed=29304


Examples of xml files to use with the gtobssim tool can be downloaded
directly from this web site:
http://fermi.gsfc.nasa.gov/ssc/data/analysis/scitools/other_sources.html



LIST OF BUGS


SEE ALSO 

     gtlike

     gtorbsim
            
