/***********************************************************************//** * @brief Print event cube information ***************************************************************************/ std::string GCTAEventCube::print(void) const { // Initialise result string std::string result; // Append header result.append("=== GCTAEventCube ==="); result.append("\n"+parformat("Number of events")+str(number())); result.append("\n"+parformat("Number of elements")+str(size())); result.append("\n"+parformat("Number of pixels")+str(npix())); result.append("\n"+parformat("Number of energy bins")+str(ebins())); // Append skymap definition result.append("\n"+m_map.print()); // Append GTI intervals result.append("\n"+parformat("Time interval")); if (gti().size() > 0) { result.append(str(tstart().secs())+" - "+str(tstop().secs())+" sec"); } else { result.append("not defined"); } // Append energy intervals if (ebounds().size() > 0) { result.append("\n"+ebounds().print()); } else { result.append("\n"+parformat("Energy intervals")+"not defined"); } // Return result return result; }
/***********************************************************************//** * @brief Write CTA event cube into FITS file. * * @param[in] fits FITS file. * * Writes CTA event cube into a FITS file. The following HDUs will be written * * COUNTS - Counts cube * WEIGHTS - Weights for each counts cube bin * EBOUNDS - Energy boundaries * GTI - Good Time Intervals * * The counts cube will be written as a double precision sky map. The * weighing cube contains the weight for each counts cube, computed as the * fraction of the event bin that has been selected in filling the counts * cube. This allows to account for proper stacking of observations with * different energy thresholds, or different regions of interest. The energy * boundaries for all counts cube layers are also written, as well as the * Good Time Intervals that have been used in generating the counts cube. ***************************************************************************/ void GCTAEventCube::write(GFits& fits) const { // Remove HDUs if they exist already if (fits.contains("GTI")) { fits.remove("GTI"); } if (fits.contains("EBOUNDS")) { fits.remove("EBOUNDS"); } if (fits.contains("WEIGHTS")) { fits.remove("WEIGHTS"); } if (fits.contains("COUNTS")) { fits.remove("COUNTS"); } if (fits.contains("Primary")) { fits.remove("Primary"); } // Write counts cube m_map.write(fits, "COUNTS"); // Write cube weighting m_weights.write(fits, "WEIGHTS"); // Write energy boundaries ebounds().write(fits); // Write Good Time intervals gti().write(fits); // Return return; }
/***********************************************************************//** * @brief Set mean event time and ontime of event cube. * * @exception GLATException::no_gti * No Good Time Intervals found in event cube. * * This method computes the mean event time and the ontime of the event * cube. The mean event time is the average between the start and the stop * time. The ontime is the sum of all Good Time Intervals. * * @todo Could add a more sophisticated mean event time computation that * weights by the length of the GTIs, yet so far we do not really use * the mean event time, hence there is no rush to implement this. ***************************************************************************/ void GLATEventCube::set_times(void) { // Throw an error if GTI is empty if (m_gti.size() < 1) { throw GLATException::no_gti(G_SET_TIMES, "Every LAT event cube needs" " associated GTIs to allow the computation of the ontime."); } // Compute mean time m_time = 0.5 * (gti().tstart() + gti().tstop()); // Set ontime m_ontime = m_gti.ontime(); // Return return; }
/***********************************************************************//** * @brief Print event cube information * * @param[in] chatter Chattiness. * @return String containing event cube information. ***************************************************************************/ std::string GCTAEventCube::print(const GChatter& chatter) const { // Initialise result string std::string result; // Continue only if chatter is not silent if (chatter != SILENT) { // Append header result.append("=== GCTAEventCube ==="); result.append("\n"+gammalib::parformat("Number of events") + gammalib::str(number())); result.append("\n"+gammalib::parformat("Number of elements") + gammalib::str(size())); result.append("\n"+gammalib::parformat("Number of pixels") + gammalib::str(npix())); result.append("\n"+gammalib::parformat("Number of energy bins") + gammalib::str(ebins())); // Append GTI intervals result.append("\n"+gammalib::parformat("Time interval")); if (gti().size() > 0) { result.append(gammalib::str(tstart().secs()) + " - " + gammalib::str(tstop().secs())+" sec"); } else { result.append("not defined"); } // Append energy intervals if (gammalib::reduce(chatter) > SILENT) { if (ebounds().size() > 0) { result.append("\n"+ebounds().print(gammalib::reduce(chatter))); } else { result.append("\n"+gammalib::parformat("Energy intervals") + "not defined"); } } // Append skymap definition if (gammalib::reduce(chatter) > SILENT) { result.append("\n"+m_map.print(gammalib::reduce(chatter))); } } // endif: chatter was not silent // Return result return result; }
/***********************************************************************//** * @brief Write CTA event cube into FITS file. * * @param[in] file FITS file. ***************************************************************************/ void GCTAEventCube::write(GFits& file) const { // Write cube m_map.write(&file); // Write energy boundaries ebounds().write(&file); // Write Good Time intervals gti().write(&file); // Return return; }
/***********************************************************************//** * @brief Write LAT event cube into FITS file * * @param[in] fits FITS file. ***************************************************************************/ void GLATEventCube::write(GFits& fits) const { // Write cube m_map.write(fits); // Write energy boundaries ebounds().write(fits); // Write Good Time intervals gti().write(fits); // Write additional source maps for (int i = 0; i < m_srcmap.size(); ++i) { m_srcmap[i]->write(fits); } // Return return; }
void ComputeClobberCall(BlockMemory *mcfg, PEdge *edge, Vector<GuardAssign> *assigns, Vector<GuardAssign> *clobbered, bool direct, BlockId *callee, Exp *rfld_chain) { PPoint point = edge->GetSource(); BlockModset *modset = GetBlockModset(callee); // fill the assigns in the caller, but only for direct calls. if (direct) { for (size_t ind = 0; ind < modset->GetAssignCount(); ind++) { const GuardAssign >s = modset->GetAssign(ind); mcfg->TranslateAssign(TRK_Callee, point, NULL, gts.left, gts.right, gts.guard, assigns); } } for (size_t mind = 0; mind < modset->GetModsetCount(); mind++) { const PointValue &cv = modset->GetModsetLval(mind); Exp *new_lval = CallEdgeAddRfldExp(cv.lval, callee, rfld_chain); GuardExpVector caller_res; mcfg->TranslateExp(TRK_Callee, point, new_lval, &caller_res); for (size_t ind = 0; ind < caller_res.Size(); ind++) { const GuardExp > = caller_res[ind]; // filter out lvalues containing rfld. if (gt.exp->RfldCount() > 0) continue; GuardAssign gti(gt.exp, cv.lval, gt.guard, cv.kind); clobbered->PushBack(gti); } } }
/***********************************************************************//** * @brief Set empty CTA event list * * @param[in] obs CTA observation. * * Attaches an empty event list to CTA observation. The method also sets the * pointing direction using the m_ra and m_dec members, the ROI based on * m_ra, m_dec and m_rad, a single GTI based on m_tmin and m_tmax, and a * single energy boundary based on m_emin and m_emax. The method furthermore * sets the ontime, livetime and deadtime correction factor. ***************************************************************************/ void ctobssim::set_list(GCTAObservation* obs) { // Continue only if observation is valid if (obs != NULL) { // Get CTA observation parameters m_ra = (*this)["ra"].real(); m_dec = (*this)["dec"].real(); m_rad = (*this)["rad"].real(); m_tmin = (*this)["tmin"].real(); m_tmax = (*this)["tmax"].real(); m_emin = (*this)["emin"].real(); m_emax = (*this)["emax"].real(); m_deadc = (*this)["deadc"].real(); // Allocate CTA event list GCTAEventList events; // Set pointing direction GCTAPointing pnt; GSkyDir skydir; skydir.radec_deg(m_ra, m_dec); pnt.dir(skydir); // Set ROI GCTAInstDir instdir(skydir); GCTARoi roi(instdir, m_rad); // Set GTI GGti gti(m_cta_ref); GTime tstart; GTime tstop; tstart.set(m_tmin, m_cta_ref); tstop.set(m_tmax, m_cta_ref); gti.append(tstart, tstop); // Set energy boundaries GEbounds ebounds; GEnergy emin; GEnergy emax; emin.TeV(m_emin); emax.TeV(m_emax); ebounds.append(emin, emax); // Set CTA event list attributes events.roi(roi); events.gti(gti); events.ebounds(ebounds); // Attach event list to CTA observation obs->events(events); // Set observation ontime, livetime and deadtime correction factor obs->ontime(gti.ontime()); obs->livetime(gti.ontime()*m_deadc); obs->deadc(m_deadc); } // endif: oberservation was valid // Return return; }
/***********************************************************************//** * @brief Print event cube information * * @param[in] chatter Chattiness (defaults to NORMAL). * @return String containing event cube information. ***************************************************************************/ std::string GLATEventCube::print(const GChatter& chatter) const { // Initialise result string std::string result; // Continue only if chatter is not silent if (chatter != SILENT) { // Append header result.append("=== GLATEventCube ==="); // Append information result.append("\n"+gammalib::parformat("Number of elements") + gammalib::str(size())); result.append("\n"+gammalib::parformat("Number of pixels")); result.append(gammalib::str(m_map.nx()) + " x " + gammalib::str(m_map.ny())); result.append("\n"+gammalib::parformat("Number of energy bins") + gammalib::str(ebins())); result.append("\n"+gammalib::parformat("Number of events") + gammalib::str(number())); // Append time interval result.append("\n"+gammalib::parformat("Time interval")); if (gti().size() > 0) { result.append(gammalib::str(tstart().secs()) + " - " + gammalib::str(tstop().secs())+" sec"); } else { result.append("not defined"); } // Append energy range result.append("\n"+gammalib::parformat("Energy range")); if (ebounds().size() > 0) { result.append(emin().print()+" - "+emax().print(chatter)); } else { result.append("not defined"); } // Append detailed information GChatter reduced_chatter = gammalib::reduce(chatter); if (reduced_chatter > SILENT) { // Append sky projection if (m_map.projection() != NULL) { result.append("\n"+m_map.projection()->print(reduced_chatter)); } // Append source maps result.append("\n"+gammalib::parformat("Number of source maps")); result.append(gammalib::str(m_srcmap.size())); for (int i = 0; i < m_srcmap.size(); ++i) { result.append("\n"+gammalib::parformat(" "+m_srcmap_names[i])); result.append(gammalib::str(m_srcmap[i]->nx())); result.append(" x "); result.append(gammalib::str(m_srcmap[i]->ny())); result.append(" x "); result.append(gammalib::str(m_srcmap[i]->nmaps())); } } } // endif: chatter was not silent // Return result return result; }
// // DrawSelf // // Redraw self // void Color::DrawSelf(PaintInfo &pi) { IControl::DrawSelf(pi); // Get the color for the current color const PlayerInfo *playerInfo; Data::Get(&playerInfo, Network::GetCurrentPlayer().GetId()); ASSERT(playerInfo); ASSERT(teamId < Game::MAX_TEAMS); const Team *team; Data::Get(&team, teamId); ASSERT(team); // Update the current color colorCurrent->SetIntegerValue(team->color); // Figure out which colors are available BinTree<GroupTree> groups; BuildPlayerHierachy(groups); Bool colors[Game::MAX_TEAMS + 1]; for (U32 t = 0; t <= Game::MAX_TEAMS; t++) { colors[t] = FALSE; } for (BinTree<GroupTree>::Iterator gti(&groups); *gti; gti++) { for (BinTree<TeamTree>::Iterator tti(&(*gti)->teams); *tti; tti++) { colors[(*tti)->team->color] = TRUE; } } groups.DisposeAll(); /* // Is the currently selected color still available ? if (colors[colorSelected->GetIntegerValue()]) { colorSelected->SetIntegerValue(team->color); } */ // Display all of the available colors for (t = 0; t <= Game::MAX_TEAMS; t++) { // Is the color available ? if (!colors[t] || t == team->color) { Point<S32> p(t * pi.client.Height(), 0); // Draw the team color ClipRect c( pi.client.p0.x + p.x + 3, pi.client.p0.y + p.y + 3, pi.client.p0.x + p.x + pi.client.Height() - 3, pi.client.p0.y + p.y + pi.client.Height() - 3); IFace::RenderShadow( c, c + IFace::GetMetric(IFace::DROPSHADOW_UP), ::Color(0, 0, 0, IFace::GetMetric(IFace::SHADOW_ALPHA)), 0); IFace::RenderGradient(c, GetTeamColor(t), 150); // Is this the selected color ? if (t == U32(colorSelected->GetIntegerValue())) { IFace::RenderGradient( ClipRect( pi.client.p0.x + p.x + 1, pi.client.p0.y + p.y + 1, pi.client.p0.x + p.x + pi.client.Height() - 1, pi.client.p0.y + p.y + pi.client.Height() - 1), ::Color(1.0f, 1.0f, 1.0f, 0.4f), ::Color(0.5f, 0.5f, 0.5f, 0.4f)); } // Is this the current color ? else if (t == team->color) { IFace::RenderGradient( ClipRect( pi.client.p0.x + p.x + 1, pi.client.p0.y + p.y + 1, pi.client.p0.x + p.x + pi.client.Height() - 1, pi.client.p0.y + p.y + pi.client.Height() - 1), ::Color(1.0f, 1.0f, 1.0f, 0.15f), ::Color(0.5f, 0.5f, 0.5f, 0.15f)); } } } }