Exemplo n.º 1
0
/***********************************************************************//**
 * @brief Get application parameters
 *
 * Get all task parameters from parameter file or (if required) by querying
 * the user. Most parameters are only required if no observation exists so
 * far in the observation container. In this case, a single CTA observation
 * will be added to the container, using the definition provided in the
 * parameter file.
 ***************************************************************************/
void ctbin::get_parameters(void)
{
    // If there are no observations in container then load them via user
    // parameters
    if (m_obs.size() == 0) {

        // Throw exception if no input observation file is given
        require_inobs(G_GET_PARAMETERS);

        // Get observation container without response (not needed)
        m_obs = get_observations(false);

    } // endif: there was no observation in the container

    // Create an event cube based on task parameters
    GCTAEventCube cube = create_cube(m_obs);

    // Get the skymap from the cube and initialise all pixels to zero
    m_cube = cube.map();
    m_cube = 0.0;

    // Get energy boundaries
    m_ebounds  = cube.ebounds();

    // Optionally read ahead parameters so that they get correctly
    // dumped into the log file
    if (read_ahead()) {
        m_outcube = (*this)["outcube"].filename();
    }

    // Return
    return;
}
Exemplo n.º 2
0
/***********************************************************************//**
 * @brief Generate model map
 *
 * @param[in] obs CTA observation pointer.
 * @param[in] models Model container.
 *
 * @exception GException::no_cube
 *            No event cube found in CTA observation.
 ***************************************************************************/
void ctmodel::model_map(GCTAObservation* obs, const GModels& models)
{
    // Continue only if observation pointer is valid
    if (obs != NULL) {

        // Get event cube pointer
        GCTAEventCube* cube =
            const_cast<GCTAEventCube*>(dynamic_cast<const GCTAEventCube*>(obs->events()));

        // Throw an exception if the observation does not hold and event
        // cube
        if (cube == NULL) {
            throw GException::no_cube(G_MODEL_MAP);
        }

        // Initialise statistics
        double sum = 0.0;

        // Loop over all events in counts map
        for (int i = 0; i < cube->size(); ++i) {

            // Get event bin
            GCTAEventBin* bin = (*cube)[i];

            // Compute model value for event bin
            double model =
                models.eval(*(const_cast<const GCTAEventBin*>(bin)), *obs) *
                bin->size();

            // Store value
            bin->counts(model);

            // Sum all events
            sum += model;
        }

        // Log results
        if (logTerse()) {
            log << gammalib::parformat("Model events in cube");
            log << sum << std::endl;
        }

    } // endif: observation pointer was not valid

    // Return
    return;
}
Exemplo n.º 3
0
/***********************************************************************//**
 * @brief Event cube constructor
 *
 * @param[in] cube Event cube.
 *
 * Construct exposure cube using the same binning and sky projection that is
 * used for the event cube.
 ***************************************************************************/
GCTACubeExposure::GCTACubeExposure(const GCTAEventCube& cube)
{
    // Initialise class members
    init_members();

    // Store energy boundaries
    m_ebounds = cube.ebounds();

    // Set GNodeArray used for interpolation
    set_eng_axis();

    // Set exposure cube to event cube
    m_cube = cube.map();

    // Set all exposure cube pixels to zero as we want to have a clean map
    // upon construction
    m_cube = 0.0;

    // Return
    return;

}